Checkout Purchase Fulfillment Beta

    Learn how to fulfill purchases with Checkout.

    When your customer successfully completes their payment using Checkout, Stripe redirects them to the destination that you specified in the successUrl parameter. Typically, it’s a page on your website that informs your customer that their payment was successful.

    You should not rely on the redirect to the successUrl page for fulfilling purchases. Customers may not always visit the successUrl page when they make a successful payment—it’s possible to close the browser tab before the redirect occurs.

    Fulfilling purchases with the Dashboard

    When the user successfully completes payment, it is recorded as a new entry in the Dashboard’s list of payments. When you click an entry in the list, it takes you to the payment detail page. In the Checkout summary section, you can find the customer’s billing information and the list of items that they purchased. You can use this information to manually fulfill the customer’s purchase.

    Manual fulfillment is typically only practical for digital goods that you can send to the customer via e-mail. If you intend to fulfill purchases that include physical goods, your application should collect shipping details.

    Fulfilling purchases with webhooks

    Stripe can send webhook events to your server to notify you when a customer completes their payment. You can create a handler for the event and use it to execute any code that you need to fulfill the customer’s purchase. To handle a webhook event, create an HTTP endpoint on your server and configure the webhook endpoint in the Dashboard.

    Stripe sends the checkout_beta.session_succeeded event when a Checkout payment is successful. The webhook payload includes an array of SKUs or plans purchased by the customer, the ID of the PaymentIntent created by Checkout, and optionally a clientReferenceId if it was provided in the redirectToCheckout call. The clientReferenceID is used to associate the successful payment with an purchase. The following example demonstrates how to create a webhook event handler that prints the SKU for each item purchased:

    require "json"
    require "sinatra"
    
    post '/' do
      event = JSON.parse(request.body.read)
    
      if event['type'] == 'checkout_beta.session_succeeded'
        for item in event['data']['object']['display_items']
          client_reference_id = event['data']['object']['client_reference_id']
    
          # Fulfill the purchase using the client_reference_id...
        end
      end
    
      status 200
    end
    

    This following table documents the keys and values present in the checkout_beta.session_succeeded webhook:

    optionalstring
    The ID of the created subscription if a plan was used.
    The ID of the confirmed PaymentIntent used for the customer's payment.
    display_items
    Array
    An array of objects representing the items that your customer purchased.
    sku, plan
    string
    The ID of the SKU that the customer purchased, or the ID of the plan that the customer subscribed to.
    quantity
    integer
    The quantity of units for the item.
    currency
    string
    The three-letter currency code used for the customer's payment.
    amount
    integer
    The amount used at time of payment for the SKU or plan.
    type
    string
    These are set to the values "sku" or "plan" which are based on the presence of the sku or plan keys.
    success_url
    string
    The URL Stripe redirected your customer to after they completed the payment.
    cancel_url
    string
    The URL Stripe redirected your customer when payment was canceled.
    client_reference_id
    string
    A unique string to reference the Checkout session. This can be a customer ID, a cart ID, or similar. This can be used to fulfill the purchase.
    livemode
    boolean
    A boolean representing whether the live mode or test mode key was used.

    You can obtain the customer’s e-mail address and billing information by retrieving the payment_intent property of the webhook payload and inspecting the PaymentIntent’s source.owner property.

    Questions?

    We're always happy to help with code or other questions you might have! Search our documentation, contact support, or connect with our sales team. You can also chat live with other developers in #stripe on freenode.

    Was this page helpful? Yes No

    Send

    Thank you for helping improve Stripe's documentation. If you need help or have any questions, please consider contacting support.