我尝试使用PayPal Reference Transactin。我已经签订了账单,在任何交易完成之前就已经设置了账单协议ID。
我提出了一个简单的交易请求,但得到了:
PPHttpConnection.php第108行中的PPConnectionException:
访问时获得Http响应代码400 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包络器:
<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>'
答案 0 :(得分:1)
在我朋友的帮助下,我发现了什么是错的。
$RTRequestDetails->PaymentAction ='Sale';
而不是
$RTRequestDetails->PaymentAction ='sale';
PayPal SOAP API需要具有正确区分大小写的所有内容。 很遗憾,他们没有发送任何信息有什么不妥。