繁体   English   中英

贝宝付款协议无效的计划ID PHP

[英]Paypal Billing Agreement Invalid Plan Id PHP

我一直在尝试执行订阅计划。 我已经以帐单协议的形式遇到了障碍。 尝试创建协议时,我一直收到以下错误。

{"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"}

我不确定问题出在哪里,试图强制协议的既定计划输出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);

$createdPlan是您需要在$agreement类中传递的计划变量

$agreement->setPlan($createdPlan);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM