Docs
STEP 3-2

onError: Unavailability reasons and failures

onError?: (error: { kind: string }) => void

The SDK does not throw exceptions. Instead, it reports why Checkout+ is unavailable, and failures, through this callback. The value passed in is { kind: string }, and the kind names are listed in the table below. More names may be added in the future. In every case, checkout is not blocked.

SituationkindBannerWhat the SDK user does
In the options passed to init(), storeId or cart is invalid (conditions)invalid-optionsNot shownCheck the values you pass to init()
There is no benefit set (the commitment charge and benefits for each range). The metafield returned by getCart is null (the benefit set is not set up yet, a wrong metafield namespace or key, and so on)not-publishedNot shown, and not shown again on that pageCheck the metafield namespace and key. If they are correct, contact Recustomer
The cart cannot be fetched. CartConnector's getCart threw an exceptionunavailableNot shown, and not shown again on that pageSend it to your monitoring system
The benefit set format is invalidinvalid-benefit-setNot shown, and not shown again on that pageNothing. Recustomer fixes the benefit set
Checkout+ acceptance is suspendedacceptance-suspendedNot shown. Decided again on the next refresh()Nothing if you receive it in production. If you receive it during development, check in the Recustomer admin dashboard that the Checkout+ status is 「受付中」 (Accepting) (Getting started)
The cart currency differs from the benefit set's currencycurrency-not-offeredNot shown. Decided again on the next refresh()Nothing
A cart amount is empty or negativeinvalid-cartNot shown, and not shown again on that pageCheck that CartConnector returns values that follow the specification
The product tags are unknown. A line returned by getCart has no tags fieldinvalid-cartNot shown, and not shown again on that pageCheck that getCart returns tags on every line. For a product without tags, return an empty array []
The values returned by CartConnector are malformedinvalid-cartNot shown, and not shown again on that pageCheck that CartConnector returns values that follow the specification
Adding the Checkout+ product was rejectedadd-failedShownSend it to your monitoring system, and contact Recustomer
Removing the Checkout+ product was rejected, and the SDK could not confirm that it was removedremove-failedShownSend it to your monitoring system. If it continues, check that updateCheckoutPlusLines updates the same cart that getCart returns, and that it removes lines using the line IDs returned by getCart as is
An unexpected failure occurred inside the UI components (the banner or the details dialog)ui-failureNot shownContact Recustomer
An exception was thrown inside a callback (onCheckoutPlusLinesChange, etc.)callback-failureDrawn as usual when there is a target and the cart is eligibleFix the callback code
  • With invalid-options and ui-failure, the SDK ends up in the same state as after calling destroy(). With ui-failure, checkout continues, but if an update was already sent, whether Checkout+ was attached is unknown. You can check it in the checkout or order line items.
  • When it's "not shown again on that page", later calls to refresh() on that page complete without doing anything. The banner is shown again only when the page reloads, or when you start over from init() after destroy() (What the SDK does for each trigger).
  • onError receives only the kind, not why getCart failed. If unavailable continues, check the exception that occurred inside your getCart.
  • invalid-options, invalid-cart, and callback-failure are integration errors.
  • The conditions for reporting add-failed and remove-failed are described in When it returns 'rejected' for updateCheckoutPlusLines. Each is reported at most once per CheckoutPlusSession.
  • When remove-failed arrives, the shopper may be proceeding to checkout with a Checkout+ product they did not select, or one for the previous range, still in the cart.

The following cases are not errors, so they are not reported through onError.

CaseWhat the SDK does
The shopper unchecked the boxA normal selection. The banner is shown with the box unchecked
The banner is not shown for a cart with only excluded products, a cart with no matching range, and so on (the second ③ row in What the SDK does for each trigger)A normal state. The banner is simply not shown
The result of adding the Checkout+ product in prepareCheckout() is unknown (for example, updateCheckoutPlusLines threw, or 10 seconds passed)The addition was not necessarily rejected, so add-failed is not reported. Unless the SDK can confirm the product was added, checkout proceeds without Checkout+
// Pass this in the options of init(). Example: send it to your existing monitoring system (Sentry, Datadog, etc.)
onError: (error) => reportError(error),

When it throws

  • How the SDK handles it: The SDK keeps running. This exception is not reported to onError again.
  • If it returns a Promise: The SDK does not wait for it to complete and does not receive a rejection. Handle failures of asynchronous work inside the callback.
© Recustomer, Inc.