forked from LiveCarta/PayPal-PHP-SDK
Final Webhook Management API Changes
- Updated Samples - Additional Functional Tests - Enabled Travis to do functional tests (with allowed failures) on each build
This commit is contained in:
@@ -1268,7 +1268,18 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
|
||||
"title": "Basic Information",
|
||||
"slug": "basic-information"
|
||||
},
|
||||
"depth": 1
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 4,
|
||||
"title": "NOTE: Please note that you need an https url for paypal webhooks. You can however override the url with https, and accept",
|
||||
"slug": "note-please-note-that-you-need-an-https-url-for-paypal-webhooks-you-can-however-override-the-url-with-https-and-accept"
|
||||
},
|
||||
"depth": 4
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
@@ -1988,6 +1999,110 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample/payments/AuthorizePaymentUsingPayPal.php",
|
||||
"projectPath": "payments/AuthorizePaymentUsingPayPal.php",
|
||||
"targetPath": "payments/AuthorizePaymentUsingPayPal",
|
||||
"pageTitle": "payments/AuthorizePaymentUsingPayPal",
|
||||
"title": "AuthorizePaymentUsingPayPal"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Authorize Payment using PayPal as payment method",
|
||||
"slug": "authorize-payment-using-paypal-as-payment-method"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Payer",
|
||||
"slug": "payer"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Itemized information",
|
||||
"slug": "itemized-information"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Additional payment details",
|
||||
"slug": "additional-payment-details"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Amount",
|
||||
"slug": "amount"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Transaction",
|
||||
"slug": "transaction"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Redirect urls",
|
||||
"slug": "redirect-urls"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Payment",
|
||||
"slug": "payment"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Create Payment",
|
||||
"slug": "create-payment"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Get redirect url",
|
||||
"slug": "get-redirect-url"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
|
||||
@@ -6,6 +6,7 @@ API used: GET /v1/notifications/webhooks-events</p></div></div></div><div class=
|
||||
<p>Creating webhook is sample purposes only. In real scenario, you dont need to create a new webhook everytime you want to search
|
||||
for a webhook events. This is made in a sample just to make sure there is minimum of one webhook to listen to.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\Webhook $webhook */</span>
|
||||
<span class="hljs-variable">$webhook</span> = <span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Authorization</span>;
|
||||
|
||||
<span class="hljs-variable">$params</span> = <span class="hljs-keyword">array</span>(</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>'start_time'=>'2014-12-06T11:00:00Z',
|
||||
'end_time'=>'2014-12-12T11:00:00Z'</p></div></div><div class="code"><div class="wrapper">);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="search-webhook-events">Search Webhook events</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
@@ -17,4 +18,5 @@ for a webhook events. This is made in a sample just to make sure there is minimu
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Search Webhook events"</span>, <span class="hljs-string">"WebhookEventList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$output</span>);
|
||||
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
||||
@@ -14,7 +14,11 @@ API used: POST /v1/notifications/webhooks</p></div></div><div class="code"><div
|
||||
]
|
||||
}</code></pre>
|
||||
<p>Fill up the basic information that is required for the webhook
|
||||
The URL should be actually accessible over the internet. Having a localhost here would not work.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$webhook</span>->setUrl(<span class="hljs-string">"https://requestb.in/10ujt3c1?uniqid="</span> . uniqid());</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="event-types">Event Types</h1>
|
||||
The URL should be actually accessible over the internet. Having a localhost here would not work.</p>
|
||||
<h4 id="there-is-an-open-source-tool-http-requestb-in-that-allows-you-to-receive-any-web-requests-to-a-url-given-there-">There is an open source tool <a href="http://requestb.in/">http://requestb.in/</a> that allows you to receive any web requests to a url given there.</h4>
|
||||
<h4 id="note-please-note-that-you-need-an-https-url-for-paypal-webhooks-you-can-however-override-the-url-with-https-and-accept">NOTE: Please note that you need an https url for paypal webhooks. You can however override the url with https, and accept</h4>
|
||||
<p>any warnings your browser might show you. Also, please note that this is entirely for demo purposes, and you should not
|
||||
be using this in production</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$webhook</span>->setUrl(<span class="hljs-string">"https://requestb.in/10ujt3c1?uniqid="</span> . uniqid());</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="event-types">Event Types</h1>
|
||||
<p>Event types correspond to what kind of notifications you want to receive on the given URL.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$webhookEventTypes</span> = <span class="hljs-keyword">array</span>();
|
||||
<span class="hljs-variable">$webhookEventTypes</span>[] = <span class="hljs-keyword">new</span> \PayPal\Api\WebhookEventType(
|
||||
<span class="hljs-string">'{
|
||||
|
||||
85
sample/doc/payments/AuthorizePaymentUsingPayPal.html
Normal file
85
sample/doc/payments/AuthorizePaymentUsingPayPal.html
Normal file
@@ -0,0 +1,85 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>payments/AuthorizePaymentUsingPayPal</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="payments/AuthorizePaymentUsingPayPal"><meta name="groc-project-path" content="payments/AuthorizePaymentUsingPayPal.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">payments/AuthorizePaymentUsingPayPal.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="authorize-payment-using-paypal-as-payment-method">Authorize Payment using PayPal as payment method</h1>
|
||||
<p>This sample code demonstrates how you can process a
|
||||
PayPal Account based Payment.
|
||||
API used: /v1/payments/payment
|
||||
As you can see, there is only one difference between creating a payment using PayPal with sale or authorize as intent.
|
||||
You need to set the proper intent in the request, and the remaining data would be the same</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Amount</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Details</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Item</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ItemList</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payer</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payment</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">RedirectUrls</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Transaction</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="payer">Payer</h3>
|
||||
<p>A resource representing a Payer that funds a payment
|
||||
For paypal account payments, set payment method
|
||||
to 'paypal'.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payer</span> = <span class="hljs-keyword">new</span> Payer();
|
||||
<span class="hljs-variable">$payer</span>->setPaymentMethod(<span class="hljs-string">"paypal"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="itemized-information">Itemized information</h3>
|
||||
<p>(Optional) Lets you specify item wise
|
||||
information</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$item1</span> = <span class="hljs-keyword">new</span> Item();
|
||||
<span class="hljs-variable">$item1</span>->setName(<span class="hljs-string">'Ground Coffee 40 oz'</span>)
|
||||
->setCurrency(<span class="hljs-string">'USD'</span>)
|
||||
->setQuantity(<span class="hljs-number">1</span>)
|
||||
->setPrice(<span class="hljs-number">7.5</span>);
|
||||
<span class="hljs-variable">$item2</span> = <span class="hljs-keyword">new</span> Item();
|
||||
<span class="hljs-variable">$item2</span>->setName(<span class="hljs-string">'Granola bars'</span>)
|
||||
->setCurrency(<span class="hljs-string">'USD'</span>)
|
||||
->setQuantity(<span class="hljs-number">5</span>)
|
||||
->setPrice(<span class="hljs-number">2</span>);
|
||||
|
||||
<span class="hljs-variable">$itemList</span> = <span class="hljs-keyword">new</span> ItemList();
|
||||
<span class="hljs-variable">$itemList</span>->setItems(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$item1</span>, <span class="hljs-variable">$item2</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="additional-payment-details">Additional payment details</h3>
|
||||
<p>Use this optional field to set additional
|
||||
payment information such as tax, shipping
|
||||
charges etc.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$details</span> = <span class="hljs-keyword">new</span> Details();
|
||||
<span class="hljs-variable">$details</span>->setShipping(<span class="hljs-number">1.2</span>)
|
||||
->setTax(<span class="hljs-number">1.3</span>)
|
||||
->setSubtotal(<span class="hljs-number">17.50</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="amount">Amount</h3>
|
||||
<p>Lets you specify a payment amount.
|
||||
You can also specify additional details
|
||||
such as shipping, tax.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$amount</span> = <span class="hljs-keyword">new</span> Amount();
|
||||
<span class="hljs-variable">$amount</span>->setCurrency(<span class="hljs-string">"USD"</span>)
|
||||
->setTotal(<span class="hljs-number">20</span>)
|
||||
->setDetails(<span class="hljs-variable">$details</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="transaction">Transaction</h3>
|
||||
<p>A transaction defines the contract of a
|
||||
payment - what is the payment for and who
|
||||
is fulfilling it. </p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$transaction</span> = <span class="hljs-keyword">new</span> Transaction();
|
||||
<span class="hljs-variable">$transaction</span>->setAmount(<span class="hljs-variable">$amount</span>)
|
||||
->setItemList(<span class="hljs-variable">$itemList</span>)
|
||||
->setDescription(<span class="hljs-string">"Payment description"</span>)
|
||||
->setInvoiceNumber(uniqid());</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="redirect-urls">Redirect urls</h3>
|
||||
<p>Set the urls that the buyer must be redirected to after
|
||||
payment approval/ cancellation.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$baseUrl</span> = getBaseUrl();
|
||||
<span class="hljs-variable">$redirectUrls</span> = <span class="hljs-keyword">new</span> RedirectUrls();
|
||||
<span class="hljs-variable">$redirectUrls</span>->setReturnUrl(<span class="hljs-string">"$baseUrl/ExecutePayment.php?success=true"</span>)
|
||||
->setCancelUrl(<span class="hljs-string">"$baseUrl/ExecutePayment.php?success=false"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="payment">Payment</h3>
|
||||
<p>A Payment Resource; create one using
|
||||
the above types and intent set to 'sale'</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payment</span> = <span class="hljs-keyword">new</span> Payment();
|
||||
<span class="hljs-variable">$payment</span>->setIntent(<span class="hljs-string">"authorize"</span>)
|
||||
->setPayer(<span class="hljs-variable">$payer</span>)
|
||||
->setRedirectUrls(<span class="hljs-variable">$redirectUrls</span>)
|
||||
->setTransactions(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$transaction</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$payment</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-payment">Create Payment</h3>
|
||||
<p>Create a payment by calling the 'create' method
|
||||
passing it a valid apiContext.
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)
|
||||
The return object contains the state and the
|
||||
url to which the buyer must be redirected to
|
||||
for payment approval</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$payment</span>->create(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Created Payment Authorization Using PayPal. Please visit the URL to Authorize."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <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"><h3 id="get-redirect-url">Get redirect url</h3>
|
||||
<p>The API response provides the url that you must redirect
|
||||
the buyer to. Retrieve the url from the $payment->getLinks()
|
||||
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$payment</span>->getLinks() <span class="hljs-keyword">as</span> <span class="hljs-variable">$link</span>) {
|
||||
<span class="hljs-keyword">if</span> (<span class="hljs-variable">$link</span>->getRel() == <span class="hljs-string">'approval_url'</span>) {
|
||||
<span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$link</span>->getHref();
|
||||
<span class="hljs-keyword">break</span>;
|
||||
}
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Created Payment Authorization Using PayPal. Please visit the URL to Authorize."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-string">"<a href='$approvalUrl' >$approvalUrl</a>"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$payment</span>;</div></div></div></div></body></html>
|
||||
@@ -54,7 +54,7 @@ payment approval/ cancellation.</p></div></div><div class="code"><div class="wra
|
||||
->setCancelUrl(<span class="hljs-string">"$baseUrl/ExecutePayment.php?success=false"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="payment">Payment</h3>
|
||||
<p>A Payment Resource; create one using
|
||||
the above types and intent set to 'sale'</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payment</span> = <span class="hljs-keyword">new</span> Payment();
|
||||
<span class="hljs-variable">$payment</span>->setIntent(<span class="hljs-string">"authorize"</span>)
|
||||
<span class="hljs-variable">$payment</span>->setIntent(<span class="hljs-string">"sale"</span>)
|
||||
->setPayer(<span class="hljs-variable">$payer</span>)
|
||||
->setRedirectUrls(<span class="hljs-variable">$redirectUrls</span>)
|
||||
->setTransactions(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$transaction</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$payment</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-payment">Create Payment</h3>
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
of an authorized payment.
|
||||
API used: /v1/payments/authorization/<$authorizationId></p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Authorization $authorization */</span>
|
||||
<span class="hljs-variable">$authorization</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'AuthorizePayment.php'</span>;
|
||||
|
||||
<span class="hljs-variable">$authorizationId</span> = <span class="hljs-string">'4U805254HC285294Y'</span>; <span class="hljs-comment">// $authorization->getId();</span>
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Authorization</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payment</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="getauthorization">GetAuthorization</h3>
|
||||
<p>You can retrieve info about an Authorization
|
||||
by invoking the Authorization::get method
|
||||
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)
|
||||
The return object contains the authorization state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieve the authorization</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$result</span> = Authorization::get(<span class="hljs-variable">$authorization</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
The return object contains the authorization state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieve the authorization</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$result</span> = Authorization::get(<span class="hljs-variable">$authorizationId</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Authorization"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Authorization"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-variable">$authorization</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$result</span>);
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Authorization"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-variable">$authorizationId</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$result</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$authorization</span>;</div></div></div></div></body></html>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$result</span>;</div></div></div></div></body></html>
|
||||
@@ -2,12 +2,11 @@
|
||||
<p>This sample code demonstrates how you can
|
||||
void an authorized payment.
|
||||
API used: /v1/payments/authorization/<{authorizationid}>/void"</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Authorization $authorization */</span>
|
||||
<span class="hljs-variable">$authorization</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'AuthorizePayment.php'</span>;
|
||||
|
||||
<span class="hljs-variable">$authorization</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'AuthorizePayment.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Replace $authorizationid with any static Id you might already have. It will do a void on it</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$authorizationId</span> = <span class="hljs-string">'1BF65516U6866543H'</span>; <span class="hljs-comment">// $authorization->getId();</span>
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Authorization</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="voidauthorization">VoidAuthorization</h3>
|
||||
<p>You can void a previously authorized payment
|
||||
by invoking the $authorization->void method
|
||||
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Lookup the authorization</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authorization</span> = Authorization::get(<span class="hljs-variable">$authorization</span>->getId(), <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Void the authorization</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$voidedAuth</span> = <span class="hljs-variable">$authorization</span>->void(<span class="hljs-variable">$apiContext</span>);
|
||||
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Lookup the authorization</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authorization</span> = Authorization::get(<span class="hljs-variable">$authorizationId</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Void the authorization</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$voidedAuth</span> = <span class="hljs-variable">$authorization</span>->void(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Void Authorization"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
|
||||
Reference in New Issue
Block a user