Before starting the steps in this guide, you must do the following:
The HTML elements associated with the card input fields can be modified as follows:
const cardForm = GlobalPayments.creditCard.form("#credit-card-form", {
style: "gp-default2",
labels: {
"card-cvv": " Security Code",
"card-expiration": "Expiry Date",
"card-number": "Card Number"
"card-holder-name": "Cardholder Name",
},
titles: {
"card-cvv": "Card CVV Input",
"card-expiration": "Card Expiration Input",
"card-number": "Card Number Input",
"card-holder-name": "Card Holder Name Input",
"submit": "Form Submit Button Input"
},
placeholders: {
"card-cvv": "•••",
"card-expiration": "MM / YY",
"card-holder-name": "Cardholder Name",
"card-number": "•••• •••• •••• ••••"
},
values: {
// IT IS NOT RECOMMENDED TO PUT VALUES FOR THE FOLLOWING FIELDS
"card-cvv": "123",
"card-expiration": "01 / 30",
"card-holder-name": "4242 4242 4242 4242",
// END
"card-holder-name": "John Doe",
},
});GlobalPayments.configure({
accessToken: "access-token",
apiVersion: "2021-03-22",
env: "sandbox", // or "production"
fieldValidation: {
enabled: true
}
})const cardForm = GlobalPayments.creditCard.form('#credit-card-form',{
style: "gp-default2",
fields: {
"submit": "Pay"
}
});Order information gives a breakdown of the merchant name, currency, amount and the order reference. This information is displayed above the card form.
const cardForm = GlobalPayments.creditCard.form("#credit-card-form", {
style: "gp-default2",
orderInformation: {
enabled: false,
merchantName: "Test Merchant Name",
orderTotalAmount: "84.90",
orderReference: "XXXX12345",
currencyCode: "USD"
}
});Event handlers can be set on the form as a whole for developer ease, but they can also be set on individual fields and the button click. The click event can only be used on the submit button. The others come from their respective fields, e.g. card-number-test/card-type from card-number.
// Returns an event with a validity of the card number entered.
// Return type: boolean.
cardForm.on("card-number-test", (resp) => {
console.log("card-number-test", resp)
});
// Returns an event with a validity of the expiration date entered.
// Return type: boolean.
cardForm.on("card-expiration-test", (resp) => {
console.log("card-expiration-test", resp)
});
// Returns an event with a validity of the CVV/CVC entered
// Return type: boolean.
cardForm.on("card-cvv-test", (resp) => {
console.log("card-cvv-test", resp)
});
// Returns the card type entered in the Card Number field.
// Return type: String ("visa", "mastercard", "amex", "diners", "discover", "jcb", "unknown")
cardForm.on("card-type", (resp) => {
console.log("card-type", resp)
});
// Returns a click event to indicate that the Submit button was clicked
// Return type: Event
cardForm.on("submit", "click", (resp) => {
console.log("click", resp)
});To get a deeper understanding of this product, we’ve provided some references for both API and SDK integrations.
Generate an access token.
Integrate via our Java, PHP, or .NET SDKs.
Demo how easy it is to integrate our customizable solutions into your existing payment experience, and view transactions from multiple channels and regions in one place.
Our Drop-In UI solution is available for testing in our free Sandbox environment for registered users of this developer portal. Use our resources below to start testing.
Test different transaction outcomes with simulated cards or banks.
View, import, or fork our API collection in Postman.
View successful responses, HTTP status codes, action response data, and errors.
Below are value-added services you can enable for Drop-In UI.