Skip to content

Commit 585c66f

Browse files
committed
fix(asaas): Try secondary field and debug Asaas credit card response without payment link
1 parent 7d63b88 commit 585c66f

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

packages/apps/asaas/src/asaas-create-transaction.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,17 @@ export default async (modBody: AppModuleBody<'create_transaction'>) => {
132132
}
133133
}
134134

135-
const {
136-
data: {
137-
id: asaasPaymentId,
138-
bankSlipUrl,
139-
invoiceUrl,
140-
},
141-
} = await asaasAxios.post(
135+
const { data: asaasCreatedPayment } = await asaasAxios.post(
142136
paymentMethod.code === 'account_deposit'
143137
? '/v3/lean/payments'
144138
: '/v3/payments/',
145139
asaasPayment,
146140
);
141+
const {
142+
id: asaasPaymentId,
143+
bankSlipUrl,
144+
invoiceUrl,
145+
} = asaasCreatedPayment;
147146
transaction.intermediator = {
148147
payment_method: {
149148
code: asaasPayment.billingType || params.payment_method.code,
@@ -174,6 +173,19 @@ export default async (modBody: AppModuleBody<'create_transaction'>) => {
174173
code: bankSlipData.barCode,
175174
};
176175
transaction.payment_link = bankSlipUrl;
176+
} else {
177+
if (!transaction.payment_link) {
178+
const { paymentLink } = asaasCreatedPayment;
179+
if (paymentLink && typeof paymentLink === 'string') {
180+
transaction.payment_link = paymentLink;
181+
}
182+
}
183+
if (!transaction.payment_link) {
184+
logger.warn('Unexpected Asaas credit card response without link', {
185+
asaasCreatedPayment,
186+
transaction,
187+
});
188+
}
177189
}
178190

179191
const {

0 commit comments

Comments
 (0)