Checkout parameter examples
Last updated
Last updated
Below are scenario examples with using defaultSpendingCap,
minimumBalanceRequired,
and cartEnabled
across various permutations and how the checkout page and widget will handle the parameters.
A few things to note:
Slippage. Since the value of a token (even a stablecoin) can move, Loop adds a "buffer" to ensure a customer has enough allowance to make a payment. All calculations below need to be adjusted to allow for this slippage (i.e. it is not accounted for in the examples). Loop uses a buffer of 0.5% (i.e. amount 1.005).
Hiding the cart: When the cart is hidden (i.e., cartEnabled=false
), the minimum balance is set by whichever amount is GREATEST, between (1) the checkout amount, or (2) the minimumBalanceReqiured
parameter (if set). To ensure the allowance and balance are set at your desired level, it is recommended that you also pass allowance and balance values when hiding the cart.
Suggested allowance: This is an allowance amount that the checkout prompts the user's wallet to set. The suggested allowance is set by taking the highest of the 3 values below:
Scheduled amount - pulls from the prices of the items in the cart that are to be paid for.
Minimum balance - this is derived based on the criteria described above.
defaultSpendingCap
parameter - this is an optional parameter that can be passed to the checkout in order to set a custom allowance amount.
Minimum allowance: At present, the minimum allowance will always match the minimum balance. This is logical as the smart contract needs permission to pull at least the amount of funds you are requiring to be in the wallet.
You can create an item in Loop that is price varies when you have a product with variable rate pricing. For example, you may charge based on monthly API calls, so the amount billed to the customer changes each month depending on their usage. Creating a price varies item allows you to collect a wallet authorization without needing to show an amount in the checkout cart.
The checkout is configured to have the following items in the cart:
defaultSpendingCap
or minimumBalanceRequired
NOT setAmount
$8000
$800
$800
Calculation
$0 + (13 * $600) + $200
$0 + $600 + $200
$0 + $600 + $200
Logic
Calculated based on items in the cart
“price varies” item assumes $0 value
subscription item is 13x the item amount
one time item is 1x the item amount
The total for a single payment based on the combined total of the items in the cart
The total for a single payment based on the combined total of the items in the cart
defaultSpendingCap
set to $2000 and minimumBalanceRequired
NOT setAmount
$2000
$800
$800
Calculation
None
$0 + $600 + $200
$0 + $600 + $200
Logic
Taken directly from the defaultSpendingCap
query string parameter
The total for a single payment based on the combined total of the items in the cart
The total for a single payment based on the combined total of the items in the cart
defaultSpendingCap
NOT set and minimumBalanceRequired
set to $1350 Amount
$8000
$1350
$1350
Calculation
$0 + (13 * $600) + $200
None
None
Logic
Calculated based on items in the cart
“price varies” item assumes $0 value
subscription item is 13 x the item amount
one time item is 1 x the item amount
Taken directly from the minimumBalanceRequired
query string parameter
Taken directly from the minimumBalanceRequired
query string parameter
defaultSpendingCap
set to $2500 and minimumBalanceRequired
set to $1500Amount
$2500
$1500
$1500
Calculation
None
None
None
Logic
Taken directly from the defaultSpendingCap
query string parameter
Taken directly from the minimumBalanceRequired
query string parameter
Taken directly from the minimumBalanceRequired
query string parameter
defaultSpendingCap
set to $150 and minimumBalanceRequired
set to $250i.e. the default spending cap is < min balance required
Amount
$250
$250
$250
Calculation
See logic
None
None
Logic
Because minimumBalanceRequired
> defaultSpendingCap
, use minimumBalanceRequired
as suggested allowance
Taken directly from the minimumBalanceRequired
query string parameter
Taken directly from the minimumBalanceRequired
query string parameter
defaultSpendingCap
or minimumBalanceRequired
NOT setAmount
$800
$800
$800
Calculation
None
None
$0 + $600 + $200
Logic
Based on the minimum balance since that is highest value.
Taken from the minimum balance.
Calculate balance based on prices of items included in the checkout URL. Price varies item is considered $0.
defaultSpendingCap
set to $2000 and minimumBalanceRequired
NOT setAmount
$2000
$800
$800
Calculation
None
None
$0 + $600 + $200
Logic
Taken directly from the defaultSpendingCap
query string parameter
Taken from the minimum balance.
Calculate balance based on prices of items included in the checkout URL. Price varies item is considered $0.
defaultSpendingCap
NOT set and minimumBalanceRequired
set to $1350Amount
$1350
$1350
$1350
Calculation
None
None
None
Logic
Based on the minimum balance since that is highest value.
Taken from the minimum balance.
Taken directly from the minimumBalanceRequired
query string parameter
defaultSpendingCap
set to $2500 and minimumBalanceRequired
set to $1500Amount
$2500
$1500
$1500
Calculation
None
None
None
Logic
Taken directly from the defaultSpendingCap
query string parameter
Taken directly from the minimumBalanceRequired
query string parameter
Taken directly from the minimumBalanceRequired
query string parameter
defaultSpendingCap
set to $150 and minimumBalanceRequired
set to $250i.e. default spending cap < min balance
Amount
$250
$250
$250
Calculation
See logic
None
None
Logic
Because minimumBalanceRequired
> defaultSpendingCap
, use minimumBalanceRequired
as suggested allowance
Taken directly from the minimumBalanceRequired
query string parameter
Taken directly from the minimumBalanceRequired
query string parameter