forked from LiveCarta/PayPal-PHP-SDK
Enabled Payout Cancel API for Unclaimed Payout Item
- PayoutItem supports [Cancel and Unclaimed Payout Item](https://developer.paypal.com/docs/api/#cancel-an-unclaimed-payout-item) - Updated Unit and Functional Tests Accordingly - Updated Samples accordingly
This commit is contained in:
@@ -192,18 +192,7 @@ 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
|
||||
"pageTitle": "billing/SearchBillingTransactions",
|
||||
"title": "SearchBillingTransactions"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Search Billing Transactions Sample",
|
||||
"slug": "search-billing-transactions-sample"
|
||||
},
|
||||
"depth": 1
|
||||
}
|
||||
]
|
||||
"depth": 2
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
@@ -1183,6 +1172,24 @@ 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/payouts/CancelPayoutItem.php",
|
||||
"projectPath": "payouts/CancelPayoutItem.php",
|
||||
"targetPath": "payouts/CancelPayoutItem",
|
||||
"pageTitle": "payouts/CancelPayoutItem",
|
||||
"title": "CancelPayoutItem"
|
||||
},
|
||||
"depth": 2
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
@@ -1199,72 +1206,7 @@ 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
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"depth": 2
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
@@ -1282,56 +1224,7 @@ 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
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"depth": 2
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
@@ -1367,7 +1260,40 @@ 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
|
||||
"pageTitle": "payouts/GetPayoutItemStatus",
|
||||
"title": "GetPayoutItemStatus"
|
||||
},
|
||||
"depth": 2
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
|
||||
21
sample/doc/payouts/CancelPayoutItem.html
Normal file
21
sample/doc/payouts/CancelPayoutItem.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>payouts/CancelPayoutItem</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/CancelPayoutItem"><meta name="groc-project-path" content="payouts/CancelPayoutItem.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/CancelPayoutItem.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="cancel-payout-item-status-sample">Cancel Payout Item Status Sample</h1>
|
||||
<p>Use this call to cancel an existing, unclaimed transaction. If an unclaimed item is not claimed within 30 days, the funds will be automatically returned to the sender. This call can be used to cancel the unclaimed item prior to the automatic 30-day return.
|
||||
<a href="https://developer.paypal.com/docs/api/#cancel-an-unclaimed-payout-item">https://developer.paypal.com/docs/api/#cancel-an-unclaimed-payout-item</a>
|
||||
API used: POST /v1/payments/payouts-item/<Payout-Item-Id>/cancel</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">'CreateSinglePayout.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">$payoutItems</span> = <span class="hljs-variable">$payoutBatch</span>->getItems();
|
||||
<span class="hljs-variable">$payoutItem</span> = <span class="hljs-variable">$payoutItems</span>[<span class="hljs-number">0</span>];
|
||||
<span class="hljs-variable">$payoutItemId</span> = <span class="hljs-variable">$payoutItem</span>->getPayoutItemId();
|
||||
|
||||
<span class="hljs-variable">$output</span> = <span class="hljs-keyword">null</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="cancel-payout-item">Cancel Payout Item</h3>
|
||||
<p>Check if Payout Item is UNCLAIMED, and if so, cancel it.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-keyword">if</span> (<span class="hljs-variable">$payoutItem</span>->getTransactionStatus() == <span class="hljs-string">'UNCLAIMED'</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Cancel the Payout Item</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$output</span> = \PayPal\Api\PayoutItem::cancel(<span class="hljs-variable">$payoutItemId</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Cancel Unclaimed Payout Item"</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">else</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>The item transaction status is not unclaimed. You can only cancel an unclaimed transaction.</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Cancel Unclaimed Payout Item"</span>, <span class="hljs-string">"PayoutItem"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$payoutItemId</span>, <span class="hljs-keyword">new</span> <span class="hljs-keyword">Exception</span>(<span class="hljs-string">"Payout Item Status is not UNCLAIMED"</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">"Cancel Unclaimed Payout Item"</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>);
|
||||
}
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
||||
@@ -3,7 +3,8 @@
|
||||
<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>];
|
||||
<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">$payoutItems</span> = <span class="hljs-variable">$payoutBatch</span>->getItems();
|
||||
<span class="hljs-variable">$payoutItem</span> = <span class="hljs-variable">$payoutItems</span>[<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>) {
|
||||
|
||||
@@ -396,6 +396,17 @@ if (PHP_SAPI == 'cli') {
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Cancel Uncliamed Payout Item</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payouts/CancelPayoutItem.php" class="btn btn-primary pull-left execute"> Try It <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payouts/CancelPayoutItem.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
34
sample/payouts/CancelPayoutItem.php
Normal file
34
sample/payouts/CancelPayoutItem.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
// # Cancel Payout Item Status Sample
|
||||
//
|
||||
// Use this call to cancel an existing, unclaimed transaction. If an unclaimed item is not claimed within 30 days, the funds will be automatically returned to the sender. This call can be used to cancel the unclaimed item prior to the automatic 30-day return.
|
||||
// https://developer.paypal.com/docs/api/#cancel-an-unclaimed-payout-item
|
||||
// API used: POST /v1/payments/payouts-item/<Payout-Item-Id>/cancel
|
||||
|
||||
/** @var \PayPal\Api\PayoutBatch $payoutBatch */
|
||||
$payoutBatch = require 'CreateSinglePayout.php';
|
||||
// ## Payout Item ID
|
||||
// You can replace this with your Payout Batch Id on already created Payout.
|
||||
$payoutItems = $payoutBatch->getItems();
|
||||
$payoutItem = $payoutItems[0];
|
||||
$payoutItemId = $payoutItem->getPayoutItemId();
|
||||
|
||||
$output = null;
|
||||
// ### Cancel Payout Item
|
||||
// Check if Payout Item is UNCLAIMED, and if so, cancel it.
|
||||
try {
|
||||
if ($payoutItem->getTransactionStatus() == 'UNCLAIMED') {
|
||||
// Cancel the Payout Item
|
||||
$output = \PayPal\Api\PayoutItem::cancel($payoutItemId, $apiContext);
|
||||
ResultPrinter::printResult("Cancel Unclaimed Payout Item", "PayoutItem", $output->getPayoutItemId(), null, $output);
|
||||
} else {
|
||||
// The item transaction status is not unclaimed. You can only cancel an unclaimed transaction.
|
||||
ResultPrinter::printError("Cancel Unclaimed Payout Item", "PayoutItem", null, $payoutItemId, new Exception("Payout Item Status is not UNCLAIMED"));
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
ResultPrinter::printError("Cancel Unclaimed Payout Item", "PayoutItem", null, $payoutItemId, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return $output;
|
||||
@@ -10,7 +10,8 @@
|
||||
$payoutBatch = require 'GetPayoutBatchStatus.php';
|
||||
// ## Payout Item ID
|
||||
// You can replace this with your Payout Batch Id on already created Payout.
|
||||
$payoutItem = $payoutBatch->getItems()[0];
|
||||
$payoutItems = $payoutBatch->getItems();
|
||||
$payoutItem = $payoutItems[0];
|
||||
$payoutItemId = $payoutItem->getPayoutItemId();
|
||||
|
||||
// ### Get Payout Item Status
|
||||
|
||||
Reference in New Issue
Block a user