From a5b16b944a096e4f152122bbf3270379fdb9cd20 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 22 Feb 2022 02:24:58 +0800 Subject: [PATCH] add wallet billplz collection --- .env.example | 1 + .../Modules/Billplzs/Services/CreatesBillplzBill.php | 6 ++++-- .../Modules/Wallets/ControllersLogic/TopUpWalletLogic.php | 2 +- config/billplz.php | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index f3d4fd56..78c079f5 100644 --- a/.env.example +++ b/.env.example @@ -56,3 +56,4 @@ BILLPLZ_BASE_URL="https://www.billplz-sandbox.com" BILLPLZ_API_KEY="0fa4c710-761b-4a7a-a501-c2c2d02643d5" BILLPLZ_X_SIGNATURE_KEY="S-pbNVthVRsvnPfZlgLwqqOg" BILLPLZ_COLLECTION_ID="hev2wdjy" +BILLPLZ_WALLET_COLLECTION_ID="hev2wdjy" diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php index ef3b5f4e..9e656e0b 100644 --- a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php +++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php @@ -4,6 +4,7 @@ namespace App\Classes\Modules\Billplzs\Services; use Illuminate\Support\Facades\Http; use App\Classes\Exceptions\MalformedRequestException; +use phpDocumentor\Reflection\Types\Boolean; class CreatesBillplzBill { @@ -15,14 +16,15 @@ class CreatesBillplzBill * @param float $amount * @param string $billNumber * @param null|string $bankCode + * @param null|Boolean $wallet * @return null|object * @throws MalformedRequestException */ - public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null) { + public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null, ?Boolean $wallet = null) { try{ // config('billplz.maybank') $response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [ - 'collection_id' => config('billplz.collection_id'), + 'collection_id' => $wallet ? config('billplz.wallet_collection_id') : config('billplz.collection_id'), 'name' => $name, 'email' => $email, 'description' => $description, diff --git a/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php index 1c95225d..9bbe6073 100644 --- a/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php +++ b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php @@ -102,7 +102,7 @@ class TopUpWalletLogic extends AbstractControllerLogic throw new MalformedRequestException('Top up credit value must be greater than zero.'); } - $billPlzBill = $this->createsBillplzBill->execute($user->name, $user->email, 'This payment is credit topup for company ref. ' . $company->reference, $amount, $billNumber, $request->input('bank_code')); + $billPlzBill = $this->createsBillplzBill->execute($user->name, $user->email, 'This payment is credit topup for company ref. ' . $company->reference, $amount, $billNumber, $request->input('bank_code'), true); $transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $company->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], $billPlzBill->id); diff --git a/config/billplz.php b/config/billplz.php index fb8ed920..904cea31 100644 --- a/config/billplz.php +++ b/config/billplz.php @@ -5,6 +5,7 @@ return [ 'api_key' => env('BILLPLZ_API_KEY', '0fa4c710-761b-4a7a-a501-c2c2d02643d5'), 'x_signature_key' => env('BILLPLZ_X_SIGNATURE_KEY', 'S-pbNVthVRsvnPfZlgLwqqOg'), 'collection_id' => env('BILLPLZ_COLLECTION_ID', 'hev2wdjy'), + 'wallet_collection_id' => env('BILLPLZ_WALLET_COLLECTION_ID', 'hev2wdjy'), 'redirect_url' => env('BILLPLZ_REDIRECT_URL', 'localhost'), 'callback_url' => env('BILLPLZ_CALLBACK_URL', 'localhost'), 'maybank' => 'MB2U0227',