Skip to main content
After setting up the SDK, you can initiate payments using two methods: User Payment (for account holders) or Guest Payment (for one-time payments).

Payment Methods Overview

MethodUse CaseUser ExperienceBest For
User PaymentAccount holders or new usersRedirects to AcountPay portalSubscriptions, repeat customers
Guest PaymentOne-time paymentsIn-page payment flowSingle purchases, checkout flows

User Payment Method

For users with AcountPay accounts or those who want to create one.
ParameterTypeRequiredDescription
amountnumber✅ YesPayment amount in major currency units (e.g., 10.50 = $10.50)
requestIdstring✅ YesUnique request identifier (your order ID)
callbackURLstring✅ YesURL the user is returned to after the payment flow
const acount = new Acount({
  clientId: 'your-client-id'
});

await acount.initiateUserPaymentByEmail({
  amount: 99.99,
  requestId: 'ORDER-' + orderId,
  callbackURL: 'https://your-website.com/payment-callback'
});
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.acountpay.com/sdk/acount.umd.js"></script>
</head>
<body>
  <button onclick="payAsUser()">Pay with AcountPay Account</button>
  
  <script>
    async function payAsUser() {
      const acount = new Acount({ 
        clientId: 'your-client-id'
      });
      
      try {
        await acount.initiateUserPaymentByEmail({
          amount: 99.99, // Your actual amount
          requestId: 'ORDER-123', // Your actual order ID
          callbackURL: 'https://your-website.com/payment-success'
        });
      } catch (error) {
        console.error('Payment failed:', error);
        alert('Payment could not be initiated. Please try again.');
      }
    }
  </script>
</body>
</html>

Guest Payment Method

For one-time payments without requiring account creation.
ParameterTypeRequiredDescription
amountnumber✅ YesPayment amount in major currency units
referenceNumberstring✅ YesUnique reference number (your order ID)
onSuccessfunction❌ NoSuccess callback function
onErrorfunction❌ NoError callback function
const acount = new Acount({
  clientId: 'your-client-id'
});

acount.initiatePayment({
  amount: 99.99,
  referenceNumber: 'ORDER-' + orderId,
  onSuccess: (result) => {
    console.log('Payment successful:', result);
    // Redirect to success page or update UI
    window.location.href = '/payment-success';
  },
  onError: (error) => {
    console.error('Payment failed:', error);
    // Handle error gracefully
    alert('Payment failed. Please try again.');
  }
});
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.acountpay.com/sdk/acount.umd.js"></script>
</head>
<body>
  <button onclick="payAsGuest()">Pay as Guest</button>
  
  <script>
    function payAsGuest() {
      const acount = new Acount({ 
        clientId: 'your-client-id'
      });
      
      acount.initiatePayment({
        amount: 99.99, // Your actual amount
        referenceNumber: 'ORDER-123', // Your actual order ID
        onSuccess: function(result) {
          console.log('Payment successful:', result);
          window.location.href = '/order-confirmation';
        },
        onError: function(error) {
          console.error('Payment failed:', error);
          alert('Payment failed. Please try again.');
        }
      });
    }
  </script>
</body>
</html>

Framework Integration Examples

import { useState } from 'react';

// Note: Add script tag to index.html or load dynamically
// <script src="https://cdn.acountpay.com/sdk/acount.umd.js"></script>

declare global {
  interface Window {
    Acount: any;
  }
}

export function PaymentButton({ amount, orderId }: { amount: number; orderId: string }) {
  const [loading, setLoading] = useState(false);

  const handleUserPayment = async () => {
    setLoading(true);
    const acount = new window.Acount({
      clientId: process.env.REACT_APP_ACOUNTPAY_CLIENT_ID
    });
    
    try {
      await acount.initiateUserPaymentByEmail({
        amount,
        requestId: orderId,
        callbackURL: `${window.location.origin}/payment-callback`
      });
    } catch (error) {
      console.error('Payment failed:', error);
      setLoading(false);
    }
  };

  const handleGuestPayment = () => {
    setLoading(true);
    const acount = new window.Acount({
      clientId: process.env.REACT_APP_ACOUNTPAY_CLIENT_ID
    });
    
    acount.initiatePayment({
      amount,
      referenceNumber: orderId,
      onSuccess: (result: any) => {
        console.log('Payment successful:', result);
        window.location.href = '/payment-success';
      },
      onError: (error: any) => {
        console.error('Payment failed:', error);
        setLoading(false);
      }
    });
  };

  return (
    <div className="space-y-4">
      <button 
        onClick={handleUserPayment} 
        disabled={loading}
        className="w-full bg-blue-600 text-white py-3 px-6 rounded-lg"
      >
        {loading ? 'Processing...' : 'Pay with AcountPay Account'}
      </button>
      
      <button 
        onClick={handleGuestPayment} 
        disabled={loading}
        className="w-full bg-green-600 text-white py-3 px-6 rounded-lg"
      >
        {loading ? 'Processing...' : 'Pay as Guest'}
      </button>
    </div>
  );
}

Flow Overview

  1. SDK Initialization: Initialize with your Client ID
  2. Payment Request: SDK calls your backend with payment details
  3. User Portal: Browser redirects to AcountPay user portal where user:
    • Creates account or logs in
    • Links IBAN to their account
    • Authenticates and consents to payment
  4. Return: User is redirected back to your callbackURL
  1. SDK Initialization: Initialize with your Client ID
  2. Payment Interface: SDK opens payment interface
  3. Bank Selection: User selects their bank
  4. Bank Authentication: User authenticates with their bank
  5. Completion: Success/error callbacks are triggered

Error Handling

acount.initiatePayment({
  amount: 99.99,
  referenceNumber: 'ORDER-123',
  onSuccess: (result) => {
    // Payment successful
    console.log('Payment completed:', result);
    // Update UI, redirect, etc.
  },
  onError: (error) => {
    // Handle different error types
    if (error.type === 'user_cancelled') {
      console.log('User cancelled the payment');
      // Show appropriate message
    } else if (error.type === 'insufficient_funds') {
      console.log('Insufficient funds');
      // Suggest alternative payment methods
    } else {
      console.error('Payment error:', error);
      // Show generic error message
    }
  }
});

Important Implementation Notes

// ❌ Don't use demo values in production
const acount = new Acount({
  clientId: "YOUR_CLIENT_ID_HERE" // Replace with actual client ID
});

acount.initiatePayment({
  amount: 1, // Replace with actual amount
  referenceNumber: "PAY" + Math.random(), // Replace with actual order ID
});

// ✅ Use actual values
const acount = new Acount({
  clientId: "682ad984-e692-4438-8503-b7e8b6ca1f94" // Your real client ID
});

acount.initiatePayment({
  amount: cartTotal, // Your actual transaction amount
  referenceNumber: orderId, // Your actual order reference
});
  • Use major currency units (e.g., 10.50 for $10.50)
  • Don’t use smallest currency units (cents/pence)
  • Ensure amounts match your actual transaction values
  • Use your internal order ID or transaction reference
  • Ensure uniqueness to avoid duplicate payments
  • This allows matching successful payments back to orders

Testing

  1. Use your sandbox Client ID from the dashboard
  2. Test both payment methods
  3. Verify callback handling
  4. Check webhook notifications
  • Production Client ID configured
  • Callback URLs working
  • Error handling implemented
  • Success flow tested
  • Webhook endpoints ready
For detailed testing guidelines, see Integration Testing.