Skip to content

Latest commit

 

History

History
395 lines (286 loc) · 14.9 KB

9_stripe.md

File metadata and controls

395 lines (286 loc) · 14.9 KB

Stripe Actions Library

Create stripe product

Return: Stripe product object.

name (str): The product’s name, meant to be displayable to the customer. description (str): The product’s description, meant to be displayable to the customer. Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes.

product  = stripe.create_product(name, description);

Create stripe product price

productId (str): The ID of the product that this price will belong to. amount (int): A positive integer in cents (or 0 for a free price) representing how much to charge. currency (str): Three-letter ISO currency code, in lowercase. Must be a supported currency recurring (dict) (Optional) : The recurring components of a price such as interval and usage_type. recurring.interval (REQUIRED): Specifies billing frequency. Either day, week, month or year. recurring.interval_count (Optional): The number of intervals between subscription billings. For example, interval=month and interval_count=3 bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, or 52 weeks).

See more details here.

product  = stripe.create_product_price(productId, amount, currency, recurring,  **kwargs);

Return: Stripe price object.

Retrieve stripe product list

detailed (bool) (Optional): Only return prices that are active or inactive (e.g., pass false to list all inactive prices).

products  = stripe.product_list(detailed);

Return Example:

{
  "object": "list",
  "url": "/v1/prices",
  "has_more": false,
  "data": [LIST OF PRICE OBJECT]
}

Create stripe customer

email (str) (Optional): Customer’s email address. It’s displayed alongside the customer in your dashboard and can be useful for searching and tracking. This may be up to 512 characters. name (str) (Optional): The customer’s full name or business name.

customer  = stripe.create_customer(email, name, address,  **kwargs);

Response: Stripe customer Object

Retrieve stripe customer

customer_id (str): The ID of the customer you want to retrieve.

customer  = stripe.get_customer(customer_id,  **kwargs);

Report: Returns the Customer object for a valid identifier. If it’s for a deleted Customer, a subset of the customer’s information is returned, including a deleted property that’s set to true.

Attach a payment method to a customer

payment_method_id (str): The ID of the customer payment method that will be attach. customer_id (str): The ID of the customer to which to attach the PaymentMethod.

payment_method  = stripe.attach_payment_method(payment_method_id, customer_id,  **kwargs);

Report: Returns a PaymentMethod object.

Detaches a payment method object from a Customer

After a PaymentMethod is detached, it can no longer be used for a payment or re-attached to a Customer. payment_method_id (str): The ID of the customer payment method that will be detach.

payment_method  = stripe.detach_payment_method(payment_method_id,  **kwargs);

Report: Returns a PaymentMethod object.

Retrieve a list of PaymentMethods for a given Customer

customer_id (str): The ID of the customer.

See more details here.

payment_methods  = stripe.get_payment_methods(customer_id,  **kwargs);

Report:

{
  "object": "list",
  "url": "/v1/customers/cus_NBsqL1C1GrrHYM/payment_methods",
  "has_more": false,
  "data": [LIST OF PAYMENT METHODS OBJECT]
}

Update customer default payment method

customer_id (str): The ID of the customer. payment_method_id (str): The ID of the payment method that will be use as customer default payment method.

customer  = stripe.update_default_payment_method(customer_id, payment_method_id,  **kwargs);

Report: Stripe customer object

Create invoice

customer_id (str): The ID of the customer.

invoice  = stripe.create_invoice(customer_id,  **kwargs);

Report: Stripe invoice object

Retrieve customer list of invoice

customer_id (str): The ID of the customer. subscription_id (str): Return invoices for the subscription starting_after (str) (Optional): A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include starting_after=obj_foo in order to fetch the next page of the list. limit (int) (Optional): A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.

invoices  = stripe.get_invoice_list(customer_id, subscription_id, starting_after, limit,  **kwargs);

Report:

{
  "object": "list",
  "url": "/v1/invoices",
  "has_more": false,
  "data": [LIST OF INVOICE OBJECT]
}

Retrieve customer list of payment intents

customer_id (str): The ID of the customer. starting_after (str) (Optional): A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include starting_after=obj_foo in order to fetch the next page of the list. limit (int) (Optional): A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.

payment_intents  = stripe.get_payment_intents(customer_id, starting_after, limit,  **kwargs);

Report:

{
  "object": "list",
  "url": "/v1/payment_intents",
  "has_more": false,
  "data": [LIST OF PAYMENT INTENTS OBJECT]
}

Create customer payment intents

customer_id (str): The ID of the customer. amount (int): Amount intended to be collected by this PaymentIntent. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99). currency (str): Three-letter ISO currency code, in lowercase. Must be a supported currency **recurring (dict) (Option payment_method_types (list): The list of payment method types that this PaymentIntent is allowed to use. If this is not provided, defaults to ["card"]. Valid payment method types include: acss_debit, affirm, afterpay_clearpay, alipay, au_becs_debit, bacs_debit, bancontact, blik, boleto, card, card_present, customer_balance, eps, fpx, giropay, grabpay, ideal, interac_present, klarna, konbini, link, oxxo, p24, paynow, pix, promptpay, sepa_debit, sofort, us_bank_account, and wechat_pay.

payment_intent = stripe.create_payment_intents(customer_id, amount, currency, payment_method_types);

Report: Returns a PaymentIntent object.

Retrieve customer list of subscriptions

customer_id (str): The ID of the customer whose subscriptions will be retrieved.

See more details here.

subscriptions = stripe.get_customer_subscription(customer_id);

Report:

{
  "object": "list",
  "url": "/v1/subscriptions",
  "has_more": false,
  "data": [LIST OF SUBSCRIPTION OBJECT]
}

Create payment method

card_type (str): The type of the PaymentMethod. An additional hash is included on the PaymentMethod with a name matching this value. It contains additional information specific to the PaymentMethod type. Required unless payment_method is specified (see the Cloning PaymentMethods guide).

  • Possible values - acss_debit, affirm, afterpay_clearpay, alipay, au_becs_debit, bacs_debit, bancontact, blik, boleto, card, card_present, customer_balance, eps, fpx, giropay, grabpay, ideal, interac_present, klarna, konbini, link, oxxo, p24, paynow, pix, promptpay, sepa_debit, sofort, us_bank_account, and wechat_pay. card (dict): Details of the card.

Sample card details:

{
  "number": "4242424242424242",
  "exp_month": 8,
  "exp_year": 2024,
  "cvc": "314",
},
payment_method = stripe.create_payment_method(card_type, card);

Report:

{
  "object": "list",
  "url": "/v1/subscriptions",
  "has_more": false,
  "data": [LIST OF SUBSCRIPTION OBJECT]
}

Create trial subscription

customer_id (str): The ID of the customer. items (list): A list of up to 20 subscription items, each with an attached price.

  1. items.price (str) (Optional): The ID of the price object.

items child parameter.

payment_method_id (str) (Optional): If you want to attach new payment method in the subscription trial_period_days (int): Integer representing the number of trial period days before the customer is charged for the first time. This will always overwrite any trials that might apply via a subscribed plan

subscription = stripe.create_trial_subscription(customer_id, items, payment_method_id, trial_period_days);

Report: Stripe subscription object

Create subscription

customer_id (str): The ID of the customer. items (list): A list of up to 20 subscription items, each with an attached price.

  1. items.price (str) (Optional): The ID of the price object.

items child parameter.

payment_method_id (str) (Optional): If you want to attach new payment method in the subscription

subscription = stripe.create_subscription(customer_id, items, payment_method_id);

Report:

Stripe subscription object

Cancel customer subscription

subscription_id (str): The ID of the subscription you want to cancel.

subscription = stripe.cancel_subscription(subscription_id);

Report: Stripe subscription object

Retrive customer subscription

subscription_id (str): The ID of the subscription you want to retrieve.

subscription = stripe.get_subscription(subscription_id);

Report: Stripe subscription object

Update customer subscription

subscription_id (str): The ID of the customer subscription. subscription_item_id (str): Subscription item to update. price_id (str): The ID of the price object.

See more details here.

subscription = stripe.update_subscription_item(subscription_id, subscription_item_id, price_id);

Report: The newly updated Subscription object

Retrieve invoice details

invoice_id (str): The ID of the customer subscription.

See more details here.

invoice = stripe.get_invoice(invoice_id);

Report: Returns an invoice object if a valid invoice ID was provided

Create usage report

Creates a usage record for a specified subscription item and date, and fills it with a quantity.

subscription_item_id (str): Subscription item quantity (int): The usage quantity for the specified timestamp.

See more details here.

record = stripe.create_usage_report(subscription_item_id, quantity);

Report: Returns usage record object

Create checkout session

success_url (str): The URL to which Stripe should send customers when payment or setup is complete. If you’d like to use information from the successful Checkout Session on your page, read the guide on customizing your success page. cancel_url (int) (Optional): If set, Checkout displays a back button and customers will be directed to this URL if they decide to cancel payment and return to your website. line_items (list) (Optional): A list of items the customer is purchasing. Use this parameter to pass one-time or recurring `Prices.

For payment mode, there is a maximum of 100 line items, however it is recommended to consolidate line items if there are more than a few dozen.

For subscription mode, there is a maximum of 20 line items with recurring Prices and 20 line items with one-time Prices. Line items with one-time Prices will be on the initial invoice only.

mode (str): The mode of the Checkout Session. Pass subscription if the Checkout Session includes at least one recurring item.

  1. Possible enum values
  • payment: Accept one-time payments for cards, iDEAL, and more.
  • setup: Save payment details to charge your customers later.
  • subscription: Use Stripe Billing to set up fixed-price subscriptions.

See more details about line_items.

checkout_session = stripe.create_checkout_session(success_url, cancel_url, line_items, mode);

Report: Returns session object