Secure Elements
Extending PayU API
Retrieving Click to Pay Configuration
To use Click to Pay in the Secure Elements application, first verify that this payment method is available and retrieve its configuration for your POS. To do this, call the Retrieve Payment Methods endpoint, extending the request with an additional features parameter set to clickToPay.
- Production environment
- Sandbox environment
curl -X GET https://secure.payu.com/api/v2_1/paymethods?features=clickToPay \
-H "Authorization: Bearer 87ad751f-7ea5-4023-a16f-04b6647a07f5"
-H "Cache-Control: no-cache"
curl -X GET https://secure.snd.payu.com/api/v2_1/paymethods?features=clickToPay \
-H "Authorization: Bearer 87ad751f-7ea5-4023-a16f-04b6647a07f5"
-H "Cache-Control: no-cache"
In the response, in the payByLinks array in the card token object ("value"="c"), you will receive an additional clickToPay object containing all the necessary data to configure Click to Pay in the Secure Elements application.
{
"payByLinks":[{
"value":"c",
"name":"Card payment",
"brandImageUrl":"http://static.payu.com/images/mobile/logos/pbl_c.png",
"status":"ENABLED",
"minAmount": 50,
"maxAmount": 100000,
"features": {
"clickToPay": {
"clickToPayBrandImageUrl": "https://static.payu.com/images/mobile/logos/pbl_cpt_on.png",
"mastercard": {
"status": "ENABLED",
"dpaId": "mddctp12"
},
"visa": {
"dpaId": "visctp01",
"acquirerBIN": "123456",
"acquirerMerchantId": "MERCH01",
"status": "ENABLED"
}
}
}
}]
}
Extending Order Create Request
To create an order with a selected payment method, you need to add the payMethods section to the standard order request. The description of the payMethods object can be found in our API reference in the Create an Order section.
Using Card Data
After the process is completed, the Secure Elements application returns an object containing the card token. You need to extract the token from this object and pass it in the value field of the payMethod object, while the type field should be set to CARD_TOKEN.
{
"payMethods": {
"payMethod": {
"type": "CARD_TOKEN",
"value": "TOKD_1LOQUV5MMRNX70i7UXXXXXXXXX"
}
}
}
Using Card with Click to Pay
After the process is completed, pass the data returned by the Secure Elements application in the payMethod object. Depending on the card brand, fill in the appropriate fields in the clickToPay object:
- for Visa Click to Pay cards, the
srcCorrelationIdfield is required, - for Mastercard Click to Pay cards, the
srcCorrelationIdandsrcDigitalCardIdfields are required.
- Visa Card
- Mastercard Card
{
"payMethods": {
"payMethod": {
"type": "PBL",
"value": "c",
"clickToPay" : {
"visa": {
"srcCorrelationId": "123e4567-e89b-12d3-a456-426614174000"
}
}
}
}
}
{
"payMethods": {
"payMethod": {
"type": "PBL",
"value": "c",
"clickToPay" : {
"mastercard": {
"srcCorrelationId": "123e4567-e89b-12d3-a456-426614174000",
"srcDigitalCardId": "DCID-111"
}
}
}
}
}
For details on parameters, please refer to Create an Order section in PayU API Reference.
Javascript SDK
PayU provides a JavaScript SDK library that runs in the browser. The library contains methods and objects that can help with integrating selected PayU solutions, such as Secure Elements. You can also try the Secure Elements demo application, where you can test the integration with your own POS data and configure custom styles.
Usage Example
- Preview
- HTML
- CSS
- JavaScript
<script
type="text/javascript"
src="https://merch-prod.snd.payu.com/javascript/sdk"
></script>
<section class="container" id="secureElementsApp"></section>
.container {
background-color: #ffffff;
width: 450px;
margin: 20px auto;
border: 3px solid #666666;
padding: 20px;
display: block;
border-radius: 5px;
box-sizing: border-box;
}
let se;
document.addEventListener("DOMContentLoaded", function() {
se = SecureElements({dev: true});
se.render('#secureElementsApp', {
configuration: {
elements: ['cards'],
posId: '1234',
buyer: {
email: 'test@payu.com'
},
clickToPay: {
dpaName: 'Test DPA',
mastercard: {
dpaId: 'jI8iGo86'
},
visa: {
dpaId: 'jI8iGo86',
acquirerBIN: '498707',
acquirerMerchantId: 'jI8iGo86'
}
}
},
customization: {
lang: 'pl'
}
});
se.on('ready', () => {
// You can run any logic here after the application is loaded.
});
se.on('completed', (result) => {
// You can trigger any actions here after the payment process is completed.
});
});
- Production
- Sandbox
<script type="text/javascript" src="https://secure.payu.com/javascript/sdk"></script>
<script type="text/javascript" src="https://secure.snd.payu.com/javascript/sdk"></script>
SecureElements instance if the page protocol where the JS SDK is loaded is not https or file, and the page is not loaded from localhost: 127.0.0.1 or 0.0.0.0. During integration work, you can enable development mode using the options parameter.- Example
const secureElements = SecureElements();
querySelectorAll method.selector parameter was not provided or is empty.selector parameter is not a string.appendChild method or it is an input element).configuration option was not provided or has an invalid type.elements field in the configuration was not provided or has an invalid type.posId field in the configuration was not provided or has an invalid type.- Example
secureElements.render('#secureElementsApp', {
configuration: {
elements: ['cards'],
posId: '482413',
clickToPay: {
dpaName: "Sandbox Test",
mastercard: {
dpaId: 'jI8iGo86'
},
visa: {
dpaId: 'jI8iGo86',
acquirerBIN: "498707",
acquirerMerchantId: 'jI8iGo86'
}
},
buyer: {
email: 'test-email@test-domain.com'
}
},
customization: {
lang: 'pl',
},
});
| Możliwe wartości | |
|---|---|
| ready | Emitted when the application is displayed. |
| completed | Emitted when the payer completes the process in the application. |
event parameter.callback parameter is not a function.- Example
secureElements
.on('ready', function () {
// application is ready
})
.on('completed', function (body) {
// payer completed the process in the application
})
Options
Options for the render method.
Configuration
All parameters are validated for type and for correct values. If an optional parameter is unknown or invalid, it is ignored and a warning is logged in the browser console.
Allowed values:
cards.Must be a string containing only digits.
If this data is not provided, Click to Pay functionality is not available.
The following example uses Sandbox test data.
- Example
{
elements: ['cards'],
posId: '482413',
clickToPay: {
dpaName: "Sandbox Test",
mastercard: {
dpaId: 'jI8iGo86'
},
visa: {
dpaId: 'jI8iGo86',
acquirerBIN: "498707",
acquirerMerchantId: 'jI8iGo86'
}
},
buyer: {
email: 'test-email@test-domain.com'
}
}
Customization
All parameters are validated for type and for correct values. If a parameter is unknown or invalid, it is ignored and a warning is logged in the browser console.
en, pl. If not provided, the language is detected from the browser settings. If the language is not supported, en is used.- Example
{
lang: 'pl',
options: {
enableCardFormFieldsAutoJump: false
},
styles: {
body: {
margin: '10px'
}
}
}
true.true.false.false.Maximum length: 150 characters. Allowed characters:
0-9a-z-\s,"'Maximum length: 150 characters. Allowed characters:
-_ a-zA-Z0-9Must be a valid URL.
Allowed values:
"collection", "embedded-opentype", "opentype", "svg", "truetype", "woff", "woff2"Allowed values:
"normal", "italic", "oblique"Allowed values:
"normal", "bold", "lighter", "bolder", "inherit", "initial", "unset", 100, 200, 300, 400, 500, 600, 700, 800, 900Allowed values:
"normal", "condensed", "expanded", "ultra-condensed", "extra-condensed", "semi-condensed", "semi-expanded", "extra-expanded", "ultra-expanded"Must be a valid Unicode range definition and match:
U+([0-9a-f?]{1,6}|[0-9a-f]{1,6}-[0-9a-f]{1,6})(,U+([0-9a-f?]{1,6}|[0-9a-f]{1,6}-[0-9a-f]{1,6}))*Includes all properties from:
MarginStylesMatching pattern:
(\d{1,4}(.\d+)?|.\d+)(px|em|rem|%)Matching pattern:
#([0-9a-f]3|[0-9a-f]4|[0-9a-f]6|[0-9a-f]8)Examples:
#FFF, #abcdef, #AAA8, #88888810Allowed values:
"normal", "bold", "lighter", "bolder", "inherit", "initial", "unset", 100, 200, 300, 400, 500, 600, 700, 800, 900Contains all properties from:
MarginStyles, PaddingStyles, BorderStyles, FontStyles, BackgroundStyles, ShadowStyles, OutlineStylesContains all properties from:
MarginStyles, PaddingStyles, BorderStyles, FontStyles, BackgroundStyles, OutlineStylesContains all properties from:
MarginStyles, PaddingStyles, BorderStyles, FontStyles, BackgroundStyles, OutlineStyles, and the following:Contains all properties from:
MarginStyles, PaddingStyles, FontStyles, OutlineStyles, and:Contains all properties from:
MarginStyles, PaddingStyles, FontStyles, OutlineStyles, and:Contains all properties from:
MarginStyles, PaddingStyles, BorderStyles, FontStyles, OutlineStyles.Allowed values:
"dotted", "dashed", "solid"Maximum length: 150 characters. Allowed characters:
0-9a-z-\s,"'Allowed values:
"none", "underline", "overline", "line-through"Allowed values:
"left", "right", "center", "justify", "start", "end"Events
The application emits events to which you can attach your own callback function using the on method.
| Field | Description |
|---|---|
type | Response type:
|
details | Object containing detailed response data. |
details object| Field | Description | Only for |
|---|---|---|
brand | Selected card type: visa or mastercard. | |
panLastFour | Last 4 digits of the card number. | |
panExpirationMonth | Card expiration month | |
panExpirationYear | Card expiration year | |
token | Card token. Use this token to complete the payment. | cardToken |
artUri | Optional parameter. Contains the URL of the card image. | clickToPay |
srcDigitalCardId | Card identifier in Click to Pay. Use this identifier to complete the payment. | clickToPay |
srcCorrelationId | Transaction identifier in Click to Pay. Use this identifier to complete the payment. | clickToPay |
The following example contains test data.
- Using an entered card
- Using a card with Click to Pay
{
"type": "cardToken",
"details": {
"brand": "visa",
"panLastFour": "1111",
"panExpirationMonth": "02",
"panExpirationYear": "2029",
"token": "TOKD_1LOQUV5MMRNX70i7UXXXXXXXXX"
}
}
{
"type": "clickToPay",
"details": {
"brand":"mastercard",
"panLastFour":"8785",
"panExpirationMonth":"12",
"panExpirationYear":"2029",
"srcDigitalCardId":"XXXXXXXXXOGsrGz0lFDMMA000000000000US",
"srcCorrelationId":"4f723be7.e0c2a619-d2bb-7590-89bc-e632e06b59cd",
"artUri":"https://sbx.assets.mastercard.com/card-art/combined-image-asset/HIGH-MASK-3x.png"
}
}