gpt4 book ai didi

php - Paypal 计费协议(protocol)无效的计划 ID PHP

转载 作者:太空宇宙 更新时间:2023-11-03 16:24:14 25 4
gpt4 key购买 nike

我一直在尝试执行订阅计划。我在计费协议(protocol)方面遇到了障碍。我在尝试创建协议(protocol)时不断收到以下错误。

{"name":"VALIDATION_ERROR","details":[{"field":"plan","issue":"Invalid Fields passed in plan. Pass only a valid plan-id."}],"message":"Invalid request. See details.","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR"}

我不确定问题出在哪里,试图强制协议(protocol)的设定计划输出 id 本身也会导致 JSON 错误并且没有任何效果。如果您需要更多信息,请随时询问。

$createdPlan = $startPlan->create($paypal);

$patch = new Patch();
$value = new PayPalModel('{
"state":"ACTIVE"
}');
$patch->setOp('replace')
->setPath('/')
->setValue($value);
$patchRequest = new PatchRequest();
$patchRequest->addPatch($patch);
$createdPlan->update($patchRequest, $paypal);
$plan = Plan::get($createdPlan->getId(), $paypal);


$agreement = new Agreement();
$agreement->setName($product . ' Agreement')
->setDescription('Recurring Payment')
->setStartDate(date(c, time()+4));

$agreement->setPlan($plan);

$payer = new Payer();
$payer->setPaymentMethod('paypal');

$agreement->setPayer($payer);
$agreement->create($paypal);

最佳答案

我能够通过创建一个新的计划对象并将 id 设置为实际计划来解决这个问题。

$jsonplan = new Plan();
$jsonplan->setId($createdPlan->getId());
$agreement->setPlan($jsonplan);

关于php - Paypal 计费协议(protocol)无效的计划 ID PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39418834/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com