cashfree / cashfree-pg
Cashfree's Payment Gateway APIs provide developers with a streamlined pathway to integrate advanced payment processing capabilities into their applications, platforms and websites.
Requires
- php: ^8.1
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^8.0 || ^9.0
This package is not auto-updated.
Last update: 2026-06-12 16:48:59 UTC
README
The Cashfree PG PHP SDK offers a convenient solution to access Cashfree PG APIs from a server-side PHP application.
Documentation
Cashfree's PG API Documentation - https://docs.cashfree.com/reference/pg-new-apis-endpoint
Learn and understand payment gateway workflows at Cashfree Payments here
Try out our interactive guides at Cashfree Dev Studio !
Getting Started
Note: This README is for the current branch and not necessarily what's released in Composer
Installation
composer require cashfree/cashfree-pg
Version >=6
Configuration
$cashfree = new \Cashfree\Cashfree( \Cashfree\Cashfree::$SANDBOX, // or \Cashfree\Cashfree::$PRODUCTION "<x-client-id>", "<x-client-secret>", "", // x-partner-api-key (leave blank if unused) "", // x-partner-merchant-id (leave blank if unused) "", // x-client-signature (leave blank if unused) true // enable error analytics );
Generate your API keys (x-client-id , x-client-secret) from Cashfree Merchant Dashboard
Basic Usage
Create Order
$create_orders_request = new \Cashfree\Model\CreateOrderRequest(); $create_orders_request->setOrderAmount(1.0); $create_orders_request->setOrderCurrency("INR"); $customer_details = new \Cashfree\Model\CustomerDetails(); $customer_details->setCustomerId("walterwNrcMi"); $customer_details->setCustomerPhone("9999999999"); $create_orders_request->setCustomerDetails($customer_details); try { $result = $cashfree->PGCreateOrder($create_orders_request); print_r($result); } catch (Exception $e) { echo 'Exception when calling PGCreateOrder: ', $e->getMessage(), PHP_EOL; }
Get Order
try { $response = $cashfree->PGFetchOrder("<order_id>"); print_r($response); } catch (Exception $e) { echo 'Exception when calling PGFetchOrder: ', $e->getMessage(), PHP_EOL; }
Version <6
Configuration
\Cashfree\Cashfree::$XClientId = "<x-client-id>"; \Cashfree\Cashfree::$XClientSecret = "<x-client-secret>"; \Cashfree\Cashfree::$XEnvironment = Cashfree\Cashfree::$SANDBOX; $cashfree = new \Cashfree\Cashfree();
Generate your API keys (x-client-id , x-client-secret) from Cashfree Merchant Dashboard
Basic Usage
Create Order
$x_api_version = "2023-08-01"; $create_orders_request = new \Cashfree\Model\CreateOrderRequest(); $create_orders_request->setOrderAmount(1.0); $create_orders_request->setOrderCurrency("INR"); $customer_details = new \Cashfree\Model\CustomerDetails(); $customer_details->setCustomerId("walterwNrcMi"); $customer_details->setCustomerPhone("9999999999"); $create_orders_request->setCustomerDetails($customer_details); try { $result = $cashfree->PGCreateOrder($x_api_version, $create_orders_request); print_r($result); } catch (Exception $e) { echo 'Exception when calling PGCreateOrder: ', $e->getMessage(), PHP_EOL; }
Get Order
$x_api_version = "2023-08-01"; try { $response = $cashfree->PGFetchOrder($x_api_version, "<order_id>"); print_r($response); } catch (Exception $e) { echo 'Exception when calling PGFetchOrder: ', $e->getMessage(), PHP_EOL; }
Supported Resources
Licence
Apache Licensed. See LICENSE.md for more details