chargily / epay-symfony
Chargily epay plugin for symfony.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- guzzlehttp/guzzle: 7.4.x-dev
Requires (Dev)
- behat/behat: ^3.4
- behat/mink: ^1.7@dev
- behat/mink-browserkit-driver: ^1.3
- behat/mink-extension: ^2.2
- behat/mink-selenium2-driver: ^1.3
- friends-of-behat/context-service-extension: ^1.2
- friends-of-behat/cross-container-extension: ^1.1
- friends-of-behat/service-container-extension: ^1.0
- friends-of-behat/symfony-extension: ^1.2.1
- friends-of-behat/variadic-extension: ^1.1
- lakion/mink-debug-extension: ^1.2.3
- phpspec/phpspec: ^5.0
- sensiolabs/security-checker: ^4.1
- sylius-labs/coding-standard: ^2.0
- symfony/browser-kit: ^3.4|^4.1
- symfony/debug-bundle: ^3.4|^4.1
- symfony/dotenv: ^3.4|^4.1
- symfony/intl: ^3.4|^4.1
- symfony/web-profiler-bundle: ^3.4|^4.1
- symfony/web-server-bundle: ^3.4|^4.1
README
Symfony Plugin for Chargily ePay Gateway
Installation
- Via Composer (Recomended)
composer require chargily/epay-symfony
- Register the bundle, add this line at the end of the file config/bundles.php
\Chargily\SymfonyBundle\ChargilySymfonyBundle::class => ['all' => true],
- Import the services, Add the follow line in config/services.yml
imports:
- { resource: "@ChargilySymfonyBundle/config/services.yaml" }
- Configure the api keys Add the follow line in config/services.yml
parameters: api_key: "API_KEY" secret_key: "SECRET_KEY"
- Process payment and redirection to payment page
$payload = array( "client" => "test", 'client_email' => "test@gmail.com", "invoice_number" => '123456789', "amount" => 110, 'discount' => 0, 'mode' => 'CIB', 'back_url' => "https://test.com", 'webhook_url' => "https://test.com" . "/" . "webHookSuffixRoute". "/" ."OrderNumber", //back_url example when you want to take your host base url //'back_url' => $request->getSchemeAndHttpHost(), //webhook_url example when you want to take your host base url and add your suffix route for the webhook //'webhook_url' => $request->getSchemeAndHttpHost() . "/" . you_back_url_suffix_here . "/" .Order_Number, 'comment' => 'My Payment Comment.', 'api_key' => $this->getParameter('api_key'), ); $chargyliController = new ChargilyEpaySymfonyController(); $response = $chargyliController->pay($payload); $status_code = $response->getStatusCode(); $response = json_decode($response->getContent()); if ($status_code == 200) { //redirect to chargily payment gateway return $this->redirect($response->response); } else { // This is a error message depending on issue that happen dd($status_code . " " . $response->response); }
- success Message for the Process payment
200 => getting redirection link with success => Redirection to url
- Error Message for the Process payment
400 => There mode must be CIB,EDAHABIA option Only 400 => There amount must be numeric and greather or equal than 75 400 => There is issue \for connecting payment gateway. Sorry \for the inconvenience => with error message 400 => There is missing information in payment parameters
- Webhook Template
/** * @Route("/chargily/webhook/{OrderNumber}",name="chargily_webhook") * @throws \Exception */ public function chargilyWebhook(Request $request) { //getting your order number $number = $request->attributes->get('OrderNumber'); //part or code for searching your order by number /* * */ //getting request content $data = json_decode($request->getContent(), true); $headers = json_decode($request->headers, true); $hashedData = hash_hmac('sha256', json_encode($data) , $this->getParameter('secret_key')); if (isset($data) and isset($number)) { if($data['invoice']['status'] == 'paid'){ //part where you update your order status for paid status return new JsonResponse([ 'code' => 200, 'message' => 'Update status with success' ]); }elseif($data['invoice']['status'] == 'failed'){ //part where you update your order status for failed status return new JsonResponse([ 'code' => 200, 'message' => 'Update status with success' ]); } elseif( $data['invoice']['status'] == 'canceled'){ //part where you update your order status for canceled status return new JsonResponse([ 'code' => 200, 'message' => 'Update status with success' ]); } } else { return new JsonResponse([ 'code' => 400, 'message' => 'Update status Failed' ]); } }
- Clear the Cache And Enjoy
php bin/console cache:clear
This Plugin is to integrate ePayment gateway with Chargily easily.
- Currently support payment by CIB / EDAHABIA cards and soon by Visa / Mastercard
- This repo is recently created for Sylius Plugin, If you are a developer and want to collaborate to the development of this plugin, you are welcomed!
Contribution tips
- Make a fork of this repo.
- Take a tour to our API documentation here
- Get your API Key/Secret from ePay by Chargily dashboard for free.
- Start developing.
- Finished? Push and merge.