Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Payment status not updated after plan swap #169

Closed
DiyanDev opened this issue Mar 10, 2020 · 8 comments
Closed

Payment status not updated after plan swap #169

DiyanDev opened this issue Mar 10, 2020 · 8 comments

Comments

@DiyanDev
Copy link
Contributor

Using the swap or swapAndInvoice functions on an existing subscription seems to swap the customer plan and charge the difference, that's fine but the created order has a payment status of "open" even tho it shows as paid on the mollie dashboard. Here are some screenshots showing what I am trying to explain:

Local payment status: https://prnt.sc/re851v
Mollie dashboard: https://prnt.sc/re86oj

Creating a new subscription works as expected and the order has a paid payment status.

I noticed that swapping plans doesn't fire any PaymentPaid event (https://prnt.sc/re8j5s)
Is this a normal behavior or I'm missing something?

@sandervanhooft
Copy link
Contributor

the created order has a payment status of "open" even tho it shows as paid on the mollie dashboard.

Can you check this is still the case? The order payment status is updated using the webhook.

Regarding the PaymentPaid event, that's also triggered when the webhook controller processes the payment update.

@DiyanDev
Copy link
Contributor Author

Yes, it's still open there was no atempt to call the webhook since yesterday: https://prnt.sc/rexjp7

@sandervanhooft
Copy link
Contributor

Is there anything in your log?

@DiyanDev
Copy link
Contributor Author

Thank you for your response.
I know this isn't helping but unfortunately I don't see anything wrong in the logs.
I managed to replicate the issue on a staging server and nothing changed. (Previously I was using ssh tunnel (ngrok) in a local environment).

Here are the webhook requests I received.

After creation of new subscription: https://prnt.sc/rf8jmy
After swapping the plan: https://prnt.sc/rf8lmf

Here are the queries ran during creation and swap

After creation of new subscription: https://prnt.sc/rf9ey5
After swapping the plan: https://prnt.sc/rf9gew & https://prnt.sc/rf9hlj

Here is the code I am using in order to swap the plans.

$subscription = $listing->subscription;
// Check if user selected different plan
if($subscription && (request('plan') != $subscription->plan)){
    $plans = config('cashier_plans.plans');
    //User chose a more expensive plan
    if($plans[request('plan')]['amount']['value'] > $plans[$listing->plan]['amount']['value']){
        $subscription->swapAndInvoice(request('plan'));
    }
    //User downgraded to a cheaper plan
    else{
        $subscription->swapNextCycle(request('plan'));
    }
}

All I do here is checking if the user opted for a more expensive plan or downgraded to cheaper one.

If you need anything else let me know.

@Paulsky
Copy link

Paulsky commented Mar 19, 2020

@DiyanDev I think I have the same issue. Could you please check my comment here: #117 (comment) ?

@sandervanhooft
Copy link
Contributor

Hi @DiyanDev ,

Are you in test mode? In test mode Mollie does not automatically update the payment status of mandated payments. You can set it manually in the browser using

mollie()->payments()->get($paymentId)->_links->changePaymentState(); // yields a url string

More info here.

The issue @Paulsky is referring to is a race condition issue that only happens in test mode as well. Also a good one to be aware of.

Does this clear things up for you?

@DiyanDev
Copy link
Contributor Author

Ow I see... That makes sense now, I am running in test mode indeed.
Thanks for the clarification.

@sandervanhooft
Copy link
Contributor

No problem, thanks for following up!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants