Checkout Form

Amplified and responsive suitable for web and mobile applications.

Import of the JavaScript Library

You can find the functionalities of the Checkout form in a JavaScript library, which must be imported into the client’s website directly from a public URL of our platform.

The call to this library must include (as a parameter) the public key of the commerce account (PublicAccountKey) which you will use for calls to the API REST from this library.

<script src="{api_environment}/v1/Scripts/PWCheckout.js?key={PublicAccountKey}" type="text/javascript"></script>

Methods

SetProperties

This method establishes the visual properties (texts and images) used in the Checkout window.

All properties are optional, except for the form_id property. So, the call to the SetProperties method is mandatory at least to establish this property, and you must invoke it before the opening of the Checkout form.

PropertyDescriptionMandatory?
nameName shown as Title of the Checkout form.No
emailCustomer e-mail that can be preloaded.No
imageAbsolute URL of the image used within the Checkout form (fixe format). Accepted image formats: jpg, jpeg, png.No
button_labelText to be displayed on the payment button (the value of the amount parameter replaces the keyword #amount#).No
descriptionA description of the payment.No
currencyPayment currency.No
amountAmount of payment (only to inform to the user, the actual amount is reported server to server in the Purchase operation).No
langInterface language in ISO 639-1 format. If not set, it is obtained from the browser’s configuration.No
form_idWeb form identifier where the data of the current purchase is handled. This data is required since it informs the token generated by the application.Yes
checkout_cardIf set, the checkout goes directly to the card capture.No
emptyIf the property is set to true, the image and title in the form windows will be hidden. The default value is false.No
autoSubmitProperty that allows to set the behavior of the PWCheckout library once the Token is received.
If set to true, the form will be automatically submitted to the server, upon receipt of the Token
If set to false the form will not be automatically submitted to the server.
The default value is true.
No
close_onclickThis property controls whether the Card Capture Form can be automatically closed when the user clicks outside the form’s area.
If it is set to true, the form will be closed when you click outside it.
If set to false, the form will not be closed automatically and it will be necessary to click on the close button.
The default value is true.
No
email_editDefines whether the user can modify the e-mail address.
The default value is true.
No
email_hideDefines the visibility of the email field in the capture form.
If the email property is not set, this property is ignored and the field is displayed anyway.
The default value is false.
No
country_codeSets the country for which we will tokenize the captured card.Yes

Example:

<script type="text/javascript">
PWCheckout.SetProperties(
{
  "name": "Mi tienda",
  "email": "cliente@gmail.com",
  "image": "http://mitienda.com/images/logocheckout.png",
  "button_label": "Pagar #monto#",
  "description": "Checkout de Mi tienda",
  "currency": "USD",
  "amount": "1843.21",
  "lang": "ES",
  "form_id": "commerce_form",
  "checkout_card": "1",
  "autoSubmit": `true`,
  "email_edit": `false`,
  "country_code" : "UY"
});
</script>

SetStyle

This method sets the colors in the Checkout window. All the properties are optional, so the call to the SetStyle method is optional. The Checkout form will use default colors if you don’t call this method.

Invoke the method before opening the Checkout form to set those properties.

PropertyDescriptionDefault
backgroundColorSets the window background color.
#FFFFFF
buttonColorSets the background color of the actions button.
#286090
buttonHoverColorSets the actions button’s color when the mouse hovers over it.
#204d74
buttonTextColorSets the text color of the actions button.
#FFFFFF
buttonTextHoverColorSets the color of the text in the actions button when the mouse passes over it.
#FFFFFF
inputBackgroundColorText fields background color.
#FFFFFF
inputTextColorText fields text color.
#555555
inputErrorColorText fields border color when the input has an error.
#FF0000
inputAddonBackgroundColorBackground color of the text fields iconography.
#EEEEEE
labelColorLabels and title text color.
#337AB7

Example:

<script type="text/javascript">
PWCheckout.SetStyle(
{
  "backgroundColor": "f2f2f2",
  "buttonColor": "555555",
  "buttonHoverColor": "777777",
  "buttonTextColor": "ffffff",
  "buttonTextHoverColor": "ffffff",
  "inputBackgroundColor": "ffffff",
  "inputTextColor": "767676",
  "inputErrorColor": "ff0000",
  "inputAddonBackgroundColor": "ffffff",
  "labelColor": "494949"
}
);
</script>

SetStyleForVbV

This method describes configurable parameters when the Verified By Visa page is returned.

All the properties are optional, so the call to the SetStyleForVbV method is optional. If you don’t invoke this method, the page appears full width on the screen.

To set these properties, invoke the method before opening the Checkout form.

PropertiesDescription
widthWidth of the div that contains the iframe with the page.
heightHeight of the div that contains the iframe with the page.
marginSet auto, so that it is centered on the screen.

Example:

<script type="text/javascript">
PWCheckout.SetStyle(
  {
    "width": "1600px",
    "height": "800px",
    "margin": "auto"
  }
);
</script>

Bind

Use this method to subscribe to the events the PWCheckout library can trigger.

To receive the events generated by this form, invoke the method before opening the Checkout form window.

PropertyDescriptionMandatory?
eventName (string)Name of the event to which you want to subscribe (see events below).Yes
callbackName (JavaScript Function)JavaScript function that will process the event.Yes

Example:

<script type="text/javascript">
function WindowIsOpen(){
  console.log("Checkout Window is Open");
}
PWCheckout.Bind("opened", WindowIsOpen);
</script>

Events

The PWCheckout library exposes the following javascript events to which you can subscribe using the Bind method.

EventDescriptionParameters
openedThe event is triggered when the payment card capture form opens.-
closedThe event is triggered when the payment card capture form was closed.CloseInfo
tokenCreatedThe event is triggered the Token created for the captured payment card was received.TokenInfo
notificationReceivedThe event is triggered when the Verification Code Request Flow was completed.NotificationInfo
onTokenCreateErrorThe event is triggered when an error is generated when generating a Token.TokenInfo

Unbind

This method removes the subscription to an event previously made by the Bind method.

PropertyDescriptionMandatory?
eventName (string)Name of the event whose subscription you want to remove.Yes

Example:

<script type="text/javascript">
PWCheckout.Unbind("opened", WindowIsOpen);
</script>

Invoking the form

The Checkout Form invocation web page must include a hidden input field named PWToken. The JavaScript library will set the field’s value after obtaining the Token.

Create the field in the following way:

    <input type="hidden" name="PWToken" id="PWToken" />

To start the payment process, you must link the page element that will make the call to the Payment Card Capture Form. This element can be a button, image or any active element you want to link.

You must call the AddActionButton method of the PWCheckout library as follows:

<script type="text/javascript">
  PWCheckout.AddActionButton("buttonId");
</script>

The parameter buttonId refers to the identifier of the element that triggers the payment process.

Multiple elements can be associated in the same call, identifying each one by its ID and separating each identifier with a comma.

<script type="text/javascript">
  PWCheckout.AddActionButton("buttonId1", "buttonId2", "buttonId3");
</script>

After performing this step, the payment process is invoked when the customer presses the linked element.

Once this invocation finishes, the JavaScript library manages the process, showing the user the form where the payment card information is requested.

When the customer enters the data of their card, our servers tokenize the information and send the Token to the PWCheckout library

The value of the generated Token is automatically inserted in the hidden field PWToken, and finally, the JavaScript library PWCheckout performs the following actions:

  1. Trigger the tokenCreated Event.
  2. Submit the form if the property autoSubmit is true.

You need to process payment form data, including the value in the PWToken field, and send the relevant information described in the API’s Purchase section.

Invoking the form with validation filters

If you need to validate the entry of a particular card, either by the brand or the issuing bank, you must proceed to the personalized opening of the Card Capture Form. Use an explicit method for validating data.

The method to be used is the OpenIframeWithPaymentMediaOptions, which receives the following parameters:

  • PaymentMediaId: Identifier of the payment method in the gateway (see table Payment method types).
  • BankId: Bank identifier on the gateway (see table Issuer Bank).
  • PaymentMediaType: Payment method type identifier (see table Payment methods).

Invocation example of OpenIframeWithPaymentMediaOptions:

<script type="text/javascript">
  PWCheckout.Iframe.OpenIframeWithPaymentMediaOptions(paymentMediaId, bankId, paymentMediaType);
</script>
footer
Last modified November 18, 2024

© Bamboo | All rights reserved 2024