我正在使用我在这里找到的paypal ipn脚本 http://coderzone.org/library/PHP-PayPal-Instant-Payment-Notification-IPN_1099.htm
我知道我可以向paypal发送信息并获得回复。它声明我可以使用$ _POST获取信息。我的问题是如何指定英国货币?
还想澄清一个小问题。我是否正确,这是我如何确认它是成功的。
if ($_POST['payment_status'] == 'completed')
// Received Payment!
// $_POST['custom'] is order id and has been paid for.
}
答案 0 :(得分:0)
这对你来说可能有点晚了,但为了以防万一 - 我目前使用“currencyCode”=> “AUD”,它正在沙盒中工作。
提供了完整的货币代码列表对于你的,我猜它会是:
$p->add_field('currencyCode', 'GBP');
至于你关于IPN本身的问题,看起来你正走在正确的轨道上。这将取决于您收到的数据以及您是否对单个交易感兴趣(如果使用自适应付款),或者您是否因错误等而将其全部撤销等。确定您需要的最简单方法就是简单地显示或记录所有的帖子数据,这样你就可以看到它是如何构建的。
您还需要进行设置,以便PayPal可以访问该脚本。然后,您将把此脚本的完整URL传递给“notify_url”参数,并将其发送给PayPal。付款完成后,PayPal会向您的脚本发送大量信息,以便您处理。
不幸的是,我不是来自PHP背景,因此我无法提供您需要的确切代码。另请注意,在进入生产环境之前,您需要考虑许多安全问题。不确定您是否已经打算使用该validateIPN功能执行此操作,但您需要确保它可以判断它是来自PayPal而不是恶意用户。一种方法是使用自定义属性传递值,并让PayPal将此传递给您,但是使用API证书等会更好。
如果您还没有,可能值得查看一些sample applications PayPal已经完成的内容,似乎有很多PHP版本。
如果您还有其他需要,请告诉我,
答案 1 :(得分:0)
使用它,对我有用
$p->add_field('currency_code', 'GBP');
答案 2 :(得分:-1)
您需要使用PayPal自适应付款,IPN无济于事。
使用PayPal PHP库,它看起来像这样:
// Create an instance, you'll make all the necessary requests through this
// object, if you digged through the code, you'll notice an AdaptivePaymentsProxy class
// wich has in it all of the classes corresponding to every object mentioned on the
// documentation of the API
$ap = new AdaptivePayments();
// Our request envelope
$requestEnvelope = new RequestEnvelope();
$requestEnvelope->detailLevel = 0;
$requestEnvelope->errorLanguage = 'en_GB';
// Our base amount, in other words the currency we want to convert to
// other currency type. It's very straighforward, just have a public
// prop. to hold de amount and the current code.
$baseAmountList = new CurrencyList();
$baseAmountList->currency = array( 'amount' => $this->amount, 'code' => 'GBP' );
// Our target currency type. Given that I'm from Mexico I would like to
// see it in mexican pesos. Again, just need to provide the code of the
// currency. On the docs you'll have access to the complete list of codes
$convertToCurrencyListUSD = new CurrencyCodeList();
$convertToCurrencyListUSD->currencyCode = 'USD';
// Now create a instance of the ConvertCurrencyRequest object, which is
// the one necessary to handle this request.
// This object takes as parameters the ones we previously created, which
// are our base currency, our target currency, and the req. envelop
$ccReq = new ConvertCurrencyRequest();
$ccReq->baseAmountList = $baseAmountList;
$ccReq->convertToCurrencyList = $convertToCurrencyListUSD;
$ccReq->requestEnvelope = $requestEnvelope;
// And finally we call the ConvertCurrency method on our AdaptivePayment object,
// and assign whatever result we get to our variable
$resultUSD = $ap->ConvertCurrency($ccReq);
$convertToCurrencyListUSD->currencyCode = 'EUR';
$resultEUR = $ap->ConvertCurrency($ccReq);
// Given that our result should be a ConvertCurrencyResponse object, we can
// look into its properties for further display/processing purposes
$resultingCurrencyListUSD = $resultUSD->estimatedAmountTable->currencyConversionList;
$resultingCurrencyListEUR = $resultEUR->estimatedAmountTable->currencyConversionList;