Skip to content

Instantly share code, notes, and snippets.

@igortrinidad
Created October 5, 2020 15:47
Show Gist options
  • Save igortrinidad/8a910283b3416146970d88e741a0e93f to your computer and use it in GitHub Desktop.
Save igortrinidad/8a910283b3416146970d88e741a0e93f to your computer and use it in GitHub Desktop.
Simulação criação conta company e transferência wirecard
Payload / dados da requisição para criar uma company
wirecardAccount = {
type: 'MERCHANT',
transparentAccount: true,
email: { address: '[email protected]' },
person: {
name: 'IGOR LUCAS',
birthDate: '1986-06-18',
taxDocument: { type: 'CPF', number: '12805364627' },
phone: { countryCode: '55', areaCode: '31', number: '91455975' },
address: {
street: 'Rua Alberto cintra',
streetNumber: '135',
complement: '',
district: 'O bairro',
city: 'Belo Horizonte',
state: 'MG',
zipCode: '35690000',
country: 'BRA'
}
},
company: {
name: 'Empresa boa',
businessName: 'SACOLAO CENTRAL LTDA',
taxDocument: { type: 'CNPJ', number: '11834266000156' },
phone: { countryCode: '55', areaCode: '31', number: '33333333' },
address: {
street: 'Rua Alberto cintra',
streetNumber: '135',
complement: '',
district: 'O bairro',
city: 'Belo Horizonte',
state: 'MG',
zipCode: '35690000',
country: 'BRA'
}
}
}
Essa conta é criada com sucesso: veja retorno na consulta da company
https://sandbox.moip.com.br/v2/accounts/MPA-E32FB98442D0
{
"limited": false,
"person": {
"lastName": "LUCAS",
"phone": {
"areaCode": "31",
"countryCode": "55",
"number": "91455975"
},
"parentsName": {
"mother": "",
"father": ""
},
"address": {
"zipcode": "35690-000",
"zipCode": "35690-000",
"street": "Rua Alberto cintra",
"state": "MG",
"streetNumber": "135",
"district": "O bairro",
"country": "BRA",
"city": "Belo Horizonte"
},
"taxDocument": {
"number": "128.053.646-27",
"type": "CPF"
},
"name": "IGOR",
"birthDate": "1986-06-18"
},
"transparentAccount": true,
"_links": {
"self": {
"href": "https://sandbox.moip.com.br/accounts/MPA-E32FB98442D0"
}
},
"monthlyRevenueId": 0,
"type": "MERCHANT",
"id": "MPA-E32FB98442D0",
"email": {
"confirmed": false,
"address": "[email protected]"
},
"verified": false,
"createdAt": "2020-10-04T13:42:45.000-03:00",
"businessSegment": {
"id": 0
},
"company": {
"monthlyRevenue": "",
"businessName": "SACOLAO CENTRAL LTDA",
"phone": {
"areaCode": "31",
"countryCode": "55",
"number": "33333333"
},
"address": {
"complement": "",
"zipcode": "35690-000",
"zipCode": "35690-000",
"street": "Rua Alberto cintra",
"state": "MG",
"streetNumber": "135",
"district": "O bairro",
"country": "BRA",
"city": "Belo Horizonte"
},
"taxDocument": {
"number": "11.834.266/0001-56",
"type": "CNPJ"
},
"name": "Empresa boa",
"constitutionType": ""
},
"feeType": "FIXED_TABLE_FEE",
"login": "MPA-E32FB98442D0",
"softDescriptor": "Empresa boa"
}
Para realizar a transferência, tento primeiro com o token da conta criada com os seguintes dados:
Payload transferência com token gerado para a company
wirecardTransfer = {
"amount": 500,
"ownId": "84771046-8e23-461c-99c6-acd2b741f88f",
"transferInstrument": {
"method": "BANK_ACCOUNT",
"bankAccount": {
"type": "CHECKING",
"bankNumber": "077",
"agencyNumber": "0001",
"agencyCheckNumber": "9",
"accountNumber": "398557",
"accountCheckNumber": "2",
"holder": {
"fullname": "IGOR L K S TRINDADE",
"taxDocument": {
"type": "CNPJ",
"number": "11.834.266/0001-56"
}
}
}
}
}
Retorno da transfencia pois a conta acima ainda não possui saldo, resultado esperado - sem erro pois a conta não possui saldo.
[
{
code: 'TRA-101',
path: '-',
description: 'Saldo disponivel insuficiente para essa operacao'
}
]
Para simular uma transferência, estou alterando o TOKEN gerado para a conta company para o token da aplicação, pois este possui saldo sendo possível completar o teste.
Payload transferência com token do APP
WirecardTransfer = {
"amount": 500,
"ownId": "84771046-8e23-461c-99c6-acd2b741f88f",
"transferInstrument": {
"method": "BANK_ACCOUNT",
"bankAccount": {
"type": "CHECKING",
"bankNumber": "077",
"agencyNumber": "0001",
"agencyCheckNumber": "9",
"accountNumber": "398557",
"accountCheckNumber": "2",
"holder": {
"fullname": "IGOR L K S TRINDADE",
"taxDocument": {
"type": "CNPJ",
"number": "11.834.266/0001-56"
}
}
}
}
}
Essa requisição retorna o seguinte erro tentando transferir com os dados acima e aceita quando troco para CPF
[
{
code: 'TRA-108',
path: '-',
description: 'Aconteceu um erro interno ao processar transferencia'
}
]
Porém quando altero o taxDocument para CPF (qualquer CPF), a transfência é aceita e processada sem erros
wirecardTransfer = {
"amount": 500,
"ownId": "84771046-8e23-461c-99c6-acd2b741f88f",
"transferInstrument": {
"method": "BANK_ACCOUNT",
"bankAccount": {
"type": "CHECKING",
"bankNumber": "077",
"agencyNumber": "0001",
"agencyCheckNumber": "9",
"accountNumber": "398557",
"accountCheckNumber": "2",
"holder": {
"fullname": "IGOR L K S TRINDADE",
"taxDocument": {
"type": "CPF",
"number": "128.053.646-27"
}
}
}
}
}
Retorno transferência com sucesso
{
fee: 350,
amount: 500,
updatedAt: '2020-10-05T12:40:28.644-03',
id: 'TRA-5898PL7FJQMS',
transferInstrument: {
method: 'BANK_ACCOUNT',
bankAccount: {
id: 'BKA-PG3JBE9YTSUP',
agencyNumber: '1',
holder: [Object],
accountNumber: '398557',
accountCheckNumber: '2',
bankName: 'BANCO INTER',
type: 'CHECKING',
agencyCheckNumber: '9',
bankNumber: '077'
}
},
status: 'REQUESTED',
events: [
{
createdAt: '2020-10-05T12:40:29.000-03',
description: 'Requested',
type: 'TRANSFER.REQUESTED'
}
],
createdAt: '2020-10-05T12:40:28.644-03',
entries: [
{
external_id: 'ENT-BFYORCZM216C',
reschedule: [],
scheduledFor: '2020-10-05T12:40:28.000-03',
status: 'SETTLED',
moipAccount: [Object],
fees: [],
type: 'TRANSFER_TO_BANK_ACCOUNT',
grossAmount: -500,
moipAccountId: 522608,
updatedAt: '2020-10-05T12:40:29.081-03',
id: 38278211,
installment: [Object],
references: [Array],
eventId: 'TRA-5898PL7FJQMS',
createdAt: '2020-10-05T12:40:29.009-03',
description: 'Transferencia para conta bancaria - TRA-5898PL7FJQMS',
blocked: false,
settledAt: '2020-10-05T12:40:29.081-03',
liquidAmount: -500
}
],
role: 'PAYER',
_links: {
self: {
href: 'https://sandbox.moip.com.br/v2/transfers/TRA-5898PL7FJQMS'
}
},
ownId: '84771046-8e23-461c-99c6-acd2b741f88f'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment