Error during plan updation

sanudas93-buye
Contributor
Contributor

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;

}

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.