worldline-ind / php-checkoutjs
PHP CheckoutJS integration for Worldline
Requires
- php: >=8.0
Requires (Dev)
- phpunit/phpunit: ^9.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
PHP CheckoutJS Integration Documentation
PHP CheckoutJS Integration
Integrate your PHP applications with Worldline's CheckoutJS to seamlessly handle payments.
Badges
Table of Contents
Installation
Install the package via Composer:
composer require worldline-ind/php-checkoutjs
Configuration
Place the worldline_AdminData.json file in your project root with the following contents:
{
"merchantCode": "YOUR_MERCHANT_CODE",
"merchantSchemeCode": "YOUR_SCHEME_CODE",
"salt": "YOUR_SALT",
"typeOfPayment": "TEST",
"currency": "INR",
"primaryColor": "#000000",
"secondaryColor": "#FFFFFF",
"buttonColor1": "#0000FF",
"buttonColor2": "#FFFFFF",
"logoURL": "https://yourdomain.com/logo.png",
"enableExpressPay": true,
"separateCardMode": false,
"enableNewWindowFlow": true,
"merchantMessage": "Thank you for your order!",
"disclaimerMessage": "Please review your order before proceeding.",
"paymentMode": "ALL",
"paymentModeOrder": "NB,CARD,UPI",
"enableInstrumentDeRegistration": false,
"transactionType": "SALE",
"hideSavedInstruments": false,
"saveInstrument": false,
"displayTransactionMessageOnPopup": false,
"embedPaymentGatewayOnPage": false,
"enableEmandate": false,
"hideSIConfirmation": false,
"expandSIDetails": false,
"enableDebitDay": false,
"showSIResponseMsg": false,
"showSIConfirmation": false,
"enableTxnForNonSICards": false,
"showAllModesWithSI": false,
"enableSIDetailsAtMerchantEnd": false
}
Usage
Basic Usage
Initialize the Checkout Class:
<?php
require 'vendor/autoload.php';
use WorldlineInd\CheckoutJS\Checkout;
$checkout = new Checkout("YOUR_MERCHANT_CODE", "INR", "YOUR_SALT");
?>
Process Payment Request:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$data = [
'mrctCode' => $_POST['mrctCode'],
'txn_id' => $_POST['txn_id'],
'amount' => $_POST['amount'],
'custID' => $_POST['custID'],
'mobNo' => $_POST['mobNo'],
'email' => $_POST['email'],
'returnUrl' => $_POST['returnUrl'],
];
$checkout->processPayment($data);
}
?>
Handle Payment Response:
<?php
$response = $_POST;
$verified = $checkout->verifyResponse($response);
if ($verified) {
if ($response['statusCode'] == '0300') {
echo "Transaction Successful";
} else {
echo "Transaction Failed";
}
} else {
echo "Invalid response hash";
}
?>
Advanced Features
Explore additional functionalities such as refunds, reconciliation, and server-to-server communication within the documentation.
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$transactionIdentifier = $_POST['transactionIdentifier'];
$fromDate = $_POST['fromtransactionDate'];
$toDate = $_POST['totransactionDate'];
$reconciliationData = $checkout->reconcile($transactionIdentifier, $fromDate, $toDate);
// Process reconciliation data
}
?>
Testing
Run the following command to execute tests:
phpunit
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for more details.
License
This project is licensed under the MIT License - see the LICENSE file for details.