[英]Paypal API v2 response The specified resource does not exist
I'm trying to /capture the funds in server side but I got the error message "The specified resource does not exist". 我正在尝试/捕获服务器端的资金,但收到错误消息“指定的资源不存在”。
I have placed Paypal script configured for sandbox nad EUR currency: 我已将配置为沙箱nad EUR货币的Paypal脚本放置:
<script src='https://www.paypal.com/sdk/js?client-id=sb¤cy=EUR&commit=true&disable-funding=card,credit' ></script>
Then, configured the button as described below 然后,如下所述配置按钮
paypal.Buttons( {
createOrder : function( data, actions ) {
return actions.order.create( {
"intent" : "CAPTURE",
"purchase_units" : [ { amount : { "value" : cart-total-amount,
"currency_code" : "EUR",
} } ] } );
},
onApprove: function( data, actions ) {
/*
MY SERVER API
*/
_this.api( "my-server-api-url/cart/submit/",
{ "items" : _this.cart.items,
"invoice" : _this.cart.invoice,
"paymentmethod" : "paypal",
"orderid" : data.orderID,
"payerid" : data.payerID,
}, function( data ) {
alert( data.message );
} );
},
style: { "layout" : "horizontal",
"color" : "blue",
"shape" : "rect",
"label" : "paypal",
"tagline" : false,
"height" : 40,
},
} ).render( "#paypal-button-id" );
Just to explain the code: 只是为了解释代码:
_this = reference to my class/library _this =参考我的班级/图书馆
_this.cart.items = ITEMS ON INVOCE _this.cart.items =发票中的项目
_this.cart.invoice = INVOICE DETAILS _this.cart.invoice =发票明细
$orderid = data.orderID (from js above) $ orderid = data.orderID(来自上面的js)
Then, on server side I get correctly the token from Paypal (variable $accesstoken) but I got an error when I try to capture the funds. 然后,在服务器端,我可以正确地从Paypal获得令牌(变量$ accesstoken),但是在尝试获取资金时却出现了错误。
$curl = curl_init( "https://api.sandbox.paypal.com/v2/checkout/orders/" . $orderid . "/capture" );
curl_setopt( $curl, CURLOPT_POST, true );
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $curl, CURLOPT_HEADER, false );
curl_setopt( $curl, CURLINFO_HEADER_OUT, true );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $curl, CURLOPT_HTTPHEADER, [ "Content-Type: application/json",
"Authorization: Bearer " . $accesstoken,
"Accept: application/json",
] );
$result = curl_exec( $curl );
curl_close( $ch );
curl_close( $curl );
Error (json_decoded and then print_r): 错误(json_decoded,然后是print_r):
stdClass Object
(
[name] => RESOURCE_NOT_FOUND
[details] => Array
(
[0] => stdClass Object
(
[location] => path
[issue] => INVALID_RESOURCE_ID
[description] => Specified resource ID does not exist. Please check the resource ID and try again.
)
)
[message] => The specified resource does not exist.
[debug_id] => cb446322c3a2c
[links] => Array
(
[0] => stdClass Object
(
[href] => https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_RESOURCE_ID
[rel] => information_link
[method] => GET
)
)
)
Basically I create an order on client side (using Paypal API via Js) and then I capture it on server side. 基本上,我在客户端(通过Js使用Paypal API)创建订单,然后在服务器端捕获订单。
What I'm missing in this process? 在此过程中我缺少什么?
包含js文件时,您缺少client-id
:
<script src='https://www.paypal.com/sdk/js?client-id=[CLIENT-ID-HERE]¤cy=EUR&commit=true&disable-funding=card,credit' ></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.