【问题标题】:Paypal IPN currency & responsePaypal IPN 货币和响应
【发布时间】:2012-10-31 11:23:33
【问题描述】:

我正在使用我在这里找到的 paypal 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.
    }

【问题讨论】:

    标签: paypal paypal-ipn


    【解决方案1】:

    使用这个,它对我有用

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

    【讨论】:

      【解决方案2】:

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

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

      对于你来说,我猜它会是:

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

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

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

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

      如果您还没有,不妨看看sample applications PayPal 已经完成的几个,似乎有不少 PHP 的。

      如果您还需要什么,请告诉我,

      【讨论】:

        【解决方案3】:

        您需要使用 PayPal 自适应付款,IPN 无济于事。

        PayPal Adaptive Payments

        使用 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;
        

        【讨论】:

        • 抱歉,您能解释一下为什么您推荐 Adaptive Payments,其他人都推荐 IPN。
        • 我相信IPN不支持货币转换。
        • 显然如果我使用 $p->add_field('currency_code', 'GBP');它应该将货币设置为 GBP
        • 对于未来的读者 - IPN 是一个独立于自适应支付 API 的系统,您可以使用经典或 REST API 并从 paypal 请求 IPN - 您无需使用特定的使用 IPN。
        猜你喜欢
        • 2019-02-07
        • 2021-01-03
        • 2017-02-14
        • 2014-06-06
        • 2017-10-17
        • 2012-03-13
        • 2014-12-29
        • 2013-08-05
        • 2013-03-16
        相关资源
        最近更新 更多