Integrate our payment gateway into your application with our comprehensive API documentation and code examples.
https://www.payesv.com/api/initiate-payment
x-api-key: YOUR_API_KEY
x-brand-key: YOUR_BRAND_KEY
x-api-secret: YOUR_API_SECRET
Content-Type: application/json
{ "amount": "100", "currency": "BDT/USD", "customer": { "name": "Anis Rahman", "email": "anis@gmail.com", "phone": "01826673690" }, "orderId": "ord17238", "redirectUrl": { "success": "https://www.your-domain.com/success", "failed": "https://www.your-domain.com/failed" } }
<?php // Payment Gateway Integration - PHP class PaymentGateway { private $apiKey = 'YOUR_API_KEY'; private $brandKey = 'YOUR_BRAND_KEY'; private $apiSecret = 'YOUR_API_SECRET'; private $baseUrl = 'https://www.payesv.com/api/initiate-payment'; public function createPayment($amount, $customer, $orderId, $redirectUrls) { $data = [ 'amount' => $amount, 'currency' => 'BDT', 'customer' => $customer, 'orderId' => $orderId, 'redirectUrl' => $redirectUrls ]; $headers = [ 'x-api-key: ' . $this->apiKey, 'x-brand-key: ' . $this->brandKey, 'x-api-secret: ' . $this->apiSecret, 'Content-Type: application/json' ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->baseUrl); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $responseData = json_decode($response, true); if ($httpCode === 200) { return [ 'status' => 'success', 'message' => $responseData['message'], 'id' => $responseData['id'], 'redirectGatewayUrl' => $responseData['redirectGatewayUrl'] ]; } else { return [ 'status' => 'error', 'message' => $responseData['message'] ?? 'Request failed' ]; } } } // Usage Example $paymentGateway = new PaymentGateway(); $customer = [ 'name' => 'Anis Rahman', 'email' => 'anis@gmail.com', 'phone' => '01826673690' ]; $redirectUrls = [ 'success' => 'https://your-domain.com/success', 'failed' => 'https://your-domain.com/failed' ]; $result = $paymentGateway->createPayment('100', $customer, 'ord17238', $redirectUrls); echo json_encode($result, JSON_PRETTY_PRINT); ?>
{ "message": "Payment initiated successfully", "id": "transaction_id_here", "redirectGatewayUrl": "https://checkout.payesv.com/pay/transaction_id_here" }
{ "status": "error", "message": "Invalid API Key or API Secret or Brand Key" }