skip to Main Content

I was trying to implement paypal api for one of my projects

I am using sandbox environment and server side sdk

In the request i have

{
    "intent": "CAPTURE",
    "application_context": {
      "brand_name": "EXAMPLE INC",
      "landing_page": "BILLING",
      "shipping_preference": "SET_PROVIDED_ADDRESS",
      "user_action": "PAY_NOW"
    },

i.e

"intent": "CAPTURE"
"user_action": "PAY_NOW"

I created an order using the api OrdersCreateRequest(). In the response i get the

result.id = "IDVALUE"
result.status = "CREATED"

and also the links

"links": [
    {
        "href": "https://api.sandbox.paypal.com/v2/checkout/orders/XXXXXXXX",
        "method": "GET",
        "rel": "self"
    },
    {
        "href": "https://www.sandbox.paypal.com/checkoutnow?token=XXXXXXXXXX",
        "method": "GET",
        "rel": "approve"
    },
    {
        "href": "https://api.sandbox.paypal.com/v2/checkout/orders/XXXXXXXXXXXXXX",
        "method": "PATCH",
        "rel": "update"
    },
    {
        "href": "https://api.sandbox.paypal.com/v2/checkout/orders/XXXXXXXXXXXXXX/capture",
        "method": "POST",
        "rel": "capture"
    }
],

I have tried to open the url

        {
            "href": "https://www.sandbox.paypal.com/checkoutnow?token=XXXXXXXXXX",
            "method": "GET",
            "rel": "approve"
        },

In the browser, it asks for PayPal login, what credentials we have to use as login and password. I have only client_id and client_secret

How to get an approved order id. What should I do now.

2

Answers


  1. Chosen as BEST ANSWER

    How to get the username and the password for the sandbox account.

    Navigate to

    enter image description here

    And we see the email and password which can used to as paypal login credentials while approve the order

    enter image description here

    So now go to the approve url https://www.sandbox.paypal.com/checkoutnow?token=XXXXXXXXXX

    enter image description here

    and click on login (paypal account) and enter email and password

    enter image description here

    enter image description here

    And after successful login pay here

    enter image description here

    So now the order gets approved.


  2. The next step is to redirect the payer to that approval_url or use the Order ID with Smart Payment Buttons, which is better than redirecting. Either way the payer will be signing in with their PayPal (sandbox) buyer account or entering their (sandbox) buyer information in a PayPal window or form.

    The best approval flow to use is the one at https://developer.paypal.com/demo/checkout/#/pattern/server

    Note that it pairs with two routes on your server, one that creates the order and one that captures the order after approval.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search