On This Page
Loading the JavaScript Library and Invoking the Accept Function
Use the client library asset path and client library integrity value that is returned by
the capture context response to invoke
Unified Checkout
on your page.You can retrieve these values from the
clientLibrary
and
clientLibraryIntegrity
fields that are returned in the JWT from
https://apitest.com//up/v1/capture-contexts
. You can use these
values to create your script tags.You must perform this process for each transaction, as these values may be unique for
each transaction. You must avoid hard-coding values for the
clientLibrary
and clientLibraryIntegrity
fields to prevent client-side errors.For example, a response from
https://apitest.cybersource.com/up/v1/capture-contexts
would
include:"data": { "clientLibrary":"[EXTRACT clientLibrary VALUE from here]", "clientLibraryIntegrity": "[EXTRACT clientLibraryIntegrity VALUE from here]" }
Below is an example script
tag:
<script src="[INSERT clientLibrary VALUE HERE]" integrity=”[INSERT clientLibraryIntegrity VALUE HERE]” crossorigin=”anonymous”></script>
When you load the library, the capture context from your initial server-side request is
used to invoke the accept function.
IMPORTANT
Use the
clientLibrary
and
clientLibraryIntegriry
parameter values in the capture context
response to obtain the Unified Checkout
JavaScript library URL and the
integrity value. This ensures that you are always using the most up-to-date library. Do
not hard-code the Unified Checkout
JavaScript library URL or integrity
value.JavaScript Example: Initializing the SDK
<script src="[INSERT clientLibrary VALUE HERE]" integrity=”[INSERT clientLibraryIntegrity VALUE HERE]” crossorigin=”anonymous”></script> <script> Accept('header.payload.signature').then(function(accept) { // use accept object }); </script>
In this example,
header.payload.signature
refers to the capture
context JWT.