mollie / laravel-mollie

Mollie API client wrapper for Laravel & Mollie Connect provider for Laravel Socialite
https://www.mollie.com/
MIT License
322 stars 62 forks source link

Losing checkout link in get() response when using przelewy24 payment method #149

Closed HarryLee186 closed 3 years ago

HarryLee186 commented 3 years ago

When using the przelewy24 payment method, the checkout link that is returned in the API response is null

Expected Behavior

The checkout link should return correctly, such as: image

Current Behavior

The checkout link is null, shown below: image

Steps to Reproduce (for bugs)

  1. Using Laravel 6, add "mollie/laravel-mollie": "2.7.0", to your composer.json and run a composer install
  2. Add the following code to a controller:
    
    use Mollie\Laravel\Facades\Mollie;

public function preparePayment() { $payment = Mollie::api()->payments->create([ "amount" => [ "currency" => "EUR", "value" => "10.00" // You must send the correct number of decimals, thus we enforce the use of strings ], "description" => "Order #12345", "redirectUrl" => route('order.success'), "webhookUrl" => route('webhooks.mollie'), "method" => 'przelewy24', "metadata" => [ "order_id" => "12345", ], ]);

$payment = Mollie::api()->payments->get($payment->id);

// redirect customer to Mollie checkout page
return redirect($payment->getCheckoutUrl(), 303);

}


3. Run the function, it'll likely throw a redirect error as the checkout url is null. You can dump out `$payment` before the return to see the null checkout url.

## Context
Trying to offer this payment method in an e-commerce application, and due to the null checkout url, when redirecting it's simply giving an error.

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used: Laravel: 6.1, laravel-mollie: 2.7.0
* Environment name and version (e.g. Chrome 39, node.js 5.4): Google Chrome
* Operating System and version (desktop or mobile): Developing on Windows, but this issue happens on Ubuntu too
* Link to your project: N/A
sandervanhooft commented 3 years ago

That's strange. I've asked Mollie support to look into this.

sandervanhooft commented 3 years ago

What is the status of the payment?

sandervanhooft commented 3 years ago

The checkoutUrl will only be available on net-yet-paid-payments, so status open.

HarryLee186 commented 3 years ago

This is before getting to the payment screen, using the code snippet from this repo's readme. So yes I would imagine the payment status would be open(this snippet works perfectly with other methods as outlined in my issue)

sandervanhooft commented 3 years ago

This behaviour is a bit weird, but if you remove this obsolete line it works:

$payment = Mollie::api()->payments->get($payment->id);
sandervanhooft commented 3 years ago

I'll ask Mollie support if they can fix this in the api. Nice catch!

Closing this for now, let me know if it should be reopened.