KrezyPay API
  • 👋Welcome to KrezyPay API
  • Environment
  • Authentification
  • Customer
    • 👨Create a customer
    • 👨Retrieve Customer
  • Card
    • 💳Create card
    • 💳Retrieve Card
    • 💳Fund Card
    • Authorization Transaction
    • Withdraw fund
    • Freeze/Unfreeze
    • Transaction
    • Countries we support
  • Topup
    • ✅Topup Shema
    • ✅Estimate
    • ✅Send
  • SMS
    • 📶SMS Shema
    • 📶Send SMS
    • Supporting country
  • Production Access
  • ❌Errors
    • 📎Error
Powered by GitBook
On this page
  1. Card

Fund Card

PreviousRetrieve CardNextAuthorization Transaction

Last updated 7 months ago

You can use this endpoint to fund a card.

Fund a card

POST

Headers

Name
Value

Content-Type

application/json

Authorization

Bearer <token>

Body

Name
Type
Description

card_id

string

The card identifier

amount

string

The amount of the recharge

Response


{
    "status": "success",
    "transaction_id": "KR413225538667",
    "amount": 10,
    "fees": "0.20",
    "message": "Transaction completed successfully."
}
{
  "error": "Invalid request"
}

See Examples Below

// Define the endpoint URL
const endpoint = 'https://api.krezypay.com/v1/sandbox/card/add_fund';

// Create the request body
const requestBody = {
    card_id: 'c451ad689f414827abb0b6dc6ea96edb',
    amount: '10'
};

// Set your bearer token
const bearerToken = 'YOUR_BEARER_TOKEN'; // Replace with your actual bearer token

// Make the POST request using fetch
fetch(endpoint, {
    method: 'POST', // Specify the request method
    headers: {
        'Content-Type': 'application/json', // Set content type to JSON
        'Authorization': `Bearer ${bearerToken}` // Add bearer token to the Authorization header
    },
    body: JSON.stringify(requestBody) // Convert the request body to a JSON string
})
.then(response => {
    // Check if the response is ok (status code in the range 200-299)
    if (!response.ok) {
        throw new Error('Network response was not ok: ' + response.statusText);
    }
    return response.json(); // Parse the JSON from the response
})
.then(data => {
    // Handle the response data
    console.log('Response:', data);
})
.catch(error => {
    // Handle any errors
    console.error('Error:', error);
});
<?php

// Define the endpoint URL
$endpoint = 'https://api.krezypay.com/v1/sandbox/card/add_fund';

// Create the request body
$requestBody = [
    'card_id' => 'c451ad689f414827abb0b6dc6ea96edb',
    'amount' => '10'
];

// Convert the request body to JSON
$jsonData = json_encode($requestBody);

// Set your bearer token
$bearerToken = 'YOUR_BEARER_TOKEN'; // Replace with your actual bearer token

// Initialize cURL
$ch = curl_init($endpoint);

// Set the cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string
curl_setopt($ch, CURLOPT_POST, true); // Specify that this is a POST request
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json', // Set content type to JSON
    'Authorization: Bearer ' . $bearerToken // Add bearer token to the Authorization header
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); // Set the request body

// Execute the request
$response = curl_exec($ch);

// Check for errors
if ($response === false) {
    $error = curl_error($ch);
    echo "cURL Error: $error";
} else {
    // Decode the JSON response
    $responseData = json_decode($response, true);
    // Handle the response data
    print_r($responseData);
}

// Close cURL
curl_close($ch);
?>
import requests

# Endpoint URL
endpoint = "https://api.krezypay.com/v1/sandbox/card/add_fund"

# Request body
request_body = {
    "card_id": "c451ad689f414827abb0b6dc6ea96edb",
    "amount": "10"
}

# Bearer token for authorization
bearer_token = "your_bearer_token_here"  # Replace with your actual bearer token

# Headers
headers = {
    "Authorization": f"Bearer {bearer_token}",
    "Content-Type": "application/json"
}

# Make the POST request
response = requests.post(endpoint, json=request_body, headers=headers)

# Check the response status code
if response.status_code == 200:
    # Successful request
    response_data = response.json()  # Get the response data as JSON
    print("Response:", response_data)  # Print the response data
else:
    # Handle errors
    print(f'Error: {response.status_code} - {response.text}')
💳
https://api.krezypay.com/v1/sandbox/card/add_fund