Env
- Golang
- Stripe
How subscriptions work
With Subscriptions customers make recurring payments for access to a product. Subscriptions require you to retain more information about your customers than one-time purchases do because you need to charge customers in the future.
Use the following core API resources to build and manage subscriptions:
Subscription objects Use the following core API resources to build and manage subscriptions:
RESOURCE | DEFINITION |
---|---|
Product | What your business offers – whether that’s goods or services. |
Price | How much and how often to charge for products, including how much the product costs, what currency to use, and the interval if the price is for subscriptions. |
Customer | Stripe Customer objects allow you to perform recurring charges for the same customer, and to track multiple charges. If you create subscriptions, the customer ID is passed to the subscription object. |
PaymentMethod | Your customer’s payment instruments – how they pay for your service. For example, you may store a credit card on the customer object for recurring use. Typically used with the Payment Intents or Setup Intents APIs. |
Subscription | The product details associated with the plan that your customer subscribes to, which allow you to charge the customer on a recurring basis. |
Invoice | A statement of amounts owed by a customer. They track the status of payments from draft through paid or otherwise finalised. Subscriptions automatically generate invoices. You can also manually create one-off invoices. |
PaymentIntent | A way to build dynamic payment flows. A Payment Intent tracks the lifecycle of a customer checkout flow and triggers additional authentication steps when required by regulatory mandates, custom Radar fraud rules, or redirect-based payment methods. Invoices create payment intents automatically. |
Products
Products describe the specific goods or services you offer to your customers. For example, you might offer a Standard and Premium version of your goods or service; each version would be a separate Product. They can be used in conjunction with Prices to configure pricing in Payment Links, Checkout, and Subscriptions.
ENDPOINTS
Object | Method | Endpoint | URL |
---|---|---|---|
Product | POST |
/v1/products |
https://stripe.com/docs/api/products#create_product |
Product | GET |
/v1/products/:id |
https://stripe.com/docs/api/products#retrieve_product |
Product | POST |
/v1/products/:id |
https://stripe.com/docs/api/products#update_product |
Product | GET |
/v1/products |
https://stripe.com/docs/api/products#list_products |
Product | DELETE |
/v1/products/:id |
https://stripe.com/docs/api/products#delete_product |
Product | GET |
/v1/products/search |
https://stripe.com/docs/api/products#search_products |
Prices
Prices define the unit cost, currency, and (optional) billing cycle for both recurring and one-time purchases of products. Products help you track inventory or provisioning, and prices help you track payment terms. Different physical goods or levels of service should be represented by products, and pricing options should be represented by prices. This approach lets you change prices without having to change your provisioning scheme.
For example, you might have a single “gold” product that has prices for $10/month, $100/year, and €9 once.
ENDPOINTS
Object | Method | Endpoint | URL |
---|---|---|---|
Price | POST |
/v1/prices |
https://stripe.com/docs/api/prices#create_price |
Price | GET |
/v1/prices/:id |
https://stripe.com/docs/api/prices#retrieve_price |
Price | POST |
/v1/prices/:id |
https://stripe.com/docs/api/prices#update_price |
Price | GET |
/v1/prices |
https://stripe.com/docs/api/prices#list_prices |
Price | GET |
/v1/prices/search |
https://stripe.com/docs/api/prices#search_prices |
PaymentMethods
PaymentMethod objects represent your customer’s payment instruments. You can use them with PaymentIntents to collect payments or save them to Customer objects to store instrument details for future payments.
ENDPOINTS
Object | Method | Endpoint | URL |
---|---|---|---|
PaymentMethod | POST |
/v1/payment_methods |
https://stripe.com/docs/api/payment_methods#create_payment_method |
PaymentMethod | GET |
/v1/payment_methods/:id |
https://stripe.com/docs/api/payment_methods#retrieve_payment_method |
PaymentMethod | GET |
/v1/customers/:customer/payment_methods/:payment_method |
https://stripe.com/docs/api/payment_methods#retrieve_customer_payment_method |
PaymentMethod | POST |
/v1/payment_methods/:id |
https://stripe.com/docs/api/payment_methods#update_payment_method |
PaymentMethod | GET |
/v1/payment_methods |
https://stripe.com/docs/api/payment_methods#list_payment_methods |
PaymentMethod | GET |
/v1/customers/:customer/payment_methods |
https://stripe.com/docs/api/payment_methods#list_customer_payment_methods |
PaymentMethod | POST |
/v1/payment_methods/:id/attach |
https://stripe.com/docs/api/payment_methods#customer_attach_payment_method |
PaymentMethod | POST |
/v1/payment_methods/:id/detach |
https://stripe.com/docs/api/payment_methods#customer_detach_payment_method |
Subscriptions
Subscriptions allow you to charge a customer on a recurring basis.
ENDPOINTS
Object | Method | Endpoint | URL |
---|---|---|---|
Subscription | POST |
/v1/subscriptions |
https://stripe.com/docs/api/subscriptions#create_subscription |
Subscription | GET |
/v1/subscriptions/:id |
https://stripe.com/docs/api/subscriptions#retrieve_subscription |
Subscription | POST |
/v1/subscriptions/:id |
https://stripe.com/docs/api/subscriptions#update_subscription |
Subscription | DELETE |
/v1/subscriptions/:id |
https://stripe.com/docs/api/subscriptions#cancel_subscription |
Subscription | GET |
/v1/subscriptions/search |
https://stripe.com/docs/api/subscriptions#subscriptions_search |