Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification on Tracking Payment Status During Checkout #120

Closed
SantoshKumarRavi opened this issue Aug 20, 2024 · 6 comments
Closed

Clarification on Tracking Payment Status During Checkout #120

SantoshKumarRavi opened this issue Aug 20, 2024 · 6 comments

Comments

@SantoshKumarRavi
Copy link

I am writing to seek clarification on the process of tracking the payment status during the checkout phase.

Currently, we need to accurately track the payment status to ensure that the checkout process is completed successfully. Additionally, we have observed that payment failure webhooks are being triggered when a user attempts to upgrade or downgrade their subscription.

Could you please provide guidance on the best practices or any specific methods we should implement to track the payment status effectively during the checkout?

@brankoconjic
Copy link
Collaborator

Hi 👋

Please see here for available webhook request event types.

order_created webhook reqest will be sent when a new order is successfully placed.

If you are selling subscriptions you can use subscription_created. order_created will be sent along subscription_created.

That webhook request includes a Subscription object that you can use to sync the data with your own database.

Since this issue is not related to the SDK itself, I will close it. If you need support, it's best to visit our Help Center so that goes through our support channels.

@SantoshKumarRavi
Copy link
Author

Thanks for response.
I already tested with the webhook events before creating issue.
When the user paid successfully in subscription , order_created followed by subscription_created webhooks triggered.
My use case is different here.
That's why i opened the issue here.
I need to check whether user completes the payment process or not or any issues in payment in initial checkout.
i am generating unique checkout link from backend like below https://mystore.lemonsqueezy.com/checkout/custom/86a05849xxxxxxxx?signature=xxxxxxxx
Based on that I need to update client side.
is there any solution available for this ?
I will move this to feature request if this feature is not there.

@SantoshKumarRavi
Copy link
Author

@brankoconjic

@brankoconjic
Copy link
Collaborator

When creating a Checkout using the API you can pass custom data (checkout_data.custom) to the API which will be returned with the webhook. Only the webhook events listed in our docs are available.

https://docs.lemonsqueezy.com/api/checkouts#create-a-checkout

const { data, error } = await createCheckout(storeId, variantId, {
  checkoutData: {
    custom: {
      custom_user_id: "1234",
    },
  },
});

In the webhook request payload:

...
"meta": {
  ...
  "custom_data": {
    "custom_user_id": "1234"
  }
}

Does that help?

These events should be what you are looking for:

  • subscription_payment_failed
  • subscription_payment_success

@SantoshKumarRavi
Copy link
Author

SantoshKumarRavi commented Aug 20, 2024

No. I already implemented this. there is no issues on this.
let me explain my scenario.
I generated this https://mystore.lemonsqueezy.com/checkout/custom/86a05849xxxxxxxx?signature=xxxxxxxx from backend.
when user clicks the link , i am redirecting to another window and started the loading.
if user completes payment successfully, i can easily get the status from webhook and stop the loader.
how can u we know whether user has issues in the payment or insufficient funds or any other issues ? here i need to stop the loader and need to show toast message .

I believe that u now got the idea

@SantoshKumarRavi
Copy link
Author

@brankoconjic

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

No branches or pull requests

2 participants