Making a Paypal Webhook Endpoint

I need to get the email and success state of webhook from paypal
how to digest the Message Payload though?
I know how to get data into a table in codeless (if i can get a handle upon the data).
Am i able to do this in code, not codeless? It would be easier fer me to process code, i’m always looking around fer the right block in codeless.

here is example message payload…

{
“id”: “WH-3XD115005N017542S-5D373663FE538392D”,
“create_time”: “2024-07-31T17:44:54.574Z”,
“resource_type”: “capture”,
“event_type”: “PAYMENT.CAPTURE.COMPLETED”,
“summary”: “Payment completed for AUD 36.0 AUD”,
“resource”: {
“payee”: {
“email_address”: “sb-5eaxc31477339@business.example.com”,
“merchant_id”: “SG32YNJAV6RJL”
},
“amount”: {
“value”: “36.00”,
“currency_code”: “AUD”
},
“seller_protection”: {
“dispute_categories”: [
“ITEM_NOT_RECEIVED”,
“UNAUTHORIZED_TRANSACTION”
],
“status”: “ELIGIBLE”
},
“supplementary_data”: {
“related_ids”: {
“order_id”: “674863911T703034N”
}
},
“update_time”: “2024-07-31T17:44:50Z”,
“create_time”: “2024-07-31T17:44:50Z”,
“final_capture”: true,
“seller_receivable_breakdown”: {
“paypal_fee”: {
“value”: “1.16”,
“currency_code”: “AUD”
},
“gross_amount”: {
“value”: “36.00”,
“currency_code”: “AUD”
},
“net_amount”: {
“value”: “34.84”,
“currency_code”: “AUD”
}
},
“custom_id”: “user-id-123”,
“links”: [
{
“method”: “GET”,
“rel”: “self”,
“href”: “https://api.sandbox.paypal.com/v2/payments/captures/7A102450PD221972B
},
{
“method”: “POST”,
“rel”: “refund”,
“href”: “https://api.sandbox.paypal.com/v2/payments/captures/7A102450PD221972B/refund
},
{
“method”: “GET”,
“rel”: “up”,
“href”: “https://api.sandbox.paypal.com/v2/checkout/orders/674863911T703034N
}
],
“id”: “7A102450PD221972B”,
“status”: “COMPLETED”
},
“status”: “SUCCESS”,
“transmissions”: [
{
“webhook_url”: “https://api.backendless.com/FF55A111-06AF-7EB1-FFDE-B5B62760CA00/82EF8043-6A25-48C9-8025-B66AC81A019C/services/PaypalWebhook/webhookPaypal”,
“http_status”: 200,
“reason_phrase”: “HTTP/1.1 200 Connection established”,
“response_headers”: {
“access-control-allow-origin”: “*”,
“date”: “Wed, 31 Jul 2024 17:45:07 GMT”,
“content-length”: “4”,
“server”: “nginx”,
“access-control-allow-credentials”: “true”,
“Connection”: “keep-alive”,
“content-type”: “application/json”,
“strict-transport-security”: “max-age=31536000; includeSubDomains; preload”,
“access-control-allow-methods”: “POST, GET, OPTIONS, PUT, DELETE, PATCH”
},
“transmission_id”: “9e276300-4f64-11ef-92a5-bf12edb9582e”,
“status”: “SUCCESS”,
“timestamp”: “2024-07-31T17:45:04Z”
}
],
“links”: [
{
“href”: “https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-3XD115005N017542S-5D373663FE538392D”,
“rel”: “self”,
“method”: “GET”,
“encType”: “application/json”
},
{
“href”: “https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-3XD115005N017542S-5D373663FE538392D/resend”,
“rel”: “resend”,
“method”: “POST”,
“encType”: “application/json”
}
],
“event_version”: “1.0”,
“resource_version”: “2.0”
}

If you’re looking for a way to process a JSON object in code, I recommend searching stack overflow or asking ChatGPT. If you need help with Codeless, please name a specific property you want to extract from this payload, and we will be happy to provide an example.

Mark

“email_address”: “sb-5eaxc31477339@business.example.com”,

is the property i would like to extract from the payload…

“resource” > “payee” > “email_address”

This should do it:

I shall try it now :slight_smile:

how to get payloadObject? i can’t find it

I do not know, it is what the webhook provides.

Sorry i meant how to get it in variable form, in codeless, im a complete codeless noob.

Could you show what you already have?

idk if that’s right…

Me neither. You could try logging the values to see what’s in them (there are blocks for the Logging API and they will log the data in the server-side log file).
https://backendless.com/docs/rest/ut_logging_a_message.html#codeless-reference

If you’re new to Codeless, I recommend doing minimal training first.

Mark

I tried invoking it with that plus returning the email_address variable. it returned the email from the payload. Success!! :slight_smile:

Thanks for your help :smiley:

You are welcome!