0

Im setting up a subscription with PayPal and php. So far I know that if the event PAYMENT.SALE.COMPLETED is called the payment was successful. To process the payment at my webhook I need more details about the payment (Who payed? What plan or subscription?). How can I get more details? Is it about the IDs?

This is the event body of an test event:

{
  "id": "WH-2WR32451HC0233532-67976317FL4543714",
  "create_time": "2014-10-23T17:23:52Z",
  "resource_type": "sale",
  "event_type": "PAYMENT.SALE.COMPLETED",
  "summary": "A successful sale payment was made for $ 0.48 USD",
  "resource": {
    "parent_payment": "PAY-1PA12106FU478450MKRETS4A",
    "update_time": "2014-10-23T17:23:04Z",
    "amount": {
      "total": "0.48",
      "currency": "USD"
    },
    "payment_mode": "ECHECK",
    "create_time": "2014-10-23T17:22:56Z",
    "clearing_time": "2014-10-30T07:00:00Z",
    "protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
    "protection_eligibility": "ELIGIBLE",
    "links": [
    ...
    ],
    "id": "80021663DE681814L",
    "state": "completed"
  },
  "links": [
...
fixxel
  • 177
  • 8

1 Answers1

1

A real (non-webhook-test-simulator) event should have the subscription ID (I-#### number) of the subscription that the payment corresponds to. You should have stored that ID in your own user's profile at subscription creation time.

Another approach is to pass your own custom_id at subscription creation time.

You can test all of this in sandbox mode.

Preston PHX
  • 27,642
  • 4
  • 24
  • 44