php - Paypal Adaptive Payments 在沙盒模式下工作,但在生产环境下不工作

标签 php paypal paypal-adaptive-payments

我正在尝试使用 Paypal 的自适应支付 API,但很难将其切换到生产环境。在沙盒模式下,一切都按预期工作,我得到了正确的响应,但是当我切换到我的实时 APP ID 时,它不起作用。

这些是我用于沙箱的配置值

PayPal URL : https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?paykey=[TOKEN_HERE]
Application ID : APP-80W284485P519543T

这些值在沙盒模式下对我有用。但是当我切换到以下生产值时,它停止工作

PayPal URL : https://www.paypal.com/webapps/adaptivepayment/flow/pay?paykey=[TOKEN_HERE]
Application ID : [ACTUAL APP ID]

This is what I mean by stops working.
  • 在生产模式下,应用程序获取 paykey
  • 将其附加到 Paypal URL,然后将其重定向到他们的网站
  • 在网站加载时,我收到以下消息

This transaction has already been approved. Please visit your PayPal Account Overview to see the details

最终的 URL - https://ic.paypal.com/webapps/adaptivepayment/flow/payinit?execution=e6s1

屏幕截图 - http://screencast.com/t/28qJZ9CIk

那里还有一个“返回”按钮,当我点击它时,我每次都会被带到不同的站点(看起来我被发送到随机的 failUrls)

我在下面包含了我使用的代码

$payRequest = new PayRequest();
$payRequest->actionType     = "PAY";
$payRequest->cancelUrl      = $cancelURL; //my success and fail urls
$payRequest->returnUrl      = $returnURL;

$payRequest->clientDetails  = new ClientDetailsType();
$payRequest->clientDetails->applicationId   = $this->config['application_id'];
$payRequest->clientDetails->deviceId        = $this->config['device_id'];
$payRequest->clientDetails->ipAddress       = $this->CI->input->ip_address();

$payRequest->currencyCode = $currencyCode;

$payRequest->requestEnvelope = new RequestEnvelope();
$payRequest->requestEnvelope->errorLanguage = "en_US";

//I set the receiver and the amounts. I also define that these are digital goods payments       
$receiver1 = new receiver();
$receiver1->email   = $opts['receiver_email'];
$receiver1->amount  = $opts['amount'];
$receiver1->paymentType = 'DIGITALGOODS';
$payRequest->receiverList = new ReceiverList();
$payRequest->receiverList = array($receiver1);

//Then I make the call
$ap          = new AdaptivePayments();
$response    = $ap->Pay($payRequest);

if(strtoupper($ap->isSuccess) == 'FAILURE') {
    log_message('error', "PAYMENT_FAIL : " . print_r($ap->getLastError(), true));
    return false;
} else {
    if($response->paymentExecStatus == "COMPLETED")  {
        header("Location: " . $this->config['success_url']);
        exit;
    } else {
        $token      = $response->payKey;
        $payPalURL  = $this->config['paypal_redirect_url'] . 'paykey='.$token;
        header("Location: ".$payPalURL);
        exit;
    }
}

这是从他们的示例实现中获取的代码,所以不太确定这里出了什么问题。其他可能相关的信息

  • 我正在使用自适应支付来确保发送方和接收方 实际做了交易

  • 我已将支付类型设置为“数字商品”

编辑

我提供了一个示例 URL 并附有支付 key

https://www.paypal.com/webapps/adaptivepayment/flow/pay?paykey=AP-0H388650F08226841

最佳答案

我找到了让我感到悲伤的问题。

Paypal SDK 使用在 /sdk/lib/Config/paypal_sdk_clientproperties 中定义的几个常量

常量包含用户名、密码、application_id、API url 和其他一些。这些直接在文件 /sdk/lib/CallerServices,php 中使用。因此,与您在 API 中所期望的相反,这些值不会在设置阶段注入(inject),因此如果您没有注意到该文件并更改值,上述代码将不起作用。

要解决此问题,只需更新文件中定义的值即可。

关于php - Paypal Adaptive Payments 在沙盒模式下工作,但在生产环境下不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11738896/

相关文章:

php - jquery ajax 结果消息

php - Yii 2 : how to bulk delete data in kartik grid view?

javascript - 从前端表单限制 ACF 的 "acf/validate_save_post"操作

html - 如何用瑞典语打开 PayPal

paypal - 将运费添加到 PayPal 简单链式支付?

php - 在paypal中实现自适应链式延迟支付的错误

php - 用户级别和 OOP 架构

paypal - 如何启用沙盒帐户的即时付款通知首选项?

paypal - 您可以通过 API 取消 PayPal 自动付款吗? (通过托管按钮创建的订阅)

paypal - Adaptive Payments 支付已完成,尽管 actionType 是 CREATE