paypal开发人员文档介绍了创建和激活Billing plan的步骤。
有没有办法删除结算方案?
答案 0 :(得分:13)
删除 BillingPlan 的另一种方法(根据原始问题)是提交补丁请求。不幸的是,通过查看API文档不太清楚:https://developer.paypal.com/docs/api/payments.billing-plans/#plan_update
您想将BillingPlan的州修补为 DELETED :
[
{
"path": "/",
"value": {
"state": "DELETED"
},
"op": "replace"
}
]
修补后,当您通过 / v1 / payments / billing-plans
列出所有可用计划时,已删除的计划将不再显示答案 1 :(得分:4)
有一种方法可以 删除 结算方案。
如果您在REST-PHP-SDK中看到示例,则会有一个名为DeletePlan.php的文件,其中包含删除结算方案的代码。
它是这样的:
$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;
这对我有用。希望这会有所帮助。
答案 2 :(得分:2)
谢谢@smiling_warrior。
对于python API https://github.com/paypal/PayPal-Python-SDK/blob/master/samples/subscription/billing_agreements/replace.py
我用过:
a=paypalrestsdk.BillingPlan.find("P-98072754CC611563JLOGIIYA")
a.replace([{"op": "replace","path": "/","value": {"state":"DELETED"}}])
或删除全部:
allplans = paypalrestsdk.BillingPlan.all()
for plan in allplans.plans:
a=paypalrestsdk.BillingPlan.find(plan.id)
a.replace([{"op": "replace","path": "/","value": {"state":"DELETED"}}])
答案 3 :(得分:2)
作为有关@maxxon15答案的补充信息,此处有actual code在PHP SDK上执行 DELETE :
public function delete($apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
$patchRequest = new PatchRequest();
$patch = new Patch();
$value = new PayPalModel('{
"state":"DELETED"
}');
$patch->setOp('replace')
->setPath('/')
->setValue($value);
$patchRequest->addPatch($patch);
return $this->update($patchRequest, $apiContext, $restCall);
}
因此,换句话说,它只是对结算端点进行更新( PATCH ),如@smiling-warrior所述
[
{
"path": "/",
"value": {
"state": "DELETED"
},
"op": "replace"
}
]