@@ -13,6 +13,10 @@ const baseUri = `https://${region}-${process.env.GCLOUD_PROJECT}.cloudfunctions.
1313
1414const pagaleveCreateTransaction = async ( body : AppModuleBody < 'create_transaction' > ) => {
1515 const { params, application } = body ;
16+ const { settingsContent } = config . get ( ) ;
17+ const domain = params . domain && params . domain !== 'localhost'
18+ ? params . domain
19+ : settingsContent . domain || 'e-com.plus' ;
1620 const appData = { ...application . data , ...application . hidden_data } ;
1721 const {
1822 PAGALEVE_USERNAME ,
@@ -60,8 +64,8 @@ const pagaleveCreateTransaction = async (body: AppModuleBody<'create_transaction
6064 const hash = createHmac ( 'sha256' , appData . password )
6165 . update ( orderId ) . digest ( 'hex' ) ;
6266 const pagaleveTransaction : Record < string , any > = {
63- cancel_url : `https://${ params . domain } /app/#/order/${ orderNumber } /${ orderId } ` ,
64- approve_url : `https://${ params . domain } /app/#/order/${ orderNumber } /${ orderId } ` ,
67+ cancel_url : `https://${ domain } /app/#/order/${ orderNumber } /${ orderId } ` ,
68+ approve_url : `https://${ domain } /app/#/order/${ orderNumber } /${ orderId } ` ,
6569 webhook_url : `${ baseUri } /pagaleve-webhook?order_id=${ orderId } &hash=${ hash } ` ,
6670 is_pix_upfront : ! ! isPix ,
6771 order : {
@@ -95,9 +99,9 @@ const pagaleveCreateTransaction = async (body: AppModuleBody<'create_transaction
9599 sku : item . sku ,
96100 quantity : item . quantity ,
97101 price : Math . floor ( ( item . final_price || item . price ) * 100 ) ,
98- url : `https://${ params . domain } ` ,
102+ url : `https://${ domain } ` ,
99103 reference : item . product_id ,
100- image : objImg && objImg . url ? objImg . url : `https://${ params . domain } ` ,
104+ image : objImg && objImg . url ? objImg . url : `https://${ domain } ` ,
101105 } ) ;
102106 }
103107 } ) ;
0 commit comments