Skip to main content
Vaultera Switch’s SDK comes with a lot of features that give you complete control of your entire payment journey, from preloading to rendering and unmount. You can use the props to change the appearance, reorder payment methods and much more to suit your business needs.

The React SDK offers 2 integral elements for you to use:
  1. Hooks
  2. Components
The API for both the Hooks and Components are listed down below.

1. Hooks

useSwitch()

This hook gives you access to methods in Switch API, which you can call.

1. vaultera_switch.confirmPayment(options)

Use vaultera_switch.confirmPayment to confirm a PaymentIntent using data collected by the Payment Element. When called, vaultera_switch.confirmPayment will attempt to complete any required actions, such as authenticating your user by displaying a 3DS dialog or redirecting them to a bank authorization page. Your user will be redirected to the return_url you pass once the confirmation is complete. ConfirmParams object

2. vaultera_switch.elements(options)

This method creates an Elements instance, which manages a group of elements.

3.vaultera_switch.confirmCardPayment(clientSecret,data?,options?)

Use vaultera_switch.confirmCardPayment when the customer submits your payment form. When called, it will confirm the PaymentIntent with data you provide and carry out 3DS or other next actions if they are required. clientSecret is a required string. payment_method example

3. vaultera_switch.retrievePaymentIntent(clientSecret)

Retrieve a PaymentIntent using its client secret.

4. vaultera_switch.paymentRequest(options)

Use vaultera_switch.paymentRequest to create a PaymentRequest object. Creating a PaymentRequest requires that you configure it with an options object. clientSecret is a required string.

5. vaultera_switch.initiateUpdateIntent()

Use vaultera_switch.initiateUpdateIntent() just before you start updating the payment intent on your end. It doesn’t require any input. When invoked, it signals the system to prepare for the update process and returns a confirmation message indicating that the update has been initiated.

6. vaultera_switch.completeUpdateIntent(clientSecret)

Use vaultera_switch.completeUpdateIntent(clientSecret) after you’ve completed the payment intent update process on your side. It takes the updated clientSecret as input and signals the system to complete the update flow. It returns a response with a confirmation message indicating the update has been processed.

useElements()

This hook gives you access to methods in Elements API, which you can call.

1. elements.getElement(type)

This method retrieves a previously created Payment Element. Here the type is payment for Unified Checkout. elements.getElement(‘payment’) returns one of the following:
  • An instance of a Unified Checkout.
  • null, when no Unified Checkout has been created.\
2. elements.create(type, options?) This method creates an instance of an individual Element. It takes the type of Element to create as well as an options object. The type can be ‘payment’ for UnifiedCheckout. Options object Classes object 3. element.update(options) Updates the options the Element was initialized with. Updates are merged into the existing configuration. If you collect certain information in a different part of your interface (e.g., ZIP or postal code), use element.update with the appropriate information. The styles of an Element can be dynamically changed using element.update. This method can be used to simulate CSS media queries that automatically adjust the size of elements when viewed on different devices

2. Components

<VaulteraSwitchElements vaultera_switch options />

This component wraps around the entire app and it consumes 2 parameters -
parametersDescription
vaultera_switch (promise)This is the response that you get after calling the loadHyper() from the JS SDK. This will be the start point of your payment journey
options (object)This follows the same API as vaultera_switch.elements()

<UnifiedCheckout options onChange? onReady? onFocus? onBlur? onClick? />

This component is the Unified Checkout itself which internally mounts the main iframe and subsequent iframes that are needed for the payment flow.

<CardWidget options onChange? onReady? onFocus? onBlur? onClick? />

This component is the CardWidget, which is a 1 line payment method consisting of only card. This is a compact widget which fits anywhere in a webpage.

It follows the same API as Unified Checkout

<CardNumberWidget options onChange? onReady? onFocus? onBlur? onClick? />

This component loads up a small individual input field iframe which communicates with other iframes to collect card information and make API calls.

It follows the same API as Unified Checkout
Note: You need to use it along with CardCVCWidget and CardExpiryWidget components, it cannot function as a standalone component.

<CardCVCWidget options onChange? onReady? onFocus? onBlur? onClick? />

This component loads up a small individual input field iframe which communicates with other iframes to collect card information and make API calls.

It follows the same API as Unified Checkout
Note: You need to use it along with CardNumberWidget and CardExpiryWidget components, it cannot function as a standalone component.

<CardExpiryWidget options onChange? onReady? onFocus? onBlur? onClick? />

This component loads up a small individual input field iframe which communicates with other iframes to collect card information and make API calls.

It follows the same API as Unified Checkout
Note: You need to use it along with CardCVCWidget and CardNumberWidget components, it cannot function as a standalone component.

Unified Checkout

The Unified Checkout provides developers a high level of customizability which enables them to shape their customer’s payment journey their own way. The snippet below explains all the options that are available to use for Unified Checkout.