thephpleague / omnipay-paypal

PayPal driver for the Omnipay PHP payment processing library
MIT License
295 stars 174 forks source link

Unable to create a plan #234

Open lucasheitorv opened 5 years ago

lucasheitorv commented 5 years ago

I'm trying to create a plan using PayPal_Rest. Here is the code I wrote:

$transaction = $gateway->createPlan(array(
   'name'                     => 'Test Plan',
   'description'              => 'A plan created for testing',
   'type'                     => $gateway::BILLING_PLAN_TYPE_FIXED,
   'paymentDefinitions'       => [
       [
           'name'                 => 'Monthly Payments for 12 months',
           'type'                 => "REGULAR",
           'frequency'            => $gateway::BILLING_PLAN_FREQUENCY_MONTH,
           'frequency_interval'   => 1,
           'cycles'               => 12,
           'amount'               => ['value' => 10.00, 'currency' => 'USD'],
       ],
   ],
   "merchantPreferences" => [
        'returnUrl' => "http://example.com/return",
        'cancelUrl' => "http://example.com/cancel",
    ]
))->send();

And here is the response:

[
    "name" => "MALFORMED_REQUEST",
    "message" => "Incoming JSON request does not map to API request",
    "information_link" => "https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST",
    "debug_id" => "71bc6e9c2e10f",
]

Obs.: purchase works perfectly