forked from LiveCarta/PayPal-PHP-SDK
Fixes to Agreement Search Transaction
- Added searchTransactions method to include params - Updated Tests accordingly. - Updated Samples accordingly
This commit is contained in:
24
sample/billing/SearchBillingTransactions.php
Normal file
24
sample/billing/SearchBillingTransactions.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
// # Search Billing Transactions Sample
|
||||
//
|
||||
// This sample code demonstrate how you can search all billing transactions, as documented here at:
|
||||
// https://developer.paypal.com/webapps/developer/docs/api/#search-for-transactions
|
||||
// API used: GET /v1/payments/billing-agreements/<Agreement-Id>/transactions? start-date=yyyy-mm-dd&end-date=yyyy-mm-dd
|
||||
|
||||
// Retrieving the Agreement object from Create Agreement From Credit Card Sample
|
||||
/** @var Agreement $agreement */
|
||||
$agreement = require 'GetBillingAgreement.php';
|
||||
$agreementId = $agreement->getId();
|
||||
use PayPal\Api\Agreement;
|
||||
|
||||
try {
|
||||
$result = Agreement::searchTransactions($agreementId,array('start_date' => '2013-01-01', 'end_date' => '2015-01-20'), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
ResultPrinter::printError("Search for Transactions", "AgreementTransaction", $agreementId, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Search for Transactions", "AgreementTransaction", $agreementId, null, $result);
|
||||
|
||||
return $agreement;
|
||||
@@ -175,6 +175,35 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
|
||||
"title": "ReactivateBillingAgreement"
|
||||
},
|
||||
"depth": 2
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/billing/SearchBillingTransactions.php",
|
||||
"projectPath": "billing/SearchBillingTransactions.php",
|
||||
"targetPath": "billing/SearchBillingTransactions",
|
||||
"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
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
@@ -328,29 +357,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": "invoice/GetInvoice",
|
||||
"title": "GetInvoice"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Get Invoice Sample",
|
||||
"slug": "get-invoice-sample"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Retrieve Invoice",
|
||||
"slug": "retrieve-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"depth": 2
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
@@ -386,45 +393,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": "invoice/RecordPayment",
|
||||
"title": "RecordPayment"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Record Payment Sample",
|
||||
"slug": "record-payment-sample"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Record Object",
|
||||
"slug": "record-object"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Record Payment for Invoice",
|
||||
"slug": "record-payment-for-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Retrieve Invoice",
|
||||
"slug": "retrieve-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"depth": 2
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
@@ -442,45 +411,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": "invoice/RecordRefund",
|
||||
"title": "RecordRefund"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Record Refund Sample",
|
||||
"slug": "record-refund-sample"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Record Object",
|
||||
"slug": "record-object"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Record Refund for Invoice",
|
||||
"slug": "record-refund-for-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Retrieve Invoice",
|
||||
"slug": "retrieve-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"depth": 2
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
@@ -498,45 +429,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": "invoice/RemindInvoice",
|
||||
"title": "RemindInvoice"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Remind Invoice Sample",
|
||||
"slug": "remind-invoice-sample"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Notification Object",
|
||||
"slug": "notification-object"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Remind Invoice",
|
||||
"slug": "remind-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Retrieve Invoice",
|
||||
"slug": "retrieve-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"depth": 2
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
@@ -590,37 +483,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": "invoice/SendInvoice",
|
||||
"title": "SendInvoice"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Create Invoice Sample",
|
||||
"slug": "create-invoice-sample"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Send Invoice",
|
||||
"slug": "send-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Retrieve Invoice",
|
||||
"slug": "retrieve-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"depth": 2
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
@@ -638,53 +501,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": "invoice/UpdateInvoice",
|
||||
"title": "UpdateInvoice"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Update Invoice Sample",
|
||||
"slug": "update-invoice-sample"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Update Invoice",
|
||||
"slug": "update-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "NOTE: These are the work-around added to the",
|
||||
"slug": "note-these-are-the-work-around-added-to-the"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Update Invoice",
|
||||
"slug": "update-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Retrieve Invoice",
|
||||
"slug": "retrieve-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"depth": 2
|
||||
}
|
||||
]
|
||||
}, {
|
||||
|
||||
18
sample/doc/billing/SearchBillingTransactions.html
Normal file
18
sample/doc/billing/SearchBillingTransactions.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>billing/SearchBillingTransactions</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="billing/SearchBillingTransactions"><meta name="groc-project-path" content="billing/SearchBillingTransactions.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">billing/SearchBillingTransactions.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="search-billing-transactions-sample">Search Billing Transactions Sample</h1>
|
||||
<p>This sample code demonstrate how you can search all billing transactions, as documented here at:
|
||||
<a href="https://developer.paypal.com/webapps/developer/docs/api/#search-for-transactions">https://developer.paypal.com/webapps/developer/docs/api/#search-for-transactions</a>
|
||||
API used: GET /v1/payments/billing-agreements/<Agreement-Id>/transactions? start-date=yyyy-mm-dd&end-date=yyyy-mm-dd</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Agreement object from Create Agreement From Credit Card Sample</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Agreement $agreement */</span>
|
||||
<span class="hljs-variable">$agreement</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'GetBillingAgreement.php'</span>;
|
||||
<span class="hljs-variable">$agreementId</span> = <span class="hljs-variable">$agreement</span>->getId();
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Agreement</span>;
|
||||
|
||||
<span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$result</span> = Agreement::searchTransactions(<span class="hljs-variable">$agreementId</span>,<span class="hljs-keyword">array</span>(<span class="hljs-string">'start_date'</span> => <span class="hljs-string">'2013-01-01'</span>, <span class="hljs-string">'end_date'</span> => <span class="hljs-string">'2015-01-20'</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">"Search for Transactions"</span>, <span class="hljs-string">"AgreementTransaction"</span>, <span class="hljs-variable">$agreementId</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Search for Transactions"</span>, <span class="hljs-string">"AgreementTransaction"</span>, <span class="hljs-variable">$agreementId</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$result</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
||||
@@ -4,23 +4,23 @@
|
||||
API used: PATCH v1/notifications/webhooks/<Webhook-Id></p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="get-webhook-id">Get Webhook ID.</h2>
|
||||
<p>In samples we are using CreateWebhook.php sample to get the created instance of webhook.
|
||||
However, in real case scenario, we could use just the ID from database or use an already existing webhook.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\Webhook $webhook */</span>
|
||||
<span class="hljs-variable">$webhook</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateWebhook.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Updating the webhook as per given request
|
||||
[
|
||||
{
|
||||
"op":"replace",
|
||||
"path":"/url",
|
||||
"value":"<a href="https://requestb.in/10ujt3c1">https://requestb.in/10ujt3c1</a>"
|
||||
},
|
||||
{
|
||||
"op":"replace",
|
||||
"path":"/event_types",
|
||||
"value":[
|
||||
{
|
||||
"name":"PAYMENT.SALE.REFUNDED"
|
||||
}
|
||||
]
|
||||
}
|
||||
]</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$patch</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Patch();
|
||||
<span class="hljs-variable">$webhook</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateWebhook.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Updating the webhook as per given request</p>
|
||||
<pre><code> [
|
||||
{
|
||||
"op":"replace",
|
||||
"path":"/url",
|
||||
"value":"https://requestb.in/10ujt3c1"
|
||||
},
|
||||
{
|
||||
"op":"replace",
|
||||
"path":"/event_types",
|
||||
"value":[
|
||||
{
|
||||
"name":"PAYMENT.SALE.REFUNDED"
|
||||
}
|
||||
]
|
||||
}
|
||||
]</code></pre></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$patch</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Patch();
|
||||
<span class="hljs-variable">$patch</span>->setOp(<span class="hljs-string">"replace"</span>)
|
||||
->setPath(<span class="hljs-string">"/url"</span>)
|
||||
->setValue(<span class="hljs-string">"https://requestb.in/10ujt3c1?uniqid="</span>. uniqid());
|
||||
|
||||
@@ -664,6 +664,18 @@ if (PHP_SAPI == 'cli') {
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Search for Transactions</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="billing/SearchBillingTransactions.php" class="btn btn-primary pull-left execute"> Try It
|
||||
<i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/billing/SearchBillingTransactions.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Update Billing Agreement</h5></div>
|
||||
|
||||
Reference in New Issue
Block a user