cancel
Showing results for 
Search instead for 
Did you mean: 

Error during plan updation

Error during plan updation

I have got an error during plan update and the error is: "Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/billing-plans/P-1JR23127SG330430ULQ74TLY."

I have used the below code:

public function updateBillingPlan($li_planId){
$apiContext = self::apiContext();

$createdPlan = Plan::get($li_planId, $apiContext);

try {
$patch = new Patch();
$paymentDefinitions = $createdPlan->getPaymentDefinitions();
$paymentDefinitionId = $paymentDefinitions[0]->getId();
$value = new PayPalModel('{
"name": "Updated Payment Definition",
"frequency": "Day",
"amount": {
"currency": "USD",
"value": "10"
}
}');
$patch->setOp('replace')
->setPath('/payment-definitions/' . $paymentDefinitionId)
->setValue($value);
$patchRequest = new PatchRequest();
$patchRequest->addPatch($patch);

$createdPlan->update($patchRequest, $apiContext);
$plan = Plan::get($createdPlan->getId(), $apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Updated the Plan Payment Definition", "Plan", null, $patchRequest, $ex);
exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Updated the Plan Payment Definition", "Plan", $plan->getId(), $patchRequest, $plan);
return $plan;

}