3

我正在使用我在这里找到的贝宝 ipn 脚本 http://coderzone.org/library/PHP-PayPal-Instant-Payment-Notification-IPN_1099.htm

我知道我可以将信息发送到贝宝并得到回复。它表明我可以使用 $_POST 取回信息。我的问题是如何指定英国货币?

还想澄清一个小问题。我是否正确,这就是我可以确认它是成功的方式。

    if ($_POST['payment_status'] == 'completed')
        // Received Payment!
        // $_POST['custom'] is order id and has been paid for.
    }
4

3 回答 3

0

抱歉,这可能有点晚了,但以防万一 - 我目前使用“currencyCode”=>“AUD”,它正在沙箱中工作。

PayPal提供了完整的货币代码列表

对于你的,我猜它会是:

$p->add_field('currencyCode', 'GBP');

至于您关于 IPN 本身的问题,看来您走在正确的轨道上。这将取决于您返回的数据以及您是否对单个交易感兴趣(如果使用自适应付款)或者您是否在错误等情况下将它们全部撤消。确定您需要什么的最简单方法要做的是简单地显示或记录所有帖子数据,以便您了解它是如何构建的。

您还需要对其进行设置,以便 PayPal 可以访问该脚本。然后,您将此脚本的完整 URL 传递给“notify_url”参数并将其发送到 PayPal。付款完成后,PayPal 将向您的脚本发送大量信息,以便您进行处理。

不幸的是,我不是 PHP 背景,所以我不能给你你需要的确切代码。另请注意,在进入生产环境之前,您需要调查许多安全问题。不确定您是否已经打算使用该 validateIPN 功能执行此操作,但您需要确保您可以判断它是否来自 PayPal 而不是恶意用户。一种方法是使用自定义属性传递一个值,然后让 PayPal 将其传回给您,但是您最好使用 API 证书等。

如果您还没有,不妨看看 PayPal 完成的一些示例应用程序,其中似乎有不少 PHP 应用程序。

需要帮助请叫我,

于 2012-12-30T07:48:51.900 回答
0

使用这个,它对我有用

$p->add_field('currency_code', 'GBP');
于 2019-12-06T19:52:01.247 回答
-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;
于 2012-11-12T00:31:17.617 回答