Webhook for Paymill cancelled subscription - webhooks

Context: We allow users to subscribe to our content by using Paymill subscriptions (monthly or yearly). The user can cancel the subscription at any time, which will remove any future transactions under their client account, but not the current transaction (ex current month or year). We do this by using subscription.setCancelAtPeriodEnd(true); when the users cancels their subscription. Also, as you can see, we are using the Java paymill-java library.
Question: The only missing bit is to actually cancel their content in our app when the current period ends. So, is there a webhook for EventType.SUBSCRIPTION_CANCELLED which will be called at the actual period end ? I see there is a EventType.SUBSCRIPTION_DELETED webhook, but I presume this won't work as we don't actually delete the subscription. I know there are probably other solutions to this matter, like managing the cancelled period end in our app, but this would be much more cumbersome than just using a webhook. At least IMHO.

there are some new webhooks with the subscription v2.1 coming out last week. For example
* subscription.expiring: returns a subscription-object
* subscription.deactivated: returns a subscription-object
* subscription.activated: returns a subscription-object
* subscription.canceled: returns a subscription-object
Have a look at https://www.paymill.com/de-de/dokumentation/referenz/api-referenz/#events
Think yours is the subscription canceled one but you need to make the subscription creation with the api v2.1.

Related

Stripe handling the customer.subscription.deleted

I have a code that disables the user to access my website upon receiving this event : customer.subscription.deleted . However, I want to set a specific condition before applying this code.
I have two cases, in one case, if the user is subscribed to INFINITE plan, he pays 40$ each month for 5 months (cancel_at field of subscription is set after 5 months)and then when the subscription ends, his access to the website remains valid. so after 5 payments, he no longer pays, but he still have access to the website. whereas in a second case, if the website's admin manually cancels the subscription or if it is cancelled after many failed payments, I want to disable the user's access. so is there any condition I can set to differentiate between a subscription that was cancelled after being fully paid and another one that was cancelled before it is fully paid ?
You would have to keep track of this on your end, or using metadata on the Subscription that you kept up to date. There's no way in Stripe to make this distinction.

Stripe PaymentIntents + Subscription

Anyone know how to make a Stripe subscription charge a card automatically on future period payments using the new PaymentsIntent SCA approach?
Stripe's docs are in need of major pruning. I've never seen such convoluted and confusing docs as these ones.
One of the confusing parts is where they say in the docs for PaymentsIntents:
confirmation_method:
automatic
(Default) PaymentIntent can be confirmed using a publishable key. After next_actions are handled, no additional confirmation is required to complete the payment.
manual
All payment attempts must be made using a secret key. The PaymentIntent returns to the requires_confirmation state after handling next_actions, and requires your server to initiate each payment attempt with an explicit confirmation.
If I put automatic, the handleCardAction doesn't work anymore on the front end. If it has to be manual, does that mean that all future recurring payments (say Month 2, 3, etc) will need some kind of SCA confirmation by the user?
I haven't found any elements examples for paymentintents and subscriptions with SCA and varying plans and prices not pre-set on the backend as they depend on each individual's parameters.
If I use manual and handleCardAction, the subscription stays incomplete, despite the payment going through. If I use confirmCardPayment, the SCA popup never shows.
Looking further into the subscription and intent objects, I noticed that a new subscription created on the server comes with its own paymentIntent object. So does it mean one has to stop creating a separate paymentIntent with own id? If you do, it doesn't work for completing the subscription, which stays as incomplete.
However, the subscription's paymentIntent has a confirmation_method set as automatic by default -- this results in an error after SCA on the frontend: "You cannot confirm this PaymentIntent because it has already succeeded after being previously confirmed". Interesting, why did it ask for the SCA then in the status: "requires_action"?? Are we supposed to change manually the confirmation_method on a subscription to "manual"??
All this is quite confusing how to make subscription / paymentIntent work with SCA.
My logic is simple: user customises a subscription and enters card details, all of which gets sent to the server => Server creates a new plan, product, customer and subscription => Sends intent (from Subscription?) back to FE => If required, SCA is performed and the subscription is confirmed. Is this not how it's supposed to be done? I don't have pre-set plans as they can vary. I just need the ability to charge a user automatically the same amount they paid for the next period.
The examples and docs I've seen so far don't address the above use case. If anyone knows how to do it or can point to an example of how stripe elements and paymentIntents work with SCA and subscriptions that actually works and activates the subscription?
Stripe has a complete guide to fixed-price Subscriptions with Elements that sounds like it covers what you're trying to do.
When you're working with Stripe Billing (Subscriptions and Invoices) you rarely need to interact with the underlying Payment Intents; those are an implementation detail inside of each Invoice.

Authorize.Net Recurring Billing Events

I have successfully deployed Authorize.net API(currently sandbox mode) for subscription purposes. I have also configured its webhooks that are also working. But I have a confusion that still exists even after a week on working with the said API.
The question is, when a subscription starts in case of recurring billing(in my scenario subscription is monthly) the event that is called is
net.authorize.customer.subscription.created
When a month passes on a subscription and next bill payment is made by the API, what event will get called? How can I capture Or to what event should I be listening to? . Is it going to be
net.authorize.customer.subscription.updated
Currently I have clicked yes on all the all the events that are there for the webhooks
The event will be a payment related event, not a subscription related event. Subscription related events only happen when you do something to a subscription (i.e. create, modify, or delete) not with it (make payment).
So you would look out for any of the following:
net.authorize.payment.capture.created
net.authorize.payment.fraud.approved
net.authorize.payment.fraud.declined
net.authorize.payment.fraud.held

Braintree how do I change the subscription lifecycle period?

I am new to braintree and I am implementing a braintree payment gateway for my nodeJs app. I have few concerns when it come to application testing.
How can I change the period of one billing cycle. Currently its limited to minimum of 1 month. If it is not changeable what is the workaround for testing multiple billing cycle transactions ??
PS: I did refer to this how-can-i-change-subscription-period-on-braintree but a valid answer can not be found.
My next question is related to the webhooks in Braintree. When a webhook is triggered for successful charge for subscription it returns a Subscription object which a transaction array which includes all the transactions for that subscription. Is there a way to filter out the data for the transaction which the webhook was triggered for ? It says the array is sorted. Does that mean that 0th position of the transaction array is the last transaction made ??
Braintree Subscription object reference
Since the test environment does not let us change the billing cycle time I have to wait a month to test this. And if there is a better way to do handle this please advice me on it.
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
It’s not possible to create a subscription billing period shorter than a month in sandbox or production. The previous answer linked in your question — creating a subscription with a 1-day trial period — is a good way to test subscription billing transactions.
The array of transactions inside a subscription object is sorted by creation date with most recent first, so the first transaction within a subscription returned in a webhook notification will be the transaction that triggered the webhook.
You can also take a look at our webhooks testing page for examples of how to generate sample webhook notifications.

How to deal with subscriptions using PayPal's REST SDK

I am trying to create a basic subscription service on my site and I am not sure of a standard way to deal with subscriptions. I'm sure I could hack something together but I'm just wondering if there is a suggested way.
So I have created a billing plan and activated it.
I have a subscribe button on my site that creates a billing agreement referring to the billing plan created in step 1 and redirects the user to the PayPal website were they can login and accept the subscription.
Once the user completes the actions on the PayPal website they are returned back to my site with a token were I then execute the agreement using the returned token from PayPal as per the documentation.
So I guess after these steps the subscription is created for that user, is active and the first payment is made immediately.
In my database, I have a field for each user names subscribed and it's value is a boolean which I set to true once they are returned to my site and the execute command is successful.
My problem is keeping this boolean value up to date for each user as this is the value I check to see if they can access the content.
Canceling - I can provide a cancel button on my site to cancel their subscription and when successful I can set the value to false. But what if they cancel through the PayPal website? I think there is a webhook names BILLING.SUBSCRIPTION.CANCELLED which may send me the agreement ID and If I save it in my database I can see which user it belongs to and set their subscription to false.
After the first month has passed and the next payment is due, is there a webhook sent for a successful payment or a failed payment so I can then set the subscription value accordingly? I see there is a webhook named PAYMENT.SALE.COMPLETED but I don't know if this fired for a successful payment and PAYMENT.SALE.DENIED for a failed payment. If these webhooks exist for subscriptions I imagine it should be a simple solution to keeping this subscribed value up to date.
Hope this made some sense.

Resources