How to test the 'unpaid' and 'incomplete_expired' status in subscriptions using stripe test cards? - testing

I want to test the following scenarios which are included in the stripe subscription status documentation.
Can anyone please suggest a test card in stripe to test it?
Scenario 1
Incomplete_expired- The initial payment on the subscription failed and no successful payment was made within 23 hours of creating the subscription. These subscriptions do not bill customers. This status exists so you can track customers that failed to activate their subscriptions.
Scenario 2
Unpaid- The latest invoice hasn’t been paid but the subscription remains in place. The latest invoice remains open and invoices continue to be generated but payments aren’t attempted.

You should use a test card where the payment will be declined for the initial subscription invoice payment. There's a full list here, but 4000000000000002 will return a generic card_declined error which should be sufficient for this testing case.

Have a look at the SO question: Simulate Stripe Subscription Renewal Failure
The idea is to create a user with a valid payment method and then change the payment method later on via the dashboard for example.

For incomplete_expired - just pay with card which need 3d secure like 4000002500003155 and don't make card authentication, subscription will move to incomplete after 3 hours, after 23 hours subscription status will move from incomplete to incomplete_expired.
For unpaid status Stripe says some additional setting should be applied
https://stripe.com/docs/api/subscriptions/object#subscription_object-status

Related

Migrate old subscriptions to stripe

We have an existing saas app where we used to handle payments for subscriptions offline in a manual way. (They pay us directly to our accounts and we update their subscription data in our database manually).
Now we are moving over to stripe so that customers can automatically add/renew their subscriptions on our platform (via stripe).
Since our app queries stripe to fetch the customers current subscription, we will have to somehow move all old subscriptions to stripe but I am not sure how to proceed with that.
What I expect at the end:
Add a subscription for all old customers to stripe WITHOUT charging the customers anything (as they have already paid to us outside of stripe).
Then when the subscription ends, let stripe proceed with its flow of auto-charging the customer.
I don't really care if the interval of the new subscription in stripe is from today to today+365days even though the customer purchased our services 3 months back (we don't mind giving him an extra 3 months for free)
What i tried and didn't work:
Create a subscription manually for the customer (via the api/dashboard) but stripe throws an error saying no payment method set for the customer which leads me to believe that stripe will want to charge for this subscription.
Approaches that I am evaluating:
Create a coupon with a 100% discount while creating a subscription for the old customers. But I am not really sure if this is the right way to approach this (what happens to stripe fees here?)
I would really appreciate it if someone can shed some light on what approach to take here?
Thanks!
I believe you can create a Subscription with a trial period. Ie. If your customer purchased your services 3 months back, you can create a Subscription with trial period = 9 months, or even 1 year if you don't mind giving them 3 months free until today + 365 days.
When a subscription is created with a trial period, it won't ask for a Payment Method. When its billing cycle is approaching, Stripe will send a trial_will_end webhook event for you to start collecting your customer payment method.
There is also a Stripe's official doc for trial Subscription.

Notification after subscription through authorize.net

I am a developer and set up authorize.net for subscription. Suppose I subscribed for 12 months from January. I can get transaction id and payment status and other necessary information on January or after first payment. But how can I get the transaction id and payment status and other necessary information on 2nd, 3rd, 4th payment and so on.
If you want to be notified of payments and retrieve all of the relevant information about them in an automated fashion use their Silent Post functionality. It is like Paypal's IPN as it will post transaction information to your website so you can record it in your database in real time.
You will get this information inside Authorize.Net Merchant Interface : https://account.authorize.net
Under the
Recurring Billing
option, inside the
Transaction Status Report
page you will find the
Monthly Transaction Status Dashboard
which contains the Subscriptions transaction details
There is also an ARB Email Notifications options to get this transactions in email, under the Recurring Billing option

Paypal Rest API - Immediate Payment life time

i didn't find any information about life time of payments with intent "sale". If a user cancel's payment by closing the paypal window, then i should be abled to continue payment by looking up the payment via api and redirect him to the approval url. But this works only for a certain time span. I'm abled to look up payments from yesterday, the response tells me about a payment state of "created" but after redirection to the approve_url paypal's website says:
Your Session has ended.
This transaction has expired. Please return to the recipient's website to complete your transaction using their regular checkout flow.
I guess i should create a new payment in that case. But how long should i wait before creating a new payment, because payments with age.. - lets say about 1 hour are still valid?
TIA
The user has three hours to approve of the PayPal payment before a new payment must be created.

Paypal IPN INCOMPLETE status cause

I am new to the paypal api, but have integrated it into my site. Every transaction has 2 receivers using the adaptive payments api. Every once in awhile I get an ipn response with status of INCOMPLETE. Reading the documentation it says this status is because
Some transfers succeeded and some failed for a parallel payment or, for a delayed chained payment, secondary receivers have not been paid
Why would only one transaction work? Only the first recipient is getting the money causing problems. What is the best way to handle this? Anyway to immediately refund the buyer with the first recipients payment?
You could reverse all payments if any of them in the request fail using the reverseAllParallelPaymentsOnError parameter.
xs:boolean (Optional) Whether to reverse parallel payments if an error
occurs with a payment. Allowable values are: true – Each parallel
payment is reversed if an error occurs false – Only incomplete
payments are reversed (default)

Getting status on canceled/expired credit cards for recurring billing with authorize.net

We're setting up a system that will use the XML API for Automated Recurring Billing with Authorize.net.
It looks simple enough to set up a recurring billing. But we have two features that do not seem obvious
* providing customers with details on individual payments
* providing notification to customers of expired/canceled cards
Anyone familiar with a mechanism to retrieve this info in automated form? We're considering
* just listing out assumed payments based on our own calculations the start date
* emailing customers based on the expiration date of the ards
But I'm stymed on how to figure out when a transaction failed due to canceled card (and automatically notify the customer).
Can anyone comment on how they handled this issue when implementing a subscription-based service based on Authorize.net?
Authorize.Net has recently published a new ARB method "ARBGetSubscriptionStatus".
You may now easily query the status of a previously submitted ARB subscription without the need to depend on the "Silent Post Method".
Example:
<?xml version="1.0" encoding="utf-8"?> <ARBGetSubscriptionStatusRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> <merchantAuthentication> <name>mytestacct</name> <transactionKey>112223344</transactionKey> </merchantAuthentication> <refId>Sample</refId> <subscriptionId>100748</subscriptionId> </ARBGetSubscriptionStatusRequest>
You want to use Authorize.Net's silent post feature. It will notify you of all payments made through their system including declines and expired credit cards. Your script will then be able to suspend accounts and/or notify your customers that their payments has failed.
See these link for more info:
Handling Authorize.Net ARB Subscription Failures
All About Authorize.Net’s Silent Post
Handling Authorize.Net Silent Post with PHP
You need to use the Silent POST URL
ARBGetSubscriptionStatusRequest will not work. If the first transaction (or first transaction since the ARB profile was updated, either via API or manually) fails, the status of the subscription is set to suspended. Otherwise, the status of a subscription does not change when a transaction declines or a card expires.
Using the Silent POST URL, you'll be notified of successful transactions and you can use them to update your data such as tracking a next payment due date/expiration date. You can then run a cron job and if this field has not been updated, you will know that the card was cancelled or expired.
In the event that it is still an active card but gets declined, you'll get notified as such at the Silent POST URL