Skip to main content

A55Pay SDK Reference (V2)

Quick Reference

WhatComplete A55Pay JavaScript SDK V2 reference
WhyIntegrate card payments, hosted checkout, and Apple Pay with the browser-side SDK
Reading Time25 min
DifficultyIntermediate
PrerequisitesAuthentication → Create charge

The A55Pay JavaScript SDK V2 runs in the buyer's browser: it collects card data, runs Device Data Collection (DDC), handles 3DS authentication, processes payments, and surfaces callbacks. Raw card data does not pass through your origin servers.


Prerequisites

Before calling any SDK method, your backend must create a charge without card data. Pass the returned charge_uuid to the frontend.

Create charge →

For Apple Pay, create a charge with type_charge: "applepay". For hosted checkout, use Create checkout and pass the checkout_uuid to A55Pay.open().


Installation

Latest version:

<script src="https://cdn.jsdelivr.net/npm/a55pay-sdk@latest/dist/a55pay-sdk.min.js"></script>

Pinned version (recommended for production):

<script src="https://cdn.jsdelivr.net/npm/a55pay-sdk@4.0.8/dist/a55pay-sdk.min.js"></script>

After loading, the SDK is available globally as window.A55Pay.

Version pinning

Pin a specific version in production (e.g., a55pay-sdk@4.0.8) for reproducible behavior across deploys.


Properties

A55Pay.VERSION

Returns the current SDK version.

console.log(A55Pay.VERSION); // "4.0.8"

Methods

A55Pay.payV2(config)

Process a credit or debit card payment with automatic device info collection, CyberSource authentication, and 3DS support.

Parameters

FieldTypeRequiredDescription
charge_uuidstringYesCharge UUID created via the A55 API
userDataobjectYesPayer and card data (see below)
onSuccessfunctionNoSuccess callback
onErrorfunctionNoError callback
onReadyfunctionNoFires when the SDK is ready to process

userData fields

FieldTypeRequiredDescription
payer_namestringYesPayer full name
payer_emailstringYesPayer email
payer_tax_idstringNoTax ID (CPF/CNPJ in Brazil)
cell_phonestringNoMobile phone number
holder_namestringYesName printed on the card
numberstringYesCard number
expiry_monthstringYesExpiry month (e.g., "12")
expiry_yearstringYesExpiry year (e.g., "2028")
ccvstringConditionalCard CVV (required if card_cryptogram is absent)
card_tokenstringNoSaved card token
card_cryptogramstringConditionalCard cryptogram (required if ccv is absent)
postal_codestringYesBilling postal code
streetstringYesBilling street
address_numberstringNoStreet number (default: "n/d")
complementstringNoAddress complement
neighborhoodstringNoNeighborhood (default: "n/d")
citystringYesCity
statestringYesState code
countrystringYesCountry (ISO alpha-2, e.g., "BR")
shipping_postal_codestringNoShipping postal code (falls back to billing)
shipping_streetstringNoShipping street
shipping_address_numberstringNoShipping street number
shipping_complementstringNoShipping complement
shipping_neighborhoodstringNoShipping neighborhood
shipping_citystringNoShipping city
shipping_statestringNoShipping state
shipping_countrystringNoShipping country

Example

<script src="https://cdn.jsdelivr.net/npm/a55pay-sdk@latest/dist/a55pay-sdk.min.js"></script>
<script>
document.getElementById('pay-btn').addEventListener('click', function() {
A55Pay.payV2({
charge_uuid: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
userData: {
payer_name: 'Joao da Silva',
payer_email: 'joao@email.com',
payer_tax_id: '12345678900',
cell_phone: '11999998888',
holder_name: 'JOAO DA SILVA',
number: '4111 1111 1111 1111',
expiry_month: '12',
expiry_year: '2028',
ccv: '123',
postal_code: '01310-100',
street: 'Av Paulista',
address_number: '1000',
complement: 'Sala 1',
neighborhood: 'Bela Vista',
city: 'Sao Paulo',
state: 'SP',
country: 'BR'
},
onReady: function() {
console.log('SDK ready to process');
},
onSuccess: function(result) {
console.log('Payment approved:', result);
// result.status = 'confirmed' | 'paid' | 'pending'
// result.charge_uuid
// result.data (full charge payload)
// result.threeds_completed (true if 3DS completed)
},
onError: function(error) {
console.error('Payment error:', error.message);
}
});
});
</script>

Internal flow


A55Pay.authentication(config)

Standalone CyberSource Device Data Collection (DDC). Called internally by payV2, but can be invoked separately.

Parameters

FieldTypeRequiredDescription
transactionReferencestringYesCharge UUID
cardBrandstringYesCard brand (see values below)
cardExpiryMonthstringYesExpiry month
cardExpiryYearstringYesExpiry year
cardNumberstringYesCard number (no spaces)
onSuccessfunctionNoSuccess callback
onErrorfunctionNoError callback

Valid cardBrand values: Visa, MasterCard, AmericanExpress, Discover, JCB, DinersClub, Hipercard, Elo

Example

A55Pay.authentication({
transactionReference: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
cardBrand: 'Visa',
cardExpiryMonth: '12',
cardExpiryYear: '2028',
cardNumber: '4111111111111111',
onSuccess: function(result) {
console.log('Session ID:', result.sessionId);
console.log('Reference ID:', result.referenceId);
// result.accessToken
// result.deviceDataCollection
},
onError: function(error) {
console.error('Authentication failed:', error.message);
}
});

A55Pay.getDeviceId()

Returns the current device ID generated via ThreatMetrix. Generated automatically when the SDK loads.

var deviceId = A55Pay.getDeviceId();
console.log(deviceId); // "a1b2c3d4-e5f6-4g7h-8i9j-k0l1m2n3o4p5"

A55Pay.regenerateDeviceId()

Forces generation of a new device ID and reloads the ThreatMetrix script.

var newDeviceId = A55Pay.regenerateDeviceId();
console.log('New device ID:', newDeviceId);

A55Pay.open(config)

Opens the A55 checkout (v2) in a modal iframe or embedded container with postMessage communication.

Parameters

FieldTypeRequiredDescription
checkoutUuidstringYesCheckout UUID
display'modal' | 'embed'NoDisplay mode (default: 'modal')
containerIdstringNoHTML element ID for embed (auto-created if missing)
onEventfunctionNoGeneric checkout event callback
onSuccessfunctionNoFires when payment is confirmed
onClosefunctionNoFires when checkout is closed
onErrorfunctionNoError callback

Return value

Returns an object with a close() method to programmatically close the checkout.

var instance = A55Pay.open({
checkoutUuid: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
display: 'modal',
onSuccess: function(data) {
console.log('Payment confirmed:', data);
// data.status = 'paid' | 'confirmed'
// data.chargeUuid
},
onError: function(err) {
console.error('Error:', err.message);
},
onClose: function() {
console.log('Checkout closed');
},
onEvent: function(event) {
console.log('Event received:', event);
}
});

// Close programmatically:
// instance.close();

Embed example

<div id="my-checkout" style="min-height:600px;"></div>

<script>
A55Pay.open({
checkoutUuid: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
display: 'embed',
containerId: 'my-checkout',
onSuccess: function(data) {
console.log('Payment confirmed:', data);
},
onClose: function() {
console.log('Checkout closed');
}
});
</script>

A55Pay.isApplePayAvailable()

Synchronously checks whether Apple Pay is available in the current browser and device.

if (A55Pay.isApplePayAvailable()) {
document.getElementById('apple-pay-btn').style.display = 'block';
} else {
console.log('Apple Pay not available');
}

A55Pay.startApplePay(config)

Starts an Apple Pay payment. Must be called inside a click handler (user gesture required).

Activation required

Apple Pay requires prior registration of your merchant in A55's Apple Pay account and hosting a domain verification file. Contact tech.services@a55.tech before integrating.

Parameters

FieldTypeRequiredDescription
chargeUuidstringYesCharge UUID created with type_charge: "applepay"
countryCodestringYesISO 3166-1 alpha-2 country code (e.g., 'BR')
amountstringYesPayment amount (e.g., '150.00')
currencyCodestringNoISO 4217 currency code (default: 'BRL')
merchantDomainstringNoMerchant domain (default: 'pay.a55.tech')
displayNamestringNoName shown on the payment sheet (default: 'A55Pay')
supportedNetworksstring[]NoSupported networks (default: ['visa', 'masterCard', 'elo', 'amex'])
onSuccessfunctionNoSuccess callback
onErrorfunctionNoError callback
onClosefunctionNoFires when the user cancels the payment sheet

Example

<button id="apple-pay-btn" style="display:none;">Pay with Apple Pay</button>

<script src="https://cdn.jsdelivr.net/npm/a55pay-sdk@latest/dist/a55pay-sdk.min.js"></script>
<script>
var btn = document.getElementById('apple-pay-btn');

if (A55Pay.isApplePayAvailable()) {
btn.style.display = 'inline-block';
}

btn.addEventListener('click', function() {
A55Pay.startApplePay({
chargeUuid: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
countryCode: 'BR',
amount: '150.00',
currencyCode: 'BRL',
displayName: 'My Store',
supportedNetworks: ['visa', 'masterCard', 'elo', 'amex'],
onSuccess: function(result) {
console.log('Apple Pay approved:', result);
},
onError: function(error) {
console.error('Apple Pay error:', error.message);
},
onClose: function() {
console.log('User cancelled Apple Pay');
}
});
});
</script>

Apple Pay flow

Apple Pay requirements

  • HTTPS required (does not work over HTTP)
  • Safari (macOS/iOS) or iOS browsers with WebKit
  • Card configured in Apple Wallet
  • Domain verified in Apple Developer Portal

Full Apple Pay documentation →


Complete HTML example

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>A55Pay SDK Example</title>
</head>
<body>
<h1>Pay with A55Pay</h1>

<form id="payment-form">
<input type="text" id="holder" placeholder="Name on card" />
<input type="text" id="card-number" placeholder="Card number" />
<input type="text" id="expiry-month" placeholder="MM" />
<input type="text" id="expiry-year" placeholder="YYYY" />
<input type="text" id="cvv" placeholder="CVV" />
<input type="text" id="email" placeholder="Email" />
<input type="text" id="name" placeholder="Full name" />
<button type="submit">Pay with Card</button>
</form>

<button id="apple-pay-btn" style="display:none;background:#000;color:#fff;padding:12px 24px;border:none;border-radius:8px;font-size:16px;cursor:pointer;">
Pay with Apple Pay
</button>

<button id="open-checkout-btn">Open A55 Checkout</button>

<div id="result"></div>

<script src="https://cdn.jsdelivr.net/npm/a55pay-sdk@latest/dist/a55pay-sdk.min.js"></script>
<script>
var CHARGE_UUID = 'YOUR_CHARGE_UUID_HERE';
var resultDiv = document.getElementById('result');

function showResult(msg) {
resultDiv.textContent = msg;
}

document.getElementById('payment-form').addEventListener('submit', function(e) {
e.preventDefault();

A55Pay.payV2({
charge_uuid: CHARGE_UUID,
userData: {
payer_name: document.getElementById('name').value,
payer_email: document.getElementById('email').value,
holder_name: document.getElementById('holder').value,
number: document.getElementById('card-number').value,
expiry_month: document.getElementById('expiry-month').value,
expiry_year: document.getElementById('expiry-year').value,
ccv: document.getElementById('cvv').value,
postal_code: '01310100',
street: 'Av Paulista',
city: 'Sao Paulo',
state: 'SP',
country: 'BR'
},
onSuccess: function(result) {
showResult('Payment approved! Status: ' + result.status);
},
onError: function(error) {
showResult('Error: ' + error.message);
}
});
});

if (A55Pay.isApplePayAvailable()) {
document.getElementById('apple-pay-btn').style.display = 'inline-block';
}

document.getElementById('apple-pay-btn').addEventListener('click', function() {
A55Pay.startApplePay({
chargeUuid: CHARGE_UUID,
countryCode: 'BR',
amount: '100.00',
currencyCode: 'BRL',
displayName: 'My Store',
onSuccess: function(result) {
showResult('Apple Pay approved!');
},
onError: function(error) {
showResult('Apple Pay error: ' + error.message);
},
onClose: function() {
showResult('Apple Pay cancelled');
}
});
});

document.getElementById('open-checkout-btn').addEventListener('click', function() {
A55Pay.open({
checkoutUuid: CHARGE_UUID,
display: 'modal',
onSuccess: function(data) {
showResult('Checkout confirmed! Status: ' + data.status);
},
onError: function(err) {
showResult('Checkout error: ' + err.message);
},
onClose: function() {
showResult('Checkout closed');
}
});
});

console.log('A55Pay SDK v' + A55Pay.VERSION);
console.log('Device ID:', A55Pay.getDeviceId());
</script>
</body>
</html>

Common errors

ErrorCauseSolution
Missing charge_uuid or userDataRequired parameters missingEnsure charge_uuid and userData are provided
payer_name and payer_email are requiredPayer data missingInclude payer_name and payer_email in userData
Either ccv or card_cryptogram is requiredNo card authentication methodSend ccv or card_cryptogram
Apple Pay is not availableBrowser does not support Apple PayUse Safari on macOS/iOS with a card in Wallet
Must create ApplePaySession from user gesturestartApplePay called outside a click handlerCall only inside addEventListener('click', ...)
Invalid countryCodeWrong formatUse uppercase ISO 3166-1 alpha-2 (e.g., "BR")
Invalid amountNon-numeric valueSend a numeric string (e.g., "150.00")
An Apple Pay session is already in progressDouble clickDisable the button while processing

Security notes

  • The SDK does not store card data — it is sent directly to the A55 backend
  • Device ID is generated via ThreatMetrix for fraud detection
  • 3DS 2.0 is handled automatically via CyberSource
  • Apple Pay tokens are end-to-end encrypted
  • All communications use HTTPS
  • Checkout postMessage filters by origin (pay.a55.tech)
Logging

Never log PAN, CVV, or cryptograms from callback payloads. The SDK handles card data in the browser context — keep it there.


Test with sandbox cards

Card NumberBrandScenarioExpected Status
4111 1111 1111 1111VisaSuccessful paymentconfirmed
5500 0000 0000 0004MastercardSuccessful paymentconfirmed
4000 0000 0000 0002VisaCard declineddeclined
4000 0000 0000 0101Visa3DS challenge requiredconfirmed
4000 0000 0000 0069VisaProcessing errorerror