Billing address collection
You can specify whether Beanie should collect the full billing address of your customer, or only its billing country - and, possibly, the zip code if required by the payment processor -.
You can set thebillingAddressCollection
property in theredirectToBeanie
call. If set torequired
, Beanie will ask for a full billing address filling. If not set, or set toauto
then Beanie will only collect the required components of the billing address.
beanie.redirectToBeanie({
items: [
{sku: 'sku_123', quantity: 1}
],
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel',
billingAddressCollection: 'required'
})
.then(function (result) {
if (result.error) {
// If `redirectToBeanie` 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;
}
}).catch(function(error) {
// If `redirectToBeanie` can't be triggered because of invalid parameters
// or implementation, error, display a generic error message to your customer,
// and report the error to the console for debugging purposes, or send it to Sentry
// Sentry.log(error)
console.log(error)
var displayError = document.getElementById('error-message');
displayError.textContent = "Implementation error, please contact website administrator"
})
Prefilling customer data
You may already have collected information about your customer that you want to prefill in the Beanie page to avoid your customers needing to enter information twice. Currently, you can prefill the customer email and the customer name on the Beanie page by filling theprefillData
field in theredirectToBeanie
call. We plan to expand this feature to allow you to prefill more fields in the future.
beanie.redirectToBeanie({
items: [
{sku: 'sku_123', quantity: 1}
],
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel',
prefillData: {
customer_name: "John Doe",
customer_email: "foo@bar.tld"
}
})
.then(function (result) {
if (result.error) {
// If `redirectToBeanie` 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;
}
}).catch(function(error) {
// If `redirectToBeanie` can't be triggered because of invalid parameters
// or implementation, error, display a generic error message to your customer,
// and report the error to the console for debugging purposes, or send it to Sentry
// Sentry.log(error)
console.log(error)
var displayError = document.getElementById('error-message');
displayError.textContent = "Implementation error, please contact website administrator"
})
Associating to a Reference Id
You can provide a unique string to reference the Beanie Session, in order to reconcile it with your internal system's IDs or data. It can be a customer email, or a customer ID or a cart ID.
beanie.redirectToBeanie({
items: [
{sku: 'sku_123', quantity: 1}
],
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel',
clientReferenceId: 'user-4242-foo-bar'
})
.then(function (result) {
if (result.error) {
// If `redirectToBeanie` 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;
}
}).catch(function(error) {
// If `redirectToBeanie` can't be triggered because of invalid parameters
// or implementation, error, display a generic error message to your customer,
// and report the error to the console for debugging purposes, or send it to Sentry
// Sentry.log(error)
console.log(error)
var displayError = document.getElementById('error-message');
displayError.textContent = "Implementation error, please contact website administrator"
})
Associating metadata
Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
The metadata attached to aBeanie Session
are replicated to the payment provider underlying objects:
respectively for Stripe:
Subscription
for subscriptionsPaymentIntent
for one-off payments
beanie.redirectToBeanie({
items: [
{sku: 'sku_123', quantity: 1}
],
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel',
metadata: {
"key": "value"
}
})
.then(function (result) {
if (result.error) {
// If `redirectToBeanie` 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;
}
}).catch(function(error) {
// If `redirectToBeanie` can't be triggered because of invalid parameters
// or implementation, error, display a generic error message to your customer,
// and report the error to the console for debugging purposes, or send it to Sentry
// Sentry.log(error)
console.log(error)
var displayError = document.getElementById('error-message');
displayError.textContent = "Implementation error, please contact website administrator"
})