I am creating a paypal payment system with Laravel 5.4. Direct payments work perfectly, but when creating a "BillingPlan" to make recurring payments I get this answer
Got Http response code 400 when accessing link
My code:
$plan = new Plan();
$plan->setName('T-Shirt of the Month Club Plan')
->setDescription('Template creation.')
->setType('fixed');
$paymentDefinition = new PaymentDefinition();
$paymentDefinition->setName('Regular Payments')
->setType('REGULAR')
->setFrequency('Year')
->setFrequencyInterval("1")
->setCycles("20")
->setAmount(new Currency(array('value' => 100, 'currency' => 'USD')));
$chargeModel = new ChargeModel();
$chargeModel->setType('TAX')
->setAmount(new Currency(array('value' => 0, 'currency' => 'USD')));
$paymentDefinition->setChargeModels(array($chargeModel));
$merchantPreferences = new MerchantPreferences();
$merchantPreferences
->setReturnUrl(url('get_agreement'))
->setCancelUrl(url('get_agreement'))
->setNotifyUrl(url('get_agreement'))
->setAutoBillAmount("yes")
->setInitialFailAmountAction("CONTINUE")
->setMaxFailAttempts("0")
->setSetupFee(new Currency(array('value' => 1, 'currency' => 'USD')));
$plan->setPaymentDefinitions(array($paymentDefinition));
$plan->setMerchantPreferences($merchantPreferences);
$request = clone $plan;
try {
$output = $plan->create($apiContext);
} catch (Exception $ex) {
}
return $output;
Json Response:
{"name":"T-Shirt of the Month Club Plan","description":"Template creation.","type":"fixed","payment_definitions":[{"name":"Regular Payments","type":"REGULAR","frequency":"Year","frequency_interval":"1","cycles":"20","amount":{"value":"100","currency":"USD"},"charge_models":[{"type":"TAX","amount":{"value":"0","currency":"USD"}}]}],"merchant_preferences":{"return_url":"http://localhost/paypalReceiver/public/get_agreement","cancel_url":"http://localhost/paypalReceiver/public/get_agreement","notify_url":"http://localhost/paypalReceiver/public/get_agreement","auto_bill_amount":"yes","initial_fail_amount_action":"CONTINUE","max_fail_attempts":"0","setup_fee":{"value":"1","currency":"USD"}}}