mollie / mollie-api-php

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

Subscription billing cycle #254

Closed sandervanhooft closed 6 years ago

sandervanhooft commented 6 years ago

Specifications

Describe the issue

For subscription handling in Laravel Cashier, I'd like to retrieve the most recent payment date and/or (preferably) the next payment date. So I can determine grace periods after canceling the subscription.

Is there a way to do this?

sandervanhooft commented 6 years ago

@Smitsel What are your thoughts on this?

I am now estimating the next payment date based on the createdAt and interval fields. But imho it's not as reliable as doing it server-side.

Smitsel commented 6 years ago

Hi @sandervanhooft,

We do it based of the startDate and interval server side too.

So i'm going to let @ndijkstra decide if we should do this internally in the client. Or create a ticket to add these to the resource :)

willemstuursma commented 6 years ago

@sandervanhooft I created an issues for us to create a customer/cst_xxxx/subscription/sub_xxxx/payments resource.

That still won't give you the next payment date though.

Smitsel commented 6 years ago

We have the logic on our side. So we might as well add that to the subscription resource. But this will have to be put on our backlog then :)

ndijkstra commented 6 years ago

I've created an issue for the next payment date on our backlog.

sandervanhooft commented 6 years ago

Thanks @willemstuursma @ndijkstra @Smitsel !

I like where this is going 😄

sandervanhooft commented 6 years ago

Let me know if you have any updates on the timeline.

I'll work around this for the Alpha release of Cashier (estimateCurrentPeriodEnd() instead of getCurrentPeriodEnd()). But it will be required for the stable release.

sandervanhooft commented 6 years ago

@willemstuursma wrote:

I created an issues for us to create a customer/cst_xxxx/subscription/sub_xxxx/payments resource.

This would also be very helpful for refunding a subscription payment.

Or is there another way to (partially) refund a subscription?

The use case here is that I need to swap a subscription plan using prorating in Laravel Cashier.

So let's say the customer swaps from plan A to plan B. So subscription A is canceled and subscription B is started.

The customer will need to be reimbursed for unused time of subscription A, which the customer has already paid for.

The cleanest solution I can think of is a partial refund on the last payment for Subscription A.

Another solution would be to cancel subscription A, create a one-off payment for plan B minus the surplus of A, and then schedule subscription B (using startDate) for the next payment cycle. But this is very hacky, harder to keep track of from client-side.

willemstuursma commented 6 years ago

Or is there another way to (partially) refund a subscription?

No, refunds are always created on the payment or on the order, which creates a refund on one of the payments.

MollieRick commented 6 years ago

The List Subscription Payments endpoint is now available. https://docs.mollie.com/reference/v2/subscriptions-api/list-subscriptions-payments

sandervanhooft commented 6 years ago

@MollieRick Thanks! 🎉

sandervanhooft commented 6 years ago

These are great features!

@willemstuursma wrote:

That still won't give you the next payment date though.

I've discussed with @ndijkstra , Mike and Taylor (Laravel founder) that we'll be scheduling recurring payments manually client-side in the upcoming Mollie Cashier package. While it would be a great feature imho, I personally no longer have a direct need for the next-payment-date feature.

sandervanhooft commented 6 years ago

We are going with "scheduling" because it allows us more flexibility / more advanced use cases.

MollieRick commented 6 years ago

@sandervanhooft:

While it would be a great feature imho, I personally no longer have a direct need for the next-payment-date feature.

I have this in development now, so maybe you can use it in the future.

sandervanhooft commented 6 years ago

It's absolutely valuable!

sandervanhooft commented 6 years ago

The List Subscription Payments endpoint is now available. https://docs.mollie.com/reference/v2/subscriptions-api/list-subscriptions-payments

Will you be adding it to this php client as well? Let me know if I can help.

MollieRick commented 6 years ago

Aaaaand also the nextPaymentDate field is now available in the Subscription API.

sandervanhooft commented 6 years ago

@MollieRick Great!