Job Runner

Create Checkout Session of Stripe

Summary

Create Checkout Session of Stripe.

The checkout session is similar to a payment link, but the checkout session is valid only once. Once the payment is made from that session, the URL will automatically become invalid. The session will automatically become invalid if the payment is not made within 24 hours.

How to Use

You need to issue the Stripe API key in advance. Stripe initially provides a standard key, but you should issue a restricted key instead of using the standard one. For details of the procedure, Stripe’s website . This is a setting on the Stripe screen, not Customine.

There is no need to register product data in advance on Stripe. Customine’s “Create Checkout Session of Stripe” automatically registers products on Stripe. Conversely, to link products that are already registered with Stripe to Kintone records, add metadata to the Stripe product and set the product code with the key product_code.

When you execute this Do, it will register a product and price data on Stripe and create a checkout session.

If you include the product code in the Mapping to Line Item, the product data on Stripe will be updated if that product code is already registered. If not, new product data will be added on Stripe.

When this action is executed and a checkout session is created on Stripe, the combination of the checkout session ID and URL will be set as the result of the action. For example, if the action of “Create Checkout Session of Stripe” is the first action, and you want to extract the ID of the checkout session, write an expression like the following:

= $1.id

Similarly, to extract a URL, write it as follows: You can share this URL with the person who purchased the product.

= $1.url

Parameter

Set Stripe API Key, Source Records, Mapping to Line Item, Currency, and Success URL.

Stripe API Key

Specify the API key that was issued in advance.

There are three types of keys in Stripe’s API: Standard Key’s Publishable Key, Standard Key’s Secret Key, and Restricted Key, but you need to use the Restricted Key.

This API key requires the following permissions:

  • Checkout Sessions: Writing
  • Files: Writing (required only when registering product images; it is unnecessary if no images are to be registered.)
  • Prices: Writing
  • Products: Writing

Source Records

Specify a separate record for each product or service. A number of product details equal to the number of records will be created within a single checkout session.

This record must contain at least one line. An error will occur at runtime if it is empty.

Mapping to Line Item

Enter the detailed information of the statement in a mapping format.

In mapping, expressions can be used. If a field code is specified in the expression during mapping, that field will become a field of the “Source Records.”

Map to the following elements:

  • Product code
    • If you specify this, if a product with the same product code is already registered on Stripe, the product data will be overwritten and updated. If the code is not already registered, it will be registered as a new code.
    • If omitted, product data will be newly registered on Stripe each time.
    • It will not be displayed on the screen of the person who will purchase the product.
  • Product Name
    • This is the name of the product displayed on the screen of the person who will purchase the product.
    • Required field.
  • Product Description
    • This is the product description displayed on the screen of the person who will purchase the product.
    • This parameter is optional.
  • Product Image
    • This is the product image displayed on the screen of the person who will purchase the product.
    • This parameter is optional.
    • To specify it, specify the attachment field in the expression. The first image attached in that attachment field will be the product image. Attached files other than images will be ignored.
      • If you know which file in the attachment field is the product image, you can specify that number. For example, to specify the second file:
        = Attachment Field[1]
        

        In the formula, the count starts from zero, so specify 1 for the second one.

    • The product image will be overwritten when you set this parameter.
    • If omitted or if no image is attached to the specified attachment file field, no image will be set for the product. In this case, the already set image will be maintained.
    • In the customization, the API token ("Set Kintone API Token") to retrieve files from the attachment field must be set. Usually, an API token should already be used to obtain the “Source Records,” so there is no need to worry about it.
  • Unit Price
    • Specify how much to sell this product for per item in this checkout session.
    • Required field.
    • If the currency unit is in dollars, specify in cents. For example, to sell for 10 USD, specify 1000. Similarly, specify the euro in euro cents.
    • Specify the price, including tax.
  • Quantity
    • Specify how many to sell.
    • This parameter is optional. By default, it will be set to 1.
  • Maximum Quantity, Minimum Quantity
    • If specified, the person who will purchase the product will be able to change the quantity they purchase, and will be the range of selectable quantities.
    • This parameter is optional. If both maximum and minimum are omitted, the person who will purchase the product cannot change the quantity and it will be fixed at the number specified in Quantity.

Currency

Select a currency unit. You can choose yen, dollars, and euros. Other currencies are not supported.

When you specify the currency as dollars or euros, pay attention to the unit of the unit price in Mapping to Line Item.

Success URL

This screen transitions after the payment of the person who purchased the product is successful.

In general, create a screen to display a message like “Thank you for your payment” in advance and specify the URL of the screen. In the case of Create Payment Link of Stripe, Stripe has prepared this page, but for the checkout session, you need to prepare it yourself.

Restrictions

  • The range of values that can be specified, such as unit price and quantity, and the supported image formats depend on the Stripe’s specifications.
  • The rich editor field is not supported. When specifying the value of the rich editor field in the product name and product description, the HTML will be displayed as is.
  • You cannot register multiple images for a single product.
  • You cannot set the expiration date for the checkout session. The expiration is fixed to a default of Stripe of 24 hours.