php - PayPal 引用交易 - 响应状态代码 400

标签 php paypal

我尝试使用 PayPal Reference Transactin。我已经制定了计费协议(protocol),在完成任何交易之前设置了计费协议(protocol) ID。

我提出了一个简单的交易请求,但得到了:

PPConnectionException in PPHttpConnection.php line 108:
Got Http response code 400 when accessing https://api-3t.sandbox.paypal.com/2.0.

我的代码(使用 merchant-sdk-php 包在 Laravel 5.3 中编写):

$user=Auth::user();

$currencyCode = 'GBP';
$price=config('constants.offer_submit_price');

$reference_id=$user->userExt()->where('field_name', '=', 'billing_agreement')->firstOrFail()->field_value;
$amount = new BasicAmountType($currencyCode, $price);

$paymentDetails = new PaymentDetailsType();
$paymentDetails->OrderTotal = $amount;

$RTRequestDetails = new DoReferenceTransactionRequestDetailsType();
$RTRequestDetails->PaymentDetails = $paymentDetails;
$RTRequestDetails->ReferenceID = $reference_id;
$RTRequestDetails->PaymentAction ='sale';

$RTRequest = new DoReferenceTransactionRequestType();
$RTRequest->DoReferenceTransactionRequestDetails  = $RTRequestDetails;

$RTReq = new DoReferenceTransactionReq();
$RTReq->DoReferenceTransactionRequest = $RTRequest;

$paypalService = new PayPalAPIInterfaceServiceService($this->config);
try {
    $setRTResponse = $paypalService->DoReferenceTransaction($RTReq);
} catch (Exception $ex) {
    dd($ex);
}

这就是脚本生成的 SAOP envelopr:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:ebay:api:PayPalAPI" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:ed="urn:ebay:apis:EnhancedDataTypes" >
    <soapenv:Header>
    <ns:RequesterCredentials>
    <ebl:Credentials>
        <ebl:Username>username
</ebl:Username>
<ebl:Password>password
</ebl:Password>
<ebl:Signature>signature
</ebl:Signature>
</ebl:Credentials>
</ns:RequesterCredentials>
</soapenv:Header>
<soapenv:Body>
    <ns:DoReferenceTransactionReq>
    <ns:DoReferenceTransactionRequest>
    <ebl:DoReferenceTransactionRequestDetails>
    <ebl:ReferenceID>B-reference_id
</ebl:ReferenceID>
<ebl:PaymentAction>sale
</ebl:PaymentAction>
<ebl:PaymentDetails>
    <ebl:OrderTotal currencyID="GBP">10
</ebl:OrderTotal>
<ebl:ButtonSource>PayPal_SDK
</ebl:ButtonSource>
</ebl:PaymentDetails>
</ebl:DoReferenceTransactionRequestDetails>
<ebl:Version>106.0
</ebl:Version>
</ns:DoReferenceTransactionRequest>
</ns:DoReferenceTransactionReq>
</soapenv:Body>
</soapenv:Envelope>'

最佳答案

在我 friend 的帮助下,我找出了问题所在。

$RTRequestDetails->PaymentAction ='Sale';

代替

$RTRequestDetails->PaymentAction ='sale';

PayPal SOAP API 需要区分大小写。 遗憾的是,他们没有发送任何错误信息。

关于php - PayPal 引用交易 - 响应状态代码 400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40744466/

相关文章:

php - 在php行中插入多个值

php - Wordpress - 如何将特定类别的特色图片显示为背景?

PHP 子类 Magic __isset 有效,但 __get 无效

ruby-on-rails - Rail 的 PayPal 与自动返回和动态 URL 数据集成的标准做法是什么?

php - 调用 DoDirectPayment 时出现权限错误 - PayPal

paypal - 签名请求 API 错误的 url

javascript - 如何在选择输入中自动选择下拉列表的第一个值?

javascript - 如何将 PHP 嵌入 Javascript 函数中?

paypal - 我如何获得 Paypal 自适应支付支付响应

node.js - 每月可变金额的 Paypal 定期付款