Create a payment link

Creates a new payment link object.
Parameters
  • line_items

    required conditionallyarray of hashes
    • The line items to be purchased by the customer. Not required when the checkout session is insetupmode. Or ifprice_datais present.
      Show child attributes
    • mode

      required conditionallyenum
      • Themodeof the Checkout Session. If not specified, it will be inferred from the recurring field values of the prices passed. However, it is required when usingsetupmode. Optionally, you can passsubscriptionif the Checkout Session includes at least one recurring item.
      Possible enum values
      • payment
        • Accept one-time payments for cards,iDEAL, and more.
      • setup
        • Save payment details to charge your customers later. Premium subscription required.
      • subscription
        • Use Stripe Billing to set up fixed-price subscriptions.
    • price_data

      required conditionallyarray of hashes
      • Data used to generate newflexPrice objects inline. AflexPrice is associated to aflexProduct which we will create within your connected account. This Product is used to capture free form charge amounts.
        Show child attributes
      • discounts

        array of hashesoptional
        • The coupon or promotion code to apply to this Payment Link. Currently, only up to one may be specified.
          Show child attributes
        • success_url

          stringoptional
          • The URL the customer will be directed to when payment or setup is complete. This url will automatically have the Checkoutsession_idappended to it. By default, this URL will be the standard PriceBlocs checkout complete success page. This value cannot be set dynamically via query string param.Learn more about default redirect urlshere.
        • cancel_url

          stringoptional
          • The URL the customer will be directed to if they decide to cancel the active Checkout Session. By default this will be the account profile url of the connected Stripe account, otherwise it will be the stanard PriceBlocs checkout error page. Can be set dynamically via query string param.Learn more about default redirect urlshere.
        • customer

          stringoptional
          • ID of an existing Customer within your connected Stripe account, if one exists. If the Customer specified does not exist, an error will be thrown. Inpaymentmode, the customer’s most recent card payment method will be used to prefill the email, name, card details, and billing address on the Checkout page. Insubscriptionmode, the customer’s default payment method will be used if it’s a card, and otherwise the most recent card will be used. A valid billing address is required for Checkout to prefill the customer’s card details.
          • If the customer changes their email on the Checkout page, the Customer object will be updated with the new email.
          • If blank for Checkout Sessions in payment or subscription mode, Checkout will create a new Customer object based on information provided during the payment flow.
        • customer_email

          string (alias email)optional
          • If provided, this value will be used to search existing Customer's in your Stripe account to find a match. If found, the Payment Link response will have its email and customer field filled with the matched Customer's details. Any Checkout session initialized from such a Payment Link, will then be created in the context of that matched Customer.
          • If a Customer match is not found for the email passed, only the email field will be set. Any Checkout session initialized from an email only Payment Link will then only have its email field prefilled, unless a Customer with such an email has been created since the time of link creation.
        • metadata

          hashoptional
          • Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Metadata keys have a 40 character limit and their values have a 500 character limit. Metadata values will be copied into either thesubscription_dataorpayment_intent_datadepending on the context of the Checkout session.
        More parameters
        Expand all
        • payment_method_types

          array of stringsoptional
        • allow_promotion_codes

          booleanoptional
        • tax_rates

          array of stringsoptional
        • dynamic_tax_rates

          array of stringsoptional
        • automatic_tax

          hashoptional
        • tax_id_collection

          hashoptional
        • client_reference_id

          stringoptional
        • title

          stringoptional
        • description

          stringoptional
        • billing_address_collection

          enumoptional
        • shipping_worldwide

          booleanoptional
        • shipping_address_collection

          hashoptional
        • shipping_options

          array of hashesoptional
        • after_expiration

          hashoptional
        • submit_type

          enumoptional
        • payment_intent_data

          hashoptional
        • trial_period_days

          numberoptional
        • trial_end

          timestampoptional
        Returns
        • Returns a payment link object if the call succeeded.
        Have any questions or feedback?
        POST
        /v1/payment-links
        1
        curl https://api.priceblocs.com/v1/payment-links \
        2
        -H "Authorization: Bearer {{API_KEY_SECRET_TEST}}" \
        3
        -H 'Content-Type: application/json' \
        4
        --data-raw '{"line_items":[{"price":"{{PRICE_ID}}"}]}'
        Response
        1
        {
        2
        "url": "https://priceblocs.com/test/links/short_id",
        3
        "brand_url": "https://priceblocs.com/test/links/short_id",
        4
        "livemode": false,
        5
        "id": "00000000-0000-0000-0000-000000000000",
        6
        "object": "payment_link",
        7
        "short_id": "short_id",
        8
        "title": "My first payment link",
        9
        "description": "Each link will start a new checkout session when clicked",
        10
        "success_url": "https://priceblocs.com/checkout/success",
        11
        "cancel_url": "https://priceblocs.com/checkout/error",
        12
        "created": 1628234366,
        13
        "updated": 1628234366,
        14
        "payment_method_types": [
        15
        "card"
        16
        ],
        17
        "currency": "usd",
        18
        "customer_email": "someone@gmail.com",
        19
        "customer": null,
        20
        "status": "active",
        21
        "discounts": [
        22
        {
        23
        "coupon": "coupon123"
        24
        }
        25
        ],
        26
        "billing_address_collection": "auto",
        27
        "shipping_address_collection": {
        28
        "allowed_countries": [
        29
        "US"
        30
        ]
        31
        },
        32
        "mode": "subscription",
        33
        "submit_type": "pay",
        34
        "allow_promotion_codes": false,
        35
        "adjustable_quantity": {
        36
        "enabled": true,
        37
        "maximum": 99,
        38
        "minimum": 1
        39
        },
        40
        "shipping_worldwide": false,
        41
        "tax_rates": [
        42
        "txr_123"
        43
        ],
        44
        "dynamic_tax_rates": [
        45
        "txr_456"
        46
        ],
        47
        "automatic_tax": {
        48
        "enabled": true
        49
        },
        50
        "tax_id_collection": {
        51
        "enabled": false,
        52
        "type": "standard"
        53
        },
        54
        "consent_collection": {
        55
        "promotions": "auto"
        56
        },
        57
        "after_expiration": {
        58
        "recovery": {
        59
        "enabled": true,
        60
        "allow_promotion_codes": true
        61
        }
        62
        },
        63
        "expires_at": 1628234366,
        64
        "shipping_options": [
        65
        {
        66
        "shipping_rate": "shr_456"
        67
        }
        68
        ],
        69
        "payment_intent_data": {
        70
        "capture_method": "automatic",
        71
        "transfer_data": {
        72
        "destination": "act_123"
        73
        }
        74
        },
        75
        "trial_period_days": null,
        76
        "trial_end": null,
        77
        "line_items": [
        78
        {
        79
        "price": "p_A_1",
        80
        "product": "p_A",
        81
        "currency": "usd",
        82
        "interval": "month",
        83
        "quantity": 1,
        84
        "dynamic_tax_rates": null,
        85
        "tax_rates": null
        86
        }
        87
        ]
        88
        }
        Show docs menu

        Create a payment link

        Creates a new payment link object.
        Parameters
        • line_items

          required conditionallyarray of hashes
          • The line items to be purchased by the customer. Not required when the checkout session is insetupmode. Or ifprice_datais present.
            Show child attributes
          • mode

            required conditionallyenum
            • Themodeof the Checkout Session. If not specified, it will be inferred from the recurring field values of the prices passed. However, it is required when usingsetupmode. Optionally, you can passsubscriptionif the Checkout Session includes at least one recurring item.
            Possible enum values
            • payment
              • Accept one-time payments for cards,iDEAL, and more.
            • setup
              • Save payment details to charge your customers later. Premium subscription required.
            • subscription
              • Use Stripe Billing to set up fixed-price subscriptions.
          • price_data

            required conditionallyarray of hashes
            • Data used to generate newflexPrice objects inline. AflexPrice is associated to aflexProduct which we will create within your connected account. This Product is used to capture free form charge amounts.
              Show child attributes
            • discounts

              array of hashesoptional
              • The coupon or promotion code to apply to this Payment Link. Currently, only up to one may be specified.
                Show child attributes
              • success_url

                stringoptional
                • The URL the customer will be directed to when payment or setup is complete. This url will automatically have the Checkoutsession_idappended to it. By default, this URL will be the standard PriceBlocs checkout complete success page. This value cannot be set dynamically via query string param.Learn more about default redirect urlshere.
              • cancel_url

                stringoptional
                • The URL the customer will be directed to if they decide to cancel the active Checkout Session. By default this will be the account profile url of the connected Stripe account, otherwise it will be the stanard PriceBlocs checkout error page. Can be set dynamically via query string param.Learn more about default redirect urlshere.
              • customer

                stringoptional
                • ID of an existing Customer within your connected Stripe account, if one exists. If the Customer specified does not exist, an error will be thrown. Inpaymentmode, the customer’s most recent card payment method will be used to prefill the email, name, card details, and billing address on the Checkout page. Insubscriptionmode, the customer’s default payment method will be used if it’s a card, and otherwise the most recent card will be used. A valid billing address is required for Checkout to prefill the customer’s card details.
                • If the customer changes their email on the Checkout page, the Customer object will be updated with the new email.
                • If blank for Checkout Sessions in payment or subscription mode, Checkout will create a new Customer object based on information provided during the payment flow.
              • customer_email

                string (alias email)optional
                • If provided, this value will be used to search existing Customer's in your Stripe account to find a match. If found, the Payment Link response will have its email and customer field filled with the matched Customer's details. Any Checkout session initialized from such a Payment Link, will then be created in the context of that matched Customer.
                • If a Customer match is not found for the email passed, only the email field will be set. Any Checkout session initialized from an email only Payment Link will then only have its email field prefilled, unless a Customer with such an email has been created since the time of link creation.
              • metadata

                hashoptional
                • Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Metadata keys have a 40 character limit and their values have a 500 character limit. Metadata values will be copied into either thesubscription_dataorpayment_intent_datadepending on the context of the Checkout session.
              More parameters
              Expand all
              • payment_method_types

                array of stringsoptional
              • allow_promotion_codes

                booleanoptional
              • tax_rates

                array of stringsoptional
              • dynamic_tax_rates

                array of stringsoptional
              • automatic_tax

                hashoptional
              • tax_id_collection

                hashoptional
              • client_reference_id

                stringoptional
              • title

                stringoptional
              • description

                stringoptional
              • billing_address_collection

                enumoptional
              • shipping_worldwide

                booleanoptional
              • shipping_address_collection

                hashoptional
              • shipping_options

                array of hashesoptional
              • after_expiration

                hashoptional
              • submit_type

                enumoptional
              • payment_intent_data

                hashoptional
              • trial_period_days

                numberoptional
              • trial_end

                timestampoptional
              Returns
              • Returns a payment link object if the call succeeded.
              Have any questions or feedback?
              POST
              /v1/payment-links
              1
              curl https://api.priceblocs.com/v1/payment-links \
              2
              -H "Authorization: Bearer {{API_KEY_SECRET_TEST}}" \
              3
              -H 'Content-Type: application/json' \
              4
              --data-raw '{"line_items":[{"price":"{{PRICE_ID}}"}]}'
              Response
              1
              {
              2
              "url": "https://priceblocs.com/test/links/short_id",
              3
              "brand_url": "https://priceblocs.com/test/links/short_id",
              4
              "livemode": false,
              5
              "id": "00000000-0000-0000-0000-000000000000",
              6
              "object": "payment_link",
              7
              "short_id": "short_id",
              8
              "title": "My first payment link",
              9
              "description": "Each link will start a new checkout session when clicked",
              10
              "success_url": "https://priceblocs.com/checkout/success",
              11
              "cancel_url": "https://priceblocs.com/checkout/error",
              12
              "created": 1628234366,
              13
              "updated": 1628234366,
              14
              "payment_method_types": [
              15
              "card"
              16
              ],
              17
              "currency": "usd",
              18
              "customer_email": "someone@gmail.com",
              19
              "customer": null,
              20
              "status": "active",
              21
              "discounts": [
              22
              {
              23
              "coupon": "coupon123"
              24
              }
              25
              ],
              26
              "billing_address_collection": "auto",
              27
              "shipping_address_collection": {
              28
              "allowed_countries": [
              29
              "US"
              30
              ]
              31
              },
              32
              "mode": "subscription",
              33
              "submit_type": "pay",
              34
              "allow_promotion_codes": false,
              35
              "adjustable_quantity": {
              36
              "enabled": true,
              37
              "maximum": 99,
              38
              "minimum": 1
              39
              },
              40
              "shipping_worldwide": false,
              41
              "tax_rates": [
              42
              "txr_123"
              43
              ],
              44
              "dynamic_tax_rates": [
              45
              "txr_456"
              46
              ],
              47
              "automatic_tax": {
              48
              "enabled": true
              49
              },
              50
              "tax_id_collection": {
              51
              "enabled": false,
              52
              "type": "standard"
              53
              },
              54
              "consent_collection": {
              55
              "promotions": "auto"
              56
              },
              57
              "after_expiration": {
              58
              "recovery": {
              59
              "enabled": true,
              60
              "allow_promotion_codes": true
              61
              }
              62
              },
              63
              "expires_at": 1628234366,
              64
              "shipping_options": [
              65
              {
              66
              "shipping_rate": "shr_456"
              67
              }
              68
              ],
              69
              "payment_intent_data": {
              70
              "capture_method": "automatic",
              71
              "transfer_data": {
              72
              "destination": "act_123"
              73
              }
              74
              },
              75
              "trial_period_days": null,
              76
              "trial_end": null,
              77
              "line_items": [
              78
              {
              79
              "price": "p_A_1",
              80
              "product": "p_A",
              81
              "currency": "usd",
              82
              "interval": "month",
              83
              "quantity": 1,
              84
              "dynamic_tax_rates": null,
              85
              "tax_rates": null
              86
              }
              87
              ]
              88
              }