Paypal API v2 response The specified resource does not exist

h2odev

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:

<script src='https://www.paypal.com/sdk/js?client-id=sb&currency=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.cart.items = ITEMS ON INVOCE

_this.cart.invoice = INVOICE DETAILS

$orderid = data.orderID (from js above)

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.

  $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):

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.

What I'm missing in this process?

Manuel Otto

You were missing the client-id when you included the js file:

<script src='https://www.paypal.com/sdk/js?client-id=[CLIENT-ID-HERE]&currency=EUR&commit=true&disable-funding=card,credit' ></script>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

PayPal API V2 Create Invoice Wrong Response/Status Code

azure blob storage getting error - the specified resource does not exist

Are there multiple reasons for Azure error: "The specified resource does not exist"?

RESOURCE_NOT_FOUND while creating Subscription Api response in PayPal in JavaScript

Resource ServletContext resource does not exist

libcocos2dx resource error: resource directory does not exist

AWS s3 api error: specified bucket does not exist

Replacing PayPal SetExpressCheckout SOAP API with REST API V2

LinkedIn API request fails with "Resource reactions does not exist"

Is there a PayPal SDK that uses V2 of the REST API

PayPal v2 Orders API - difference between OrdersGetRequest and OrdersCaptureRequest

Paypal API v2 request bearer token

PayPal Smart Button / Orders V2 API Shipping Value

Should I be using webhooks with PayPal's V2 API?

paypal v2 curl api invalid_client

PayPal API v2, get Transaction ID

Get Transaction Data via PayPal REST API V2

How to handle "The specified resource does not exist" exception while using Entity group transactions to purge WADLogs table

Put & post method for a blob on azure returning 404 The specified resource does not exist.

Property spring.datasource.schema with value 'class path resource [schema-mysql.sql]' is invalid: The specified resource does not exist

Dialogflow v2 API + Actions v2 API: MalformedResponse 'final_response' must be set

LocalDB instance specified does not exist

Serverless: The specified bucket does not exist

specified destination directory does not exist

specified JRE installation does not exist

The specified project directory ''" does not exist

The specified provider "google" does not exist

The specified LocalDb instance does not exist

'Resource' does not exist in current context