����JFIF��x�x����'
Server IP : 66.29.137.217 / Your IP : 52.15.60.240 Web Server : LiteSpeed System : Linux premium294.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : gltevjme ( 1095) PHP Version : 7.0.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/gltevjme/cbt.gltechlimited.com/app/Repositories/ |
Upload File : |
<?php /** * File name: RazorpayRepository.php * Last modified: 05/02/22, 8:08 PM * Author: NearCraft - https://codecanyon.net/user/nearcraft * Copyright (c) 2022 */ namespace App\Repositories; use App\Settings\PaymentSettings; use App\Settings\RazorpaySettings; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; use Razorpay\Api\Api; use Razorpay\Api\Errors\SignatureVerificationError; class RazorpayRepository { /** * @var RazorpaySettings */ private RazorpaySettings $settings; public function __construct(RazorpaySettings $settings) { $this->settings = $settings; } /** * Create an order on Razorpay * * @param $paymentId * @param $amount * @return \GuzzleHttp\Promise\PromiseInterface|\Illuminate\Http\Client\Response */ public function createOrder($paymentId, $amount) { return Http::withBasicAuth($this->settings->key_id, $this->settings->key_secret) ->withHeaders(['Content-Type' => 'application/json'] )->post('https://api.razorpay.com/v1/orders', [ 'receipt' => $paymentId, 'amount' => $amount, 'payment_capture' => 1, 'currency' => app(PaymentSettings::class)->default_currency ]); } /** * Verify Razorpay payment with signature * * @param $attributes * @return bool */ public function verifyPayment($attributes) { try { $api = new Api($this->settings->key_id, $this->settings->key_secret); $api->utility->verifyPaymentSignature($attributes); $success = true; } catch (SignatureVerificationError $e) { $success = false; Log::channel('daily')->error($e->getMessage()); } return $success; } /** * Verify Razorpay webhook signature * * @param $webhookBody * @param $webhookSignature * @return bool */ public function verifyWebhook($webhookBody, $webhookSignature) { try { $api = new Api($this->settings->key_id, $this->settings->key_secret); $api->utility->verifyWebhookSignature($webhookBody, $webhookSignature, $this->settings->webhook_secret); $success = true; } catch (SignatureVerificationError $e) { $success = false; Log::channel('daily')->error($e->getMessage()); } return $success; } }