diff --git a/lib/PayPal/Api/Plan.php b/lib/PayPal/Api/Plan.php index 3b46398..9e85ef2 100644 --- a/lib/PayPal/Api/Plan.php +++ b/lib/PayPal/Api/Plan.php @@ -2,6 +2,7 @@ namespace PayPal\Api; +use PayPal\Common\PPModel; use PayPal\Common\ResourceModel; use PayPal\Validation\ArgumentValidator; use PayPal\Api\PlanList; @@ -543,6 +544,28 @@ class Plan extends ResourceModel return true; } + /** + * Delete a billing plan by passing the ID of the billing plan to the request URI. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function delete($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + $patchRequest = new PatchRequest(); + $patch = new Patch(); + $value = new PPModel('{ + "state":"DELETED" + }'); + $patch->setOp('replace') + ->setPath('/') + ->setValue($value); + $patchRequest->addPatch($patch); + return $this->update($patchRequest, $apiContext, $restCall); + } + /** * List billing plans according to optional query string parameters specified. * diff --git a/sample/billing/DeletePlan.php b/sample/billing/DeletePlan.php new file mode 100644 index 0000000..33901f4 --- /dev/null +++ b/sample/billing/DeletePlan.php @@ -0,0 +1,24 @@ +delete($apiContext); +} catch (Exception $ex) { + ResultPrinter::printError("Deleted a Plan", "Plan", $plan->getId(), null, $ex); + exit(1); +} + +ResultPrinter::printResult("Deleted a Plan", "Plan", $plan->getId(), null, null); + +return $plan; diff --git a/sample/doc/assets/behavior.js b/sample/doc/assets/behavior.js index a79fd10..ddd3872 100644 --- a/sample/doc/assets/behavior.js +++ b/sample/doc/assets/behavior.js @@ -157,6 +157,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 ] } ] + }, { + "type": "file", + "data": { + "language": { + "nameMatchers": [{}, ".fbp"], + "pygmentsLexer": "php", + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "PHP" + }, + "sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample/billing/DeletePlan.php", + "projectPath": "billing/DeletePlan.php", + "targetPath": "billing/DeletePlan", + "pageTitle": "billing/DeletePlan", + "title": "DeletePlan" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Delete Plan Sample", + "slug": "delete-plan-sample" + }, + "depth": 1 + } + ] }, { "type": "file", "data": { diff --git a/sample/doc/billing/DeletePlan.html b/sample/doc/billing/DeletePlan.html new file mode 100644 index 0000000..171c90e --- /dev/null +++ b/sample/doc/billing/DeletePlan.html @@ -0,0 +1,18 @@ +
Retrieving the Plan object from Create Plan Sample
Delete Plan Sample
+This sample code demonstrate how you can delete a billing plan, as documented here at: +https://developer.paypal.com/webapps/developer/docs/api/#retrieve-a-plan +API used: /v1/payments/billing-plans