diff --git a/lib/PayPal/Api/Agreement.php b/lib/PayPal/Api/Agreement.php index 0348de5..12d61c3 100644 --- a/lib/PayPal/Api/Agreement.php +++ b/lib/PayPal/Api/Agreement.php @@ -589,6 +589,7 @@ class Agreement extends PayPalResourceModel /** * List transactions for a billing agreement by passing the ID of the agreement, as well as the start and end dates of the range of transactions to list, to the request URI. * + * @deprecated Please use searchTransactions Instead * @param string $agreementId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls @@ -611,4 +612,37 @@ class Agreement extends PayPalResourceModel return $ret; } + /** + * List transactions for a billing agreement by passing the ID of the agreement, as well as the start and end dates of the range of transactions to list, to the request URI. + * + * @param string $agreementId + * @param array $params Parameters for search string. Options: start_date, and end_date + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return AgreementTransactions + */ + public static function searchTransactions($agreementId, $params = array(), $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($agreementId, 'agreementId'); + ArgumentValidator::validate($params, 'params'); + + $allowedParams = array( + 'start_date' => 1, + 'end_date' => 1, + ); + + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/billing-agreements/$agreementId/transactions?" . http_build_query(array_intersect_key($params, $allowedParams)), + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new AgreementTransactions(); + $ret->fromJson($json); + return $ret; + } + } diff --git a/sample/billing/SearchBillingTransactions.php b/sample/billing/SearchBillingTransactions.php new file mode 100644 index 0000000..35fe660 --- /dev/null +++ b/sample/billing/SearchBillingTransactions.php @@ -0,0 +1,24 @@ +/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; diff --git a/sample/doc/assets/behavior.js b/sample/doc/assets/behavior.js index 88f5f6f..8f79a71 100644 --- a/sample/doc/assets/behavior.js +++ b/sample/doc/assets/behavior.js @@ -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 } ] }, { diff --git a/sample/doc/billing/SearchBillingTransactions.html b/sample/doc/billing/SearchBillingTransactions.html new file mode 100644 index 0000000..8d362a0 --- /dev/null +++ b/sample/doc/billing/SearchBillingTransactions.html @@ -0,0 +1,18 @@ +
Retrieving the Agreement object from Create Agreement From Credit Card Sample
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.
Updating the webhook as per given request - [ - { - "op":"replace", - "path":"/url", - "value":"https://requestb.in/10ujt3c1" - }, - { - "op":"replace", - "path":"/event_types", - "value":[ - { - "name":"PAYMENT.SALE.REFUNDED" - } - ] - } - ]
Updating the webhook as per given request
+ [
+ {
+ "op":"replace",
+ "path":"/url",
+ "value":"https://requestb.in/10ujt3c1"
+ },
+ {
+ "op":"replace",
+ "path":"/event_types",
+ "value":[
+ {
+ "name":"PAYMENT.SALE.REFUNDED"
+ }
+ ]
+ }
+ ]
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//transactions? start-date=yyyy-mm-dd&end-date=yyyy-mm-dd