How to Know If a User Has Paid for a Subscription

How do you know if a user has paid for a subscription

That tutorial uses a deprecated SDK that only works with the previous version of PayPal Subscriptions. Do not follow anything in that tutorial, it is no good.


For the current version of PayPal Subscriptions, the button described there will activate the subscription on the client side.

You can instead set up your button and use a REST API call to activate a subscription from your server immediately after approval. Activating from the server gives you a reliable server-side notification that a subscription is started. There is no SDK for these calls, you must first get the API access token and perform the call yourself, via HTTPS.

However, to be notified of actual payments for the subscription -- which typically start the following day and repeat on its cycle -- you need a webhook listener for the event PAYMENT.SALE.COMPLETED. There is no supported SDK for webhooks, so you must set up your own listening code and also perform any desired verification of webhooks messages received yourself (verification can be done by checking the signature, or an API call back to PayPal)

If you need to receive a payment the moment a subscription starts (instead of the following day), configure it with a setup_fee and a one cycle trial period before the regular billing cycle begins.

How to check if the user has an active subscription in Android, Google Play?

Okay, figured it out, was my mistake.

I was calling queryPurchases() in my main activity onCreate(), but the BillingClient was not ready yet.

I moved it to onBillingSetupFinished() and it now returns the correct purchases.
Everything is now working as expected. You get the active subscriptions when you call queryPurchases() after an app restart.

Check to see if user actually payed for in-app purchase [iOS, Swift]

You can obtain the receipt from the user's device and check with Apple's endpoint to see if the user has a valid purchase. Ideally you should take the receipt from the app and send it to your server to perform the verification in your backend.

Check this documentation to obtain receipt from the device - https://developer.apple.com/documentation/storekit/in-app_purchase/validating_receipts_with_the_app_store

Check this documentation to call verify the receipt with Apple's endpoint - https://developer.apple.com/documentation/appstorereceipts/verifyreceipt



Related Topics



Leave a reply



Submit