diff --git a/lib/PayPal/Api/CreditCard.php b/lib/PayPal/Api/CreditCard.php index a7dccbb..75ed802 100644 --- a/lib/PayPal/Api/CreditCard.php +++ b/lib/PayPal/Api/CreditCard.php @@ -426,18 +426,20 @@ class CreditCard extends PayPalResourceModel /** * Update information in a previously saved card. Only the modified fields need to be passed in the request. * + * @param PatchRequest $patchRequest * @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 CreditCard */ - public function update($apiContext = null, $restCall = null) + public function update($patchRequest, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); - $payLoad = $this->toJSON(); + ArgumentValidator::validate($patchRequest, 'patch'); + $payload = $patchRequest->toJSON(); $json = self::executeCall( "/v1/vault/credit-card/{$this->getId()}", "PATCH", - $payLoad, + $payload, null, $apiContext, $restCall diff --git a/sample/doc/assets/behavior.js b/sample/doc/assets/behavior.js index 9fd4c5a..4b31526 100644 --- a/sample/doc/assets/behavior.js +++ b/sample/doc/assets/behavior.js @@ -48,7 +48,37 @@ 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/CreateBillingAgreementWithPayPal", "title": "CreateBillingAgreementWithPayPal" }, - "depth": 2 + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Create Billing Agreement with PayPal as Payment Source", + "slug": "create-billing-agreement-with-paypal-as-payment-source" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Create Agreement", + "slug": "create-agreement" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Get redirect url", + "slug": "get-redirect-url" + }, + "depth": 3 + } + ] + } + ] }, { "type": "file", "data": { @@ -310,77 +340,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/CreateInvoice", "title": "CreateInvoice" }, - "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": "Invoice Info", - "slug": "invoice-info" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "Merchant Info", - "slug": "merchant-info" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "Address Information", - "slug": "address-information" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "Billing Information", - "slug": "billing-information" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "Items List", - "slug": "items-list" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "Shipping Information", - "slug": "shipping-information" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "Create Invoice", - "slug": "create-invoice" - }, - "depth": 3 - } - ] - } - ] + "depth": 2 }, { "type": "file", "data": { @@ -1050,7 +1010,93 @@ 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": "payments/CreatePaymentUsingPayPal", "title": "CreatePaymentUsingPayPal" }, - "depth": 2 + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Create Payment using PayPal as payment method", + "slug": "create-payment-using-paypal-as-payment-method" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Payer", + "slug": "payer" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Itemized information", + "slug": "itemized-information" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Additional payment details", + "slug": "additional-payment-details" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Amount", + "slug": "amount" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Transaction", + "slug": "transaction" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Redirect urls", + "slug": "redirect-urls" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Payment", + "slug": "payment" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Create Payment", + "slug": "create-payment" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Get redirect url", + "slug": "get-redirect-url" + }, + "depth": 3 + } + ] + } + ] }, { "type": "file", "data": { @@ -1294,7 +1340,56 @@ 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 + "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": { @@ -1422,7 +1517,37 @@ 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": "vault/CreateCreditCard", "title": "CreateCreditCard" }, - "depth": 2 + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Create Credit Card Sample", + "slug": "create-credit-card-sample" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "CreditCard", + "slug": "creditcard" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Save card", + "slug": "save-card" + }, + "depth": 3 + } + ] + } + ] }, { "type": "file", "data": { @@ -1495,6 +1620,54 @@ 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": "GetCreditCard" }, "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/vault/UpdateCreditCard.php", + "projectPath": "vault/UpdateCreditCard.php", + "targetPath": "vault/UpdateCreditCard", + "pageTitle": "vault/UpdateCreditCard", + "title": "UpdateCreditCard" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Update Credit Card Sample", + "slug": "update-credit-card-sample" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Patch Object", + "slug": "patch-object" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Another Patch Object", + "slug": "another-patch-object" + }, + "depth": 3 + } + ] + } + ] } ] } diff --git a/sample/doc/vault/UpdateCreditCard.html b/sample/doc/vault/UpdateCreditCard.html new file mode 100644 index 0000000..c69323a --- /dev/null +++ b/sample/doc/vault/UpdateCreditCard.html @@ -0,0 +1,39 @@ +
You could update a credit card by sending patch requests. Each path object would have a specific detail in the object to be updated.
You could set more than one patch while updating a credit card.
(See bootstrap.php for more on ApiContext)
Update Credit Card Sample
+The CreditCard resource allows you to +update previously saved CreditCards. +API called: PATCH /v1/vault/credit-cards/
+The following code takes you through
+the process of updating a saved CreditCard