Skip to content

Commit

Permalink
islamiBankSpotCash function done for test
Browse files Browse the repository at this point in the history
  • Loading branch information
mah-shamim committed May 4, 2024
1 parent 2739993 commit 4c6c495
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 25 deletions.
3 changes: 3 additions & 0 deletions routes/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
43 changes: 43 additions & 0 deletions src/Http/Controllers/VendorTestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]", "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": "[email protected]", "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));
}
}
79 changes: 54 additions & 25 deletions src/Vendors/IslamiBankApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,35 +175,61 @@ public function fetchRemittanceStatus(array $data): array
*/
public function directCreditRemittance(array $data): array
{
//dd($data);
$xmlString = '
<ser:userID>'.$this->config[$this->status]['username'].'</ser:userID>
<ser:password>'.$this->config[$this->status]['password'].'</ser:password>
';
$xmlString .= '<ser:transRefNo>'.($data['transaction_reference_number'] ?? null).'</ser:transRefNo>';
//$xmlString .= '<ser:transRefNo>'.($data['beneficiary_data']['reference_no'] ?? null).'</ser:transRefNo>';
$xmlString .= '<ser:wsMessage>';
$xmlString .= '<xsd:amount>'.($data['amount'] ?? null).'</xsd:amount>';
$xmlString .= '<xsd:isoCode>'.($data['isoCode'] ?? null).'</xsd:isoCode>';

$xmlString .= '<xsd:beneficiaryAccNo>'.($data['beneficiaryAccNo'] ?? null).'</xsd:beneficiaryAccNo>';
$xmlString .= '<xsd:beneficiaryAccType>'.($data['beneficiaryAccType'] ?? null).'</xsd:beneficiaryAccType>';

$xmlString .= '<xsd:beneficiaryAddress>'.($data['beneficiaryAddress'] ?? null).'</xsd:beneficiaryAddress>';
$xmlString .= '<xsd:beneficiaryBankCode>'.($data['beneficiaryBankCode'] ?? null).'</xsd:beneficiaryBankCode>';
$xmlString .= '<xsd:beneficiaryBankName>'.($data['beneficiaryBankName'] ?? null).'</xsd:beneficiaryBankName>';
$xmlString .= '<xsd:beneficiaryBranchCode>'.($data['beneficiaryBranchCode'] ?? null).'</xsd:beneficiaryBranchCode>';
$xmlString .= '<xsd:beneficiaryBranchName>'.($data['beneficiaryBranchName'] ?? null).'</xsd:beneficiaryBranchName>';
$xmlString .= '<xsd:beneficiaryName>'.($data['beneficiaryName'] ?? null).'</xsd:beneficiaryName>';
$xmlString .= '<xsd:beneficiaryPhoneNo>'.($data['beneficiaryPhoneNo'] ?? null).'</xsd:beneficiaryPhoneNo>';
$xmlString .= '<xsd:issueDate>'.($data['issueDate'] ?? null).'</xsd:issueDate>';
$xmlString .= '<xsd:amount>'.($data['sending_amount'] ?? null).'</xsd:amount>';
$xmlString .= '<xsd:isoCode>'.($data['sending_currency'] ?? null).'</xsd:isoCode>';

if($data['service_slug'] == 'bank_transfer'){
$xmlString .= '<xsd:beneficiaryAccNo>'.($data['beneficiary_data']['bank_account_number'] ?? null).'</xsd:beneficiaryAccNo>';
if($data['beneficiary_data']['bank_information']['bank_slug'] == 'islami_bank_bangladesh_limited'){
$xmlString .= '<xsd:beneficiaryAccType>'.($data['beneficiary_data']['beneficiaryAccType'] ?? null).'</xsd:beneficiaryAccType>';
$xmlString .= '<xsd:beneficiaryBranchCode>'.($data['beneficiary_data']['branch_information']['branch_data']['islami_bank_branch_code'] ?? null).'</xsd:beneficiaryBranchCode>';
$xmlString .= '<xsd:paymentType>2</xsd:paymentType>';
}else{
$xmlString .= '<xsd:beneficiaryAccType>?</xsd:beneficiaryAccType>';
$xmlString .= '<xsd:beneficiaryBranchCode>?</xsd:beneficiaryBranchCode>';
$xmlString .= '<xsd:paymentType>3</xsd:paymentType>';
}
}elseif($data['receiver_information']['beneficiary_type_name'] == 'cash_pickup'){
$xmlString .= '<xsd:beneficiaryAccNo>?</xsd:beneficiaryAccNo>';
if($data['beneficiary_data']['bank_information']['bank_slug'] == 'islami_bank_bangladesh_limited'){
$xmlString .= '<xsd:beneficiaryAccType>?</xsd:beneficiaryAccType>';
$xmlString .= '<xsd:beneficiaryBranchCode>'.($data['beneficiary_data']['branch_information']['branch_data']['islami_bank_branch_code'] ?? null).'</xsd:beneficiaryBranchCode>';
$xmlString .= '<xsd:paymentType>1</xsd:paymentType>';
}else{
$xmlString .= '<xsd:beneficiaryAccType>?</xsd:beneficiaryAccType>';
$xmlString .= '<xsd:paymentType>3</xsd:paymentType>';
}
}
$xmlString .= '<xsd:beneficiaryRoutingNo>'.($data['beneficiary_data']['branch_information']['branch_data']['routing_no'] ?? null).'</xsd:beneficiaryRoutingNo>';

$xmlString .= '<xsd:beneficiaryAddress>'.($data['beneficiary_data']['receiver_information']['city_name'] ?? null).','.($data['beneficiary_data']['receiver_information']['country_name'] ?? null).'</xsd:beneficiaryAddress>';
$xmlString .= '<xsd:beneficiaryBankCode>'.($data['beneficiary_data']['bank_information']['bank_data']['islami_bank_code'] ?? null).'</xsd:beneficiaryBankCode>';
$xmlString .= '<xsd:beneficiaryBankName>'.($data['beneficiary_data']['bank_information']['bank_name'] ?? null).'</xsd:beneficiaryBankName>';
$xmlString .= '<xsd:beneficiaryBranchName>'.($data['beneficiary_data']['branch_information']['branch_name'] ?? null).'</xsd:beneficiaryBranchName>';
$xmlString .= '<xsd:beneficiaryName>'.($data['beneficiary_data']['receiver_information']['beneficiary_name'] ?? null).'</xsd:beneficiaryName>';
$xmlString .= '<xsd:beneficiaryPhoneNo>'.($data['beneficiary_data']['receiver_information']['beneficiary_mobile'] ?? null).'</xsd:beneficiaryPhoneNo>';
$xmlString .= '<xsd:issueDate>'.(date('Y-m-d', strtotime($data['created_at'])) ?? null).'</xsd:issueDate>';
$xmlString .= '<xsd:note>'.($data['note'] ?? null).'</xsd:note>';
$xmlString .= '<xsd:paymentType>'.($data['paymentType'] ?? null).'</xsd:paymentType>';
$xmlString .= '<xsd:remitterAddress>'.($data['remitterAddress'] ?? null).'</xsd:remitterAddress>';
$xmlString .= '<xsd:remitterIdentificationNo>'.($data['remitterIdentificationNo'] ?? null).'</xsd:remitterIdentificationNo>';
$xmlString .= '<xsd:remitterName'.($data['remitterName'] ?? null).'</xsd:remitterName>';
$xmlString .= '<xsd:remitterPhoneNo>'.($data['remitterPhoneNo'] ?? null).'</xsd:remitterPhoneNo>';
$xmlString .= '<xsd:secretKey>'.($data['secretKey'] ?? null).'</xsd:secretKey>';
$xmlString .= '<xsd:transReferenceNo>'.($data['transReferenceNo'] ?? null).'</xsd:transReferenceNo>';
$xmlString .= '<xsd: remittancePurpose>'.($data['remittancePurpose'] ?? null).'</xsd: remittancePurpose >';
$xmlString .= '<xsd:remitterAddress>'.($data['beneficiary_data']['sender_information']['profile']['present_address']['city_name'] ?? null).'</xsd:remitterAddress>';
$xmlString .= '<xsd:remitterCountry>'.($data['beneficiary_data']['sender_information']['profile']['present_address']['country_name'] ?? null).'</xsd:remitterCountry>';
$xmlString .= '<xsd:identityType>'.($data['beneficiary_data']['sender_information']['profile']['id_doc']['id_type'] ?? null).'</xsd:identityType>';
if($data['beneficiary_data']['sender_information']['profile']['id_doc']['id_type'] == 'passport'){
$xmlString .= '<xsd:remitterPassportNo>'.($data['beneficiary_data']['sender_information']['profile']['id_doc']['id_no'] ?? null).'</xsd:remitterPassportNo>';
}else{
$xmlString .= '<xsd:remitterIdentificationNo>'.($data['beneficiary_data']['sender_information']['profile']['id_doc']['id_no'] ?? null).'</xsd:remitterIdentificationNo>';
}
$xmlString .= '<xsd:remitterName'.($data['beneficiary_data']['sender_information']['name'] ?? null).'</xsd:remitterName>';
$xmlString .= '<xsd:remitterPhoneNo>'.($data['beneficiary_data']['sender_information']['mobile'] ?? null).'</xsd:remitterPhoneNo>';
$xmlString .= '<xsd:secretKey>'.($data['beneficiary_data']['reference_no'] ?? null).'</xsd:secretKey>';
$xmlString .= '<xsd:transReferenceNo>'.($data['beneficiary_data']['reference_no'] ?? null).'</xsd:transReferenceNo>';
$xmlString .= '<xsd:remittancePurpose>'.($data['remittance_purpose'] ?? null).'</xsd:remittancePurpose>';
$xmlString .= '</ser:wsMessage>';
$soapMethod = 'directCreditWSMessage';
$response = $this->connectionCheck($xmlString, $soapMethod);
Expand Down Expand Up @@ -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.'<br>'.$xml_string);
dump($method.'<br>'.$xml_string);exit();
$response = Http::soap($this->apiUrl, $method, $xml_string);

// $headers = [
Expand Down Expand Up @@ -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)',
Expand All @@ -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
Expand Down

0 comments on commit 4c6c495

Please sign in to comment.