diff --git a/routes/test.php b/routes/test.php index 1dbdca3..4c3dfad 100644 --- a/routes/test.php +++ b/routes/test.php @@ -20,3 +20,6 @@ Route::get('islami-bank-fetch-validate-beneficiary-wallet', [VendorTestController::class, 'islamiBankValidateBeneficiaryWallet']) ->name('islami-bank-fetch-validate-beneficiary-wallet'); + +Route::get('islami-bank-spot-cash', [VendorTestController::class, 'islamiBankSpotCash']) + ->name('islami-bank-spot-cash'); diff --git a/src/Http/Controllers/VendorTestController.php b/src/Http/Controllers/VendorTestController.php index 6484b5c..2139f55 100644 --- a/src/Http/Controllers/VendorTestController.php +++ b/src/Http/Controllers/VendorTestController.php @@ -54,4 +54,47 @@ public function islamiBankFetchMobileBankingMCash(): void $data['branch_code'] = '358'; dump($vendor->fetchAccountDetail($data)); } + + public function islamiBankSpotCash(): void + { + $vendor = app()->make(\Fintech\Remit\Vendors\IslamiBankApi::class); + $repo = app()->make(\Fintech\Transaction\Services\OrderService::class); + //$order = $repo->find(265); + //$order_data = $order->order_data; + $order = [ + "id" => 265, + "source_country_id" => 231, + "destination_country_id" => 19, + "parent_id" => null, + "sender_receiver_id" => 10, + "user_id" => 6, + "service_id" => 13, + "transaction_form_id" => 6, + "ordered_at" => "2024-04-22 09:49:47", + "amount" => "10000.000000", + "currency" => "BDT", + "converted_amount" => "131.995776", + "converted_currency" => "AED", + "order_number" => "ARE00000000000000265", + "risk_profile" => "green", + "notes" => null, + "is_refunded" => 0, + "order_data" => '{"bank_id": 18, "user_name": "Test User 1", "created_at": "2024-04-22T09:49:48.694109Z", "created_by": "Test User 1", "fund_source": "Bank Deposit", "assign_order": "no", "request_from": "web", "service_name": "Bank Transfer", "service_slug": "bank_transfer", "account_number": "88023456789", "bank_branch_id": 3142, "beneficiary_id": 35, "current_amount": 585.997246, "previous_amount": 585.997246, "purchase_number": "ARE00000000000000265", "beneficiary_data": {"reference_no": "MCM00000000000000265", "bank_information": {"bank_data": {"swift_code": "IBBLBDDH", "islami_bank_code": 42}, "bank_name": "Islami Bank Bangladesh Limited", "bank_slug": "islami_bank_bangladesh_limited"}, "branch_information": {"branch_data": {"routing_no": "100154364", "islami_bank_branch_code": 213}, "branch_name": "Head Office Complex"}, "sender_information": {"name": "Test User 1", "email": "testuser1@gmail.com", "mobile": "01600000007", "profile": {"id_doc": {"id_no": "12345678", "id_type": "passport", "id_issue_at": "2024-02-04T00:00:00.000000Z", "id_expired_at": "2029-02-04T00:00:00.000000Z", "id_no_duplicate": "no", "id_issue_country": "Bangladesh"}, "blacklisted": "no", "profile_data": {"note": "Testing", "gender": "male", "occupation": "service", "father_name": "Mustak Ahmed", "mother_name": "Hamida Begum", "nationality": "Bangladeshi", "marital_status": "unmarried", "source_of_income": "salary"}, "date_of_birth": "1999-02-04T00:00:00.000000Z", "present_address": {"address": "Mohammadpur", "city_id": 16152, "state_id": 866, "city_data": null, "city_name": "Ajax", "post_code": "1234", "country_id": 39, "state_data": [], "state_name": "Ontario", "country_data": {"is_serving": true, "language_enabled": true, "multi_currency_enabled": true}, "country_name": "Canada"}}, "currency": "CAD", "language": "en", "fcm_token": "8uqMfhCq6ieLiTm2EKZHDs6eDf76Gv6iFvF8oAiD"}, "receiver_information": {"city_id": 8486, "state_id": 771, "city_data": null, "city_name": "Dhaka", "country_id": 19, "state_data": [], "state_name": "Dhaka District", "relation_id": 3, "country_data": {"is_serving": true, "language_enabled": true, "multi_currency_enabled": true}, "country_name": "Bangladesh", "relation_data": null, "relation_name": "Brother In Law", "beneficiary_data": {"email": "testuser1@gmail.com", "bank_id": 18, "cash_id": 18, "bank_name": "Islami Bank Bangladesh Limited", "cash_name": "Islami Bank Bangladesh Limited", "last_name": null, "wallet_id": null, "first_name": null, "wallet_name": null, "account_name": "recip1 bank", "bank_branch_id": 3142, "instant_bank_id": null, "bank_branch_name": "Head Office Complex", "account_type_code": "02", "instant_bank_name": null, "bank_account_number": "88023456789", "cash_account_number": null, "wallet_account_number": null, "instant_bank_branch_id": null, "instant_bank_branch_name": null, "instant_bank_account_number": null}, "beneficiary_name": "test.instant test.instant", "beneficiary_mobile": "01600000007", "beneficiary_address": null, "beneficiary_type_id": 1, "beneficiary_type_name": "Bank Transfer"}}, "master_user_name": "Afghanistan Master User", "service_stat_data": {"charge": "5%", "discount": "5%", "commission": "3%", "charge_refund": "yes", "discount_refund": "yes", "service_stat_id": 6257, "commission_refund": "yes", "charge_break_down_id": null}, "remittance_purpose": "Family Maintenance or Savings", "beneficiary_type_id": 1, "currency_convert_rate": {"rate": 75.76, "input": "BDT", "amount": "10000", "output": "AED", "converted": 131.99577613516365, "amount_formatted": "AED 10,000.00", "converted_formatted": "BDT 132.00"}, "created_by_mobile_number": "01600000007", "system_notification_variable_failed": "bank_transfer_failed", "system_notification_variable_success": "bank_transfer_success"}', + "status" => "successful", + "creator_id" => null, + "editor_id" => null, + "destroyer_id" => null, + "restorer_id" => null, + "created_at" => "2024-04-22 09:49:48", + "updated_at" => "2024-04-22 09:49:48", + "deleted_at" => null, + "restored_at" => null, + ]; + $order_data = json_decode($order['order_data'], true); + $order_data['beneficiary_data']['reference_no'] = 'TEST'.time(); + $order_data['sending_amount'] = $order['amount']; + $order_data['sending_currency'] = $order['currency']; + //dd($order_data); + dump($vendor->directCreditRemittance($order_data)); + } } diff --git a/src/Vendors/IslamiBankApi.php b/src/Vendors/IslamiBankApi.php index 5d7fa19..284de37 100644 --- a/src/Vendors/IslamiBankApi.php +++ b/src/Vendors/IslamiBankApi.php @@ -175,35 +175,61 @@ public function fetchRemittanceStatus(array $data): array */ public function directCreditRemittance(array $data): array { + //dd($data); $xmlString = ' '.$this->config[$this->status]['username'].' '.$this->config[$this->status]['password'].' '; - $xmlString .= ''.($data['transaction_reference_number'] ?? null).''; + //$xmlString .= ''.($data['beneficiary_data']['reference_no'] ?? null).''; $xmlString .= ''; - $xmlString .= ''.($data['amount'] ?? null).''; - $xmlString .= ''.($data['isoCode'] ?? null).''; - - $xmlString .= ''.($data['beneficiaryAccNo'] ?? null).''; - $xmlString .= ''.($data['beneficiaryAccType'] ?? null).''; - - $xmlString .= ''.($data['beneficiaryAddress'] ?? null).''; - $xmlString .= ''.($data['beneficiaryBankCode'] ?? null).''; - $xmlString .= ''.($data['beneficiaryBankName'] ?? null).''; - $xmlString .= ''.($data['beneficiaryBranchCode'] ?? null).''; - $xmlString .= ''.($data['beneficiaryBranchName'] ?? null).''; - $xmlString .= ''.($data['beneficiaryName'] ?? null).''; - $xmlString .= ''.($data['beneficiaryPhoneNo'] ?? null).''; - $xmlString .= ''.($data['issueDate'] ?? null).''; + $xmlString .= ''.($data['sending_amount'] ?? null).''; + $xmlString .= ''.($data['sending_currency'] ?? null).''; + + if($data['service_slug'] == 'bank_transfer'){ + $xmlString .= ''.($data['beneficiary_data']['bank_account_number'] ?? null).''; + if($data['beneficiary_data']['bank_information']['bank_slug'] == 'islami_bank_bangladesh_limited'){ + $xmlString .= ''.($data['beneficiary_data']['beneficiaryAccType'] ?? null).''; + $xmlString .= ''.($data['beneficiary_data']['branch_information']['branch_data']['islami_bank_branch_code'] ?? null).''; + $xmlString .= '2'; + }else{ + $xmlString .= '?'; + $xmlString .= '?'; + $xmlString .= '3'; + } + }elseif($data['receiver_information']['beneficiary_type_name'] == 'cash_pickup'){ + $xmlString .= '?'; + if($data['beneficiary_data']['bank_information']['bank_slug'] == 'islami_bank_bangladesh_limited'){ + $xmlString .= '?'; + $xmlString .= ''.($data['beneficiary_data']['branch_information']['branch_data']['islami_bank_branch_code'] ?? null).''; + $xmlString .= '1'; + }else{ + $xmlString .= '?'; + $xmlString .= '3'; + } + } + $xmlString .= ''.($data['beneficiary_data']['branch_information']['branch_data']['routing_no'] ?? null).''; + + $xmlString .= ''.($data['beneficiary_data']['receiver_information']['city_name'] ?? null).','.($data['beneficiary_data']['receiver_information']['country_name'] ?? null).''; + $xmlString .= ''.($data['beneficiary_data']['bank_information']['bank_data']['islami_bank_code'] ?? null).''; + $xmlString .= ''.($data['beneficiary_data']['bank_information']['bank_name'] ?? null).''; + $xmlString .= ''.($data['beneficiary_data']['branch_information']['branch_name'] ?? null).''; + $xmlString .= ''.($data['beneficiary_data']['receiver_information']['beneficiary_name'] ?? null).''; + $xmlString .= ''.($data['beneficiary_data']['receiver_information']['beneficiary_mobile'] ?? null).''; + $xmlString .= ''.(date('Y-m-d', strtotime($data['created_at'])) ?? null).''; $xmlString .= ''.($data['note'] ?? null).''; - $xmlString .= ''.($data['paymentType'] ?? null).''; - $xmlString .= ''.($data['remitterAddress'] ?? null).''; - $xmlString .= ''.($data['remitterIdentificationNo'] ?? null).''; - $xmlString .= ''; - $xmlString .= ''.($data['remitterPhoneNo'] ?? null).''; - $xmlString .= ''.($data['secretKey'] ?? null).''; - $xmlString .= ''.($data['transReferenceNo'] ?? null).''; - $xmlString .= ''.($data['remittancePurpose'] ?? null).''; + $xmlString .= ''.($data['beneficiary_data']['sender_information']['profile']['present_address']['city_name'] ?? null).''; + $xmlString .= ''.($data['beneficiary_data']['sender_information']['profile']['present_address']['country_name'] ?? null).''; + $xmlString .= ''.($data['beneficiary_data']['sender_information']['profile']['id_doc']['id_type'] ?? null).''; + if($data['beneficiary_data']['sender_information']['profile']['id_doc']['id_type'] == 'passport'){ + $xmlString .= ''.($data['beneficiary_data']['sender_information']['profile']['id_doc']['id_no'] ?? null).''; + }else{ + $xmlString .= ''.($data['beneficiary_data']['sender_information']['profile']['id_doc']['id_no'] ?? null).''; + } + $xmlString .= ''; + $xmlString .= ''.($data['beneficiary_data']['sender_information']['mobile'] ?? null).''; + $xmlString .= ''.($data['beneficiary_data']['reference_no'] ?? null).''; + $xmlString .= ''.($data['beneficiary_data']['reference_no'] ?? null).''; + $xmlString .= ''.($data['remittance_purpose'] ?? null).''; $xmlString .= ''; $soapMethod = 'directCreditWSMessage'; $response = $this->connectionCheck($xmlString, $soapMethod); @@ -369,7 +395,7 @@ public function validateBeneficiaryWallet(array $data): array private function connectionCheck($xml_post_string, $method): array { $xml_string = $this->xmlGenerate($xml_post_string, $method); - dump($method.'
'.$xml_string); + dump($method.'
'.$xml_string);exit(); $response = Http::soap($this->apiUrl, $method, $xml_string); // $headers = [ @@ -592,7 +618,7 @@ private function __beneficiaryIdentityTypeCode(int $code): string */ private function __accountTypeCode(string $code): array { - return [ + $return = [ '01' => 'AWCA (Current)', '02' => 'MSA (Savings)', '03' => 'MSSA (Scheme)', @@ -605,7 +631,10 @@ private function __accountTypeCode(string $code): array '12' => 'MFCA (FC Savings)', '67' => 'SMSA(Student Savings)', '68' => 'MNSBA(NRB Savings Bond)', + '71' => 'Remittance card', ]; + + return $return[$code]; } public function makeTransfer(array $orderInfo = []): array