Documentation version 0.1.0
Alviere's Web Javascript SDK leverages our financial platform on the client side, in compliance with all security and regulations.
Before integrating with our SDK, you need to securely generate a session. The flow is as follows:
Please see details on our API documentation
The first step is to include our SDK, ideally at the very bottom of your web app.
(...) <script src="https://api.snd.alviere.com/sdk/js?session_id={{YOUR-SESSION-ID}}"></script> </body> </html>
Please Note:
- You must include the session id obtained in the Backend
Authentication step above.
- Make sure you use the appropriate URL depending on the mode you are in; production or sandbox.
After you include our SDK, it exposes a public global variable Alviere
where you
can access
our Controller Factory. You can then use this factory to instantiate the desired Alviere
Service. Each controller corresponds to one Alviere Service.
For instance, if you wanted to instantiate our Payments Service or our Fraud Service, you would call the below example.
let service = Alviere.Factory.NewPaymentsController({});
let service = Alviere.Factory.NewFraudController();
{ success_cb: (result: AddCardResult) => void; error_cb: (error: AddCardGatewayError) => void; validation_cb: (errors: Array<AddCardValidationError>) => void; debug: {boolean}; }
success_cb
(required)
Add Card submit success. This is a function that will receive a AddCardResult
object
error_cb
(required)
Add Card submit error. This is a function that will receive a AddCardGatewayError
object
validation_cb
(required)
Add Card form validation fail. This is a function that will receive an array of AddCardValidationError
objects
debug
This, when true, will make our SDK output debug messages to console
The result object yields information about the payment add card process result.
{ "card": { "payment_method_uuid": "09f46e1f-aa02-46ec-ae6d-34946f385e3d", "external_id": "string", "account_uuid": "string", "brand": "VISA", "type": "CREDIT", "country": "USA", "last_4": "0000", "status": "ACTIVE", "status_reason": "string", "flags": { "load_supported": true, "withdraw_supported": false }, "metadata": {}, "created_at": "string", "updated_at": "string" }, "validation": { "error_code": "", "error_description": "", "cvv_result": "M", "avs_result": "A" } }
card.payment_method_uuid
This is Alviere internal card ID. This is the uuid you should store on your backend and it
allows you to perform PCI compliant operations on that payment card through your backend.
card.status
The status of the card
Allowed values: CREATED, ACTIVE, FAILED, EXPIRED, REJECTED, DELETED
card.status_reason
In case the card failed, this will hold the exact error reason.
The gateway error object yields information about request failure on the network level.
{ message: string, http_code: number, error_code: boolean, error_description: string, }
message
An SDK error message.
http_code
The underlying request HTTP Status Code
error_code
The Alviere internal API specific error code (when applicable)
The Add Card Validation object yields information about the initial form validation result.
{ message: string, field_id: string, field_name: string, }
message
An SDK validation error message.
field_id
The DOM id
where the validation error was triggered
field_name
The DOM name
value where the validation error was triggered
The Payments Controller allows you to bind to any given DOM form. For that, you need to pass the DOM id to the controller. Please note that the form inputs must follow a specific contract with data attributes.
let payments = Alviere.Factory.NewPaymentsController({}); payments.bind("add-card-form").addCard();
data-alviere-id="chn"
For the card holder name field
data-alviere-id="pan"
For the card number field (numeric - we will strip any dashes or spaces)
data-alviere-id="exp"
For the card expiry date (string - must be in format MM/YY)
data-alviere-id="sec"
For the card security code (numeric - must be 3 or 4 digits e.g. cvv)
data-alviere-id="mid"
This can/should be hidden field as it must have YOUR own payment method ID.
This field will be stored on our servers and used for searching as well as an idempotency checking mechanism.
The Payments Controller allows you to bind to any given DOM form. For that you need to pass the DOM id to the controller. Please note the form inputs must follow a specific contract with data attributes.
<!doctype html> <html class="no-js" lang=""> <head> <script src="https://api.snd.alviere.com/sdk/js?session_id={{YOUR-SESSION-ID}}"></script> <script> payments = Alviere.Factory.NewPaymentsController({ "success_cb": function handler(result) { console.log("received from success cb: " + result.card.payment_method_uuid) }, "error_cb": function handler(error) { console.log("received from error cb: " + error.error_description) }, "validation_cb": function handler(errors) { console.log("received from validation cb: " + errors) }, "debug": true, }); payments.bind("add-card-form").addCard(); </script> </head> <body> <form id="add-card-form"> <input id="name" type="text" data-alviere-id="chn" value="John Doe"><br> <input id="pan" type="text" data-alviere-id="pan" value="5280705922407691"><br> <input id="expiry" type="text" data-alviere-id="exp" value="11/22"><br> <input id="sec-code" type="text" data-alviere-id="sec" value="123"><br> <input type="hidden" data-alviere-id="mid" value="123456789abc"> <input type="submit"> </form> </body> </html>
<!doctype html> <html class="no-js" lang=""> <head> <script src="https://api.snd.alviere.com/sdk/js?session_id={{YOUR-SESSION-ID}}"></script> <script> fraud = Alviere.Factory.NewFraudController(); fraud.bind().start(); </script> </head> <body>...
</body> </html>
{ success_cb: (result: SetPinResult) => void; error_cb: (error: CardIssuanceGatewayError) => void; validation_cb: (errors: Array<CardIssuanceValidationError>) => void; debug: {boolean}; }
success_cb
(required)
Set PIN submit success. This is a function that will receive a SetPinResult
object
error_cb
(required)
Set PIN submit error. This is a function that will receive a CardIssuanceGatewayError
object
validation_cb
(required)
Set PIN form validation fail. This is a function that will receive an array of CardIssuanceValidationError
objects
debug
This, when true, will make our SDK output debug messages to console
The result object yields information about the Set PIN request result.
{ accepted: boolean, error_code: string, error_description: string, }
accepted
If the request succeed or not
error_code
In case the request failed, this will hold the exact error reason code.
The gateway error object yields information about request failure on the network level.
{ message: string, http_code: number, error_code: boolean, error_description: string, }
message
An SDK error message.
http_code
The underlying request HTTP Status Code
error_code
The Alviere internal API specific error code (when applicable)
The Card Issuance Validation object yields information about the initial form validation result.
{ message: string, field_id: string, field_name: string, }
message
An SDK validation error message.
field_id
The DOM id
where the validation error was triggered
field_name
The DOM name
value where the validation error was triggered
The Set PIN Controller allows you to bind to any given DOM form. For that, you need to pass the DOM id to the controller. Please note that the form inputs must follow a specific contract with data attributes.
let card_issuance = Alviere.Factory.NewCardIssuanceController({}); card_issuance.bind("card-set-pin-form").setPin();
data-alviere-id="pin"
For the card PIN field
data-alviere-id="pinc"
For the card PIN confirmation field
data-alviere-id="cuid"
For the card UUID
The Set PIN Controller allows you to bind to any given DOM form. For that, you need to pass the DOM id to the controller. Please note that the form inputs must follow a specific contract with data attributes.
<!doctype html> <html class="no-js" lang=""> <head> <script src="https://api.snd.alviere.com/sdk/js?session_id={{YOUR-SESSION-ID}}"></script> <script> cardIssuance = Alviere.Factory.NewCardIssuanceController({ "success_cb": function handler(result) { console.log("received from success cb: " + result.accepted) }, "error_cb": function handler(error) { console.log("received from error cb: " + error.error_description) }, "validation_cb": function handler(errors) { console.log("received from validation cb: " + errors) }, "debug": true, }); card_issuance.bind("card-set-pin-form").setPin(); </script> </head> <body> <form id="card-set-pin-form"> <input id="pin" type="text" data-alviere-id="pin" value="1234"><br> <input id="pin-confirmation" type="text" data-alviere-id="pinc" value="1234"><br> <input type="hidden" data-alviere-id="cuid" value="650ad655-5f91-4956-866d-764072986955"> <input type="submit"> </form> </body> </html>
----------------------------------------------------------------------------------------- Version 0.6.0 - Dec 28th, 2023 ----------------------------------------------------------------------------------------- - added payments add card ----------------------------------------------------------------------------------------- Version 0.5.0 - Sep 28th, 2022 ----------------------------------------------------------------------------------------- - added card issued set pin ----------------------------------------------------------------------------------------- Version 0.4.0 - May 16th, 2022 ----------------------------------------------------------------------------------------- - added fraud controller ----------------------------------------------------------------------------------------- Version 0.1.0 - Jan 13th, 2021 ----------------------------------------------------------------------------------------- - initial version - tokenization controller
WIP