Quick Start
Bread integrations require both a frontend and backend component. However, if you would like to quickly start with creating Bread buttons on your frontend take the following steps:
- Load the Bread script on your page and set the API Key that has been provided by your Bread Success representative
- Add the HTML element where you want Bread to load
- Configure an
opts
object - Create a Bread button by passing the
opts
object into thebread.checkout
function viabread.checkout(opts)
If you are creating a Bread button on a page other than your checkout page make sure to set
allowCheckout
to false in youropts
object
Quick Start Sample Code
The below code is the minimum amount needed to render a Bread button on the frontend of your site. For more information on Bread buttons and the backend portion of a Bread integration please see the Bread Checkout page.
<!--
STEP 1: Load the Bread script on your page and set your API Key
NOTE: this is loading the Bread sandbox script
-->
<script
src="https://checkout-sandbox.getbread.com/bread.js"
data-api-key="YOUR-API-KEY"
></script>
<!-- STEP 2: Add an HTML element where you want Bread to load -->
<div id="bread-checkout-btn"></div>
<script>
/*
STEP 3: Configure opts object
*/
const opts = {
buttonId: "bread-checkout-btn", // match HTML element ID
allowCheckout: true, // set to false on non-checkout pages
customTotal: 1000, // amount in cents
done: function (err, tx_token) {
// callback function runs after Bread checkout complete
// function is required even if allowCheckout = false
}
};
/*
STEP 4: Create Bread button
*/
bread.checkout(opts);
</script>
Updated over 1 year ago