API – Developers Docs API – Developers Docs
  • Cyberpac
  • Addon Payments
  • POS integrated Payments
  • SpanishSwitch to Spanish
API – Developers Docs API – Developers Docs
API – Developers Docs
  • Cyberpac
  • Addon Payments
  • POS integrated Payments
  • SpanishSwitch to Spanish
Addon Payments
  • Folder icon closed Folder open iconIntegrations
    • Start integrating
      • Welcome for CMS integrations
      • Introduction to integrations: Hosted, Host2Host and JavaScript
    • CMS Plugins
      • Prestashop
        • PrestaShop installation and set-up
        • Common mistakes with PrestaShop installation and set-up
        • Managing transactions with PrestaShop
      • WooCommerce
        • WooCommerce installation and set-up
        • Common mistakes with WooCommerce installation and set-up
        • Managing transactions with WooCommerce
      • Magento
        • Magento installation and set-up
        • Common mistakes with Magento installation and set-up
        • Managing transactions with Magento
      • Salesforce
        • Salesforce Commerce Cloud
    • Cards
      • Hosted Integration
      • Host2Host Integration
      • JavaScript Integration
      • PSD2 and 3DSv2
      • PCI DSS Certification
    • Complement your integration
      • Additional features
      • Managing notifications
      • Complement your JavaScript integration
      • Customizing the payment experience
      • Going Live (Switching to Production)
      • Encryption, signature and sending the request
      • Redirecting customer
    • Payment methods
      • Apple Pay
      • PayByBank
      • Bizum
      • PeX
      • Quix
    • Resources
      • Glossary
      • Payment solutions
      • Response codes
      • State and country codes
      • Currency codes
      • ID document type codes and validations
      • Test cards
    • Tools
      • Postman
      • SDKs
  • Folder icon closed Folder open iconBackOffice Portal
    • Pay by link guide
    • Search operations
    • Creating users
  • Folder icon closed Folder open iconFrequently Asked Questions

Complement your JavaScript integration

On this page, you can complement and expand on the information in the JavaScript Integration guide. Click on the link to learn how to integrate Addon Payments this way.  

Transaction flow

Below is a diagram of the whole JavaScript integration process.

The flow is as follows: 

  1. The merchant performs a AuthToken request, passing off some information related to the merchant and the customer. Refer to JS AuthToken request for more information.
  2. AddonPayments returns a unique and single used AuthToken which is linked to the sent data.
  3. At this time, the merchant could send the AuthToken to the customer browser and start renreding the AddonPayments JS cashier.
  4. Using the AuthToken the merchant render the cashier payment form. Refer to Rendering cashier for more information and available use cases.
  5. The customer filled in all the customer or payment information and submit the form.
  6. AddonPayments recollets the payment info and generates an unique prepayToken which is linked to the original AuthToken requested values. Once the token is generated, AddonPayments will perform a call to merchantPrePayCallback method that is set in the step 4. For more information, refer to PrePayToken section.
  7. Send the prepayToken to the merchant backend site.
  8. Build and perform the payment charge request passing off all the required payment information. Remember that it requires to send the prepayToken in the request. Refer to Charge operation for more information.
  9. AddonPayments performs the payment.
  10. AddonPayments gets the Payment Solution response.
  11. AddonPayment returns the charge response to the merchant. Depending the response, it could require some customer redirection.
  12. Payment is completed because it reached a final status. Refer to Response section for more information.
  13. Payment requires a customer redirection, so the merchant has to redirect the customer to the third party url, passed off in the response. Refer to Charge response section for more information.
  14. Customer interacts with the payment solution page.
  15. Payment Solution informs the status of the payment.
  16. AddonPayment sends a notification to the merchant, using the statusUrl field of the request.
  17. Merchant shows the final payment page to the customer.

      Environments: Staging and Production

      Addon Payments has two (2) separate operating environments:

      • Staging environment:
        • This is the first environment you will use.
        • There is a list of cards to use for testing the system, creating transaction simulations of various operations, authentication types (frictionless, challenge) and results (authorized, declined).
        • This will allow you to make sure that the different situations are handled properly by your integration.
        • Real cards and accounts don’t work.
      • Production Environment:
        • In this environment, transactions are real.
        • You can only use real, operational cards and accounts.

      This is a table with the endpoints to send the request to, whether authorization or payment, depending on the environment you are using: 

      RequestEnvironmentURL
      Request /authStaginghttps://epgjs-mep-stg.addonpayments.com/auth
      Request /chargeStaginghttps://epgjs-mep-stg.addonpayments.com/charge/v2
      Request /authProductionhttps://epgjs-mep.addonpayments.com/auth
      Request /chargeProductionhttps://epgjs-mep.addonpayments.com/charge/v2

      Below is a table with the AP library for JavaScript that you need to import and the call to set up the base URL for the payment gateway.

      • You have to add a <script> HTML element with the route to the AP JS library to your ecommerce platform payment page. This route must include the version of the library to load. We currently recommend using version 4.0.0. 
      FunctionEnvironmentURL
      Import the Addon Payments JS libraryStaginghttps://epgjs-rendercashier-stg.addonpayments.com/js/public/epgjs-[versión]-min.js
      Set the base URL for the payment gatewayStaginghttps://epgjs-web-stg.addonpayments.com/
      Import the Addon Payments JS libraryProductionhttps://epgjs-rendercashier.addonpayments.com/js/public/epgjs-[versión]-min.js
      Set the base URL for the payment gatewayProductionhttps://epgjs-web.addonpayments.com/

      Getting the authToken

      The first step in the JavaScript integration is to get the authToken so we can render the cashier. A request must be sent with at least the info shown below: 

      				
      					{   
          "merchantId": "12345",
          "merchantKey": "dd0bc115-6f8f-4e65-9447-e06862eb62ec",
          "productId": "123450001",
          "currency": "EUR",
          "country": "ES",
          "customerId": "customer25879",
          "operationType": "debit"
      }
      				
      			
      				
      					curl --location 'https://epgjs-mep-stg.addonpayments.com/auth' \
      --header 'Content-Type: application/json' \
      --data '{
          "merchantId": "12345",
          "merchantKey": "dd0bc115-6f8f-4e65-9447-e06862eb62ec",
          "productId": "123450001",
          "currency": "EUR",
          "country": "ES",
          "customerId": "customer25879",
          "operationType": "DEBIT"
      }'
      				
      			

      If the request is valid, Addon Payments will return an “authToken” for you to render the cashier on the frontend of your page. If the request isn’t valid, you will get a message like you see on the second tab:

      				
      					{
          "authToken": "50fe7cab-63c4-4197-9484-50f9a0792f8b"
      }
      				
      			
      				
      					{
          "error": true,
          "errorMessage": "Invalid merchant id or merchant key",
          "errorCode": 400
      }
      
      				
      			

      Your platform must store this code to continue to the next step. The authorization tokens received have the following characteristics:

      • Valid for 30 minutes.
      • It can be used several times to link to the payment gateway.

      Parameters of the authToken request

      The type shows whether the element is Required (R) or Optional (O).

      FieldFormatTypeDescriptionExample
      merchantIdWhole number
      4~7 digits
      RYour merchant’s ID on the AP platform. Provided by Support in the welcome email. It is the same for both environments14983
      merchantKeyAlphanumeric
      UUID Format
      RThe JavaScript password. Used to verify the request is legitimate. For the staging environment, it comes in the welcome email. For production environments, recover it from the BackOffice.67a33d37-64b9-408e-a1b7-cef28ef94970
      productIdWhole number
      6~11 digits
      RProduct ID created on your AP merchant. You’ll find it in the welcome email.149830
      currencyAlphabetical
      3 characters
      ISO-4217.3
      RCurrency of the transactionEUR
      countryAlphabetical
      2 characters
      ISO 3166-1 alfa-2
      RCountry from which the transaction is sentES
      customerIdAlphanumeric
      Max 80 characters
      RCustomer ID in your e-commerce platform.
      – To save the customer’s card token, use the “forceTokenRequest” parameter, with value “true” to save the token and “false” not to.
      – To show or hide the option to remember the customer’s card, use the “showRememberMe” parameter, with value “true” to show it and “false” to hide it.
      A34623
      operationTypeAlphanumeric
      Max 45 characters
      RShows type of operation to carry out. Valores admitidos:
      – debit (default): Payment transaction. That is, cash travels from the customer’s account to the merchant.
      – credit: Deposit transaction to the customer’s account. That is, cash travels from the merchant to the customer’s account. For example, in the payment of a prize. Not to be confused with returns. These have their own type of transaction.
      debit
      showRememberMePossible values:
      – true: Displays the “Remember Me” checkbox, which the customer can select (or not) to save the card token.
      – false: Does not display the “Remember Me” checkbox. The card token will only be saved if “forceTokenRequest” is set to true.
      OShows or hides the “Remember Me” checkbox, allowing the customer to choose whether to save the card token.true
      forceTokenRequestBoolean
      – true
      – false
      OIndicates whether to save the customer’s card token. Use “false” if you don’t want to save the card. If this value is “true” but the customer does not check the “Remember Me” box, the token will not be saved.false

      Rendering the cashier on your frontend

      After you get the “authToken” you can render the cashier on your frontend. Remember, the cashier can’t be rendered on a localhost and you must authorize the domain from the Addon Payments dashboard. 

      When you render the cashier, you can choose which payment solutions to show. You can also choose the type of cashier you want to render. 

      Below is a simple example showing how to render the cashier with all the payment methods available:

      				
      					<!DOCTYPE html>
      <html lang="en">
      <head>
          <meta charset="UTF-8">
          <title>JS render cashier</title>
          <style>
              #render-cashier {
                  width: 350px;
                  margin-top: 100px;
                  border: 1px solid #ccc;
                  padding: 20px;
                  text-align: center;
              }
          </style>
      </head>
      <body>
          <div id="render-cashier"></div>
          <script src="https://epgjs-rendercashier-stg.addonpayments.com/js/public/epgjs-4.0.0-min.js"></script>
          <script>
              var authtoken = "bdae356b-0236-47db-bbea-24de03168195"; // Add here your authToken
              function prePayCallback(prepayData) {
                  // Show prepayToken This is just for example purposes only and should not be shown to your customer
                  alert(JSON.stringify(prepayData, null, 2));
              }
              function displayingMessageOnButtonClick() {
                  EPGJS_COMM.setEpgBaseUrl('https://epgjs-web-stg.addonpayments.com/');
                  EPGJS.renderIntegratedCashier(authtoken, 'render-cashier');
                  EPGJS_COMM.setMerchantPrePayCallback(prePayCallback);
              }
              window.onload = displayingMessageOnButtonClick;
          </script>
      </body>
      </html>
      				
      			

      You can check the functions, required or optional, in this section.

      This will allow you to render the cashier in the frontend currency so the cashier can make payment, as you see in the picture below.

      When the customer clicks on the payment button, Addon Payments will return an object with the “prepayToken” so you can send the payment request.

      Function call for different types of cashiers:
      • Cashier with all the payment solutions:
      EPGJS.renderIntegratedCashier(authToken, 'render-cashier');
      • Cashier with only one payment solution
      EPGJS.renderIntegratedCashier(authtoken, 'render-cashier', 'payment solution');

      Getting the prepayToken

      If the customer enters card or account details, your ecommerce platform will receive a JS object with the token to prepare payment (prepayToken). Here is an example of a “prePayToken”:

      "prePayToken": "8862abf9-ca5a-49da-9527-1e3163e64954"

      Your platform must store this code to continue to the next step. It is the code that gives the customer authorization to send the charge. The authorization tokens received have the following characteristics:

      • Valid for 30 minutes.
      • It can only be used to authorize payment once.

      DIY (Do It Yourself)

      This allows the cashier elements to be rendered inside the merchant’s HTML elements.

      The customized payment form option allows merchants to choose the appearance and design for each element of the cashier.

      Here are the steps to create a cashier:

      1. Add a < div > element to your website and define < divs > for each one of the components on the payment form you want to use.
      2. Define a variable that assigns the <div> IDs you created in the corresponding elements on the Addon Payments form.
      3. Call setDIY(string) method and give the variable you created in the previous step.

      Below we’ll look at these steps in more detail: 

      Step one: Define the HTML

      Define in the HTML a form with < div > elements with IDs for each of the components on the payment form. 

      The following example shows the HTML to create a form that accepts credit card details (card number, cardholder’s name, expiry date and CVV):

      				
      					<div id="diy-container">
          <form id="diy-custom-form" >
            cardNumber:
              <div id="diy-pan"></div>
            Ch Name:
              <div id="diy-chName"></div>
            ExpDate:
              <div id="diy-expdate"></div>
            Cvv:
              <div id="diy-cvnNumber"></div>
              <button id="pay-btn" type="submit">Proceed</button>
          </form>
        </div>
      				
      			

      Step two: Create a JavaScript variable

      Define in JS a variable with a JSON that assigns the form IDs with the fields created in the previous step:

      				
      					var json='{
          "epgjs-cashier-quickpay-form":"id_formulario_tarjeta",
          "chName":"campo_nombre_titular",
          "cardNumber":"campo_numero_tarjeta",
          "expDate":"campo_fecha_caducidad",
          "cvnNumber":"campo_cvv",
          "epgjs-cashier-quickpay-form-button-CreditCards":"boton_pago"
      }';
      				
      			

      Step three: Call the function

      Call the JS library function “setDiy()” with the JSON we created as the parameter:

      				
      					EPGJS_DIY.setDiy(JSON.parse(json));
      				
      			

      Step four: Rendering the cashier

      Call the JS library function “renderQuickDepositByPaymentSolution()” with the following parameters:

      • The authToken received from AP.
      • The form ID created in point 1.
      • The card payment solution set up on your merchant.
      				
      					EPGJS.renderQuickDepositByPaymentSolution(authToken,'id_formulario_tarjeta','creditcards');
      				
      			

      Charge call

      With the “prepayToken”, you can send the payment/charge request. Below is a sample request and response with the basic fields. 

      Remember that the parameters change depending on the payment method and use cases.

      This is a basic example of a card payment: 

      				
      					{
          "merchantId": "12345",
          "merchantTransactionId": "00000001",
          "amount": "10.00",
          "apiVersion: "5",
          "currency": "EUR",
          "country": "ES",
          "customerId": "000001",
          "paymentSolution": "creditcards",
          "productId": "123450001",
          "statusURL": "https://micomercio.com/recepcion_notificacion.php?tipo=redireccion",
          "successURL": "https:// micomercio.com/url-ok.php",
          "errorURL": "https:// micomercio.com/url-ko.php",
          "cancelURL": "https:// micomercio.com/url-cancelacion.php"
      }
      				
      			
      				
      					curl --location --request POST 'https://epgjs-mep-stg.addonpayments.com/charge/v2' \
      --header 'Content-Type: application/json' \
      --header 'prepayToken: 8862abf9-ca5a-49da-9527-1e3163e64954' \
      --data-raw '{
          "merchantId": "12345",
          "merchantTransactionId": "00000001",
          "amount": "10.00",
          "apiVersion: "5",
          "currency": "EUR",
          "country": "ES",
          "customerId": "000001",
          "paymentSolution": "creditcards",
          "productId": "123450001",
          "statusURL": "https://micomercio.com/recepcion_notificacion.php",
          "successURL": "https://micomercio.com/url-ok.php",
          "errorURL": "https://micomercio.com/url-ko.php",
          "cancelURL": "https://micomercio.com/url-cancelacion.php"
      }'
      				
      			

      Below you have the charge parameters. Plus, we recommend you visit our 3DSecure section to add additional fields to the payment process. These optional data fields enrich the payment request and can facilitate the authentication process.

      FieldFormatTypeDescriptionExample
      prepayTokenAlphanumeric
      UUID Format
      RIt is sent in the request header. AP returns this reference after the customer enters their details in the JS payment form. It is the reference that links to the customer’s card or account details for JavaScript integration.97fe3726-adb1-4e24-9fb8-92593a75ae74
      merchantIdWhole number
      4~7 digits
      RYour merchant’s ID on the AP platform. Provided by Support in the welcome email. It is the same for both environments14983
      productIdWhole number
      6~11 digits
      RProduct ID created on your AP merchant. You’ll find it in the welcome email.149830
      apiVersionNumerical
      Accepted value:
      5
      RVersion of the Addon Payments gateway API through which the transaction is to be processed.5
      paymentSolutionAlphanumeric
      Max 45 characters
      RName of the payment solution to process the transaction. IMPORTANT: If you don’t want all the payment solutions you have available to be shown, do NOT send this parameter.creditcards
      operationTypeAlphanumeric
      Max 45 characters
      RShows type of operation to carry out. Eligible values:
      – DEBIT(default): Payment transaction. That is, cash travels from the customer’s account to the merchant.
      – CREDIT: Deposit transaction to the customer’s account. That is, cash travels from the merchant to the customer’s account. For example, in the payment of a prize. Not to be confused with returns. These have their own type of transaction.
      debit
      merchantTransactionIdAlphanumeric
      Max 45 characters
      RThis is the unique identifier of the merchant’s transaction. It is used by your platform to link the notifications received with the customer’s order.order_91684
      amountNumerical with decimals
      0~1000000.00
      RAmount of the transaction. If the amount has decimals, the separator is a dot (.). The separator cannot be included in the thousands.127.5
      currencyAlphabetical
      3 characters
      ISO-4217.3
      RCurrency of the transactionEUR
      countryAlphabetical
      2 characters
      ISO 3166-1 alfa-2
      RCountry from which the transaction is sentES
      customerIdAlphanumeric
      Max 80 characters
      RCustomer ID in your e-commerce platform.
      – To save the customer’s card, use the “forceTokenRequest” parameter, with value “true” to save the token and “false” not to.
      – To show or hide the option to remember the customer’s card, use the “showRememberMe” parameter, with value “true” to show it and “false” to hide it.
      A34623
      statusURLAlphanumeric (characters allowed in URL)
      Max. 2048 characters
      RURL of your e-commerce platform where AP will send the notification with the status of the transaction. If it is sent in the request, it will take priority over the one configured in the Addon Payments BackOffice Portal. If it is not sent in the request, the customer will be redirected to the URL configured in the administration module.https://www.example.com/status
      successURLAlphanumeric (characters allowed in URL)
      Max. 2048 characters
      RURL of your platform to which the customer is redirected if the transaction is authorized. If it is sent in the request, it will take priority over the one configured in the Addon Payments BackOffice Portal. If it is not sent in the request, the customer will be redirected to the URL configured in the administration module.https://www.example.com/success
      errorURLAlphanumeric (characters allowed in URL)
      Max. 2048 characters
      RURL of your platform to which the customer is redirected if the transaction is declined. If it is sent in the request, it will take priority over the one configured in the Addon Payments BackOffice Portal. If it is not sent in the request, the customer will be redirected to the URL configured in the administration module.https://www.example.com/error
      cancelURLAlphanumeric (characters allowed in URL)
      Max. 2048 characters
      RURL of your platform to which the customer is redirected if the transaction is cancelled during the payment process. If it is sent in the request, it will take priority over the one configured in the Addon Payments BackOffice Portal. If it is not sent in the request, the customer will be redirected to the URL configured in the administration module.https://www.example.com/cancel
      awaitingURLAlphanumeric (characters allowed in URL)
      Max. 2048 characters
      RURL of your platform to which the customer is redirected if the transaction is pending processing. If it is sent in the request, it will take priority over the one configured in the Addon Payments BackOffice Portal. If it is not sent in the request, the customer will be redirected to the URL configured in the administration module.https://www.example.com/awaiting
      customerEmailAlphanumeric
      Max 100 characters
      R*Cardholder’s email.

      European merchants: required for SCA
      *customerEmail or telephone must be sent. Only 1 of those paramaters is mandatory
      correo@ejemplo.com
      telephoneAlphanumeric
      Max 45 characters
      R*International prefix + Cardholder’s phone number. Can be mobile, work or home phone number.

      European merchants: required for SCA
      *customerEmail or telephone must be sent. Only 1 of those paramaters is mandatory
      34600600600
      languageISO 639-1 codeOLanguage to be displayed on the customer checkout. Currently, it is only available in Spanish (ES) and English (EN).EN
      referenceIdAlphanumeric
      12 characters
      OVariable reference for merchants requiring FB500 reconciliation files.SM1258X795WW
      merchantParamsKey1:Value1;Key2:Value2;KeyN:ValueN
      Max 500 characters
      OParameters that are sent to modify the mechant configuration or the processing of a transaction.
      They are received back within the tag.
      Does not support special characters
      name:pablo;surname:ferrer;clientid:12345
      printReceiptBooleanOShow the end customer a receipt in the redirection process optional type.True
      autoCaptureBooleanOEstablishes whether the transaction will be an authorization or pre-authorization. In the latter case, it requires a subsequent capture or release by the merchant.True
      typeAlphanumeric:
      MOTO
      ECOM
      OSets whether the payment request is e-commerce or MO/TO type. If not included, it is e-commerce type by default.ECOM
      descriptionAlphanumeric
      Max 1000 characters
      ODescription of the transaction.Product description
      cityAlphanumeric
      Max 100 characters
      OCity of cardholder.

      European merchants: optional for SCA
      Barcelona
      chCountry2 characters
      ISO 3166-1 alfa-2
      OISO 3166-1 alfa-2 code of cardholder’s country.

      European merchants: optional for SCA
      ES
      addressLine1Alphanumeric
      Max 250 characters
      OFirst line of cardholder’s address.

      European merchants: optional for SCA
      Calle Romero 123
      addressLine2Alphanumeric
      Max 50 characters
      OCradholder’s zip code.

      European merchants: optional for SCA
      08001
      stateAlphanumeric
      Max 45 characters
      OState or province of the cardholder.

      European merchants: optional for SCA
      Barcelona

      Response

      This is the response to the payment request in the previous example: 

      				
      					<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <payfrex-response operation-size="3">
      	<message>WorkFlow has finished successfully, for transaction Id: 7711867</message>
      	<operations>
      		<operation sorted-order="1">
      			<amount>10.00</amount>
      			<currency>EUR</currency>
      			<merchantTransactionId>00000001</merchantTransactionId>
      			<message>Exemptions has been removed</message>
      			<operationType>DEBIT</operationType>
      			<payFrexTransactionId>7711867</payFrexTransactionId>
      			<service>TRA</service>
      			<status>SUCCESS</status>
      		</operation>
      		<operation sorted-order="2">
      			<amount>10.00</amount>
      			<currency>EUR</currency>
      			<merchantTransactionId>00000001</merchantTransactionId>
      			<message>3dsv2 - processed</message>
      			<operationType>DEBIT</operationType>
      			<payFrexTransactionId>7711867</payFrexTransactionId>
      			<paymentDetails>
      				<cardNumberToken>5774655584592227</cardNumberToken>
      				<extraDetails/>
      			</paymentDetails>
      			<service>3DSv2</service>
      			<status>SUCCESS3DS</status>
      		</operation>
      		<operation sorted-order="3">
      			<amount>10.00</amount>
      			<currency>EUR</currency>
      			<details>{"resultCode":"00000","resultDescription":"OK","values":{"rfTransactionCurrency":"EUR","rfRTS":"355534686 790190 845433 231030160823","rfContactlessLogo":"false","rfOperationType":"Settle","rfAuthMode":"On","rfDataEntryMode":"Manual","rfCardHolderVerificationMode":"No","rfFuc":"355534686","rfTerminalID":"00000500","rfProcessor":"Redsys","rfMerchantName":"Pruebas Addon 25","rfMerchantCity":"BARCELONA","rfMerchantPostalCode":"08014","rfMerchantAddress":"GRAN VIA DE LES CORTS CATALANE, 159 PLANTA 7","rfMaskedPan":"************2227","rfOperationDateTime":"30/10/23 16:08:23","rfTerminalOperationNumber":"1197","rfAuthNumber":"150515","rfTransactionAmountCurrency":"10,00 EUR","rfProcessorMessage":"","rfPrintSignatureBox":"false","rfCardPresent":"true","rfReferenceId":"1197","posTransactionToken":"{\"pucIdMsg\":\"1200\",\"pucP3ProcessCode\":\"000000\",\"pucP4OriginalAmount\":\"000000001000\",\"pucP11TransactionNumber\":\"845433\",\"pucP12LocalDateTime\":\"231030160823\",\"pucP22ServicePointData\":\"1U00506K3000\",\"pucP38AuthNumber\":\"150515\",\"pucP39ActionCode\":\"000\",\"pucP53SecurityControlInfo\":\"0102000001000000\",\"pinpadId\":\"1440\",\"pinpadAcquirerId\":\"00000500\",\"pinpadManufacturer\":null,\"pinpadModel\":null,\"pinpadSerialNumber\":null,\"pinpadSoftwareName\":null,\"pinpadSoftwareVersion\":null,\"pinpadKernelEmv\":null,\"pinpadVccStrip\":null,\"pinpadVerPup\":null,\"pinpadPciStage\":null,\"pinpadVerEmvParams\":null,\"pinpadEmvType\":null,\"pinpadCapabilities\":null,\"pinpadLanguage\":null,\"transactionType\":\"O\",\"transactionContactless\":\"0\",\"transactionDcc\":\"0\",\"transactionDccComission\":null,\"transactionDccExchangeRate\":null,\"transactionDccMarkUp\":null,\"transactionDccEntity\":null,\"transactionDccBceExchangeRate\":null,\"transactionDccBceMarkUp\":null,\"transactionPanSequenceNumber\":null,\"transactionTerminalOperationNumber\":\"1197\",\"transactionResponseCode\":null,\"transactionCurrency\":\"978\",\"transactionFuc\":\"355534686\",\"cardMaskedPan\":\"************2227\",\"cardAid\":null,\"cardDdfName\":null,\"cardApplicationLabel\":null,\"cardCypherData\":null}","OperationResult":"000"},"threeDsProtocolVersion":"2.2.0"}</details>
      			<merchantTransactionId>00000001</merchantTransactionId>
      			<message>Success 'Settle' operation</message>
      			<operationType>DEBIT</operationType>
      			<optionalTransactionParams/>
      			<payFrexTransactionId>7711867</payFrexTransactionId>
      			<paySolTransactionId>355534686 790190 845433 231030160823</paySolTransactionId>
      			<paymentDetails>
      				<cardHolderName>Pruebas Visa Frictioless</cardHolderName>
      				<cardNumber>490727****2227</cardNumber>
      				<cardNumberToken>5774655584592227</cardNumberToken>
      				<cardType>VISA/CREDIT</cardType>
      				<expDate>1234</expDate>
      				<extraDetails>
      					<entry>
      						<key>cardCategory</key>
      						<value>Not Available</value>
      					</entry>
      					<entry>
      						<key>rememberMe</key>
      						<value>true</value>
      					</entry>
      				</extraDetails>
      				<issuerBank>SERVIRED MASTERCARD INTERNACIONAL</issuerBank>
      				<issuerCountry>ES</issuerCountry>
      			</paymentDetails>
      			<paymentMethod>19900</paymentMethod>
      			<paymentSolution>caixapucpuce</paymentSolution>
      			<status>SUCCESS</status>
      		</operation>
      	</operations>
      	<optionalTransactionParams/>
      	<status>SUCCESS</status>
      	<workFlowResponse>
      		<id>31380</id>
      		<name>debit creditcards (TRA)</name>
      		<version>0</version>
      	</workFlowResponse>
      </payfrex-response>
      				
      			

      JavaScript integration functions

      In the JavaScript library, you have several functions you can call. The most important functions (required) have already been covered in previous sections. Below you will find more detailed information:

      Define the base URL for the payment gateway (required)
      To define it: EPGJS_COMM.setEpgBaseUrl(‘[base URL]’) Set up the AP URL the linked form will send the customer’s data to, with [URL base] being one of the following URLs, depending on the environment you are using:
      • Staging: https://epgjs-web-stg.addonpayments.com/
      • Production: https://epgjs-web.addonpayments.com/
      This is an example of the function call for the Staging environment:
      EPGJS_COMM.setEpgBaseUrl('https://epgjs-web-stg.addonpayments.com/');
      Call the form link function (required)

      To define it: EPGJS.renderIntegratedCashier(authToken, ‘id. div’, ‘payment solution’);

      With all the previous parameters defined, we proceed to call the JS library function to load the form on your platform’s payment page. The parameters for the function “renderIntegratedCashier()” are:

      1. authToken: Authorization token received.
      2. id. div: ID for the <div> element on the payment page of your platform. 
      3. payment solution (optional): Payment solution the form will be limited to.
        • Only if you have opted for the single payment solution cashier.

      If all the parameters in this point and the previous ones are correct, AP will show the payment form in the <div> element sent in the function call.

      Once the customer has entered their card or account details, AP will generate a pre-pay token (prepayToken).

      Object { prepayToken: "e686282e-fad0-45d7-84b6-eff5bf0c126d", action: "quickpay" }
      Define the function to receive the pre-payment token (required)
      To define it: EPGJS_COMM.setMerchantPrePayCallback([receive function]) It is used to tell the AP form which function it should call, with the parameter being a JS object that contains the pre-pay token (prepayToken). Your ecommerce platform must have a function programmed on the site to link to the payment form that collects and saves the token to proceed to authorization and settlement of payment. The function can have any name you want, as the name is sent as a parameter [receive function] in the call to the AP JS library. For example, you can set a function “receive_prepayToken” on your platform programmed to receive the object with the pre-pay token and send it to your platform server to be used later. The following example defines the function to receive and show on screen the pre-pay token received in a JS object from AP (this example is for reference only. The customer shouldn’t be able to see the token received):
      function receive_prepayToken(object){
      alert(object.prepayToken);
      return true;
      };
      With this function defined previously, the function call to the JS library will be as follows:
      EPGJS_COMM.setMerchantPrePayCallback(receive_prepayToken);
      Define the form limitation to saved accounts (optional)
      To define it: EPGJS_COMM.setOnlyRegisteredAccounts([boolean value]) Indicating with [boolean value] if the form should accept new cards and payment accounts (default) or limit customer operations to the cards and/or accounts already saved in the customer ID.
      • false (default): The payment form allows you to use both cards the customer has saved previously and enter, use and save new cards or accounts.
      • true: The payment form limits use to the cards and accounts already saved for the customer ID. The customer can’t use or save any new cards or accounts.
      Sample function call to limit customer operations to saved cards and accounts:
      EPGJS_COMM.setOnlyRegisteredAccounts(true);
      Functions related to the CSS style (optional)
      Below we have the auxiliary functions related to the CSS style for the payment gateway.  1. Get the CSS class Returns the class(es) for the current CSS theme that apply to the key sent
      • Function: EPGJS_STYLE.getClass(object)
      • Parameter: Object to search for.
      • Use: Getting the classes associated with the class of the object to customize the JS cashier.
      2. Get the active CSS theme Returns the keys for the active CSS theme.
      • Function: EPGJS_STYLE.getCssTheme()
      • Parameters: None.
      • Use: Returns the transformation of keys if a theme is applied to the rendering.
      • Values returned: JSON with the mapping between AP classes and those of the theme chosen by the merchant using the EPGJS_STYLE.setCssTheme(Theme) function.
      3. Apply CSS theme Applies one of the two themes sent as a parameter to the payment gateway. If this function isn’t called, the AP form will use the JS default theme.
      • Function: EPGJS_STYLE.setCssTheme(theme)
      • Parameters:
        • EPGJS_STYLE.DEFAULT_THEME (JS default theme)
        • EPGJS_STYLE.DEFAULT_BOOTSTRAP_THEME (JS Bootstrap theme)
      • Use: Applies one of the two available themes to the payment gateway.
      • Values returned: None.
      You can get a list of the classes in the theme by executing the following JavaScript command:
      console.log(theme);
      — List the classes of the theme EPGJS_STYLE.DEFAULT_THEME —console.log(EPGJS_STYLE.DEFAULT_THEME);
      — List the classes of the theme EPGJS_STYLE.DEFAULT_BOOTSTRAP_THEME —
      console.log(EPGJS_STYLE.DEFAULT_BOOTSTRAP_THEME);
      Validate PAN
      To define it: EPGJS.getValidPan() Notify if the PAN for the card entered is valid. Meaning, whether it passes the Luhn algorithm.
      • Parameters: None.
      • Use: If the card isn’t valid, the payment transaction isn’t sent for authorization. 
      • Values returned:
        • true: The card PAN is valid.
        • false: The card PAN isn’t valid.
      Get card brand

      To define it: EPGJS.getCardType()

      Notifies the brand of the card entered by the customer.

      • Parameters: None.
      • Use: Send it in the “cardType” parameter in the payment transaction.
      • Values returned:
        • amex
        • astropay
        • dankort
        • diners_club_carte_blanche
        • diners_club_international
        • discover
        • jcb
        • laser
        • maestro
        • mastercard
        • mir
        • visa
        • visa_electron

      Customization

      Addon Payments offers several ways to customize the look and content of the cashier. These sections explain how to customize the look, design and language on the form.

      In this section you’ll find how to:

      • Customize the cashier with different styles.
      • Set a theme with CSS styles for buttons, text and images. 

      Customized style

      The easiest way to customize the look of the payment form is to create a CSS file that defines the colours, fonts and logos for the elements on the payment form. The following steps link your CSS classes to the elements on the Addon Payments form and tell it to use your styles: 

      1. Define a JSON object theme that links the names of the CSS classes to the elements on the Addon Payments form.
      2. Create a CSS file using the class names established in the theme.
      3. Call the method “EPGJS_STYLE.setCssTheme” and send your theme as the parameter.

      Step one

      Create a JSON variable linking the elements on the Addon Payments payment form to the names of your CSS classes. Addon Payments offers set themes linking the payment form to the CSS class names:

      • DEFAULT_THEME: Links the elements on the payment form to the names of generic CSS classes.
      • DEFAULT_BOOTSTRAP_THEME: Links the elements on the payment form to the existing elements on the initial theme.

      These themes are constants you can switch to the method “EPGJS_STYLE.setCssTheme(string)”. See the section JS Themes in this guide for more information on default themes and defining elements that can be customized.

      Step two

      Create a CSS file that uses the class names specified in the theme to assign styles to the elements on the payment form. This is an example of how to make the expiry date red using the default theme:

      				
      					<style>
          .cashier-form-field-expdate {
            color: red;
          }
        </style>
      				
      			

      Step three

      Call the method “EPGJS_STYLE.setCssTheme” before calling the method “renderCashier”. The method “EPGJS_STYLE.setCssTheme” takes a JSON theme object as the parameter.

      This example shows the method call using the default theme:

      				
      					EPGJS_STYLE.setCssTheme(EPGJS_STYLE.DEFAULT_THEME);
      				
      			

      This is an example showing the method call using the initial default theme:

      				
      					EPGJS_STYLE.setCssTheme(EPGJS_STYLE.DEFAULT_BOOTSTRAP_THEME);
      				
      			

      The method “EPGJS_STYLE.setCssTheme” tells the Addon Payments backend which styles to use for the elements on the form and where to apply them. When you call the method “renderCashier”, the payment form is rendered using your styles.

      JavaScript themes

      The JavaScript themes define the CSS class that controls the look of each element on the payment form. This section defines the customizable parameters and includes the JSON object for the default theme and the initial theme.

      Theme elements and classes

      This table shows the components that can be customized on the Addon Payments payment form.

      Clase Addon PaymentsDescription
      epgjs-cashier-containerEPGJS cashier main DIV container.
      epgjs-cashierEPGJS Cashier. Child of the merchant DIV container.
      cashier-edit-rowAccount editor row container.
      cashier-edit-activate-panelAccount editor panel when the account is active.
      cashier-edit-deactivate-panelAccount editor panel when the account is disabled.
      cashier-account-rowAccount container.
      cashier-account-row-headingAccount header.
      cashier-register-rowRegistered Account container.
      cashier-register-row-headingRegistered Account header.
      cashier-quickpay-rowQuickPay container.
      cashier-quickpay-row-headingQuickPay header.
      cashier-paysol-panelPayment solution panel.
      cashier-form-row-removeRemove account container for the account editor section.
      cashier-form-panelCashier form panel.
      cashier-form-fieldForm field component.
      cashier-form-field-labelForm field label.
      cashier-form-field-textForm field text.
      cashier-form-field-expdateExpiry date form field.
      cashier-form-field-passwordPassword form field.
      cashier-form-field-cvvCVV form field.
      cashier-form-field-dropdownSelect or Dropdown menu form field.
      cashier-form-row-selectedSelected cashier form component.
      submit-buttonSubmit button.

      Internationalization

      The Addon Payments JavaScript cashier comes in English by default. It can also be shown in Spanish. You can change the language any time, even with the cashier rendered. 

      You can include any language or customize any tag as long as you define the corresponding literals. If the translation or customization is incomplete, the tags without defined literals will be shown in English. 

      If you want to render the cashier in a language other than English or Spanish, or customize any of the field literals, get the list of literals for the cashier. 

      Get the list of literals for the cashier

      The function “getI18n()”, in the JavaScript library returns a JSON with the cashier literals in the language supported.

      To get the JSON with the cashier literals, assign the output of that function call to a variable and show its content on the console.

      Here is an example of the JS code to get and show the JSON with the cashier literals:

      var languages= EPGJS_I18N.getI18n();
      console.log (languages);

      This is an object with the JSON shown on the console:

      This is an example with the structure of the JSON you get:

      				
      					{
        "etiqueta_idioma_1": {
          "id_literal_1": "texto_literal_1",
          "id_literal_2": "texto_literal_2",
          "id_literal_n": "texto_literal_n",
          "objeto_1": {
            "id_literal_1_1": "texto_literal_1_1",
            "id_literal_1_2": "texto_literal_1_2",
            "id_literal_1_n": "texto_literal_1_n",
            "objeto_1_1": {
              "id_literal_objeto_1_1_1": "texto_literal_objeto_1_1_1",
              "id_literal_objeto_1_1_2": "texto_literal_objeto_1_1_2"
            }
          }
        },
        "etiqueta_idioma_2": { … },
        "etiqueta_idioma_n": { … }
      }
      				
      			

      Creating and loading the JSON with the cashier literals

      After downloading the cashier literals, you can translate them and assign them a language tag (English and Spanish are included, so you don’t have to translate them).

      The following example shows fragments of the JSON with the JS cashier literals. The first tab has the originals in English and the second, the Catalan translation. 

      				
      					{
        "en": {
          "account": "Account",
          "CreditCards": "Credit Cards",
          "Neteller": "Neteller",
          "Skrill": "Skrill",
          "astropay": {
            "bankAccount": {
              "clabe": "CLABE",
              "debitCard": "Debit Card"
            },
            "cardholdername": "AstroCard Holder Name",
            "cardnumber": "AstroCard Number",
            "cvv": "CVV / CVN",
            "expirationdate": "AstroCard Expiration Date",
            "mail": "By email",
            "mobile": "By mobile"
          },
          "astropayCards": "AstroPay Cards",
          "creditcards": {
            "cardholdername": "Card Holder",
            "cardnumber": "Card Number",
            "cardtype": "Card Type",
            "cvv": "CVV / CVN",
            "expirationdate": "Exp. Date",
            "invalidCVV": "Invalid CVV",
            "invalidChName": "Invalid Card Holder Name",
            "invalidExpDate": "Invalid Expiry Date",
            "invalidPAN": "Invalid Card Number",
            "placeholderdate": "MM/YY",
            "placeholdercvv": "CVV"
          },
          "customer": {
            "firstName": "Customer first name",
            "lastName": "Customer last name",
            "addressLine1": "Customer address",
            "city": "Customer city",
            "postCode": "Customer post code",
            "state": "Customer state",
            "telephone": "Customer telephone"
            "companyName": "Customer company",
            "customerEmail": "Customer email",
            "customerNatIdRadioCC": "CC",
            "customerNatIdRadioCE": "CE",
            "customerNatIdRadioDNI": "DNI",
            "customerNatIdRadioNIT": "NIT",
            "customerNatIdRadioPASS": "PASS",
            "customerNatIdRadioRUC": "RUC",
            "customerNationalId": "Customer national ID",
            "customerNationalIdType": "Customer national ID type",
          }, …
      				
      			
      				
      					{
        "ca": {
          "account": "Compte d'usuari",
          "CreditCards": "Targetes de crèdit",
          "Neteller": "Neteller",
          "Skrill": "Skrill",
          "astropay": {
            "bankAccount": {
              "clabe": "CLABE",
              "debitCard": "Targeta de dèbit"
            },
            "cardholdername": "Nom del titular",
            "cardnumber": "Número de targeta",
            "cvv": "CVV / CVN",
            "expirationdate": "Data d'expiració",
            "mail": "Via correu electrònic",
            "mobile": "Via mòbil"
          },
          "astropayCards": "AstroPay Cards",
          "creditcards": {
            "cardholdername": "Nom del titular",
            "cardnumber": "Número de targeta",
            "cardtype": "Tipus de targeta",
            "cvv": "CVV / CVN",
            "expirationdate": "Data d'expiració",
            "invalidCVV": "El CCV no és vàlid",
            "invalidChName": "El nom del titular no és vàlid",
            "invalidExpDate": "La data de caducitat no és vàlida",
            "invalidPAN": "El número de la targeta no és vàlid",
            "placeholderdate": "MM/YY",
            "placeholdercvv": "CVV"
          },
          "customer": {
            "firstName": "Nom",
            "lastName": "Cognoms",
            "addressLine1": "Direcció",
            "city": "Ciutat",
            "postCode": "Codi postal",
            "state": "Província/estat",
            "telephone": "Núm. de telèfon",
            "companyName": "Nom de l'empresa",
            "customerEmail": "Correu electrònic",
            "customerNatIdRadioCC": "CC",
            "customerNatIdRadioCE": "CE",
            "customerNatIdRadioDNI": "DNI",
            "customerNatIdRadioNIT": "NIT",
            "customerNatIdRadioPASS": "PASS",
            "customerNatIdRadioRUC": "RUC",
            "customerNationalId": "Número d'identificació nacional",
            "customerNationalIdType": "Tipus de document d'identificació"
          }, …
      				
      			

      The next step is a variable declaration that contains the JSON created with the translation or customization.

      In the next fragment of the JS example, we declare the constant “translations” with the JSON with the Catalan translation of the cashier literals. One unique variable or constant can contain many translations. So, it is important to assign a field at the beginning that identifies the language:

      				
      					const traducciones = {
        "ca": {
          "account": "Compte d'usuari",
          "astropay": {
            "bankAccount": {
              "clabe": "CLABE",
              "debitCard": "Targeta de dèbit"
            },
            "cardholdername": "Nom del titular",
            "cardnumber": "Número de targeta",
            "cvv": "CVV / CVN",
            "expirationdate": "Data d'expiració",
            "mail": "Via correu electrònic",
            "mobile": "Via mòbil"
          },
          "astropayCards": "AstroPay Cards",
          "bank": {
            "accTypeRadioCM": "Compte Mestre",
            "accTypeRadioCheckings": "Pagaments",
            "accTypeRadioSavings": "Estalvis",
            "accTypeRadioVista": "Vista",
            "accountNum": "Número de compte bancària",
            "accountType": "Tipus de compte bancari",
            "bankAccountDetails": "Detalls del compte bancari",
            "bankBranchCode": "Codi de la sucursal",
            "bankBranchName": "Nom de la sucursal",
            "bankCity": "Ciutat del banc",
            "bankCode": "Codi del banc",
            "bankName": "Nom del banc",
            "bankProvinceCode": "Província del banc",
            "firstName": "Nom",
            "lastName": "Cognoms"
          },
          "bankAccountNum": "Número del compte bancari",
          "bankBic": "SWIFT / BIC",
          "bankBranchCode": "Codi de sucursal",
          "breakoutgaming": {
            "account": "Clau d'autorització de compte",
            "accountPassword": "Clau de cartera digital"
          },
      ...
      				
      			
      Finally, to load the language, launch the function setI18n(constant):
      EPGJS_I18N.setI18n(translations);

      Changing cashier language

      To change the cashier language, you just need to call the function “setLang(language)”, sending the text for the field that identifies the cashier or language you want to apply as the parameter.

      Sample JS code to change the JS cashier literals to Spanish (included with the cashier, no additional programming required):

      EPGJS_I18N.setLang('es');

      Sample JS code to change the JS cashier literals to Catalan (after declaration and loading from the examples in the points above):

      EPGJS_I18N.setLang('ca');

      This function can be called at any time, even if the cashier is already rendered and it will change the literals to the language or customization indicated.

      Comparte este documento

      Complement your JavaScript integration

      Copiar el enlace

      Clipboard Icon
      Tabla de Contenidos

      Products

      • Cyberpac
      • Addon Payments
      • POS integrated Payments
      • Universal Pay

      Sales

      Tell us about your business so we can offer you the best solution.

      Contact an expert
      Contact an expert
      Contact an expert
      Contact an expert
      Contact an expert

      Technical Support

      Already a client and need help? Contact us, we’re here for you.

      Help

      Partners

      We work with the best partners for in-store and ecommerce solutions. Want to join us?

      Join us

      © Comercia Global Payments

      Privacy policy
      Exercising rights
      Client information
      Whistleblowing channel
      Legal disclaimer
      Cookies policy
      Ask AI
      Write your question. For example: How do I create a payment link?
      SmartWiki may skip data. Verify the information or contact support.

      SmartWiki, Powered by AI

      API - Developers Docs
      Manage cookie consent

      To offer the best experiences, we use technologies such as cookies to store and/or access device information. Consent to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Failure to consent, or withdrawal of consent, may adversely affect certain features and functions.

      Functional Always active
      Storage or technical access is strictly necessary for the legitimate purpose of allowing the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
      Preferences
      Technical storage or access is necessary for the legitimate purpose of storing preferences not requested by the subscriber or user.
      Statistics
      El almacenamiento o acceso técnico que es utilizado exclusivamente con fines estadísticos. Storage or technical access that is used exclusively for anonymous statistical purposes. Without a requirement, voluntary compliance by your Internet service provider, or additional records from a third party, information stored or retrieved solely for this purpose cannot be used to identify you.
      Marketing
      Storage or technical access is necessary to create user profiles to send advertising, or to track the user on a website or several websites for similar marketing purposes.
      Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
      See preferences
      {title} {title} {title}

      Consulta la documentación de las distintas secciones de integraciones:

      Comienza a integrar

      undraw_add_to_cart_re_wrdo 1 (1) (1)

      Plugins para CMS

      Complementa la integración

      SDKs

      Métodos de pago

      Herramientas

      Addon Payments

      Consulta la documentación de Addon Payments. Aquí tienes las distintas secciones:

      Integraciones

      Consultas frecuentes

      Portal Backoffice

      Cyberpac

      We are currently working on the English version of the Cyberpac documentation. You can view the Spanish version using the buttons below:

      Canales BackOffice Portal

      Plugins integration

      Custom integrations

      POS integrated Payments

      Create a solution that will help you automate processes. You can even add payment processes on physical terminals.

      Payment Integrated with Android POS

      Payment Integrated with Smartphone POS

      POS Data sheets

      Addon Payments

      Comercia Global Payments has several integration options so you can choose the most efficient one for you.

      Integrations

      Frequently Asked Questions

      BackOffice Portal

      Consult the documentation of the different integrations sections:​

      Start integration

      undraw_add_to_cart_re_wrdo 1 (1) (1)

      CMS Plugins

      Complement your integration

      SDKs

      Payment Methods

      Tools