kiakaha / chargily-v2
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.1
- ext-ctype: *
- ext-curl: *
- ext-iconv: *
- guzzlehttp/guzzle: ^7.8
- symfony/console: 6.4.*
- symfony/dotenv: 6.4.*
- symfony/flex: ^2
- symfony/framework-bundle: 6.4.*
- symfony/runtime: 6.4.*
- symfony/yaml: 6.4.*
This package is auto-updated.
Last update: 2024-05-05 18:17:30 UTC
README
Symfony Plugin for Chargily v2 ePay Gateway Installation
Installation
- Via Composer (Recomended)
composer require kiakaha/chargily-v2
- Register the bundle, add this line at the end of the file config/bundles.php
Chargily\V2Bundle\ChargilyV2Bundle::class => ['all' => true]
- Import the services, Add the follow line in config/services.yml
imports: services: .... Chargily\V2Bundle\Service\HandleRequest\ChargilySendRequest: public: true
- Configure the api keys Add the follow line in config/services.yml
parameters: ....... sandbox_url: 'Your test URL' live_url: 'Your Live URL' public_key: "Your Public KEY" secret_key: "Your Secret KEY" dev: Boolean true|flase
- Create Product Method
#[Route('/chargily/create/product', name: 'create_new_product', methods: ['GET'])] public function createNewProduct(ChargilySendRequest $sendRequest) { $payload = json_encode(["name" => "Super Product"]); $response = $sendRequest->createNewProduct($payload); if ($response->getStatusCode() == 200) { $response = json_decode($response->getContent()); return new JsonResponse([ "id" => $response->id ?? null, "entity" => $response->entity ?? null, "livemode" => $response->livemode ?? null, "name" => $response->name ?? null, "description" => $response->description ?? null, "images" => $response->images ?? null, "metadata" => $response->metadata ?? null, "created_at" => $response->created_at ?? null, "updated_at" => $response->updated_at ?? null ]); } else { $response = json_decode($response->getContent()); return new JsonResponse($response); } }
- Create Price Method
#[Route('/chargily/create/price', name: 'create_price', methods: ['GET'])] public function createPrice(ChargilySendRequest $sendRequest) { $payload = json_encode(["amount" => 5000, "currency" => "dzd", "product_id" => "01hnwn32spw57bz2b4m52rdjrh"]); return $sendRequest->createPrice($payload); }
- Create checkout Method
#[Route('/chargily/create/checkout', name: 'create_checkout', methods: ['GET'])] public function createCheckout(ChargilySendRequest $sendRequest) { $payload = json_encode(["items" => [[ "price" => "01hntrjg31kkxebqzxk37xzhp8", "quantity" => 1 ]], "success_url" => "https://your-cool-website.com/payments/success" ]); return $sendRequest->createCheckout($payload); }
- Webhook Method
/** * @Route("/chargily/webhook/checkout",name="webhook_checkout") * @throws \Exception */ public function webhookCheckout(ChargilySendRequest $sendRequest, Request $request) { $response = $sendRequest->webhookCheckout($request); return $response; }
- this is a full controller for the implementations
<?php namespace App\Controller; use Chargily\V2Bundle\Service\HandleRequest\ChargilySendRequest; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Attribute\Route; class ChargilyEpaySymfonyController extends AbstractController { #[Route('/chargily/create/product', name: 'create_new_product', methods: ['GET'])] public function createNewProduct(ChargilySendRequest $sendRequest) { $payload = json_encode(["name" => "Super Product"]); $response = $sendRequest->createNewProduct($payload); if ($response->getStatusCode() == 200) { $response = json_decode($response->getContent()); return new JsonResponse([ "id" => $response->id ?? null, "entity" => $response->entity ?? null, "livemode" => $response->livemode ?? null, "name" => $response->name ?? null, "description" => $response->description ?? null, "images" => $response->images ?? null, "metadata" => $response->metadata ?? null, "created_at" => $response->created_at ?? null, "updated_at" => $response->updated_at ?? null ]); } else { $response = json_decode($response->getContent()); return new JsonResponse($response); } } #[Route('/chargily/create/price', name: 'create_price', methods: ['GET'])] public function createPrice(ChargilySendRequest $sendRequest) { $payload = json_encode(["amount" => 5000, "currency" => "dzd", "product_id" => "01hnwn32spw57bz2b4m52rdjrh"]); return $sendRequest->createPrice($payload); } #[Route('/chargily/create/checkout', name: 'create_checkout', methods: ['GET'])] public function createCheckout(ChargilySendRequest $sendRequest) { $payload = json_encode(["items" => [[ "price" => "01hntrjg31kkxebqzxk37xzhp8", "quantity" => 1 ]], "success_url" => "https://your-cool-website.com/payments/success" ]); return $sendRequest->createCheckout($payload); } /** * @Route("/chargily/webhook/checkout",name="webhook_checkout") * @throws \Exception */ public function webhookCheckout(ChargilySendRequest $sendRequest, Request $request) { $response = $sendRequest->webhookCheckout($request); return $response; } }
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 V2 For test Mode ePay by Chargily V2 For live Mode dashboard for free.
- Start developing.
- Finished? Push and merge.