Skip to main content

Quickstart Guide

This guide will help you integrate ResolutPay into your application in just a few minutes. We'll walk through setting up authentication, initializing a payment, and handling the response.

Prerequisites

  • A ResolutPay account (sign up at resolutpay.com)
  • Your API keys from the dashboard
  • Basic knowledge of HTTP requests and JSON

Step 1: Get Your API Keys

  1. Log in to your ResolutPay Dashboard
  2. Navigate to SettingsAPI Keys
  3. Copy your Public Key and Secret Key
Keep Your Keys Secure
  • Never expose your secret key in client-side code
  • Use environment variables to store your keys
  • Rotate your keys regularly for security

Step 2: Initialize a Payment

Here's a simple example of how to initialize a payment:

// Using JavaScript/Node.js
const axios = require("axios");

const initializePayment = async () => {
try {
const response = await axios.post(
"https://api.resolutpay.com/transaction/initialize",
{
amount: 5000, // Amount in pesewas (50 GHS)
email: "customer@example.com",
reference: "REF_" + Date.now(),
callback_url: "https://yourwebsite.com/verify",
currency: "GHS",
},
{
headers: {
Authorization: "Bearer YOUR_SECRET_KEY",
"Content-Type": "application/json",
},
}
);

console.log("Payment URL:", response.data.data.authorization_url);
// Redirect customer to this URL to complete payment
} catch (error) {
console.error("Error:", error.response.data);
}
};
// Using PHP
<?php
$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.resolutpay.com/transaction/initialize",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 5000,
'email' => 'customer@example.com',
'reference' => 'REF_' . time(),
'callback_url' => 'https://yourwebsite.com/verify',
'currency' => 'GHS'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_SECRET_KEY",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
$result = json_decode($response, true);
echo "Payment URL: " . $result['data']['authorization_url'];
}
?>

Step 3: Handle the Payment Response

After the customer completes the payment, they'll be redirected to your callback_url. You should verify the payment on your server:

// Verify payment on your server
const verifyPayment = async (reference) => {
try {
const response = await axios.get(
`https://api.resolutpay.com/transaction/verify/${reference}`,
{
headers: {
Authorization: "Bearer YOUR_SECRET_KEY",
},
}
);

const transaction = response.data.data;

if (transaction.status === "success") {
// Payment successful - update your database
console.log("Payment successful:", transaction);
} else {
// Payment failed
console.log("Payment failed:", transaction);
}
} catch (error) {
console.error("Verification error:", error.response.data);
}
};

Step 4: Test Your Integration

  1. Use the sandbox mode for testing
  2. Use test card numbers provided in the dashboard
  3. Test different payment scenarios (success, failure, pending)

Complete Example

Here's a complete example using Express.js:

const express = require("express");
const axios = require("axios");
const app = express();

app.use(express.json());

// Initialize payment
app.post("/pay", async (req, res) => {
try {
const response = await axios.post(
"https://api.resolutpay.com/transaction/initialize",
{
amount: req.body.amount,
email: req.body.email,
reference: "REF_" + Date.now(),
callback_url: "https://yourwebsite.com/verify",
currency: "GHS",
},
{
headers: {
Authorization: `Bearer ${process.env.RESOLUTPAY_SECRET_KEY}`,
"Content-Type": "application/json",
},
}
);

res.json({
success: true,
authorization_url: response.data.data.authorization_url,
});
} catch (error) {
res.status(400).json({
success: false,
message: error.response.data.message,
});
}
});

// Verify payment
app.get("/verify/:reference", async (req, res) => {
try {
const response = await axios.get(
`https://api.resolutpay.com/transaction/verify/${req.params.reference}`,
{
headers: {
Authorization: `Bearer ${process.env.RESOLUTPAY_SECRET_KEY}`,
},
}
);

const transaction = response.data.data;

if (transaction.status === "success") {
res.json({
success: true,
message: "Payment verified successfully",
data: transaction,
});
} else {
res.json({
success: false,
message: "Payment verification failed",
data: transaction,
});
}
} catch (error) {
res.status(400).json({
success: false,
message: error.response.data.message,
});
}
});

app.listen(3000, () => {
console.log("Server running on port 3000");
});

Next Steps

Need Help?

If you run into any issues:

  1. Check our Error Codes documentation
  2. Visit our Help Center
  3. Contact our Support Team