onCheckout callback

The onCheckout callback function is called once the checkout form is submitted. This happens in the very first step of the checkout flow. This callback takes two arguments, info, and actions.

info argument

info is an Object with the values collected in the checkout form. Depending on which fields you chose, it could look like this:

{
  firstName: 'John',
  lastName: 'Doe',
  email: 'john@bidali.com'
}

You could use these values and pass them as the charge's metadata.

actions argument

The actions argument enables you to do two things: create a charge, and close the checkout dialog. It's pretty easy to create a charge:

actions.createCharge({
  amount: 100,      // This is the amount in fiat.
  currency: 'cad',  // The fiat currency you'll be dealing in. Either CAD or USD.
  metadata: {}      // The charge's metadata.
});

The createCharge method returns a Promise that you can await on:

bidali.Checkout.render({
  // ...other required properties
  onCheckout: async (info, actions) => {
    const charge = await actions.createCharge({
      amount: 100,
      currency: 'cad',
      metadata: info
    });

    // Do something with `charge`, if you need to
  }
});

You can review the other required properties in the main Checkout section

To dismiss the Checkout dialog you can just invoke:

actions.close();

results matching ""

    No results matching ""