Webhook event PAYMENT.SALE.COMPLETED has no reference to Subscription or Subscription Plan

dadandan12
Contributor
Contributor

Hi,

 

Does anyone know how can i get subscription plan id when PayPal successfully capture the payment?

I'm struggling to get it via Sale object or billing agreement.

 

Thanks,

Login to Me Too
4 REPLIES 4

yogitamankani
Contributor
Contributor

hi,

 

The 'Billing Agreement Id' is the Subscription Id in the PAYMENT.SALE.COMPLETED event. See a sample below.

 

{
  "id": "WH-72J78916XW253041B-5HG111500B361204H",
  "event_version": "1.0",
  "create_time": "2019-11-08T19:18:05.489Z",
  "resource_type": "sale",
  "event_type": "PAYMENT.SALE.COMPLETED",
  "summary": "Payment completed for $ 11.0 USD",
  "resource": {
    "id": "8VD9479630095983G",
    "state": "completed",
    "amount": {
      "total": "11.00",
      "currency": "USD",
      "details": {
        "subtotal": "11.00"
      }
    },
    "payment_mode": "INSTANT_TRANSFER",
    "protection_eligibility": "ELIGIBLE",
    "protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
    "transaction_fee": {
      "value": "0.62",
      "currency": "USD"
    },
    "invoice_number": "",
    "billing_agreement_id": "I-GPVDFDPJEXGP",
    "create_time": "2019-11-08T19:17:53Z",
    "update_time": "2019-11-08T19:17:53Z",
    "links": [
      {
        "href": "https://api.sandbox.paypal.com/v1/payments/sale/8VD9479630095983G",
        "rel": "self",
        "method": "GET"
      },
      {
        "href": "https://api.sandbox.paypal.com/v1/payments/sale/8VD9479630095983G/refund",
        "rel": "refund",
        "method": "POST"
      }
    ]
  },
  "links": [
    {
      "href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-72J78916XW253041B-5HG111500B36120...",
      "rel": "self",
      "method": "GET"
    },
    {
      "href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-72J78916XW253041B-5HG111500B36120...",
      "rel": "resend",
      "method": "POST"
    }
  ]
}

Login to Me Too

nicosavini
Contributor
Contributor

Is it possible that the webhooks simulator is not populating that field?

 

I am probably going to go the way you suggest, but is there any official documentation on the matter?

 

Thanks,

Login to Me Too

yogitamankani
Contributor
Contributor

Yes, the webhook simulator is not populating it. I had reported/queried the same in email to technical support and they confirmed it is the same webhook event which will have the billing agreement details.

 

What I would suggest is that you have a quick notification listener URL up and configure that in your Paypal developer ssandbox account. That way you will get better idea. the listener can be on localhost during development and you can use ngrok to configure that in Paypal env.

Login to Me Too

darule0
Contributor
Contributor

looks like the events generated by the WebhookSimulator omit billing_agreement_id

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.