forked from LiveCarta/PayPal-PHP-SDK
Updated samples and its documentation
This commit is contained in:
@@ -39,11 +39,11 @@ To resolve that, we need to use alternative, which makes a call to PayPal's
|
||||
<span class="hljs-comment">//$headers = getallheaders();</span>
|
||||
|
||||
<span class="hljs-comment">/**
|
||||
* In Documentions https://developer.paypal.com/docs/api/webhooks/#verify-webhook-signature_post
|
||||
* 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
|
||||
*/</span>
|
||||
<span class="hljs-variable">$headers</span> = array_change_key_case(<span class="hljs-variable">$headers</span>, CASE_UPPER);
|
||||
|
||||
|
||||
<span class="hljs-variable">$signatureVerification</span> = <span class="hljs-keyword">new</span> VerifyWebhookSignature();
|
||||
<span class="hljs-variable">$signatureVerification</span>->setAuthAlgo(<span class="hljs-variable">$headers</span>[<span class="hljs-string">'PAYPAL-AUTH-ALGO'</span>]);
|
||||
<span class="hljs-variable">$signatureVerification</span>->setTransmissionId(<span class="hljs-variable">$headers</span>[<span class="hljs-string">'PAYPAL-TRANSMISSION-ID'</span>]);
|
||||
@@ -52,9 +52,7 @@ To resolve that, we need to use alternative, which makes a call to PayPal's
|
||||
<span class="hljs-variable">$signatureVerification</span>->setTransmissionSig(<span class="hljs-variable">$headers</span>[<span class="hljs-string">'PAYPAL-TRANSMISSION-SIG'</span>]);
|
||||
<span class="hljs-variable">$signatureVerification</span>->setTransmissionTime(<span class="hljs-variable">$headers</span>[<span class="hljs-string">'PAYPAL-TRANSMISSION-TIME'</span>]);
|
||||
|
||||
<span class="hljs-variable">$webhookEvent</span> = <span class="hljs-keyword">new</span> WebhookEvent();
|
||||
<span class="hljs-variable">$webhookEvent</span>->fromJson(<span class="hljs-variable">$requestBody</span>);
|
||||
<span class="hljs-variable">$signatureVerification</span>->setWebhookEvent(<span class="hljs-variable">$webhookEvent</span>);
|
||||
<span class="hljs-variable">$signatureVerification</span>->setRequestBody(<span class="hljs-variable">$requestBody</span>);
|
||||
<span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$signatureVerification</span>;
|
||||
|
||||
<span class="hljs-keyword">try</span> {
|
||||
@@ -62,4 +60,4 @@ To resolve that, we need to use alternative, which makes a call to PayPal's
|
||||
<span class="hljs-variable">$output</span> = <span class="hljs-variable">$signatureVerification</span>->post(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Validate Received Webhook Event"</span>, <span class="hljs-string">"WebhookEvent"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>->toJSON(), <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper">ResultPrinter::printResult(<span class="hljs-string">"Validate Received Webhook Event"</span>, <span class="hljs-string">"WebhookEvent"</span>, <span class="hljs-variable">$output</span>->getVerificationStatus(), <span class="hljs-variable">$request</span>->toJSON(), <span class="hljs-variable">$output</span>);</div></div></div></div></body></html>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper">ResultPrinter::printResult(<span class="hljs-string">"Validate Received Webhook Event"</span>, <span class="hljs-string">"WebhookEvent"</span>, <span class="hljs-variable">$output</span>->getVerificationStatus(), <span class="hljs-variable">$request</span>->toJSON(), <span class="hljs-variable">$output</span>);</div></div></div></div></body></html>
|
||||
Reference in New Issue
Block a user