Skip to content

Commit

Permalink
[BANK-3352] support BRL fx (#377)
Browse files Browse the repository at this point in the history
<img width="1421" alt="Screenshot 2024-12-02 at 3 57 09 PM"
src="https://github.com/user-attachments/assets/758be296-948d-41ed-bab9-062cef2cef83">
<img width="1407" alt="Screenshot 2024-12-02 at 3 59 32 PM"
src="https://github.com/user-attachments/assets/38bb97c7-5c6e-4b9e-8113-bbeba10e5a53">
  • Loading branch information
yitianx00 authored Dec 4, 2024
1 parent 282382e commit bdf3a02
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 2 deletions.
4 changes: 4 additions & 0 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ export default class DefaultLayoutsClass extends Vue {
title: 'POST /mocks/payments/wire',
to: '/debug/payments/mocks/wire',
},
{
title: 'POST /mocks/payments/pix',
to: '/debug/payments/mocks/pix',
},
{
title: 'POST /businessAccount/banks/cbit',
to: '/debug/businessAccount/cbitAccounts/create',
Expand Down
17 changes: 17 additions & 0 deletions lib/mocksApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ export interface CreateMockPushPaymentPayload {
rail: string
}

export interface CreateMockPixPushPaymentPayload {
trackingRef: string
accountNumber: string
amount: {
amount: string
}
}

export interface CreateMockChargebackPayload {
paymentId: string
}
Expand Down Expand Up @@ -59,6 +67,14 @@ function createMockWirePayment(payload: CreateMockPushPaymentPayload) {
return instance.post(url, payload)
}

/**
* Trigger pix payment
*/
function createMockPixPyament(payload: CreateMockPixPushPaymentPayload) {
const url = '/v1/mocks/payments/pix'
return instance.post(url, payload)
}

/**
* Create a mock chargeback
* @param {*} payload
Expand All @@ -72,4 +88,5 @@ export default {
getInstance,
createMockWirePayment,
createMockChargeback,
createMockPixPyament,
}
10 changes: 8 additions & 2 deletions pages/debug/businessAccount/payouts/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,30 @@ export default class CreatePayoutClass extends Vue {
}
required = [(v: string) => !!v || 'Field is required']
destinationType = ['wire', 'cbit', 'xpay', 'rtp', 'rtgs', 'sepa']
destinationType = ['wire', 'cbit', 'xpay', 'rtp', 'rtgs', 'sepa', 'pix']
wireCurrencyTypes = ['USD', 'EUR']
cbitCurrencyTypes = ['USD']
xpayCurrencyTypes = ['USD']
rtpCurrencyTypes = ['USD']
rtgsCurrencyTypes = ['USD', 'EUR']
sepaCurrencyTypes = ['EUR']
pixCurrencyTypes = ['USD']
fxCurrencyTypes = ['', 'SGD', 'MXN']
pixFxCurrencyTypes = ['BRL']
currencyTypes = new Map([
['wire', this.wireCurrencyTypes],
['cbit', this.cbitCurrencyTypes],
['xpay', this.xpayCurrencyTypes],
['rtp', this.rtpCurrencyTypes],
['rtgs', this.rtgsCurrencyTypes],
['sepa', this.sepaCurrencyTypes],
['pix', this.pixCurrencyTypes],
])
toCurrencyTypes = new Map([['USDwire', this.fxCurrencyTypes]])
toCurrencyTypes = new Map([
['USDwire', this.fxCurrencyTypes],
['USDpix', this.pixFxCurrencyTypes],
])
error = {}
loading = false
Expand Down
99 changes: 99 additions & 0 deletions pages/debug/payments/mocks/pix.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<template>
<v-layout>
<v-row>
<v-col cols="12" md="4">
<v-form>
<v-text-field v-model="formData.trackingRef" label="Tracking Ref" />
<v-text-field
v-model="formData.accountNumber"
label="Account Number"
/>
<v-text-field v-model="formData.amount" label="Amount" />
<v-btn
v-if="isSandbox"
depressed
class="mb-7"
color="primary"
:loading="loading"
@click.prevent="makeApiCall"
>
Make api call
</v-btn>
</v-form>
</v-col>
<v-col cols="12" md="8">
<RequestInfo
:url="requestUrl"
:payload="payload"
:response="response"
/>
</v-col>
</v-row>
<ErrorSheet
:error="error"
:show-error="showError"
@onChange="onErrorSheetClosed"
/>
</v-layout>
</template>

<script lang="ts">
import { Component, Vue } from 'nuxt-property-decorator'
import { mapGetters } from 'vuex'
import { getLive } from '../../../../lib/apiTarget'
import RequestInfo from '../../../../components/RequestInfo.vue'
import ErrorSheet from '../../../../components/ErrorSheet.vue'
import { CreateMockPixPushPaymentPayload } from '~/lib/mocksApi'
@Component({
components: {
RequestInfo,
ErrorSheet,
},
computed: {
...mapGetters({
payload: 'getRequestPayload',
response: 'getRequestResponse',
requestUrl: 'getRequestUrl',
}),
},
})
export default class CreateMockIncomingPixClass extends Vue {
formData = {
trackingRef: '',
accountNumber: '',
amount: '0.00',
currency: 'BRL',
}
isSandbox: Boolean = !getLive()
required = [(v: string) => !!v || 'Field is required']
error = {}
loading = false
showError = false
onErrorSheetClosed() {
this.error = {}
this.showError = false
}
async makeApiCall() {
this.loading = true
const amountDetail = {
amount: this.formData.amount,
currency: this.formData.currency,
}
const payload: CreateMockPixPushPaymentPayload = {
trackingRef: this.formData.trackingRef,
accountNumber: this.formData.accountNumber,
amount: amountDetail,
}
try {
await this.$mocksApi.createMockPixPyament(payload)
} catch (error) {
this.error = error
this.showError = true
} finally {
this.loading = false
}
}
}
</script>
2 changes: 2 additions & 0 deletions plugins/mocksApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import mocksApi, {
CreateMockChargebackPayload,
CreateMockPixPushPaymentPayload,
CreateMockPushPaymentPayload,
} from '@/lib/mocksApi'

Expand All @@ -9,6 +10,7 @@ declare module 'vue/types/vue' {
getInstance: any
createMockChargeback: (payload: CreateMockChargebackPayload) => any
createMockWirePayment: (payload: CreateMockPushPaymentPayload) => any
createMockPixPyament: (payload: CreateMockPixPushPaymentPayload) => any
}
}
}
Expand Down

0 comments on commit bdf3a02

Please sign in to comment.