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

Create card

PreviousCardNextRetrieve Card

Last updated 7 months ago

This endpoint allows you to create a new card (virtual or physical) for a customer registered in the KrezyPay system. It ensures the validation of the information provided and checks the uniqueness of the card to avoid duplicates.

Create a new card

POST

Headers

Name
Value

Content-Type

application/json

Authorization

Bearer <token>

Body

Name
Type
Description

customer_id

string

The customer_id of the customer provided during registration

card_type

string

The type of card "Virtual" or "Physical"

card_brand

string

The brand of card "Visa" or "Mastercard"

Response


{
    "status": "success",
    "card_id": "6711305d3cc1c6711305d3cc1e",
    "message": "Card created successfully"
}
{
  "error": "Invalid request"
}

See Examples Below

const endpoint = 'https://api.krezypay.com/v1/sandbox/card/create_card';
const bearerToken = 'YOUR_BEARER_TOKEN'; // Replace with your actual bearer token

const requestBody = {
    customer_id: "67112de111f2667112de111f28",
    card_type: "Virtual",
    card_brand: "Mastercard"
};

fetch(endpoint, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${bearerToken}`
    },
    body: JSON.stringify(requestBody)
})
.then(response => {
    if (!response.ok) {
        throw new Error('Network response was not ok ' + response.statusText);
    }
    return response.json(); // Parse the JSON from the response
})
.then(data => {
    console.log('Success:', data); // Handle the successful response data
})
.catch(error => {
    console.error('Error:', error); // Handle any errors
});
<?php
// Set the API endpoint
$endpoint = 'https://api.krezypay.com/v1/sandbox/card/create_card';

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

// Request body data
$requestBody = [
    'customer_id' => '67112de111f2667112de111f28',
    'card_type' => 'Virtual',
    'card_brand' => 'Mastercard'
];

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

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

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

// Check for errors
if (curl_errno($ch)) {
    echo 'cURL error: ' . curl_error($ch);
} else {
    // Decode the JSON response
    $responseData = json_decode($response, true);
    // Handle the response data
    echo 'Response: ';
    print_r($responseData); // Print the response data
}

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

# Set the API endpoint
endpoint = 'https://api.krezypay.com/v1/sandbox/card/create_card'

# Your Bearer token
bearer_token = 'YOUR_BEARER_TOKEN'  # Replace with your actual bearer token

# Request body data
request_body = {
    'customer_id': '67112de111f2667112de111f28',
    'card_type': 'Virtual',
    'card_brand': 'Mastercard'
}

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

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

# Check if the request was successful
if response.status_code == 200:
    # Print the response data
    print('Response:', response.json())
else:
    # Print the error response
    print(f'Error: {response.status_code}, Message: {response.text}')

Don't forget to save your rating's card_id

💳
https://api.krezypay.com/v1/sandbox/card/create_card