1. Go to this page and download the library: Download imlolman/phonepe-php-sdk 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/ */
imlolman / phonepe-php-sdk example snippets
honePe\PhonePe;
// Below are the Test Details for Standard Checkout UAT, you can get your own from PhonePe Team. Make sure to keep the Salt Key and Salt Index safe (in environment variables or .env file).
$phonepe = PhonePe::init(
"PGTESTPAYUAT86", // Merchant ID
"MUID123", // Merchant User ID
"96434309-7796-489d-8924-ab56988a6076", // Salt Key
"1", // Salt Index
"https://webhook.site/f7b80fd4-dc89-49a5-b569-d9d0a10b19c8", // Redirect URL, can be defined on per transaction basis
"https://webhook.site/f7b80fd4-dc89-49a5-b569-d9d0a10b19c8", // Callback URL, can be defined on per transaction basis
"DEV" // or "PROD"
);
$amountInPaisa = 100; // Amount in Paisa
$userMobile = "9999999999"; // User Mobile Number
$transactionID = "MERCHANT".rand(100000, 999999); // Transaction ID to track and identify the transaction, make sure to save this in your database.
$redirectURL = $phonepe->standardCheckout()->createTransaction($amountInPaisa, $userMobile, $transactionID)->getTransactionURL();
// You can also define the redirect and callback URL on per transaction basis
// $redirectURL = $phonepe->standardCheckout()->createTransaction($amountInPaisa, $userMobile, $transactionID, "https://webhook.site/f7b80fd4-dc89-49a5-b569-d9d0a10b19c8", "https://webhook.site/f7b80fd4-dc89-49a5-b569-d9d0a10b19c8")->getTransactionURL();
echo "Redirect URL: ".$redirectURL.PHP_EOL;
header("Location: ".$redirectURL);
honePe\PhonePe;
// Below are the Test Details for Standard Checkout UAT
$phonepe = PhonePe::init(
"MERCHANTUAT", // Merchant ID
"MUID123", // Merchant User ID
"099eb0cd-02cf-4e2a-8aca-3e6c6aff0399", // Salt Key
"1", // Salt Index
"https://webhook.site/f7b80fd4-dc89-49a5-b569-d9d0a10b19c8", // Redirect URL
"https://webhook.site/f7b80fd4-dc89-49a5-b569-d9d0a10b19c8", // Callback URL
"DEV" // or "PROD"
);
$phonepe->standardCheckout()->getTransactionResponse(); // Returns Transaction Response Array after validating if the transaction is from PhonePe
$phonepe->standardCheckout()->getTransactionID(); // Returns Transaction ID
$phonepe->standardCheckout()->getTransactionStatus(); // [
// "PAYMENT_SUCCESS",
// "BAD_REQUEST",
// "AUTHORIZATION_FAILED",
// "INTERNAL_SERVER_ERROR",
// "TRANSACTION_NOT_FOUND",
// "PAYMENT_ERROR",
// "PAYMENT_PENDING",
// "PAYMENT_DECLINED",
// "TIMED_OUT",
// ]
$phonepe->standardCheckout()->isTransactionSuccess(); // Returns true if transaction is successful, false otherwise.
honePe\PhonePe;
// Below are the Test Details for Standard Checkout UAT
$phonepe = PhonePe::init(
"MERCHANTUAT", // Merchant ID
"MUID123", // Merchant User ID
"099eb0cd-02cf-4e2a-8aca-3e6c6aff0399", // Salt Key
"1", // Salt Index
"https://webhook.site/f7b80fd4-dc89-49a5-b569-d9d0a10b19c8", // Redirect URL
"https://webhook.site/f7b80fd4-dc89-49a5-b569-d9d0a10b19c8", // Callback URL
"DEV" // or "PROD"
);
$transactionId = "MERCHANT123456"; // Transaction ID
$phonepe->standardCheckout()->getTransactionResponseByTransactionId($transactionId); // Returns Transaction Response Array after validating if the transaction is from PhonePe
$phonepe->standardCheckout()->getTransactionIDByTransactionId($transactionId); // Returns Transaction ID
$phonepe->standardCheckout()->getTransactionStatusByTransactionId($transactionId); // [
// "PAYMENT_SUCCESS",
// "BAD_REQUEST",
// "AUTHORIZATION_FAILED",
// "INTERNAL_SERVER_ERROR",
// "TRANSACTION_NOT_FOUND",
// "PAYMENT_ERROR",
// "PAYMENT_PENDING",
// "PAYMENT_DECLINED",
// "TIMED_OUT",
// ]
$phonepe->standardCheckout()->isTransactionSuccessByTransactionId($transactionId); // Returns true if transaction is successful, false otherwise.
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.