Skip to content

Commit

Permalink
add ability to choose preferable bank for fiat replenish
Browse files Browse the repository at this point in the history
fix small issues
  • Loading branch information
BuyOwnEx committed Jul 13, 2024
1 parent 8b2bebb commit f9548d7
Show file tree
Hide file tree
Showing 19 changed files with 365 additions and 71 deletions.
13 changes: 13 additions & 0 deletions app/Http/Controllers/TraderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,17 @@ public function getAllFiatFees()
return ['success'=>false, 'message'=>$e->getMessage()];
}
}
public function getAllBanks()
{
try {
return Cache::remember('all_banks', 60, function (){
$api = new BuyOwnExClientAPI(config('app.api-public-key'), config('app.api-secret-key'));
return $api->all_banks();
});
} catch (\Exception $e) {
return ['success'=>false, 'message'=>$e->getMessage()];
}
}
public function getHealth()
{
try {
Expand Down Expand Up @@ -1213,6 +1224,7 @@ public function NotifyFiatQRReplenish(Request $request)
return $api->notifyFiatQRReplenish(
Auth::id(),
$request->currency,
$request->bank_id,
$request->amount,
$request->gateway_id
);
Expand All @@ -1230,6 +1242,7 @@ public function NotifyFiatInvoiceReplenish(Request $request)
Auth::id(),
$request->currency,
$request->amount,
$request->bank_id,
$request->inn,
$request->bic,
$request->acc,
Expand Down
1 change: 0 additions & 1 deletion app/Http/Middleware/CheckMobileSign.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ private function signature($params, $secret)
{
ksort($params);
$postFields = http_build_query($params, '', '&');
Log::info($postFields);
$signature = strtoupper(hash_hmac('sha256', $postFields, $secret));
return $signature;
}
Expand Down
21 changes: 16 additions & 5 deletions app/Library/BuyOwnExClientAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public function all_fiat_fees()
return response()->json($response->json(),$response->status());
}

public function all_banks()
{
$response = Http::withToken($this->api_key)->get($this->base.'v1/all_banks');
return response()->json($response->json(),$response->status());
}

public function health()
{
$response = Http::withToken($this->api_key)->get($this->base.'v1/health');
Expand Down Expand Up @@ -925,30 +931,34 @@ public function verificationPayment($trader_id)
return response()->json($response->json(),$response->status());
}

public function notifyFiatQRReplenish($trader_id, $currency, $amount, $gateway_id)
public function notifyFiatQRReplenish($trader_id, $currency, $bank_id, $amount, $gateway_id)
{
$params = [
'trader' => $trader_id,
'currency' => $currency,
'bank_id' => $bank_id,
'amount' => $amount,
'gateway_id' => $gateway_id
'gateway_id' => $gateway_id,
'kyc_driver' => config('app.kyc_driver')
];
$response = Http::asForm()->withToken($this->api_key)
->withHeaders($this->sign($params))
->post($this->base.'v1/notify_fiat_qr_replenish',$params);
return response()->json($response->json(),$response->status());
}

public function notifyFiatInvoiceReplenish($trader_id, $currency, $amount, $inn, $bic, $acc, $gateway_id)
public function notifyFiatInvoiceReplenish($trader_id, $currency, $amount, $bank_id, $inn, $bic, $acc, $gateway_id)
{
$params = [
'trader' => $trader_id,
'currency' => $currency,
'amount' => $amount,
'bank_id' => $bank_id,
'inn' => $inn,
'bic' => $bic,
'acc' => $acc,
'gateway_id' => $gateway_id
'gateway_id' => $gateway_id,
'kyc_driver' => config('app.kyc_driver')
];
$response = Http::asForm()->withToken($this->api_key)
->withHeaders($this->sign($params))
Expand All @@ -965,7 +975,8 @@ public function notifyFiatInvoiceWithdraw($trader_id, $currency, $amount, $inn,
'inn' => $inn,
'bic' => $bic,
'acc' => $acc,
'gateway_id' => $gateway_id
'gateway_id' => $gateway_id,
'kyc_driver' => config('app.kyc_driver')
];
$response = Http::asForm()->withToken($this->api_key)
->withHeaders($this->sign($params))
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"laravel/ui": "^4.2",
"league/flysystem-aws-s3-v3": "^3.0",
"pragmarx/google2fa": "^8.0",
"pragmarx/google2fa-qrcode": "^2.1",
"predis/predis": "^2.2"
Expand Down
1 change: 1 addition & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
'mobile-api-enabled' => (bool) env('MOBILE_API_ENABLED', false),
'spa_enabled' => (bool) env('SPA_ENABLED', false),
'support_enabled' => (bool) env('VITE_CONFIG_ENABLED_SUPPORT', false),
'kyc_driver' => env('VITE_KYC_DRIVER', 'local'),
/*
|--------------------------------------------------------------------------
| Application Name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</v-card-title>

<v-card-text class="common-dialog__content pb-1">
<v-stepper v-model="step">
<v-stepper v-model="step" class="no-transition">
<v-stepper-header>
<v-stepper-step :complete="step > 1" step="1">
{{ $t('balance.select_payment_method') }}
Expand Down Expand Up @@ -61,6 +61,8 @@
v-if="selected_gateway && selected_gateway.code === 'QR'"
:selectedPlatform="selectedPlatfrom"
:currency_scale="currencyObj.scale"
:fees="fees"
:bank_details="bank_details"
@filled="amount_filled"
@back_pressed="back"
/>
Expand All @@ -69,22 +71,28 @@
:trader_status="trader_status"
:selectedPlatform="selectedPlatfrom"
:currency_scale="currencyObj.scale"
:fees="fees"
:bank_details="bank_details"
@filled="fields_filled"
@back_pressed="back"
/>
</v-stepper-content>

<v-stepper-content class="pa-0" step="3">
<ShowQr
v-if="selected_gateway && selected_gateway.code === 'QR' && amount !== null"
v-if="selected_gateway && selected_gateway.code === 'QR' && amount !== null && bank_id !== null"
:selectedPlatform="selectedPlatfrom"
:amount="amount"
:bank_details="bank_details"
:bank_id="bank_id"
@back_pressed="back"
@success_response="close"
/>
<ConfirmationStep
v-if="selected_gateway && selected_gateway.code === 'INVOICE' && amount !== null && inn !== null && bic !== null && acc !== null"
:banks="banks"
:amount="amount"
:bank_id="bank_id"
:inn="inn"
:bic="bic"
:acc="acc"
Expand Down Expand Up @@ -148,11 +156,14 @@ export default {
selectedPlatfrom: null,
selectedGateway: null,
amount: null,
bank_id: null,
inn: null,
bic: null,
acc: null,
gateways: [],
banks: [],
fees: [],
bank_details: [],
step: 1,
};
},
Expand Down Expand Up @@ -188,14 +199,17 @@ export default {
methods: {
fields_filled(data) {
this.bank_id = data.bank_id;
this.amount = data.amount;
this.inn = data.inn;
this.bic = data.bic;
this.acc = data.acc;
this.banks = data.banks;
this.step++;
},
amount_filled(amount) {
this.amount = amount;
amount_filled(data) {
this.amount = data.amount;
this.bank_id = data.bank_id;
this.step++;
},
platformSelected(data) {
Expand All @@ -221,6 +235,9 @@ export default {
axios.get('/trader/ext/all_fiat_fees').then(response => {
this.fees = response.data.data;
});
axios.get('/trader/ext/replenish_bank_details').then(response => {
this.bank_details = response.data.data;
});
}
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default {
getGatewayLogo(gateway_id)
{
let gateway = _.find(this.gateways, item => (item.id === gateway_id));
return `/storage/fiat_gateways/${gateway.logo}`;
return `${gateway.logo}`;
},
getMinAmount(item) {
return item.minReplenish;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default {
getGatewayLogo(gateway_id)
{
let gateway = _.find(this.gateways, item => (item.id === gateway_id));
return `/storage/fiat_gateways/${gateway.logo}`;
return `${gateway.logo}`;
},
getMinAmount(item) {
return item.minWithdraw;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
{{ $t('balance.dialog.fiat_invoice_confirm_step_description') }}
</div>
<div class="confirmation-item__info-wrapper">
<div class="confirmation-item__info-key-wrapper">
<div class="confirmation-item__header mr-auto">
{{ $t('balance.select_bank') }}
</div>
<div class="confirmation-item__secret-key">
<v-img
class="elevation-0 d-inline-flex"
style="vertical-align: middle"
:src="bank_logo"
max-height="16"
max-width="16"
></v-img>
<span class="ml-1">{{ bank_name }}</span>
</div>
</div>
<div class="confirmation-item__info-key-wrapper">
<div class="confirmation-item__header mr-auto">
{{ $t('common.amount') }}
Expand Down Expand Up @@ -83,6 +98,10 @@ export default {
type: Array,
required: true,
},
banks: {
type: Array,
required: true,
},
amount: {
type: String,
required: true,
Expand All @@ -99,14 +118,14 @@ export default {
type: String,
required: true,
},
bank_id: {
type: [String, Number],
required: true,
},
},
data() {
return {
platform: this.selectedPlatform,
d_amount: this.amount,
d_inn: this.inn,
d_bic: this.bic,
d_acc: this.acc
};
},
computed: {
Expand All @@ -116,6 +135,20 @@ export default {
currency() {
return this.selectedPlatfrom?.currency;
},
bank_logo() {
let bank_ind = _.findIndex(this.banks, (item) => {
return item.id === this.bank_id
});
if(bank_ind > 0) return this.banks[bank_ind].logo;
else return null;
},
bank_name() {
let bank_ind = _.findIndex(this.banks, (item) => {
return item.id === this.bank_id
});
if(bank_ind > 0) return this.banks[bank_ind].name;
else return null;
}
},
mounted() {
Expand Down Expand Up @@ -187,10 +220,11 @@ export default {
finish() {
axios.post('/trader/ext/notify_fiat_invoice_replenish', {
currency: this.platform.currency,
amount: this.d_amount,
inn: this.d_inn,
bic: this.d_bic,
acc: this.d_acc,
amount: this.amount,
bank_id: this.bank_id,
inn: this.inn,
bic: this.bic,
acc: this.acc,
gateway_id: this.platform.gateway_id
}).then(response => {
if (response.data.success === true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
<div class="confirmation-item__secret-key">{{ inn }}</div>
</div>

<div class="confirmation-item__info-key-wrapper">
<div class="confirmation-item__info-key-wrapper" v-if="selectedPlatform.currency !== 'USD'">
<div class="confirmation-item__header mr-auto">
{{ $t('fiat.bic') }}
</div>
<div class="confirmation-item__secret-key">{{ bic }}</div>
</div>

<div class="confirmation-item__info-key-wrapper">
<div class="confirmation-item__info-key-wrapper" v-if="selectedPlatform.currency !== 'USD'">
<div class="confirmation-item__header mr-auto">
{{ $t('fiat.acc') }}
</div>
Expand Down
Loading

0 comments on commit f9548d7

Please sign in to comment.