Using coupon codes with stripe relay - stripe-payments

Can someone please help me understand how coupon codes works with Stripe relay?
According to the api docs, you can pass a coupon code when creating an order:
https://stripe.com/docs/api#create_order
However, what should this coupon code be? From what I understand, coupons created are only available for subscriptions. In the new dashboard, they coupon page is also only found under subscriptions -> coupons.
So, what should the coupon field contain?
I can't handle the discount logic on my side, as you pass the SKU id's of the products, when creating an order, so you don't pass any amount that you can manipulate yourself.
Thanks.

You can use subscription coupons with Relay's orders. Coupons started out as part of the subscriptions API, and are still grouped under "Subscriptions" in the dashboard and the API reference, but they're also usable with Relay.

Related

Stripe Payment Links - promo codes for non-recurring Products

I have two types of products in my Stripe accounts - one which has a recurring payment model (subscription) and another which has a one time payment option. For both products, I am creating a Payment Link and providing 'allow_promotion_codes = true' on the creation call (docs: https://stripe.com/docs/api/payment_links/payment_links/create).
I have created a promo code / coupon which takes 100% off of the entire order - which is for admin/testing purposes only. This promotion code works just fine on the subscription/recurring products. However, when attempting to use the code for the one-time products, I get "The code is invalid" response.
Are promotional codes only applicable to subscriptions? Is there any way to use promo codes for one-time payment products via payment links? I would like to stick with the current model of providing payment links, hoping it's possible to add discounts to both types of products via payment links. Please do let me know if any code is needed to provide more context.
I created the coupon and payment links and the coupon in Stripe. The payment link only accepts the coupon for subscriptions and not the one-time payment products. I would expect the discount to be applied to all products.
It's expected behaviour mentioned in https://stripe.com/docs/payments/checkout/discounts
Checkout does not currently support discounting a purchase below the minimum charge amount for one-time payments.
Note : Payment Links is essentially Checkout under the hood

Docusign and Stripe integration - Payments are created without a customer

I'm trying to integrate the Docusign eSignature API with Stripe.
I've created a Quickstart application and have successfully run through the process, signing the contract and making a test payment.
However, I noticed that the payment in Stripe does not have a customer object attached to it:
I'd like to know if it's possible to specify a customerId, or create one as part of the process. I did notice that the PaymentDetails constructor accepts a customerId parameter, but I could not see any relevant documentation for this, and specifying it in my request didn't seem to make any difference.
Any advice appreciated.
Thanks
Dan,
For regular payments that are one time and right away - DocuSign will not create a customer record. This is "by design" and is meant to support quick payments without any customer record.
You can set recurring/future payments and then you'll get customer records when you set the gateway. If you want, your recurring payment or future payment can be just one time in the near future and then you can achieve what you want and get a customer record.

Stripe Plan Pricing with Coupon Applied without charging the customer

I am trying to figure out how I can get the final total amount from Stripe for a subscription plan with a coupon applied, without charging the customer to show in the confirmation page before checkout.
I see there is API in Stripe to get Plan info and Coupon info that created in Stripe Dashboard but I want to find out if there is a way to get the Plan pricing info after applying Coupon but without charging the customer. All of the rules for the coupon exist in Stripe Dashboard so wanted to see if there is a way Stripe can give me the pricing info otherwise the rules for Coupon would be duplicated in Stripe and in my application server.
You can use the Upcoming Invoice API [1]. Pass in the Customer or Subscription, Coupon, and any invoice items to see what an upcoming invoice would look like for a Customer.
[1] https://stripe.com/docs/api/invoices/upcoming

Getting Stripe Checkout Product SKU from Stripe charge API

I have a very basic website that runs a stripe checkout with 2 product. This all works fine and I am able to sell products and they appear in the dashboard. Now I want to automate the whole shipping process and get the shipping address for each new purchase along with what was purchased. I can get the address through the stripe API but I can't find any GET commands that can tell me which product sku was ordered along with the Charge. This seems like something that should be pretty easy to find out? It shows up in the web GUI dashboard but not in the web requests. I've read through the documents here https://stripe.com/docs/api but I'm not finding much help.
I have a working web request in python that can return all of my charges that were created but it has no product info.
Alright I found out how to do it. It's a little convoluted and should be streamlined by stripe but here is how you can do it.
First requests a list of events like this (I'm using python)
import stripe
foo = stripe. PaymentIntent.list(type='checkout.session.completed',limit=10)
Once you get the events you can find the payment intent buried inside of the json object.
payment_intent = foo['data']['object']['payment_intent']
Once you have a payment intent you can retrieve the payment_intent object from stripe like this
charges = stripe.PaymentIntent.retrieve(payment_intent)['charges']['data'][0]
which will yield a charges object that has all the billing data in it.
Now to the get the product that was ordered from that payment intent. This can be found in the event object at
item = events['data'][<insert or loop over this list element>]['data']['object']['display_items'][0]['sku']['attributes']['name']
And doing this you can get the shipping and item that was sold.

stripe API - possible to combine multiple invoices into one payment?

i have a use case where its possible for a user to accumulate multiple unpaid invoices with a stripe subscription (which would be marked as overdue). The only way i see to pay the invoices via the API would be to pay each one as a separate manual invoice payment (thus producing X lines items on a users credit card).
Is there any way to combine all unpaid invoices into one payment ?
It's not something that the Stripe API supports. The best solution would be to create a one-time charge for the total amount of all the invoices and then mark each invoice as forgiven.
You could also create multiple invoice items, one for each invoice with a clear description and amount and then invoice the list so that your customer knows what he's paying for.
From the Stripe docs, it suggests that you can batch multiple transactions together but only if the customer has a payment method saved (and it still may require some custom programming to get it working the way you want):
https://support.stripe.com/questions/batch-multiple-transactions-from-one-customer-into-a-single-charge
Stripe docs also offers this option as well, on combining multiple products into one subscription:
https://stripe.com/docs/billing/subscriptions/multiple
Yes, You can combine multiple invoices using pass stripe customer id in to
/Stripe/Invoices::retrieve({customer_id});
You can get all the invoice of the customer, you can also search date wise invoices using a function.

Resources