mollie / mollie-api-php

Mollie API client for PHP
http://www.mollie.com
BSD 2-Clause "Simplified" License
551 stars 189 forks source link

oAuth new payment is not working #191

Closed an-pankajpatil closed 5 years ago

an-pankajpatil commented 6 years ago

Trying with 10-oauth-new-payment.php currently it is giving me the following error "API call failed: Error executing API call (422: Unprocessable Entity): No suitable payment methods found. Documentation: https://docs.mollie.com/guides/handling-errors".

willemstuursma commented 6 years ago

There's probably no payment methods activated on the account you are creating payments for.

Try adding "testmode": true to the POST body.

an-pankajpatil commented 6 years ago

This is how I am making the call $payment = $mollie->payments->create(array( "amount" => [ "value" => "10.00", "currency" => "EUR" ], "description" => "My first API payment", "redirectUrl" => "{$protocol}://{$hostname}{$path}/03-return-page.php?order_id={$orderId}", "webhookUrl" => "{$protocol}://{$hostname}{$path}/02-webhook-verification.php", "metadata" => array( "order_id" => $orderId, ), "testmode"=> true, "profileId" => $profile->id // This is specifically necessary for payment resources via OAuth access. ));

This is still showing the error "API call failed: Error executing API call (422: Unprocessable Entity): No suitable payment methods found. Documentation: https://docs.mollie.com/guides/handling-errors"

ndijkstra commented 6 years ago

You have to enable some payment methods first in your account: https://www.mollie.com/dashboard/settings/profiles

freddyamsterdam commented 6 years ago

@willemstuursma I think this issue was maybe closed prematurely. I can only speak for myself here, but I have checked the profile for payment methods: iDeal is enabled. The payment method in question is a first payment for a subscription. Any missing vars in code below are properly defined populated in the actual code in my application.

For the record: I'm using api keys and not oAuth. I can make a new issue if your prefer.

$amount = number_format($amount, 2);
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
$hostname = $_SERVER['HTTP_HOST'];

$customer = $this->mollie->customers->create([
    "name" => "Dude McTestguy",
    "email" => "not_your_buddy@guy.friend"
]);

$customer->createPayment([
    "amount" => [
        "value" => "$amount",
        "currency" => "EUR"
    ],
    "description" => $description,
    "redirectUrl" => "$protocol://$hostname/someUrl",
    "webhookUrl" => "$protocol://$hostname/api/v1/payment/webhook",
    "metadata" => [
        "order_id" => "pal_buddy",
    ],
    "sequenceType" => "first"
]);

The customer is created as expected, but the createPayment method throws the error originally described in this issue. In addition, setting testmode => true throws another error:

Mollie\Api\Exceptions\ApiException: Error executing API call (422: Unprocessable Entity): Non-existent body parameter "testmode" for this API call. Did you mean: "method"?. Field: testmode.

Thanks!

Ken-vdE commented 5 years ago

@willemstuursma I think this issue was maybe closed prematurely. I can only speak for myself here, but I have checked the profile for payment methods: iDeal is enabled. The payment method in question is a first payment for a subscription. Any missing vars in code below are properly defined populated in the actual code in my application.

For the record: I'm using api keys and not oAuth. I can make a new issue if your prefer.

$amount = number_format($amount, 2);
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
$hostname = $_SERVER['HTTP_HOST'];

$customer = $this->mollie->customers->create([
    "name" => "Dude McTestguy",
    "email" => "not_your_buddy@guy.friend"
]);

$customer->createPayment([
    "amount" => [
        "value" => "$amount",
        "currency" => "EUR"
    ],
    "description" => $description,
    "redirectUrl" => "$protocol://$hostname/someUrl",
    "webhookUrl" => "$protocol://$hostname/api/v1/payment/webhook",
    "metadata" => [
        "order_id" => "pal_buddy",
    ],
    "sequenceType" => "first"
]);

The customer is created as expected, but the createPayment method throws the error originally described in this issue. In addition, setting testmode => true throws another error:

Mollie\Api\Exceptions\ApiException: Error executing API call (422: Unprocessable Entity): Non-existent body parameter "testmode" for this API call. Did you mean: "method"?. Field: testmode.

Thanks!

I'm having the same issue, did this ever get resolved?

willemstuursma commented 5 years ago

@sandervanhooft could you have a look?

rkluwen commented 5 years ago

I'm having the same problem, trying to create a directdebit payment, using the c# client. Note: In my case, it's a recurring payment with an existing and valid mandate. I just upgraded the c# nuget module, but this always used to work.

sandervanhooft commented 5 years ago

@willemstuursma Ok!

About using the testmode parameter

I'm using api keys and not oAuth.

The testmode parameter is only available when using OAuth access tokens, so the mentioned error response seems ok to me.

About testmode spontaneously popping up when using $customer->createPayment()

Not sure what's going on here yet. What mollie-api-php version are you using?

Ken-vdE commented 5 years ago

@sandervanhooft Thank you for responding. I'm having a hard time figuring out how to correctly process my webhook call by mollie when in test mode. I don't get a payment Id from mollie when in test mode and when I try to retrieve a payment using a fake id I get No payment exists with token tr_7UhSN1zuXS (where tr_7UhSN1zuXS is a fake id)

sandervanhooft commented 5 years ago

@rkluwen Thanks for reporting this. I can't help you when it comes to C#, so could you please open a separate ticket in the C# client repo? Alternatively, if you think it's an issue with the Mollie Api itself, please contact Mollie support directly. I'll get back to you if we find out that these issues are related.

@Ken-vdE That sounds like yet another issue. Could you open a separate issue for this? I think I'll be able to help you from there.

Ken-vdE commented 5 years ago

@sandervanhooft Alright, here you go: https://github.com/mollie/mollie-api-php/issues/385 :)

freddyamsterdam commented 5 years ago

@sandervanhooft as far as I can tell, the testmode parameter is secondary to what the main issue was here, which was that the createPayment method was not working.

At the time I was using the API v2.0.5.

sandervanhooft commented 5 years ago

@freddyamsterdam Agreed. Were you able to resolve your issue?