- Get Started
- Guides
- Integrations
- References
- API Reference
- Basic Payment
- Forex
- Authentication
- Card Account
- Apple Pay
- Virtual Account
- Bank Account
- Token Account
- Customer
- Billing Address
- Merchant Billing Address
- Shipping Address
- Merchant Shipping Address
- Merchant
- Corporate
- Recipient
- Marketplace & Cart
- Airline
- Lodging
- Passenger
- Tokenization
- Recurring Migration
- 3D Secure
- Custom Parameters
- Async Payments
- Webhook notifications
- Job
- Risk
- Response Parameters
- Card On File
- Chargeback
- Result Codes
- Payment Methods
- Transaction Flows
- Regression Testing
- Data Retention Policy
- API Reference
- Support
Advanced Options
Quick links
- Add custom fields
- Change label
- Have card holder mandatory
- Create custom ui - headling
- Create custom ui - boxing
- Summary page
- Store payment details
- Field order in the payment form
- Billing Address
- Mask Cvv
- Brand detection
- Unload/Reload the Widget
- PayPal - Reload button for creating registration due to user consent
Here you can find some examples of advanced workflow customization for COPYandPAY. Each of the examples provided use the wpwlOptions
variable, the full reference for which can be found on our COPYandPAY API Reference.
Please note that JavaScript examples from COPYandPAY can be used only when including jQuery.
<script src="https://code.jquery.com/jquery.js" type="text/javascript"></script>
Add custom fields
You can add additional parameters to the payment form using the wpwlOptions
variable, prior to loading COPYandPAY. In the example above, we add a custom parameter to the payment form for recording the number of installments requested by the customer. The steps are listed below.
- Prepare the checkout
- Using the wpwlOptions API onLoad event, add the custom field HTML to the payment form
- Set the name of the html input field to your API parameter e.g. recurring.numberOfInstallments
Change label
You can change a label in the payment form using the wpwlOptions
variable, prior to loading the COPYandPAY payment widget. In the following example, we'll change the credit card brand label in the payment form.
- Prepare the order
- Using the wpwlOptions API onLoad event, use a JQuery selector to set the desired value of the label
Have card holder mandatory
By default the card holder is optional. Some integrations would like to have it mandatory. In order to achieve this we can implement the check on the onBeforeSubmitCard event, like below:
- Prepare the checkout
- Using the wpwlOptions API onBeforeCardSubmit event, check if the holder contains 2 or more characters.
Create custom UI
You can change the behavior of the payment page when there are multiple types of payment methods using the wpwlOptions
variable, prior to loading the COPYandPAY payment widget.
- Prepare the checkout
- Using the wpwlOptions API onLoad event, iterate through each .wpwl-container adding custom HTML before the container
- Create a JQuery click handler to show the container on click.
Create custom UI - Box model
You can change the behavior of the payment page when there are multiple types of payment methods using the wpwlOptions
variable, prior to loading the COPYandPAY payment widget.
- Prepare the checkout
- Using the wpwlOptions API onReady event and make some adaptions to the containers.
- Create a JQuery click handler to show the container on click.
Summary page
It is possible to use COPYandPAY to temporarily store the payment information after submission, rather than executing it straight away. This can be useful if you want to display an order summary page before committing the payment. This can be done using the wpwlOptions
variable, prior to loading the COPYandPAY.
To commit the payment after the summary page has been displayed, you can include the following form on the summary page. When the submit button is pressed, the payment will be executed.
<form action="https://test.global-connect.tech/v1/checkouts/{id}/payment" method="POST"> <input type="submit" value="Pay now" />
Store payment details
There are two ways to store the payment details used during a checkout:
- Set the createRegistration parameter to true during step 1 - prepare the checkout
- Add a checkbox to the COPYandPAY form to let the customer decide whether or not to store the card details.
(Option 2 is demonstrated in the example below).
Field order in the payment form
COPYandPAY allows you to modify the order of the fields in the payment form. As a result of this reordering, the order in which fields get tabbed will be adjusted accordingly. For details, please take a look at the JavaScript section in the following integration form.
Billing Address
It's possible to have the billing address fields available and even have them pre-filled. There are two options to do this:
1. Pre-filled data in the billing address that can be editable
To display the form, use the following option in wpwlOptions:
var wpwlOptions = { billingAddress: { country: "US", state: "NY", city: "New York", postcode: "12345", street1: "Suite 1234", street2: "Some Road" }, mandatoryBillingFields:{ country: true, state: true, city: true, postcode: true, street1: true, street2: false } }
2. Display empty fields in the billing address so the shopper can edit them
To display the form, use the following option in wpwlOptions:
var wpwlOptions = { billingAddress: {}, mandatoryBillingFields:{ country: true, state: true, city: true, postcode: true, street1: true, street2: false } }Remarks:
- Use the mandatoryBillingFields options in order to control if some field will be validated (for empty value) or not.
- By default, the billing address fields are mandatory
- The state will be a dropdown for US and Canada.
MaskCvv page
It is possible to mask cvv on COPYandPAY, which can be done by setting "maskCvv" to true in wpwlOptions
variable, prior to loading the COPYandPAY payment widget.
var wpwlOptions = { maskCvv: true }
Brand detection
To influence the brand detection behavior, use the following options in wpwlOptions
variable prior to loading the COPYandPAY payment widget.
var wpwlOptions = { // Enable brand detection brandDetection: true, // Use our internal BIN list to precisely detect brands brandDetectionType: "binlist", // Give priority to detected brands brandDetectionPriority: ["CARTEBANCAIRE","VISA","MAESTRO","MASTER"] }
Disable non-detected brands
By default, the brand detection only recommends brands that are considered valid. It does not enforce the brand selection. The shopper is still free to select any brand.
If you want to change this behavior by allowing the shopper to select only detected brands, you can implment onDetectBrand
—the callback function to which its argument is a list of detected brands. With this information you can choose to disable or hide any brands you want.
See for example in the following snippet. Except the detected brands, all other brands are disabled.
Try for example the BIN 513678 from which multiple brands are detected.
Hide detected brands
Sometimes you might want to hide some brands when multiple brands are detected. This can guide the shopper to select your preferred brand. There are several options to implement this feature:
- If you use your own brand images, implement
onDetectBrand
, similarly to the example above. This method is called with a list of detected brands. With this information you can choose to show or hide your images. - Use COPYandPAY images the "logos" style. By default this style dynamically displays all detected brands as you type the card number. You can implement
onChangeBrand
to change this behavior.
Try for example the BIN 513678 from which multiple brands are detected.
Unload/Reload the Widget
In order to reload the widget, it's not enough to remove it from the page. You need to remove event bindings and stop the iframe communication, otherwise the previous widget will present unwanted error messages. To achieve that, use the wpwl.unload method and remove the static.min.js script.
After doing this, you can insert again the form with the brands and the paymentWidgets.js script in order to reload the widget.
The code below is an example of how to unload the widget.
var unloadWidget = function() { if (window.wpwl !== undefined && window.wpwl.unload !== undefined) { window.wpwl.unload(); $('script').each(function () { if (this.src.indexOf('static.min.js') !== -1) { $(this).remove(); } }); } };
PayPal - Reload button for creating registration due to user consent
For Paypal, we are accepting createRegistration info on either checkout data or wpwlOptions
. If used in wpwlOptions, merchants have the ability to update its value (true/false) based on the shopper preferences, and then update the Paypal button using wpwl.reloadButton()
for the new workflow.
var wpwlOptions = { paypal: {"createRegistration":"true"} } function handleClick(checkbox) { wpwlOptions.paypal.createRegistration = checkbox.checked.toString(); wpwl.reloadButton(); }