Using Checkout with Connect

    Checkout supports creating Connect direct or destination charges, so you do not need to create these charges yourself via the API. Instead, create a Checkout Session with the desired behavior.

    Direct charges

    The integration to create a direct charge on a connected account looks the same as a normal Checkout server integration, except that you specify the Stripe account when creating the Checkout Session on the server and in JavaScript on the client. You may optionally define an application fee via payment_intent_data.application_fee_amount. The resulting Checkout experience is branded using the configuration on the connected account.

    get '/purchase' do
      session = Stripe::Checkout::Session.create({
        success_url: "https://www.example.com/success",
        cancel_url: "https://www.example.com/cancel",
        payment_method_types: ["card"],
        line_items: [{
          amount: 800,
          quantity: 10,
          name: "Cucumber",
          currency: "usd",
        }],
        payment_intent_data: {application_fee_amount: 200},
      }, {stripe_account: "{{CONNECTED_STRIPE_ACCOUNT_ID}}"})
    
      @session_id = session.id
      erb :purchase
    end
    
    var stripe = Stripe('pk_test_TYooMQauvdEDq54NiTphI7jx', {
      // This should match the stripe_account value when creating the session
      stripeAccount: '{{CONNECTED_STRIPE_ACCOUNT_ID}}',
    });
    
    // In a button handler/form submit:
    stripe.redirectToCheckout({
      // Using the session ID we created on the server, Stripe Checkout will open
      // a page to purchase the items or plans specified during session creation.
      sessionId: '{{CHECKOUT_SESSION_ID}}'
    })
    .then(function (result) {
        if (result.error) {
          // If `redirectToCheckout` fails due to a browser or network
          // error, display the localized error message to your customer.
          var displayError = document.getElementById('error-message');
          displayError.textContent = result.error.message;
        }
      });
    });
    

    Destination charges

    The integration to create a destination charge on a connected account looks the same as a normal Checkout server integration except that you specify a transfer destination or payment_intent_data.on_behalf_of. You may optionally define an application fee via payment_intent_data.application_fee_amount. The resulting Checkout experience uses your (the platform’s) branding configuration. If payment_intent_data.on_behalf_of is used, the branding configuration of the connected account is used instead.

    With destination

    get '/purchase' do
      session = Stripe::Checkout::Session.create({
        success_url: "https://www.example.com/success",
        cancel_url: "https://www.example.com/cancel",
        payment_method_types: ["card"],
        line_items: [{
          amount: 800,
          quantity: 10,
          name: "Cucumber",
          currency: "usd",
        }],
        payment_intent_data: {
          application_fee_amount: 200,
          transfer_data: {
            destination: "{{CONNECTED_STRIPE_ACCOUNT_ID}}",
          },
        },
      })
    
      @session_id = session.id
      erb :purchase
    end
    

    With on_behalf_of

    get '/purchase' do
      session = Stripe::Checkout::Session.create({
        success_url: "https://www.example.com/success",
        cancel_url: "https://www.example.com/cancel",
        payment_method_types: ["card"],
        line_items: [{
          amount: 800,
          quantity: 10,
          name: "Cucumber",
          currency: "usd",
        }],
        payment_intent_data: {
          application_fee_amount: 200,
          on_behalf_of: "{{CONNECTED_STRIPE_ACCOUNT_ID}}",
        },
      })
    
      @session_id = session.id
      erb :purchase
    end
    

    Stripe.js code

    var stripe = Stripe('pk_test_TYooMQauvdEDq54NiTphI7jx');
    
    // In a button handler/form submit:
    stripe.redirectToCheckout({
      // Using the session ID we created on the server, Stripe Checkout will open
      // a page to purchase the items or plans specified during session creation.
      sessionId: '{{CHECKOUT_SESSION_ID}}'
    })
    .then(function (result) {
        if (result.error) {
          // If `redirectToCheckout` fails due to a browser or network
          // error, display the localized error message to your customer.
          var displayError = document.getElementById('error-message');
          displayError.textContent = result.error.message;
        }
      });
    });
    

    Branding

    Platforms and Standard Connect accounts control their own branding via the Branding settings in the Dashboard. Platforms may configure the branding settings for Express and Custom accounts via the Accounts API.

    Stripe::Account.update(
      "{{CONNECTED_STRIPE_ACCOUNT_ID}}",
      {
        settings: {
          branding: {
            # used in conjunction with business name in Checkout header
            icon: "file_123",
            # if supplied, used instead of icon + business name in header
            logo: "file_456",
            # used as the accent color in Checkout
            primary_color: "#123456",
          },
        },
      }
    )
    

    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.

    On this page