On Stripe's API docs the value returned when attempting to create a subscription on a customer is described as follows:
The newly created subscription object if the call succeeded. If the customer has no card or the attempted charge fails, this call returns an error (unless the specified plan is free or has a trial period).
From this, I am assuming that if the first attempted charge fails (and an error is returned) this means that the subscription has not been created?
I am wanting to be able to create subscriptions on customers who may not yet have any billing sources added and as soon as they add a billing source the first payment will be processed. Is there a way to accomplish this?
From this, I am assuming that if the first attempted charge fails (and an error is returned) this means that the subscription has not been created?
Yes, that's correct.
I am wanting to be able to create subscriptions on customers who may not yet have any billing sources added and as soon as they add a billing source the first payment will be processed. Is there a way to accomplish this?
You could create a subscription with a plan for $0, or create a sub with a trial using trial_end to create a 'free' subscription.
As far as "as soon as they add a billing source the first payment will be processed." -- you'd need to create logic to handle this on your own. When a user adds a payment source you could update their subscription ending the trial (trial_end=now), or moving them to a paid plan.
https://stripe.com/docs/api#update_subscription
Related
I am working with Stripe to manage subscriptions. I would like to delegate payment of a subscription to another customer.
Specifically, I want the customer of the subscription to reap the benefits of a subscription, but assign another customer to pay for it.
Is that possible? If not, what are the possible workarounds? Thanks.
Notes:
Once a subscription is created, an invoice is automatically generated and is not editable according to what I have tried previously
I would like to keep as close to the usual subscription flows as possible, as I don't want to lose out on things such as being able to pro-rate an invoice (which becomes messy if I have to manually craft invoices myself)
suppose i have a membership service which cost $10/month in a subscription way
but some users can not have a reusable source to make a subscription via plan api ,alternatively i will let him to do an one-time payment via order api.(at least accept one month's money)
it is the same product,same amount,difference is one is for plan,another is for order,so question is, should i create two products one is goods type(for order),one is service(for plan/subscription). or one service type product is enough?
As a concept in the Stripe Dashboard, product SKUs are only used for recurring plans or invoicing. Any one time purchase can just be a charge, and does not need to be associated with any "Product" within your Stripe configuration.
If the product in this case is literally just one month of the plan, then you should probably use the same Product you have specified.
If the payment method will only work once, you could do nothing, and when the first period is up, and Stripe tries to renew, the payment will fail and the subscription will be canceled.
Or, if you're positive beforehand that it should only be charged once, you could cancel the subscription right after the first payment is completed. The customer would still have an active subscription for the period they paid for, but Stripe would not try to charge them automatically when that first period expired.
I have a number of users who are currently subscribers to a monthly subscription.
For business reason, I want to be able to
1) Charge the customer when he decides to subscribe to our plan
2) Let the subscription become effective a number of days after the purchase
Currently a charge is immediately attempted when a subscription is added to a customer in stripe.
I want to stick to the stripe subscription because a) I still want to have stripe to manage subscription for me in future dates, and b) I have written a lot of code for the subscription model.
Is it feasible at all to demarcate the charge/invoice and the subscription start date?
You can control the time when the subscription actually starts (i.e. when Stripe will start billing the customer) by using the trial_end parameter in your subscription creation request. Simply set the value of the parameter to the timestamp of the exact time you wish Stripe to start automatically billing the customer.
If I understand your desired payment flow correctly, you'd want to do something like this when a customer signs up:
Collect and tokenize the customer's payment information (using Elements or Checkout).
Using the resulting token, create a customer object and save the resulting customer ID in your database.
Create a one-off charge using the customer object for the first payment.
Create a subscription using the customer object and the trial_end parameter set to the time you want Stripe to start automatically billing the customer.
See https://stripe.com/docs/subscriptions/trials for more information about using trial periods.
This is possible now through Stripe Subscription Schedules. With that, you can create a one phase schedule that starts in the future. By default, this will start the subscription on the date you want, automatically renew, and charge the customer on the start date. Also by default, it will immediately perform a transaction to pay for the subscription.
I found the required iterations to be a bit confusing. Essentially that is a multiplier against how many times the original price's interval repeats before moving on.
If all you want to do is start a subscription price in the future, use the Subscription Schedule API call. Create an items array of 1. Set the price_id of the price, the iterations on that item, and the start_date to the unix timestamp you want to start the subscription.
Stripe has different use cases for subscription schedules. The first one they list is exactly this purpose, starting and charging a subscription on a future date. Look through them if you want to adjust some more, like making the first phase a trial period instead.
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.
Today after doing thorough testing i switched to Live Account for Stripe. For my very 1st customer stripe charged twice even though on the server side i am creating just one customer and posting a single charge. I have a monthly subscription plan that i am using.
I never saw this issue in Test Account. I even tried my own card and got charged twice. The two charges are posted within 1 second of each other. I have checked my plan too and they are correctly set up
If you have a monthly subscription, that will automatically make a charge, there is no need for you to be posting a charge when the subscription does it automatically.
(Should have commented but i do not have the rep)
I had the same problem on production not in testing.
I found that if a customer is not a subscriber, my code was making it a customer first and then charging customer. But Stripe is already charged customer upon subscription.
"If(subscriber)->charge
else(make subscriber(Stripe charges now))->charge as customer"
The obvious fix is to make the customer a subscriber and quit if it is a new one, please do not call charge.
The not reproducible on testing issue is because all test accounts were already a subscriber .