mollie / mollie-api-node

Official Mollie API client for Node
http://www.mollie.com
BSD 3-Clause "New" or "Revised" License
231 stars 63 forks source link

Please add PaymentLink to types.d.ts #264

Open JohanManders opened 2 years ago

JohanManders commented 2 years ago

Because I have to switch from the Payment API to the Payment Link API, I came across this little annoyance.

For importing Payment I can use:

import { Payment as MolliePayment } from '@mollie/api-client'

So when I switched to Payment Link, I thought I could use:

import { PaymentLink as MolliePaymentLink } from '@mollie/api-client'

But this does not work, because the file @mollie\api-client\dist\types\types.d.ts does not have this line:

export { default as PaymentLink } from './data/paymentLink/PaymentLink';

Could you please add it, this would make PaymentLink work similar like Payment.

Thanks!

PS It would be great if I could use expiresAt with the regular Payment API, so that I did not have to switch to the Link version of the API.

Pimm commented 2 years ago

Thanks Johan,

I'll export PaymentLink!

Could you elaborate on how you would use expiresAt for payments?

JohanManders commented 2 years ago

Hi Pimm,

I have a case where we want to sell some tickets between 14:00 and 15:00 and a raffle will be held at 15:30, 30 minutes after the last moment someone can buy a ticket.

But, payment methods have different expire times. I am sure that no iDeal payment will come through after 15:15, because the expire time is 15 minutes, but for example Credit card (30 minutes) or Paypal (3 hours) can come through (way) after the raffle is done.

We have to inform these people that they paid for something that they did not participate in the raffle and have to pay them back. This is extra hassle...

Payment Link API has a expiresAt field that helps a bit. The payment link is not valid after this set datetime, but people could open the link, get some beer while leaving their browser tab open and still pay after an hour if they use Paypal for instance.

A solution for the Payment API would be to loop through all pending orders at 15:15 and cancel them all, but yeah... it is a bit of a hacky solution in my opinion.

So, I would love to 'say' to Mollie that a payment cannot be done after a certain datetime. That the payment expiresAt, even if someone leaves his browser tab open at a certain Mollie payment page/ link.

Pimm commented 2 years ago

I discussed this with some Mollieneers.

The orders API does have an expiresAt field. This field doesn't help in your case, unfortunately, because the minimal value for that field is tomorrow.

I would personally try your "hacky" solution, which I don't feel is all that hacky.

However, please note that no solution is going to be airtight. Even if Mollie completely respects your 14:00 to 15:00 window, a customer who has already started making the payment (at the website of their bank or PayPal) is outside of the reach of Mollie. I'm afraid you can't entirely rule out the scenario where you have to issue a refund.