PHP code example of credopay / paymentgateway

1. Go to this page and download the library: Download credopay/paymentgateway library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

credopay / paymentgateway example snippets




use CredoPay\CredoPayPaymentGateway;
use CredoPay\Resources\OrderAPI;

// Initialize the payment gateway
$clientId = 'your-client-id';
$clientSecret = 'your-client-secret';
$gateway = new CredoPayPaymentGateway($clientId, $clientSecret);

// Initialize the OrderAPI
$orderAPI = new OrderAPI($gateway);



$orderData = [
    'receiptId' => 'RE_YOURRECEIPT123',
    'amount' => 500, // Amount in smallest currency unit
    'currency' => 'INR',
    'description' => 'Test Payment',
    'customerFields' => [
        'name' => 'John Doe',
        'email' => '[email protected]',
        'phone' => '9876543210'
    ],
    'uiMode' => 'checkout'
];

try {
    $orderResponse = $orderAPI->createOrder($orderData);
    echo "Order Response: " . $orderResponse;
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}



try {
    $orderId = 'your-order-id'; // Replace with an actual order ID
    $statusResponse = $orderAPI->checkStatus($orderId);
    echo "Order Status: " . $statusResponse;
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}

graphql

src/
├── Config.php            # Contains API endpoints and configurations
├── CredoPayPaymentGateway.php  # Handles HTTP requests
└── resources/
    ├── OrderAPI.php      # Methods for order operations
    └── TransactionAPI.php # Placeholder for future enhancements