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
  • Authorization Balance Management
  • Authorization estimate
  • Send Authorization
  1. Card

Authorization Transaction

Authorization Balance Management

As part of the transactions conducted through the KrezyPay API, an authorization balance system is in place to ensure the security and validity of transactions.

What is the Authorization Balance?

The authorization balance is an amount that the user must add before performing a transaction. This amount is used to cover the transaction amount as well as the associated banking fees. This security mechanism ensures that each transaction is validated and that there are sufficient funds for its execution.

Fund Addition Process

  1. Adding Funds: Before executing a transaction, the user must use the API to add funds to their authorization balance.

  2. Duration of Funds: Funds added to the authorization balance remain available for 10 minutes. After this period, any unused funds will be automatically returned to the card's main balance.

  3. Business Cards: If the user has subscriptions (e.g., Facebook Ads), they must upgrade their card to a business card. In this case, funds will remain available in the authorization balance for 24 hours to cover transactions related to these subscriptions.

Banking Fees

For each transaction conducted with a card via KrezyPay, banking fees are applied, including:

  • Fixed Fee: A fixed fee of 1 USD is charged for each transaction.

  • Variable Fee: In addition to the fixed fee, a fee of 1% of the total transaction amount is also applied.

Example of Fee Calculation

  • Transaction of 50 USD:

    • Fixed Fee: 1 USD

    • Variable Fee: 1% of 50 USD = 0.50 USD

    • Total Fees: 1 USD + 0.50 USD = 1.50 USD

    • Total Amount Deducted: 51.50 USD

  • Transaction of 100 USD:

    • Fixed Fee: 1 USD

    • Variable Fee: 1% of 100 USD = 1 USD

    • Total Fees: 2 USD

    • Total Amount Deducted: 102 USD

Security and Control

KrezyPay's authorization balance system aims to provide an additional level of security. It ensures that each transaction is pre-approved and that the user has the necessary funds. This reduces the risk of failed or declined transactions and ensures rigorous control of funds during transactions.

Summary of Steps for the User

  1. Add funds to the authorization balance before executing a transaction.

  2. Be aware of the associated banking fees: 1 USD fixed + 1% of the total amount.

  3. Ensure the authorization balance contains sufficient funds to cover the transaction and fees.

  4. Be mindful of the availability duration of funds in the authorization balance: 10 minutes by default or 24 hours for business cards linked to subscriptions.

Authorization estimate

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 transaction that the user will make

Response


{
    "status": "success",
    "amount": "3.00",
    "tax": "1.03",
    "total": 4.03
}
{
  "error": "Invalid request"
}

See Examples Below

// Function to make a POST request to the KrezyPay API
async function estimateAuthorization(cardId, amount, bearerToken) {
    const url = 'https://api.krezypay.com/v1/sandbox/card/authorization_estimate';

    const body = {
        card_id: cardId,
        amount: amount
    };

    try {
        const response = await fetch(url, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${bearerToken}`
            },
            body: JSON.stringify(body)
        });

        // Check if the response is ok (status code 200-299)
        if (!response.ok) {
            throw new Error(`Error: ${response.status} ${response.statusText}`);
        }

        const data = await response.json();
        console.log('Response Data:', data);
    } catch (error) {
        console.error('Error:', error);
    }
}

// Example usage
const cardId = "c451ad689f414827abb0b6dc6ea96edb";
const amount = "3";
const bearerToken = "your_bearer_token_here"; // Replace with your actual Bearer token

estimateAuthorization(cardId, amount, bearerToken);
<?php
// Function to estimate authorization
function estimateAuthorization($cardId, $amount, $bearerToken) {
    $url = 'https://api.krezypay.com/v1/sandbox/card/authorization_estimate';

    // Prepare the data to send
    $data = [
        'card_id' => $cardId,
        'amount' => $amount
    ];

    // Initialize cURL session
    $ch = curl_init($url);

    // Set cURL options
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return response as a string
    curl_setopt($ch, CURLOPT_POST, true); // Set method to POST
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); // Set the request body
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'Authorization: Bearer ' . $bearerToken // Add Bearer token to headers
    ]);

    // Execute cURL session
    $response = curl_exec($ch);

    // Check for cURL errors
    if (curl_errno($ch)) {
        echo 'cURL Error: ' . curl_error($ch);
    } else {
        // Decode and display the response
        $responseData = json_decode($response, true);
        print_r($responseData);
    }

    // Close cURL session
    curl_close($ch);
}

// Example usage
$cardId = "c451ad689f414827abb0b6dc6ea96edb";
$amount = "3";
$bearerToken = "your_bearer_token_here"; // Replace with your actual Bearer token

estimateAuthorization($cardId, $amount, $bearerToken);
?>
import requests
import json

def estimate_authorization(card_id, amount, bearer_token):
    url = 'https://api.krezypay.com/v1/sandbox/card/authorization_estimate'

    # Prepare the data to send
    data = {
        'card_id': card_id,
        'amount': amount
    }

    # Set the headers
    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {bearer_token}'  # Add Bearer token to headers
    }

    # Make the POST request
    response = requests.post(url, headers=headers, data=json.dumps(data))

    # Check for response status
    if response.status_code == 200:
        # Decode and print the JSON response
        response_data = response.json()
        print(response_data)
    else:
        print(f'Error: {response.status_code} - {response.text}')

# Example usage
card_id = "c451ad689f414827abb0b6dc6ea96edb"
amount = "3"
bearer_token = "your_bearer_token_here"  # Replace with your actual Bearer token

estimate_authorization(card_id, amount, bearer_token)

Send Authorization

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 transaction that the user will make

Response


{
    "status": "success",
    "message": "Transaction successful."
}
{
  "error": "Invalid request"
}

// Function to make a POST request to the KrezyPay API
async function estimateAuthorization(cardId, amount, bearerToken) {
    const url = 'https://api.krezypay.com/v1/sandbox/card/send_authorization';

    const body = {
        card_id: cardId,
        amount: amount
    };

    try {
        const response = await fetch(url, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${bearerToken}`
            },
            body: JSON.stringify(body)
        });

        // Check if the response is ok (status code 200-299)
        if (!response.ok) {
            throw new Error(`Error: ${response.status} ${response.statusText}`);
        }

        const data = await response.json();
        console.log('Response Data:', data);
    } catch (error) {
        console.error('Error:', error);
    }
}

// Example usage
const cardId = "c451ad689f414827abb0b6dc6ea96edb";
const amount = "3";
const bearerToken = "your_bearer_token_here"; // Replace with your actual Bearer token

estimateAuthorization(cardId, amount, bearerToken);
<?php
// Function to estimate authorization
function estimateAuthorization($cardId, $amount, $bearerToken) {
    $url = 'https://api.krezypay.com/v1/sandbox/card/send_authorization';

    // Prepare the data to send
    $data = [
        'card_id' => $cardId,
        'amount' => $amount
    ];

    // Initialize cURL session
    $ch = curl_init($url);

    // Set cURL options
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return response as a string
    curl_setopt($ch, CURLOPT_POST, true); // Set method to POST
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); // Set the request body
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'Authorization: Bearer ' . $bearerToken // Add Bearer token to headers
    ]);

    // Execute cURL session
    $response = curl_exec($ch);

    // Check for cURL errors
    if (curl_errno($ch)) {
        echo 'cURL Error: ' . curl_error($ch);
    } else {
        // Decode and display the response
        $responseData = json_decode($response, true);
        print_r($responseData);
    }

    // Close cURL session
    curl_close($ch);
}

// Example usage
$cardId = "c451ad689f414827abb0b6dc6ea96edb";
$amount = "3";
$bearerToken = "your_bearer_token_here"; // Replace with your actual Bearer token

estimateAuthorization($cardId, $amount, $bearerToken);
?>
import requests
import json

def estimate_authorization(card_id, amount, bearer_token):
    url = 'https://api.krezypay.com/v1/sandbox/card/send_authorization'

    # Prepare the data to send
    data = {
        'card_id': card_id,
        'amount': amount
    }

    # Set the headers
    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {bearer_token}'  # Add Bearer token to headers
    }

    # Make the POST request
    response = requests.post(url, headers=headers, data=json.dumps(data))

    # Check for response status
    if response.status_code == 200:
        # Decode and print the JSON response
        response_data = response.json()
        print(response_data)
    else:
        print(f'Error: {response.status_code} - {response.text}')

# Example usage
card_id = "c451ad689f414827abb0b6dc6ea96edb"
amount = "3"
bearer_token = "your_bearer_token_here"  # Replace with your actual Bearer token

estimate_authorization(card_id, amount, bearer_token)
PreviousFund CardNextWithdraw fund

Last updated 7 months ago

POST

POST

https://api.krezypay.com/v1/sandbox/card/authorization_estimate
https://api.krezypay.com/v1/sandbox/card/send_authorization