Webhook: PHP-Example for PAYMENT.SALE.COMPLETED?
Martho2
New Community Member
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Sep-26-2018
09:00 AM
Hello,
I'm missing an example where you show how to get details of a resource from a webhook. So far I got:
$signatureVerification = new \PayPal\Api\VerifyWebhookSignature(); $signatureVerification->setAuthAlgo($headers['PAYPAL-AUTH-ALGO']); $signatureVerification->setTransmissionId($headers['PAYPAL-TRANSMISSION-ID']); $signatureVerification->setCertUrl($headers['PAYPAL-CERT-URL']); $signatureVerification->setWebhookId([my-webhook-id]); $signatureVerification->setTransmissionSig($headers['PAYPAL-TRANSMISSION-SIG']); $signatureVerification->setTransmissionTime($headers['PAYPAL-TRANSMISSION-TIME']); $webhookEvent = new \PayPal\Api\WebhookEvent(); $webhookEvent->fromJson($requestBody); $signatureVerification->setWebhookEvent($webhookEvent); // This is marked as deprecated $request = clone $signatureVerification; try { $output = $signatureVerification->post($apiContext);
}
catch(Exception $ex)
{ // Error-handling
}
if ($webhookEvent->event_type = "PAYMENT.SALE.COMPLETED")
{ $sale = $webhookEvent->getResource();
// What to do next?
}
I got 2 problems with the code:
- setWebhookEvent is marked as deprecated
- $sale seems to be an object of the type "PayPalModel", but how can I get a Sale-Object from it? Or where can I find which type a resource is for a specific webhook anyway?
0 REPLIES 0

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- Assistance Needed: Passing and Retrieving Custom Data in PayPal Webhook Payload in PayPal Payments Standard
- Unable to issue a refund from our business sandbox account in Sandbox Environment
- How to get the custom field from a payment with webhook/API? in REST APIs
- CHECKOUT.ORDER.APPROVED webhook event not triggered if payment_source is passed in in REST APIs
- Paypal Sandbox webshook (SANDBOX WEBHOOKS) not working Real time issue not trigger in Sandbox Environment