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

Withdraw fund

This endpoint allows you to unload a Visa or Mastercard card

PreviousAuthorization TransactionNextFreeze/Unfreeze

Last updated 7 months ago

Withdraw fund

POST

Headers

Name
Value

Content-Type

application/json

Authorization

Bearer <token>

Body

Name
Type
Description

card_id

string

The card identifier

amount

string

The withdrawal amount

Response


{
    "status": "success",
    "transaction_id": "VC383611797554",
    "amount": 3,
    "fees": "0",
    "message": "Transaction completed successfully"
}
{
  "error": "Invalid request"
}

See Examples Below

// API URL
const url = "https://api.krezypay.com/v1/sandbox/card/withdraw_fund";

// Data to send in the body of the request
const data = {
  card_id: "c451ad689f414827abb0b6dc6ea96edb",
  amount: "3"
};

// Bearer token
const token = "YOUR_BEARER_TOKEN_HERE";  // Replace with the actual token

// Request options
const options = {
  method: "POST",  // HTTP method
  headers: {
    "Content-Type": "application/json",  // Sending JSON data
    "Authorization": `Bearer ${token}`   // Authorization header with Bearer token
  },
  body: JSON.stringify(data)  // Convert the data object to a JSON string
};

// Execute the HTTP request
fetch(url, options)
  .then(response => {
    if (!response.ok) {
      // If the response status is not OK (200-299), throw an error
      throw new Error(`HTTP error! status: ${response.status}`);
    }
    return response.json();  // Parse the response body as JSON
  })
  .then(result => {
    // Handle success - log the result
    console.log("Success:", result);
  })
  .catch(error => {
    // Handle errors during the request
    console.error("Error:", error);
  });
<?php
// API URL
$url = "https://api.krezypay.com/v1/sandbox/card/withdraw_fund";

// Data to send in the body
$data = [
    "card_id" => "c451ad689f414827abb0b6dc6ea96edb",
    "amount" => "3"
];

// Bearer token
$token = "YOUR_BEARER_TOKEN_HERE"; // Replace with the actual token

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

// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  // Return the response as a string
curl_setopt($ch, CURLOPT_POST, true);            // Make a POST request
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',           // Content type set to JSON
    "Authorization: Bearer $token"              // Authorization with Bearer token
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));  // JSON-encoded data sent in the body

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

// Error handling
if (curl_errno($ch)) {
    echo 'cURL error: ' . curl_error($ch);
} else {
    // Decode the JSON response
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    
    if ($httpCode === 200) {
        // Successful response
        $result = json_decode($response, true);
        echo json_encode([
            "status" => "success",
            "data" => $result
        ], JSON_PRETTY_PRINT);
    } else {
        // Handle failed response
        echo json_encode([
            "status" => "error",
            "http_code" => $httpCode,
            "message" => "An error occurred during the request."
        ], JSON_PRETTY_PRINT);
    }
}

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

# API URL
url = "https://api.krezypay.com/v1/sandbox/card/withdraw_fund"

# Data to send in the body of the request
data = {
    "card_id": "c451ad689f414827abb0b6dc6ea96edb",
    "amount": "3"
}

# Bearer token
token = "YOUR_BEARER_TOKEN_HERE"  # Replace with the actual token

# Set the headers, including the Authorization Bearer token
headers = {
    "Content-Type": "application/json",  # Data type we're sending
    "Authorization": f"Bearer {token}"   # Bearer token for authorization
}

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

# Check if the request was successful (status code 200-299)
if response.status_code == 200:
    # Parse the response as JSON and print the result
    result = response.json()
    print("Success:", json.dumps(result, indent=4))
else:
    # Handle any errors during the request
    print(f"Error: {response.status_code}, {response.text}")
https://api.krezypay.com/v1/sandbox/card/withdraw_fund