#yadulla malik shaik
1 messages ยท Page 1 of 1 (latest)
When the interval comes (it's called "billing cycle") we will generate Invoices from the Subscription and also send webhook events to you
im using the webhook here, these are the events, how to know invoice is paid or not, will we get message from these switch cases.
You will get invoice.paid
I would recommend using Billing Clock to test your Subscription
in test clock i need to create a customer, but i don't want to create a customer from there, i need to test about who did a payment already.
It's just for testing, why can't you have a customer ๐
if i create a customer, how could i make a subscription payment from my app
You can simply give the customer some payment method, and then create a Subscription from them, all in backend
can u elaborate, i didn't understand
Sorry, on your backend you can create a Customer, create a PaymentMethod using test card and attach the PaymentMethod to the customer as well as set it as their default payment method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Then you can create a Subscription on that Customer. It will automatically takes the customer payment method to charge on-file
can u provide an example, on how to create a customer and assign a payment subscription mode to that customer and use test clock for that payment.
Purely illustrative but here is an example in Ruby
prod =Stripe::Product.create({
name: "Product1"
})
price = Stripe::Price.create({
unit_amount: 3000,
currency: 'usd',
recurring: {interval: 'month'},
product: prod.id,
})
clock = Stripe::TestHelpers::TestClock.create(
frozen_time: 1635750000, # 7:00 Nov 1st 2021
name: 'Annual renewal',
)
cus = Stripe::Customer.create(
email: 'jenny.rosen@example.com',
test_clock: clock.id,
payment_method: 'pm_card_visa',
invoice_settings: {default_payment_method: 'pm_card_visa'},
)
sub = Stripe::Subscription.create({
customer: cus.id,
items: [{price: price.id}],
})
p sub.id
# Advance by 1 month
Stripe::TestHelpers::TestClock.advance(
clock.id,
{frozen_time: 1638352800}, # Dec 1st 2021
)
I'm trying to create a subscription through dashboard for test clock use, but I'm getting this error, but while adding a customer, don't have any option to add the payment method.
Use API would be easier, like I did above.
cus = Stripe::Customer.create(
email: 'jenny.rosen@example.com',
test_clock: clock.id,
payment_method: 'pm_card_visa',
invoice_settings: {default_payment_method: 'pm_card_visa'},
)
# This part
Here you specify both payment_method and invoice_settings.default_payment_method to pm_card_visa
how to know test_clock id and frozen_time
After you create it you can print the clock object
it should have the frozen time too