TypeScript/JavaScript SDK for RaiAccept payment gateway API.
npm install @raiaccept/raiaccept-api-clientimport { RaiAcceptService } from '@raiaccept/raiaccept-api-client';
// Create service instance
const service = new RaiAcceptService();
// Authenticate with your credentials
const accessToken = await service.retrieveAccessTokenWithCredentials(
'your-username', // Replace with your actual username
'your-password' // Replace with your actual password
);
const response = await service.createOrderEntry(accessToken, orderRequest);import { RaiAcceptService, HttpClient } from '@raiaccept/raiaccept-api-client';
// Initialize HTTP client (optional, for logging)
const httpClient = new HttpClient({
logger: console, // Optional: for debugging
});
// Initialize the unified SDK client
const service = new RaiAcceptService(httpClient);
// Authenticate
const accessToken = await service.retrieveAccessTokenWithCredentials(
'your-username',
'your-password'
);
// Create an order and payment session (two-step process)
const orderRequest = {
invoice: {
amount: 100.00,
currency: 'EUR',
description: 'Test payment',
merchantOrderReference: 'ORDER-123',
items: [
{
description: 'Product 1',
numberOfItems: 1,
price: 100.00
}
]
},
urls: {
successUrl: 'https://example.com/success',
failUrl: 'https://example.com/fail',
cancelUrl: 'https://example.com/cancel',
notificationUrl: 'https://example.com/webhook'
},
consumer: {
email: 'customer@example.com',
firstName: 'John',
lastName: 'Doe',
phone: '+1234567890'
},
paymentMethodPreference: 'CARD',
linkId: 'unique-link-id'
};
// Step 1: Create order entry
const orderResponse = await service.createOrderEntry(accessToken, orderRequest);
const orderIdentification = orderResponse.object.getOrderIdentification();
console.log('Order created:', orderIdentification);
// Step 2: Create payment session for the order
const paymentSessionResponse = await service.createPaymentSession(
accessToken,
orderRequest,
orderIdentification
);
const paymentRedirectURL = paymentSessionResponse.object?.paymentRedirectURL;
console.log('Payment session created. Redirect customer to:', paymentRedirectURL);import { RaiAcceptService, HttpClient } from '@raiaccept/raiaccept-api-client';
// With HTTP client (recommended for logging)
const httpClient = new HttpClient({ logger: console });
const client = new RaiAcceptService(httpClient);
// Without HTTP client (uses default)
const client = new RaiAcceptService();const accessToken = await client.retrieveAccessTokenWithCredentials(
username,
password
);client.createOrderEntry(accessToken, orderRequest)- Create a new orderclient.createPaymentSession(accessToken, sessionRequest, externalOrderId)- Create payment sessionclient.getOrderDetails(accessToken, orderId)- Get order detailsclient.getOrderTransactions(accessToken, orderId)- Get order transactions
client.getTransactionDetails(accessToken, orderId, transactionId)- Get transaction detailsclient.refund(accessToken, orderId, transactionId, refundRequest)- Process a refund
RaiAcceptService.transliterate(string)- Transliterate non-Latin charactersRaiAcceptService.transliterateAndLimitLength(string, limit)- Transliterate and limit lengthRaiAcceptService.cleanPhoneNumber(phoneNumber)- Clean phone number formatRaiAcceptService.getCountryIso3(countryCode)- Convert 2-letter to 3-letter country code
This SDK is written in TypeScript and includes full type definitions. All types are exported and available for use in your TypeScript projects.
Run the test suite:
# Run unit tests (mocked)
npm run unit-tests
# Run integration tests (real API calls!)
npm run integration-testsFor more details, see TEST_SETUP.md and tests/README.md.
OSL-3.0