Updated samples and its documentation

This commit is contained in:
brluk and japatel
2017-10-24 12:05:49 -05:00
parent ddc8b6d482
commit 0303e2c0c9
98 changed files with 3063 additions and 1068 deletions

View File

@@ -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>-&gt;setAuthAlgo(<span class="hljs-variable">$headers</span>[<span class="hljs-string">'PAYPAL-AUTH-ALGO'</span>]);
<span class="hljs-variable">$signatureVerification</span>-&gt;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&#39;s
<span class="hljs-variable">$signatureVerification</span>-&gt;setTransmissionSig(<span class="hljs-variable">$headers</span>[<span class="hljs-string">'PAYPAL-TRANSMISSION-SIG'</span>]);
<span class="hljs-variable">$signatureVerification</span>-&gt;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>-&gt;fromJson(<span class="hljs-variable">$requestBody</span>);
<span class="hljs-variable">$signatureVerification</span>-&gt;setWebhookEvent(<span class="hljs-variable">$webhookEvent</span>);
<span class="hljs-variable">$signatureVerification</span>-&gt;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&#39;s
<span class="hljs-variable">$output</span> = <span class="hljs-variable">$signatureVerification</span>-&gt;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>-&gt;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>-&gt;getVerificationStatus(), <span class="hljs-variable">$request</span>-&gt;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>-&gt;getVerificationStatus(), <span class="hljs-variable">$request</span>-&gt;toJSON(), <span class="hljs-variable">$output</span>);</div></div></div></div></body></html>