如何将Paypal结算计划从ACTIVE状态更改为CREATED状态?

时间:2015-04-16 08:55:07

标签: php paypal billing paypal-rest-sdk

我已经制定了3个单独的结算计划,并将其更新为 ACTIVE 状态。目前还没有与之相关的任何协议。

我希望能够在计划切换到ACTIVE状态后编辑计划的详细信息。

所以,当我尝试更新计划时,它给了我一个错误说:

{"name":"BUSINESS_VALIDATION_ERROR","details":[{"field":"validation_error","issue":"Requested state change is invalid."}]

因此,我尝试将状态再次转换为 CREATED ,因此我可以编辑详细信息。这是我试过的代码片段:

try {

         $statePatch = new PayPal\Api\Patch();
         $statePatch->setOp('replace')
           ->setPath('/')
           ->setValue(array('state' => 'CREATED'));
         $statePatchRequest = new \PayPal\Api\PatchRequest();
         $statePatchRequest->addPatch($statePatch);
         $plan->update($statePatchRequest, $apiContext);
         $updatedPlan = \PayPal\Api\Plan::get($plan->getId(), $apiContext);

      } catch (Exception $ex) {
         var_dump($ex);
         exit(1);
      }

但那仍然无效。 API再次出现了类似的错误。

private 'url' => string 'https://api.sandbox.paypal.com/v1/payments/billing-plans/P-6DK979342A210870GWHVJFGY' (length=83)
  private 'data' => string '{"name":"BUSINESS_VALIDATION_ERROR","details":[{"field":"validation_error","issue":"Requested state change is invalid."}],"message":"Validation Error.","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#BUSINESS_VALIDATION_ERROR","debug_id":"5cf8ac1da4fa8"}' (length=283)
  protected 'message' => string 'Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/billing-plans/P-6DK979342A210870GWHVJFGY.' (length=126)
  private 'string' (Exception) => string '' (length=0)
  protected 'code' => int 400
  protected 'file' => string '/var/www/public/application/third_party/PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php' (length=119)
  protected 'line' => int 177

我无法在任何地方找到任何有关如何执行此操作的参考资料。它甚至可能吗?

1 个答案:

答案 0 :(得分:1)

您可能希望直接关注samples中提供的PayPal REST API SDK

http://paypal.github.io/PayPal-PHP-SDK/sample/doc/billing/UpdatePlan.html

从它的外观来看,你需要"状态"要有效,而不是已创建