The PayPal-generated asymmetric signature. Extract this value from the PAYPAL-TRANSMISSION-SIG response header, which is received with the webhook notification.
public setTransmissionSig ( string $transmission_sig ) | ||
$transmission_sig | string |
* Just uncomment the below line to read the data from actual request. */ /** @var Array $headers */ //$headers = getallheaders(); /** * In Documentions https://developer.paypal.com/docs/api/webhooks/#verify-webhook-signature_post * All header keys as UPPERCASE, but I recive the header key as the example array, First letter as UPPERCASE */ $headers = array_change_key_case($headers, CASE_UPPER); $signatureVerification = new VerifyWebhookSignature(); $signatureVerification->setAuthAlgo($headers['PAYPAL-AUTH-ALGO']); $signatureVerification->setTransmissionId($headers['PAYPAL-TRANSMISSION-ID']); $signatureVerification->setCertUrl($headers['PAYPAL-CERT-URL']); $signatureVerification->setWebhookId("9XL90610J3647323C"); // Note that the Webhook ID must be a currently valid Webhook that you created with your client ID/secret. $signatureVerification->setTransmissionSig($headers['PAYPAL-TRANSMISSION-SIG']); $signatureVerification->setTransmissionTime($headers['PAYPAL-TRANSMISSION-TIME']); $webhookEvent = new WebhookEvent(); $webhookEvent->fromJson($requestBody); $signatureVerification->setWebhookEvent($webhookEvent); $request = clone $signatureVerification; try { /** @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, $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->getVerificationStatus(), $request->toJSON(), $output);