Paypal账单协议无效的计划ID PHP

时间:2016-09-09 19:51:52

标签: php paypal paypal-rest-sdk paypal-subscriptions

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

{"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);

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:0)

$createdPlan是您需要在$agreement

中传递的计划变量
$agreement->setPlan($createdPlan);