Merge pull request #203 from paypal/Payouts

Enabled Payout API Support
This commit is contained in:
Jay
2015-01-08 14:22:09 -06:00
32 changed files with 4752 additions and 1165 deletions

View File

@@ -1243,73 +1243,6 @@ 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
"depth": 1,
"children": [
{
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/notifications/CreateWebhook.php",
"projectPath": "notifications/CreateWebhook.php",
"targetPath": "notifications/CreateWebhook",
"pageTitle": "notifications/CreateWebhook",
"title": "CreateWebhook"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Create Webhook Sample",
"slug": "create-webhook-sample"
},
"depth": 1
}, {
"type": "heading",
"data": {
"level": 1,
"title": "Basic Information",
"slug": "basic-information"
},
"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": {
"level": 1,
"title": "Event Types",
"slug": "event-types"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Create Webhook",
"slug": "create-webhook"
},
"depth": 3
}
]
}
]
}, {
"type": "file",
"data": {
"language": {
@@ -1714,6 +1647,73 @@ 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/paypal/PayPal-PHP-SDK/sample/notifications/createWebhook.php",
"projectPath": "notifications/createWebhook.php",
"targetPath": "notifications/createWebhook",
"pageTitle": "notifications/createWebhook",
"title": "createWebhook"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Create Webhook Sample",
"slug": "create-webhook-sample"
},
"depth": 1
}, {
"type": "heading",
"data": {
"level": 1,
"title": "Basic Information",
"slug": "basic-information"
},
"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": {
"level": 1,
"title": "Event Types",
"slug": "event-types"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Create Webhook",
"slug": "create-webhook"
},
"depth": 3
}
]
}
]
}
]
}, {
@@ -2924,6 +2924,268 @@ 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": "folder",
"data": {
"path": "payouts",
"title": "payouts"
},
"depth": 1,
"children": [
{
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payouts/CreateBatchPayout.php",
"projectPath": "payouts/CreateBatchPayout.php",
"targetPath": "payouts/CreateBatchPayout",
"pageTitle": "payouts/CreateBatchPayout",
"title": "CreateBatchPayout"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Create Bulk Payout Sample",
"slug": "create-bulk-payout-sample"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "NOTE:",
"slug": "note"
},
"depth": 3,
"children": [
{
"type": "heading",
"data": {
"level": 4,
"title": "Batch Header Instance",
"slug": "batch-header-instance"
},
"depth": 4
}, {
"type": "heading",
"data": {
"level": 4,
"title": "Sender Item",
"slug": "sender-item"
},
"depth": 4
}, {
"type": "heading",
"data": {
"level": 4,
"title": "Sender Item 2",
"slug": "sender-item-2"
},
"depth": 4
}, {
"type": "heading",
"data": {
"level": 4,
"title": "Sender Item 3",
"slug": "sender-item-3"
},
"depth": 4
}
]
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Create Payout",
"slug": "create-payout"
},
"depth": 3
}
]
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payouts/CreateSinglePayout.php",
"projectPath": "payouts/CreateSinglePayout.php",
"targetPath": "payouts/CreateSinglePayout",
"pageTitle": "payouts/CreateSinglePayout",
"title": "CreateSinglePayout"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Create Single Synchronous Payout Sample",
"slug": "create-single-synchronous-payout-sample"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "NOTE:",
"slug": "note"
},
"depth": 3,
"children": [
{
"type": "heading",
"data": {
"level": 4,
"title": "Batch Header Instance",
"slug": "batch-header-instance"
},
"depth": 4
}, {
"type": "heading",
"data": {
"level": 4,
"title": "Sender Item",
"slug": "sender-item"
},
"depth": 4
}
]
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Create Payout",
"slug": "create-payout"
},
"depth": 3
}
]
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payouts/GetPayoutBatchStatus.php",
"projectPath": "payouts/GetPayoutBatchStatus.php",
"targetPath": "payouts/GetPayoutBatchStatus",
"pageTitle": "payouts/GetPayoutBatchStatus",
"title": "GetPayoutBatchStatus"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Get Payout Batch Status Sample",
"slug": "get-payout-batch-status-sample"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 2,
"title": "Payout Batch ID",
"slug": "payout-batch-id"
},
"depth": 2,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Get Payout Batch Status",
"slug": "get-payout-batch-status"
},
"depth": 3
}
]
}
]
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payouts/GetPayoutItemStatus.php",
"projectPath": "payouts/GetPayoutItemStatus.php",
"targetPath": "payouts/GetPayoutItemStatus",
"pageTitle": "payouts/GetPayoutItemStatus",
"title": "GetPayoutItemStatus"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Get Payout Item Status Sample",
"slug": "get-payout-item-status-sample"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 2,
"title": "Payout Item ID",
"slug": "payout-item-id"
},
"depth": 2,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Get Payout Item Status",
"slug": "get-payout-item-status"
},
"depth": 3
}
]
}
]
}
]
}
]
}, {
"type": "folder",
"data": {

View File

@@ -46,13 +46,8 @@ Please note that the plan Id should be only set in this case.</p></div></div><di
-&gt;setCountryCode(<span class="hljs-string">'US'</span>);
<span class="hljs-variable">$agreement</span>-&gt;setShippingAddress(<span class="hljs-variable">$shippingAddress</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">$agreement</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-agreement">Create Agreement</h3></div></div></div><div class="segment"><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>Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span> = <span class="hljs-variable">$agreement</span>-&gt;create(<span class="hljs-variable">$apiContext</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 $agreement-&gt;getLinks()
method</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$agreement</span>-&gt;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>-&gt;getRel() == <span class="hljs-string">'approval_url'</span>) {
<span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$link</span>-&gt;getHref();
<span class="hljs-keyword">break</span>;
}
}
the buyer to. Retrieve the url from the $agreement-&gt;getApprovalLink()
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$agreement</span>-&gt;getApprovalLink();
} <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 Billing Agreement."</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html><html lang="en"><head><title>notifications/CreateWebhook</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="notifications/CreateWebhook"><meta name="groc-project-path" content="notifications/CreateWebhook.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">notifications/CreateWebhook.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-webhook-sample">Create Webhook Sample</h1>
<!DOCTYPE html><html lang="en"><head><title>notifications/createWebhook</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="notifications/createWebhook"><meta name="groc-project-path" content="notifications/createWebhook.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">notifications/createWebhook.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-webhook-sample">Create Webhook Sample</h1>
<p>This sample code demonstrate how you can create a webhook, as documented here at:
<a href="https://developer.paypal.com/webapps/developer/docs/api/#create-a-webhook">https://developer.paypal.com/webapps/developer/docs/api/#create-a-webhook</a>
API used: POST /v1/notifications/webhooks</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>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a new instance of Webhook object</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$webhook</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Webhook();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="basic-information">Basic Information</h1>

View File

@@ -73,12 +73,7 @@ for payment approval</p></div></div><div class="code"><div class="wrapper"><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-&gt;getLinks()
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$payment</span>-&gt;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>-&gt;getRel() == <span class="hljs-string">'approval_url'</span>) {
<span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$link</span>-&gt;getHref();
<span class="hljs-keyword">break</span>;
}
}
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$payment</span>-&gt;getApprovalLink();
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">"&lt;a href='$approvalUrl' &gt;$approvalUrl&lt;/a&gt;"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);

View File

@@ -70,13 +70,8 @@ for payment approval</p></div></div><div class="code"><div class="wrapper"><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-&gt;getLinks()
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$payment</span>-&gt;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>-&gt;getRel() == <span class="hljs-string">'approval_url'</span>) {
<span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$link</span>-&gt;getHref();
<span class="hljs-keyword">break</span>;
}
}
the buyer to. Retrieve the url from the $payment-&gt;getApprovalLink()
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$payment</span>-&gt;getApprovalLink();
ResultPrinter::printResult(<span class="hljs-string">"Created Payment Using PayPal. Please visit the URL to Approve."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-string">"&lt;a href='$approvalUrl' &gt;$approvalUrl&lt;/a&gt;"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);

View File

@@ -0,0 +1,93 @@
<!DOCTYPE html><html lang="en"><head><title>payouts/CreateBatchPayout</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="payouts/CreateBatchPayout"><meta name="groc-project-path" content="payouts/CreateBatchPayout.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">payouts/CreateBatchPayout.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-bulk-payout-sample">Create Bulk Payout Sample</h1>
<p>This sample code demonstrate how you can create a synchronous payout sample, as documented here at:
<a href="https://developer.paypal.com/docs/integration/direct/create-batch-payout/">https://developer.paypal.com/docs/integration/direct/create-batch-payout/</a>
API used: /v1/payments/payouts</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>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a new instance of Payout object</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payouts</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Payout();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>This is how our body should look like:</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/*
*{
"sender_batch_header": {
"sender_batch_id": "random_uniq_id",
"email_subject": "You have a payment"
},
"items": [
{
"recipient_type": "EMAIL",
"amount": {
"value": 0.99,
"currency": "USD"
},
"receiver": "shirt-supplier-one@mail.com",
"note": "Thank you.",
"sender_item_id": "item_1"
},
{
"recipient_type": "EMAIL",
"amount": {
"value": 0.90,
"currency": "USD"
},
"receiver": "shirt-supplier-two@mail.com",
"note": "Thank you.",
"sender_item_id": "item_2"
},
{
"recipient_type": "EMAIL",
"amount": {
"value": 2.00,
"currency": "USD"
},
"receiver": "shirt-supplier-three@mail.com",
"note": "Thank you.",
"sender_item_id": "item_3"
}
]
}
*/</span>
<span class="hljs-variable">$senderBatchHeader</span> = <span class="hljs-keyword">new</span> \PayPal\Api\PayoutSenderBatchHeader();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="note">NOTE:</h3>
<p>You can prevent duplicate batches from being processed. If you specify a <code>sender_batch_id</code> that was used in the last 30 days, the batch will not be processed. For items, you can specify a <code>sender_item_id</code>. If the value for the <code>sender_item_id</code> is a duplicate of a payout item that was processed in the last 30 days, the item will not be processed.</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="batch-header-instance">Batch Header Instance</h4></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-variable">$senderBatchHeader</span>-&gt;setSenderBatchId(uniqid())
-&gt;setEmailSubject(<span class="hljs-string">"You have a payment"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="sender-item">Sender Item</h4>
<p>Please note that if you are using single payout with sync mode, you can only pass one Item in the request</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$senderItem1</span> = <span class="hljs-keyword">new</span> \PayPal\Api\PayoutItem();
<span class="hljs-variable">$senderItem1</span>-&gt;setRecipientType(<span class="hljs-string">'Email'</span>)
-&gt;setNote(<span class="hljs-string">'Thanks you.'</span>)
-&gt;setReceiver(<span class="hljs-string">'shirt-supplier-one@gmail.com'</span>)
-&gt;setSenderItemId(<span class="hljs-string">"item_1"</span> . uniqid())
-&gt;setAmount(<span class="hljs-keyword">new</span> \PayPal\Api\Currency(<span class="hljs-string">'{
"value":"0.99",
"currency":"USD"
}'</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="sender-item-2">Sender Item 2</h4>
<p>There are many different ways of assigning values in PayPal SDK. Here is another way where you could directly inject json string.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$senderItem2</span> = <span class="hljs-keyword">new</span> \PayPal\Api\PayoutItem(
<span class="hljs-string">'{
"recipient_type": "EMAIL",
"amount": {
"value": 0.90,
"currency": "USD"
},
"receiver": "shirt-supplier-two@mail.com",
"note": "Thank you.",
"sender_item_id": "item_2"
}'</span>
);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="sender-item-3">Sender Item 3</h4>
<p>One more way of assigning values in constructor when creating instance of PayPalModel object. Injecting array.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$senderItem3</span> = <span class="hljs-keyword">new</span> \PayPal\Api\PayoutItem(
<span class="hljs-keyword">array</span>(
<span class="hljs-string">"recipient_type"</span> =&gt; <span class="hljs-string">"EMAIL"</span>,
<span class="hljs-string">"receiver"</span> =&gt; <span class="hljs-string">"shirt-supplier-three@mail.com"</span>,
<span class="hljs-string">"note"</span> =&gt; <span class="hljs-string">"Thank you."</span>,
<span class="hljs-string">"sender_item_id"</span> =&gt; uniqid(),
<span class="hljs-string">"amount"</span> =&gt; <span class="hljs-keyword">array</span>(
<span class="hljs-string">"value"</span> =&gt; <span class="hljs-string">"0.90"</span>,
<span class="hljs-string">"currency"</span> =&gt; <span class="hljs-string">"USD"</span>
)
)
);
<span class="hljs-variable">$payouts</span>-&gt;setSenderBatchHeader(<span class="hljs-variable">$senderBatchHeader</span>)
-&gt;addItem(<span class="hljs-variable">$senderItem1</span>)-&gt;addItem(<span class="hljs-variable">$senderItem2</span>)-&gt;addItem(<span class="hljs-variable">$senderItem3</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">$payouts</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-payout">Create Payout</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$output</span> = <span class="hljs-variable">$payouts</span>-&gt;create(<span class="hljs-keyword">null</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">"Created Batch Payout"</span>, <span class="hljs-string">"Payout"</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>);
}
ResultPrinter::printResult(<span class="hljs-string">"Created Batch Payout"</span>, <span class="hljs-string">"Payout"</span>, <span class="hljs-variable">$output</span>-&gt;getBatchHeader()-&gt;getPayoutBatchId(), <span class="hljs-variable">$request</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>

View File

@@ -0,0 +1,48 @@
<!DOCTYPE html><html lang="en"><head><title>payouts/CreateSinglePayout</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="payouts/CreateSinglePayout"><meta name="groc-project-path" content="payouts/CreateSinglePayout.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">payouts/CreateSinglePayout.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-single-synchronous-payout-sample">Create Single Synchronous Payout Sample</h1>
<p>This sample code demonstrate how you can create a synchronous payout sample, as documented here at:
<a href="https://developer.paypal.com/docs/integration/direct/create-single-payout/">https://developer.paypal.com/docs/integration/direct/create-single-payout/</a>
API used: /v1/payments/payouts?sync_mode=true</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>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a new instance of Payout object</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payouts</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Payout();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>This is how our body should look like:</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/*
* {
"sender_batch_header":{
"sender_batch_id":"2014021801",
"email_subject":"You have a Payout!"
},
"items":[
{
"recipient_type":"EMAIL",
"amount":{
"value":"1.0",
"currency":"USD"
},
"note":"Thanks for your patronage!",
"sender_item_id":"2014031400023",
"receiver":"shirt-supplier-one@mail.com"
}
]
}
*/</span>
<span class="hljs-variable">$senderBatchHeader</span> = <span class="hljs-keyword">new</span> \PayPal\Api\PayoutSenderBatchHeader();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="note">NOTE:</h3>
<p>You can prevent duplicate batches from being processed. If you specify a <code>sender_batch_id</code> that was used in the last 30 days, the batch will not be processed. For items, you can specify a <code>sender_item_id</code>. If the value for the <code>sender_item_id</code> is a duplicate of a payout item that was processed in the last 30 days, the item will not be processed.</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="batch-header-instance">Batch Header Instance</h4></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-variable">$senderBatchHeader</span>-&gt;setSenderBatchId(uniqid())
-&gt;setEmailSubject(<span class="hljs-string">"You have a Payout!"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="sender-item">Sender Item</h4>
<p>Please note that if you are using single payout with sync mode, you can only pass one Item in the request</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$senderItem</span> = <span class="hljs-keyword">new</span> \PayPal\Api\PayoutItem();
<span class="hljs-variable">$senderItem</span>-&gt;setRecipientType(<span class="hljs-string">'Email'</span>)
-&gt;setNote(<span class="hljs-string">'Thanks for your patronage!'</span>)
-&gt;setReceiver(<span class="hljs-string">'shirt-supplier-one@gmail.com'</span>)
-&gt;setSenderItemId(<span class="hljs-string">"2014031400023"</span>)
-&gt;setAmount(<span class="hljs-keyword">new</span> \PayPal\Api\Currency(<span class="hljs-string">'{
"value":"1.0",
"currency":"USD"
}'</span>));
<span class="hljs-variable">$payouts</span>-&gt;setSenderBatchHeader(<span class="hljs-variable">$senderBatchHeader</span>)
-&gt;addItem(<span class="hljs-variable">$senderItem</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">$payouts</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-payout">Create Payout</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$output</span> = <span class="hljs-variable">$payouts</span>-&gt;createSynchronous(<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 Single Synchronous Payout"</span>, <span class="hljs-string">"Payout"</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>);
}
ResultPrinter::printResult(<span class="hljs-string">"Created Single Synchronous Payout"</span>, <span class="hljs-string">"Payout"</span>, <span class="hljs-variable">$output</span>-&gt;getBatchHeader()-&gt;getPayoutBatchId(), <span class="hljs-variable">$request</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>

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html><html lang="en"><head><title>payouts/GetPayoutBatchStatus</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="payouts/GetPayoutBatchStatus"><meta name="groc-project-path" content="payouts/GetPayoutBatchStatus.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">payouts/GetPayoutBatchStatus.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="get-payout-batch-status-sample">Get Payout Batch Status Sample</h1>
<p>This sample code demonstrate how you can get the batch payout status of a created batch payout, as documented here at:
<a href="https://developer.paypal.com/docs/api/#get-the-status-of-a-batch-payout">https://developer.paypal.com/docs/api/#get-the-status-of-a-batch-payout</a>
API used: GET /v1/payments/payouts/<Payout-Batch-Id></p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\PayoutBatch $payoutBatch */</span>
<span class="hljs-variable">$payoutBatch</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateBatchPayout.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="payout-batch-id">Payout Batch ID</h2>
<p>You can replace this with your Payout Batch Id on already created Payout.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payoutBatchId</span> = <span class="hljs-variable">$payoutBatch</span>-&gt;getBatchHeader()-&gt;getPayoutBatchId();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-payout-batch-status">Get Payout Batch Status</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$output</span> = \PayPal\Api\Payout::get(<span class="hljs-variable">$payoutBatchId</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 Payout Batch Status"</span>, <span class="hljs-string">"PayoutBatch"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$payoutBatchId</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 Payout Batch Status"</span>, <span class="hljs-string">"PayoutBatch"</span>, <span class="hljs-variable">$output</span>-&gt;getBatchHeader()-&gt;getPayoutBatchId(), <span class="hljs-keyword">null</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>

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html><html lang="en"><head><title>payouts/GetPayoutItemStatus</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="payouts/GetPayoutItemStatus"><meta name="groc-project-path" content="payouts/GetPayoutItemStatus.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">payouts/GetPayoutItemStatus.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="get-payout-item-status-sample">Get Payout Item Status Sample</h1>
<p>Use this call to get data about a payout item, including the status, without retrieving an entire batch. You can get the status of an individual payout item in a batch in order to review the current status of a previously-unclaimed, or pending, payout item.
<a href="https://developer.paypal.com/docs/api/#get-the-status-of-a-payout-item">https://developer.paypal.com/docs/api/#get-the-status-of-a-payout-item</a>
API used: GET /v1/payments/payouts-item/<Payout-Item-Id></p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\PayoutBatch $payoutBatch */</span>
<span class="hljs-variable">$payoutBatch</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'GetPayoutBatchStatus.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="payout-item-id">Payout Item ID</h2>
<p>You can replace this with your Payout Batch Id on already created Payout.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payoutItem</span> = <span class="hljs-variable">$payoutBatch</span>-&gt;getItems()[<span class="hljs-number">0</span>];
<span class="hljs-variable">$payoutItemId</span> = <span class="hljs-variable">$payoutItem</span>-&gt;getPayoutItemId();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-payout-item-status">Get Payout Item Status</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$output</span> = \PayPal\Api\PayoutItem::get(<span class="hljs-variable">$payoutItemId</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 Payout Item Status"</span>, <span class="hljs-string">"PayoutItem"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$payoutItemId</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 Payout Item Status"</span>, <span class="hljs-string">"PayoutItem"</span>, <span class="hljs-variable">$output</span>-&gt;getPayoutItemId(), <span class="hljs-keyword">null</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>

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,124 @@
<?php
// # Create Bulk Payout Sample
//
// This sample code demonstrate how you can create a synchronous payout sample, as documented here at:
// https://developer.paypal.com/docs/integration/direct/create-batch-payout/
// API used: /v1/payments/payouts
require __DIR__ . '/../bootstrap.php';
// Create a new instance of Payout object
$payouts = new \PayPal\Api\Payout();
// This is how our body should look like:
/*
*{
"sender_batch_header": {
"sender_batch_id": "random_uniq_id",
"email_subject": "You have a payment"
},
"items": [
{
"recipient_type": "EMAIL",
"amount": {
"value": 0.99,
"currency": "USD"
},
"receiver": "shirt-supplier-one@mail.com",
"note": "Thank you.",
"sender_item_id": "item_1"
},
{
"recipient_type": "EMAIL",
"amount": {
"value": 0.90,
"currency": "USD"
},
"receiver": "shirt-supplier-two@mail.com",
"note": "Thank you.",
"sender_item_id": "item_2"
},
{
"recipient_type": "EMAIL",
"amount": {
"value": 2.00,
"currency": "USD"
},
"receiver": "shirt-supplier-three@mail.com",
"note": "Thank you.",
"sender_item_id": "item_3"
}
]
}
*/
$senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();
// ### NOTE:
// You can prevent duplicate batches from being processed. If you specify a `sender_batch_id` that was used in the last 30 days, the batch will not be processed. For items, you can specify a `sender_item_id`. If the value for the `sender_item_id` is a duplicate of a payout item that was processed in the last 30 days, the item will not be processed.
// #### Batch Header Instance
$senderBatchHeader->setSenderBatchId(uniqid())
->setEmailSubject("You have a payment");
// #### Sender Item
// Please note that if you are using single payout with sync mode, you can only pass one Item in the request
$senderItem1 = new \PayPal\Api\PayoutItem();
$senderItem1->setRecipientType('Email')
->setNote('Thanks you.')
->setReceiver('shirt-supplier-one@gmail.com')
->setSenderItemId("item_1" . uniqid())
->setAmount(new \PayPal\Api\Currency('{
"value":"0.99",
"currency":"USD"
}'));
// #### Sender Item 2
// There are many different ways of assigning values in PayPal SDK. Here is another way where you could directly inject json string.
$senderItem2 = new \PayPal\Api\PayoutItem(
'{
"recipient_type": "EMAIL",
"amount": {
"value": 0.90,
"currency": "USD"
},
"receiver": "shirt-supplier-two@mail.com",
"note": "Thank you.",
"sender_item_id": "item_2"
}'
);
// #### Sender Item 3
// One more way of assigning values in constructor when creating instance of PayPalModel object. Injecting array.
$senderItem3 = new \PayPal\Api\PayoutItem(
array(
"recipient_type" => "EMAIL",
"receiver" => "shirt-supplier-three@mail.com",
"note" => "Thank you.",
"sender_item_id" => uniqid(),
"amount" => array(
"value" => "0.90",
"currency" => "USD"
)
)
);
$payouts->setSenderBatchHeader($senderBatchHeader)
->addItem($senderItem1)->addItem($senderItem2)->addItem($senderItem3);
// For Sample Purposes Only.
$request = clone $payouts;
// ### Create Payout
try {
$output = $payouts->create(null, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Created Batch Payout", "Payout", null, $request, $ex);
exit(1);
}
ResultPrinter::printResult("Created Batch Payout", "Payout", $output->getBatchHeader()->getPayoutBatchId(), $request, $output);
return $output;

View File

@@ -0,0 +1,73 @@
<?php
// # Create Single Synchronous Payout Sample
//
// This sample code demonstrate how you can create a synchronous payout sample, as documented here at:
// https://developer.paypal.com/docs/integration/direct/create-single-payout/
// API used: /v1/payments/payouts?sync_mode=true
require __DIR__ . '/../bootstrap.php';
// Create a new instance of Payout object
$payouts = new \PayPal\Api\Payout();
// This is how our body should look like:
/*
* {
"sender_batch_header":{
"sender_batch_id":"2014021801",
"email_subject":"You have a Payout!"
},
"items":[
{
"recipient_type":"EMAIL",
"amount":{
"value":"1.0",
"currency":"USD"
},
"note":"Thanks for your patronage!",
"sender_item_id":"2014031400023",
"receiver":"shirt-supplier-one@mail.com"
}
]
}
*/
$senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();
// ### NOTE:
// You can prevent duplicate batches from being processed. If you specify a `sender_batch_id` that was used in the last 30 days, the batch will not be processed. For items, you can specify a `sender_item_id`. If the value for the `sender_item_id` is a duplicate of a payout item that was processed in the last 30 days, the item will not be processed.
// #### Batch Header Instance
$senderBatchHeader->setSenderBatchId(uniqid())
->setEmailSubject("You have a Payout!");
// #### Sender Item
// Please note that if you are using single payout with sync mode, you can only pass one Item in the request
$senderItem = new \PayPal\Api\PayoutItem();
$senderItem->setRecipientType('Email')
->setNote('Thanks for your patronage!')
->setReceiver('shirt-supplier-one@gmail.com')
->setSenderItemId("2014031400023")
->setAmount(new \PayPal\Api\Currency('{
"value":"1.0",
"currency":"USD"
}'));
$payouts->setSenderBatchHeader($senderBatchHeader)
->addItem($senderItem);
// For Sample Purposes Only.
$request = clone $payouts;
// ### Create Payout
try {
$output = $payouts->createSynchronous($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Created Single Synchronous Payout", "Payout", null, $request, $ex);
exit(1);
}
ResultPrinter::printResult("Created Single Synchronous Payout", "Payout", $output->getBatchHeader()->getPayoutBatchId(), $request, $output);
return $output;

View File

@@ -0,0 +1,25 @@
<?php
// # Get Payout Batch Status Sample
//
// This sample code demonstrate how you can get the batch payout status of a created batch payout, as documented here at:
// https://developer.paypal.com/docs/api/#get-the-status-of-a-batch-payout
// API used: GET /v1/payments/payouts/<Payout-Batch-Id>
/** @var \PayPal\Api\PayoutBatch $payoutBatch */
$payoutBatch = require 'CreateBatchPayout.php';
// ## Payout Batch ID
// You can replace this with your Payout Batch Id on already created Payout.
$payoutBatchId = $payoutBatch->getBatchHeader()->getPayoutBatchId();
// ### Get Payout Batch Status
try {
$output = \PayPal\Api\Payout::get($payoutBatchId, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Get Payout Batch Status", "PayoutBatch", null, $payoutBatchId, $ex);
exit(1);
}
ResultPrinter::printResult("Get Payout Batch Status", "PayoutBatch", $output->getBatchHeader()->getPayoutBatchId(), null, $output);
return $output;

View File

@@ -0,0 +1,26 @@
<?php
// # Get Payout Item Status Sample
//
// Use this call to get data about a payout item, including the status, without retrieving an entire batch. You can get the status of an individual payout item in a batch in order to review the current status of a previously-unclaimed, or pending, payout item.
// https://developer.paypal.com/docs/api/#get-the-status-of-a-payout-item
// API used: GET /v1/payments/payouts-item/<Payout-Item-Id>
/** @var \PayPal\Api\PayoutBatch $payoutBatch */
$payoutBatch = require 'GetPayoutBatchStatus.php';
// ## Payout Item ID
// You can replace this with your Payout Batch Id on already created Payout.
$payoutItem = $payoutBatch->getItems()[0];
$payoutItemId = $payoutItem->getPayoutItemId();
// ### Get Payout Item Status
try {
$output = \PayPal\Api\PayoutItem::get($payoutItemId, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Get Payout Item Status", "PayoutItem", null, $payoutItemId, $ex);
exit(1);
}
ResultPrinter::printResult("Get Payout Item Status", "PayoutItem", $output->getPayoutItemId(), null, $output);
return $output;