The paypal developer documentation explains the steps to create and activate a Billing plan.
Is there a way to delete a billing plan?
An alternative way of deleting a BillingPlan (as per the original question) is to submit a patch request. Unfortunately this isn't too clear from looking at the API docs: https://developer.paypal.com/docs/api/payments.billing-plans/#plan_update
You want to patch the state of the BillingPlan into DELETED:
[
{
"path": "/",
"value": {
"state": "DELETED"
},
"op": "replace"
}
]
Once patched, the deleted plan no longer shows up when you list all available plans via /v1/payments/billing-plans
There is a way to DELETE a Billing Plan.
If you see the samples in the REST-PHP-SDK, there is a file named DeletePlan.php which has the code to delete the billing plan.
It goes something like this:
$createdPlan = require 'CreatePlan.php';
use PayPal\Api\Plan;
try {
$result = $createdPlan->delete($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Deleted a Plan", "Plan", $createdPlan->getId(), null, $ex);
exit(1);
}
ResultPrinter::printResult("Deleted a Plan", "Plan", $createdPlan->getId(), null, null);
return $createdPlan;
This worked for me. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With