Error during plan updation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;
}

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Error message for obtaining access_token in REST APIs
- Couldn't receive International payment in PayPal Payments Standard
- "System error. Please try again later" when connecting to paypal sandbox account with my android app in Sandbox Environment
- Things don’t appear to be working at the moment in PayPal Payments Standard
- Something went wrong. Contact the merchant for help. in PayPal Payments Standard