File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed
Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments