diff --git a/sample/index.php b/sample/index.php index daeb2d9..a23facd 100644 --- a/sample/index.php +++ b/sample/index.php @@ -1175,6 +1175,17 @@ if (PHP_SAPI == 'cli') { +
  • +
    +
    Validate Webhook Event
    + +
    +
  • diff --git a/sample/notifications/ValidateWebhookEvent.php b/sample/notifications/ValidateWebhookEvent.php index 3e24a17..8dbb134 100644 --- a/sample/notifications/ValidateWebhookEvent.php +++ b/sample/notifications/ValidateWebhookEvent.php @@ -1,34 +1,42 @@ setAuthAlgo("SHA256withRSA"); +$signatureVerification->setTransmissionId("d938e770-8046-11e6-8103-6b62a8a99ac4"); +$signatureVerification->setCertUrl("https://api.sandbox.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-a5cafa77"); // todo: this isn't going to work +$signatureVerification->setWebhookId("9XL90610J3647323C"); +$signatureVerification->setTransmissionSig("eDOnWUj9FXOnr2naQnrdL7bhgejVSTwRbwbJ0kuk5wAtm2ZYkr7w5BSUDO7e5ZOsqLwN3sPn3RV85Jd9pjHuTlpuXDLYk+l5qiViPbaaC0tLV+8C/zbDjg2WCfvtf2NmFT8CHgPPQAByUqiiTY+RJZPPQC5np7j7WuxcegsJLeWStRAofsDLiSKrzYV3CKZYtNoNnRvYmSFMkYp/5vk4xGcQLeYNV1CC2PyqraZj8HGG6Y+KV4trhreV9VZDn+rPtLDZTbzUohie1LpEy31k2dg+1szpWaGYOz+MRb40U04oD7fD69vghCrDTYs5AsuFM2+WZtsMDmYGI0pxLjn2yw=="); +$signatureVerification->setTransmissionTime("2016-09-21T22:00:46Z"); + + +$webhookEvent = new WebhookEvent(); +$webhookEvent->fromJson($requestBody); +$signatureVerification->setWebhookEvent($webhookEvent); +$request = clone $signatureVerification; -// ### Validate Received Event Method -// Call the validateReceivedEvent() method with provided body, and apiContext object to validate try { - /** @var \PayPal\Api\WebhookEvent $output */ - $output = \PayPal\Api\WebhookEvent::validateAndGetReceivedEvent($bodyReceived, $apiContext); + /** @var \PayPal\Api\VerifyWebhookSignatureResponse $output */ + $output = $signatureVerification->post($apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY - ResultPrinter::printError("Validate Received Webhook Event", "WebhookEvent", null, $bodyReceived, $ex); + ResultPrinter::printError("Validate Received Webhook Event", "WebhookEvent", null, $request->toJSON(), $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY -ResultPrinter::printResult("Validate Received Webhook Event", "WebhookEvent", $output->getId(), $bodyReceived, $output); +ResultPrinter::printResult("Validate Received Webhook Event", "WebhookEvent", $output->getVerificationStatus(), $request->toJSON(), $output);