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
- Disputes Webhook does not works on Sandbox (23/04/24) in Sandbox Environment
- when I payout , webhook URL cannot receive callbacks. in Sandbox Environment
- I want to implement subscription functionality. in REST APIs
- Receiving a PAYMENT.SALE.COMPLETED webhook notification - how can I trace the parent Subscription in REST APIs
- third party direct payments towards developers in REST APIs