@acountpay/pis-sdk
v1.0.5
Published
A simple payment integration for your website that allows secure bank payments through Open Banking.
Readme
AcountPay SDK
A simple payment integration for your website that allows secure bank payments through Open Banking.
5-Minute Integration Guide
Step 1: Add the SDK to your website
Option A: Script tag (quickest)
<script src="https://cdn.acountpay.com/sdk/acount.umd.js"></script>Option B: npm (React, Next.js, Vue, etc.)
npm i @acountpay/pis-sdkStep 2: Create a payment button
<button id="pay-button">Pay with AcountPay</button>
<script>
document.getElementById('pay-button').addEventListener('click', async function() {
const acount = new Acount({
clientId: "YOUR_CLIENT_ID" // Replace with your client ID from AcountPay dashboard
});
try {
const { redirectUrl } = await acount.createPaymentLink({
amount: 99.99,
referenceNumber: "ORDER-123",
redirectUrl: window.location.origin + "/payment-callback",
});
// Customer is taken to AcountPay's payment page to select bank and authenticate
window.location.href = redirectUrl;
} catch (error) {
console.error("Payment failed:", error);
alert("Could not start payment. Please try again.");
}
});
</script>Step 3: Handle the return
After payment, the customer is returned to your redirectUrl with a ?status=success|failed|pending query parameter.
// On your callback page
const params = new URLSearchParams(window.location.search);
const status = params.get('status');
if (status === 'success') {
// Show order confirmation
} else if (status === 'failed') {
// Offer retry
} else {
// Payment is processing
}React / Next.js Integration
'use client';
import { useState } from 'react';
import AcountPay from '@acountpay/pis-sdk';
export function PaymentButton({ amount, orderId }: { amount: number; orderId: string }) {
const [loading, setLoading] = useState(false);
const handlePayment = async () => {
setLoading(true);
try {
const acount = new AcountPay({
clientId: process.env.NEXT_PUBLIC_ACOUNTPAY_CLIENT_ID!
});
const { redirectUrl } = await acount.createPaymentLink({
amount,
referenceNumber: orderId,
redirectUrl: `${window.location.origin}/payment-callback?orderId=${orderId}`,
});
window.location.href = redirectUrl;
} catch (error) {
console.error('Payment failed:', error);
setLoading(false);
}
};
return (
<button onClick={handlePayment} disabled={loading}>
{loading ? 'Processing...' : 'Pay with AcountPay'}
</button>
);
}Payment Methods
| Method | Description |
|--------|-------------|
| createPaymentLink() | Recommended. Creates a payment and returns a hosted payment page URL. Customer selects bank on AcountPay's page and is returned to your redirectUrl. |
| initiateUserPaymentByEmail() | For registered AcountPay users. Redirects to AcountPay portal. |
| initiatePayment() | Direct Token.io redirect for bank authentication. |
| initiateCrossBorderPayment() | Converts currency to EUR and initiates a SEPA payment. |
createPaymentLink Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| amount | number | Yes | Payment amount (e.g., 10.50) |
| referenceNumber | string | Yes | Your unique order reference |
| redirectUrl | string | Yes | URL to return customer to after payment |
| description | string | No | Description shown during payment |
| currency | string | No | Currency code (default: DKK) |
| webhookUrl | string | No | Server-side URL for status updates |
Important Implementation Notes
Client ID
Replace "YOUR_CLIENT_ID" with your actual client ID from the AcountPay dashboard.
Amount
Use major currency units (e.g., 10.50 for $10.50). Use your actual cart total or product price.
Reference Number
Use your unique order ID or invoice number so you can match payments back to orders.
Need Help?
- Email: [email protected]
- Documentation: docs.acountpay.com
- Dashboard: dashboard.acountpay.com
