Documentation Index
Fetch the complete documentation index at: https://docs.useaxra.com/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Or load via CDN:
<script src="https://pay.useaxra.com/sdk/axra-pay.js"></script>
Quick start
<div id="card-element"></div>
<button id="pay-btn">Pay</button>
<script type="module">
import Axra from '@axra/pay-js';
const axra = Axra('pk_test_...');
// Create an Elements session (server-side first)
// POST /api/v1/elements/session → { id: 'es_...' }
const sessionId = 'es_...'; // from your server
const elements = axra.elements({ session: sessionId });
const card = elements.create('card');
card.mount('#card-element');
document.getElementById('pay-btn').addEventListener('click', async () => {
const result = await axra.createToken(card);
if (result.token) {
// Send result.token.id to your server
console.log('Token:', result.token.id);
} else {
console.error('Error:', result.error);
}
});
</script>
Element types
| Type | Description | Min height |
|---|
card | Card number, expiry, CVC | 48px |
payment | Card + cardholder name + postal code | 120px |
paymentRequestButton | Apple Pay / Google Pay button | 40px |
Configuration
const axra = Axra('pk_test_...', {
elementsHost: 'https://pay.useaxra.com', // default
apiBaseUrl: 'https://api.useaxra.com', // default
});
Server-side session creation
Before mounting Elements, create a session from your server:
curl -X POST https://api.useaxra.com/api/v1/elements/session \
-H "Content-Type: application/json" \
-d '{
"publishableKey": "pk_test_...",
"amount": 19.99,
"currency": "usd"
}'
Response:
{
"id": "es_abc123...",
"expiresInSeconds": 900
}
Tokenization response
// Success
{ token: { id: "tok_abc123..." } }
// Error
{ error: { code: "invalid_card", message: "Card number is invalid" } }
Never send raw card numbers to your server. Always tokenize with Pay.js first, then send the token ID.