Checkout Form
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>
Note
You must import the library through the public URL provided by Bamboo Payment. It must not be downloaded and used locally from a merchant’s server or from a URL of a third party not authorized by Bamboo Payment.
This is important for security reasons and to keep updated with the latest modifications and corrections.
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.
Property | Description | Mandatory? |
---|---|---|
name | Name shown as Title of the Checkout form. | No |
Customer e-mail that can be preloaded. | No | |
image | Absolute URL of the image used within the Checkout form (fixe format). Accepted image formats: jpg, jpeg, png. | No |
button_label | Text to be displayed on the payment button (the value of the amount parameter replaces the keyword #amount# ). | No |
description | A description of the payment. | No |
currency | Payment currency. | No |
amount | Amount of payment (only to inform to the user, the actual amount is reported server to server in the Purchase operation). | No |
lang | Interface language in ISO 639-1 format. If not set, it is obtained from the browser’s configuration. | No |
form_id | Web 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_card | If set, the checkout goes directly to the card capture. | No |
empty | If the property is set to true , the image and title in the form windows will be hidden. The default value is false . | No |
autoSubmit | Property 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 TokenIf set to false the form will not be automatically submitted to the server.The default value is true . | No |
close_onclick | This 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_edit | Defines whether the user can modify the e-mail address. The default value is true . | No |
email_hide | Defines 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_code | Sets 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.
Property | Description | Default |
---|---|---|
backgroundColor | Sets the window background color. | #FFFFFF |
buttonColor | Sets the background color of the actions button. | #286090 |
buttonHoverColor | Sets the actions button’s color when the mouse hovers over it. | #204d74 |
buttonTextColor | Sets the text color of the actions button. | #FFFFFF |
buttonTextHoverColor | Sets the color of the text in the actions button when the mouse passes over it. | #FFFFFF |
inputBackgroundColor | Text fields background color. | #FFFFFF |
inputTextColor | Text fields text color. | #555555 |
inputErrorColor | Text fields border color when the input has an error. | #FF0000 |
inputAddonBackgroundColor | Background color of the text fields iconography. | #EEEEEE |
labelColor | Labels 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>
Note
You must set the colors in hexadecimal RGB format.
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.
Properties | Description |
---|---|
width | Width of the div that contains the iframe with the page. |
height | Height of the div that contains the iframe with the page. |
margin | Set 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.
Property | Description | Mandatory? |
---|---|---|
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 |
Note
You must implement the javascript function that processes the event (if required).
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.
Event | Description | Parameters |
---|---|---|
opened | The event is triggered when the payment card capture form opens. | - |
closed | The event is triggered when the payment card capture form was closed. | CloseInfo |
tokenCreated | The event is triggered the Token created for the captured payment card was received. | TokenInfo |
notificationReceived | The event is triggered when the Verification Code Request Flow was completed. | NotificationInfo |
onTokenCreateError | The 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.
Property | Description | Mandatory? |
---|---|---|
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:
- Trigger the
tokenCreated
Event. - Submit the form if the property
autoSubmit
istrue
.
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>