Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BANK-3352] support BRL fx #377

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading