paymentech-ui
Allow your projects to take payments in as few lines of code possible.
Credit/Debit cards supported only.
Testing Credit Cards
Usage
This component requires no dependencies, use the <paymentech-ui>
HTML custom element where you wish to display. Ensure to import the script on your page.
Consume the payload
event, which gets emitted when a valid payment method is chosen and completed by the user.
<paymentech-ui data-config="{{ { "token": "", "environment": "" } }}"></paymentech-ui>
<script src="https://uicomponent.live.pci.cavu-tech.com/payments.js"></script>
<script>
el = document.querySelector('paymentech-ui')
function makePayment (nonce) {
fetch('https://example.com/checkout')
.then(response => response.json())
.then(result => {
// Pass the result through to the component.
// Expected format:
// {
// success: Boolean,
// verification: {
// status: String("processor_declined|processor_declined"),
// gatewayRejectionReason: String
// }
// }
el.dispatchEvent(new CustomEvent('complete', { detail: result }))
if (result.success) {
alert('Payment successful')
} else {
el.dataset.error = 'There was an error'
}
})
}
el.addEventListener('payload', function(event) {
console.log(event.detail)
// { nonce: "kz4r7k_7c2fsp_4qyf6q_wb5vmy_6y8", ... }
makePayment(event.detail.nonce)
})
</script>
Debugging
To view debugging in DevTools Console, enable the debug key on LocalStorage.
localStorage.debug = "paymentech-ui:*"
Sandbox Example
Example cards
Card Number | Card Type | Response |
---|---|---|
4788250000028291 | VISA | Valid |
5454545454545454 | MasterCard | Valid |
371449635398431 | American Express | Valid |
More information, see CPS Test Conditions
API Options
Properties and events that can be used to interface with this Web Component.
Properties
Property | Attribute | Type | Default | Description |
---|---|---|---|---|
config | data-config | { token: null; environment: null; } | {"token":null,"environment":null} | Object that contains both Paymentech tokenization key token that authorizes to render a predefined payment iframe.And the Environment status environment , values must be either test or live .As an integrator of this component, This object is returned from the paymentGateway/client-config payments api endpoint, via your server layer.Learn more about uiD's |
configurable | boolean | |||
enumerable | boolean | |||
errorMessage | data-error-message | string | "" | Display a Paymentech related error message, ideal for server side errors when attempting transactions. |
showTooltip | showTooltip | boolean | false |
Events
Event | Description |
---|---|
complete | Dispatch this event to the component when you've successfully completed a transaction or when the transaction has failed from your server. |
error | Handle the human readable display of a Server Side error, and allow the user to change payment method. List of all Paymentech errors. |
payload | Dispatched when the payment is payment method has been provided |
ready | Dispatched when the payment iframe has rendered successfully ready for input. |
userError |
CSS Custom Properties
Property | Description |
---|---|
--border | Controls the main theme colors for borders not contained within the iframe. (default: #E2E8EB) |
--primary | Controls the main theme colors for elements not contained within the iframe. (default: #032f61) |