Problems implementing rest API

CedisDev
Contributor
Contributor

Hi,

 

I'm trying to implement paypal's rest API into our solution and I have 2 issues which I can't seem to solve via documentation and can't find an answer on the forums or other media.

 

Issue 1:

I'm sending this json:

 

 

{
    "intent": "CAPTURE",
    "purchase_units": [{
            "reference_id": "469440611",
            "amount": {
                "currency_code": "EUR",
                "value": "5.00"
            }
        }
    ],
    "payment_source": {
        "paypal": {
            "experience_context": {
                "payment_method_preference": "IMMEDIATE_PAYMENT_REQUIRED",
                "user_action": "PAY_NOW",
                "locale": "pt-PT",
                "cancel_url": "https://localhost:44398/Shopping",
                "return_url": "https://localhost:44398/Payments/PaypalComplete?payID=81&cartId=3470"
            }
        }
    }
}

 

 

 

And I get 2 links in the answer, one with rel=self and one with rel=payer-action. I'm using the second which has the path /checkoutnow in it.

When it redirects sometimes I get a page with the options "Login" and "Pay with Debit or Credit Card", other times I have "Login" and "Create an account" option only.

It's always the same request, but the result will vary inconsistently. Is there a way to force the first option to always show? We want to allow guest payment.

 

Issue 2:

When I do get the option to pay with guest, I use one of the cards valid for sandbox. Everything goes fine and I get redirected back to my site (in this case localhost for debugging). I then try to make a confirmation of the status of the order via the url https://api-m.sandbox.paypal.com/v2/checkout/orders/<token>/confirm-payment-source and send the json:

 

 

 

{
    "payment_source": {
        "paypal": {
            "experience_context": {
                "payment_method_preference": "IMMEDIATE_PAYMENT_REQUIRED",
                "user_action": "PAY_NOW",
                "locale": "pt-PT"
            }
        }
    }
}

 

 

 

However, I always get the status "PAYER_ACTION_REQUIRED" in the answer.

I was expecting the status to be "COMPLETED" at this point so I could process the order. So what am I doing wrong?

 

Thanks in advance for the help.

Login to Me Too
3 REPLIES 3

eckosneekz
Contributor
Contributor

Have you found a solution?

 

I am having the same exact problem!

Login to Me Too

OW_Chris
Member
Member

I think you need to do a Capture to complete the transaction? (to receive the payment after the buyer approves with the "rel": "payer-action" )   ... /v2/checkout/orders/{id}/capture 

 

The buyer needs to be the personal sandbox account (if you are using the sandbox api). 

 

But I'm having problems with Capture at the moment, so I'm no expert.

Login to Me Too

Mike_Fensoft
Contributor
Contributor

I'm having similar problems.  I can create an order and take the buyer to the payment page but, when I try to capture the payment, the checkout/orders/{orderid}/capture returns "not found".

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.