add wallet billplz collection

This commit is contained in:
omair saleh
2022-02-22 02:24:58 +08:00
parent c110440316
commit a5b16b944a
4 changed files with 7 additions and 3 deletions
+1
View File
@@ -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"
@@ -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,
@@ -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);
+1
View File
@@ -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',