forked from LiveCarta/PayPal-PHP-SDK
Enabled Payout API Support
- Includes Unit and Functional Tests - Includes Samples
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -46,13 +46,8 @@ Please note that the plan Id should be only set in this case.</p></div></div><di
|
||||
->setCountryCode(<span class="hljs-string">'US'</span>);
|
||||
<span class="hljs-variable">$agreement</span>->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>->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->getLinks()
|
||||
method</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$agreement</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>;
|
||||
}
|
||||
}
|
||||
the buyer to. Retrieve the url from the $agreement->getApprovalLink()
|
||||
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$agreement</span>->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>);
|
||||
|
||||
@@ -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"><?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"><?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>
|
||||
|
||||
@@ -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->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>;
|
||||
}
|
||||
}
|
||||
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$payment</span>->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">"<a href='$approvalUrl' >$approvalUrl</a>"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
|
||||
|
||||
@@ -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->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>;
|
||||
}
|
||||
}
|
||||
the buyer to. Retrieve the url from the $payment->getApprovalLink()
|
||||
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$payment</span>->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">"<a href='$approvalUrl' >$approvalUrl</a>"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
|
||||
|
||||
93
sample/doc/payouts/CreateBatchPayout.html
Normal file
93
sample/doc/payouts/CreateBatchPayout.html
Normal 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"><?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>->setSenderBatchId(uniqid())
|
||||
->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>->setRecipientType(<span class="hljs-string">'Email'</span>)
|
||||
->setNote(<span class="hljs-string">'Thanks you.'</span>)
|
||||
->setReceiver(<span class="hljs-string">'shirt-supplier-one@gmail.com'</span>)
|
||||
->setSenderItemId(<span class="hljs-string">"item_1"</span> . uniqid())
|
||||
->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> => <span class="hljs-string">"EMAIL"</span>,
|
||||
<span class="hljs-string">"receiver"</span> => <span class="hljs-string">"shirt-supplier-three@mail.com"</span>,
|
||||
<span class="hljs-string">"note"</span> => <span class="hljs-string">"Thank you."</span>,
|
||||
<span class="hljs-string">"sender_item_id"</span> => uniqid(),
|
||||
<span class="hljs-string">"amount"</span> => <span class="hljs-keyword">array</span>(
|
||||
<span class="hljs-string">"value"</span> => <span class="hljs-string">"0.90"</span>,
|
||||
<span class="hljs-string">"currency"</span> => <span class="hljs-string">"USD"</span>
|
||||
)
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
<span class="hljs-variable">$payouts</span>->setSenderBatchHeader(<span class="hljs-variable">$senderBatchHeader</span>)
|
||||
->addItem(<span class="hljs-variable">$senderItem1</span>)->addItem(<span class="hljs-variable">$senderItem2</span>)->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>->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>->getBatchHeader()->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>
|
||||
48
sample/doc/payouts/CreateSinglePayout.html
Normal file
48
sample/doc/payouts/CreateSinglePayout.html
Normal 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"><?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>->setSenderBatchId(uniqid())
|
||||
->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>->setRecipientType(<span class="hljs-string">'Email'</span>)
|
||||
->setNote(<span class="hljs-string">'Thanks for your patronage!'</span>)
|
||||
->setReceiver(<span class="hljs-string">'shirt-supplier-one@gmail.com'</span>)
|
||||
->setSenderItemId(<span class="hljs-string">"2014031400023"</span>)
|
||||
->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>->setSenderBatchHeader(<span class="hljs-variable">$senderBatchHeader</span>)
|
||||
->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>->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>->getBatchHeader()->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>
|
||||
15
sample/doc/payouts/GetPayoutBatchStatus.html
Normal file
15
sample/doc/payouts/GetPayoutBatchStatus.html
Normal 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"><?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>->getBatchHeader()->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>->getBatchHeader()->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>
|
||||
16
sample/doc/payouts/GetPayoutItemStatus.html
Normal file
16
sample/doc/payouts/GetPayoutItemStatus.html
Normal 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"><?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>->getItems()[<span class="hljs-number">0</span>];
|
||||
<span class="hljs-variable">$payoutItemId</span> = <span class="hljs-variable">$payoutItem</span>->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>->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>
|
||||
Reference in New Issue
Block a user