Migrating from v1 to v2
The latest Web SDK has evolved significantly from the previous release SDK v1. This guide describes what is new in v2, what has changed from v1 and what you need to do to migrate to the latest Universal Checkout SDK v2.The latest version v2 of Universal Checkout Web SDK introduces a few breaking changes.
Universal Checkout v2 SDK is super efficient and simpler to integrate. Going forward, the prior Primer Checkout SDK v1.x.x will be no longer supported.
Key Highlights
- There is a brand new way to initialize checkout
- Universal Checkout now creates payments automatically in a more secure manner.
- Some of the earlier payment method options and methods are no longer required, therefore removed or addressed via other calls or functions.
- The way to customize merchant branding through styling has changed.
Initializing Universal Checkout
In the new Primer Universal Checkout Web SDK, you’ll find that the boilerplate for initializing is reduced to just one line of code!Initialize Vault Manager
In the v2 SDK, you can initialize the vault manager using the following function:Other Initialization Changes
The new Universal Checkout initialization makes integration much simpler and easier. As a result, developers are no longer required to construct the Primer object usingnew Primer()
call. Instead, you need to use Primer.showUniversalCheckout()
or Primer.showVaultManager()
.Another set of changes that you need to take into account is when the package is loaded from npm:- The
loadPrimer()
call is now removed from the latest SDK. When the user approaches checkout, if you need to preload Primer Universal Checkout SDK, usepreloadPrimer()
instead. Under the hood,loadPrimer()
is automatically called byPrimer.showUniversalCheckout()
so you do not need to callloadPrimer()
explicitly anymore. - It is no longer required to import the CSS file anymore.
Primer.showUniversalCheckout()
will automatically load it.
Automatic Payment Creation
Universal Checkout Web SDK v2 now creates, resumes and handles payments under the hood 🎉The automatic payment flow is activated by default.When migrating to Web SDK v2, you need to use the following simpler code for payment creation:onTokenizeSuccess
and onResumeSuccess
. Not anymore.The functions onTokenizeSuccess
and onResumeSuccess
are no longer required to be used. This essentially means that you do not need to make any API calls for creating and resuming payments.Those can be edited out of your integration code.No complex integrations to maintain anymore!With the new SDK, you can simply listen to the PAYMENT.STATUS
webhook and the callback onCheckoutComplete
to process successful and even more secure payments as compared to the earlier versions.
Should you wish to go back to the manual flow of v1, pass the option
paymentHandling: "MANUAL"
. See Manual Payment Creation Guide for details.onTokenizeSuccess and onResumeSuccess change
In the earlier version,onTokenizeSuccess
and onResumeSuccess
had to return specific data to trigger various scenarios. This proved to be quite error-prone and not self-explanatory.handler
argument that contains the functions to continue.Improved 3DS
In Web SDK v2 the
threeDSecure
option is now completely removed from the Universal Checkout. Earlier, this option was provided to trigger 3DS at the time of tokenization.Payment Options Updates
The following payment method options in Primer Checkout SDK v1.x.x are no longer available in the latest Universal Checkout SDK v2. Developers must now specify the order and customer details when creating the client session with .Earlier v1.x.x | Latest v2 SDK |
---|---|
purchaseInfo and orderDetails (in the SDK) | Pass the order details through the client-session API call. |
customerDetails (in the SDK) | Pass the customer information through the client-session API call. |
customerId (in the SDK) | Specify the customerId through the client-session API call. |
countryCode (in the SDK) | Pass order.countryCode through the client-session API call. |
businessDetails (in the SDK) | Only needed for tax calculation using TaxJar. Removed. In the future, business details… |
Setters Removed
The Setters in Web SDK v1.x.x listed below have been removed. Now this information is retrieved by Universal Checkout through the client session.Developers need to migrate their integration backend to use the latest Universal Checkout SDK v2 and update order details using . The token obtained through the client-session API needs to be passed to the SDK withsetClientToken(newClientToken)
API call.Earlier v1.x.x | Latest v2 SDK |
---|---|
setPurchaseInfo and setOrderDetails (in the SDK) | Update the order in the client session, then call setClientToken(...) . |
setCustomerDetails (in the SDK) | Update the customer in the client session, then call setClientToken(...) . |
setBusinessDetails (in the SDK) | This has been completely removed |
Once you migrate your merchant backend, all your implementations will be able to properly display payment methods through the Primer Universal Checkout, regardless of the platform!
allowedPaymentMethods Removed
In the previous Primer Checkout v1.x.x, the optionallowedPaymentMethods
was used to filter and display the payment methods as required by a specific merchant integration. This is no longer necessary and has been completely removed in the latest SDK v2.The recently introduced Checkout section in the Dashboard enables display of merchant-specific payment methods, based on the conditions defined by them.With Universal Checkout, Primer can now dynamically show payment methods in the user interface. It uses the conditions set up by you on the dashboard, along with the data passed in the client session call, to dynamically display only those payment methods that are applicable as per your selection and inputs.
Client Session Actions Automation
Earlier versions of Primer Checkout SDK required you to integrate usingonClientSessionActions
.Now, with the latest SDK v2, as the customer interacts with the UI, Universal Checkout takes care of setting up “client session actions” via onClientsessionActions()
.Developers are no longer required to call this function anymore and it has been removed from the SDK. Instead, now you need to set up the following callbacks:
onClientSessionUpdate
onClientSessionUpdateStart
onClientSessionActions
. These callbacks are now replaced by the client session update call.onAmountChange
onAmountChanging
onAmountChangeError
The previous SDK version had Primer Checkout functionality that was sending you
Client session actions
in order to enable you to update the client session according to the merchant checkout requirements. This is now completely managed automatically by the Primer Universal Web SDK v2.The latest SDK can now collect various customer data such as the billing address
, customer contact
details and update the client session by itself. It no longer requires any explicit developer initiated actions or function calls to update these details while integrating with Primer.Submit Button Updates
If you have setup a custom submit button in the checkout user interface here is what you need to do in order to migrate from previous Primer Checkout Web SDK:- Use the function
submit()
to implement a custom submit button. For details, see Universal Checkout Submit button usage guide.
- The option
submitButton.visible
is now renamed tosubmitButton.useBuiltInButton
.
Styling Customization Changes
Earlier, the card input fields could be customized as per merchant checkout requirements usingcard.css
.Now, you can instead use the style
option to customize the style 🎨 for the entire Universal Checkout SDK and align with the merchant branding in a more cohesive and unified way!For more details, refer to the Primer Universal Checkout Web SDK Styling Guide.Miscellaneous Updates
-
Card holder name display option
The option
card.cardholderName.visible
available in the previous version of Primer Checkout SDK has been removed altogether. You can continue to configure this setting through the Dashboard in the forthcoming release. Stay tuned! In the meantime, if you need to show or hide the cardholder name field, please get in touch with us. -
Renamed
CheckoutOptions
The TypeScriptCheckoutOptions
is now renamed toUniversalCheckoutOptions
. -
Checkout object updates
The checkout object functions
tokenize()
andvalidate()
are no longer available in Universal Checkout SDK v2.
Deprecated Items
- Checkout Components
Checkout Components are now sunset and no longer supported. The new Universal Checkout SDK does not contain the
primer.render()
function. Make sure you clean that up!
At Primer, we are all working hard towards a fully customisable payment framework that enables you to build any checkout that you want!Stay tuned for more updates!