phpjuice / paypal-checkout-sdk

PHP SDK for PayPal's Checkout REST API

Home Page:https://phpjuice.gitbook.io/paypal-checkout-sdk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get more clarity on what to do after order create

ponasromas opened this issue · comments

After I create order, what next step should I do? Isn't it should generate approval_link? After order create step I get this:

{
  "create_time": "2023-02-28T07:46:30Z",
  "id": "18545950ND137401U",
  "intent": "CAPTURE",
  "links": [
    {
      "href": "https://api.sandbox.paypal.com/v2/checkout/orders/18545950ND137401U",
      "method": "GET",
      "rel": "self"
    },
    {
      "href": "https://www.sandbox.paypal.com/checkoutnow?token=18545950ND137401U",
      "method": "GET",
      "rel": "approve"
    },
    {
      "href": "https://api.sandbox.paypal.com/v2/checkout/orders/18545950ND137401U",
      "method": "PATCH",
      "rel": "update"
    },
    {
      "href": "https://api.sandbox.paypal.com/v2/checkout/orders/18545950ND137401U/capture",
      "method": "POST",
      "rel": "capture"
    }
  ],
  "purchase_units": [
    {
      "amount": {
        "breakdown": {
          "item_total": {
            "currency_code": "EUR",
            "value": "10.00"
          }
        },
        "currency_code": "EUR",
        "value": "10.00"
      },
      "items": [
        {
          "category": "DIGITAL_GOODS",
          "description": "",
          "name": "Invoice PRF-15",
          "quantity": "1",
          "unit_amount": {
            "currency_code": "EUR",
            "value": "10.00"
          }
        }
      ],
      "payee": {
        "email_address": "*****",
        "merchant_id": "AZUR3*******"
      },
      "reference_id": "default"
    }
  ],
  "status": "CREATED"
}

Where else to go? "Capture an Order" step possible only after customer approves payment. But where is the link for approval?

commented

@ponasromas I think, you'd need to redirect user to

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

that's where they approve purchase on PayPal's side.
After which PayPal is gonna send you response that you ned to work with. (either purchase complete or not)

Yes correct you should redirect user to the approval link so they can approve your created order. Thanks @1337haxx0r