@@ -11,7 +11,7 @@ exports.post = ({ appSdk }, req, res) => {
11
11
12
12
const orderId = params . order_id
13
13
const { amount, buyer, payer, to, items } = params
14
- console . log ( ' > Transaction #' , storeId , orderId )
14
+ console . log ( ` > Transaction #${ storeId } , ${ orderId } ` )
15
15
let quantityItems = 0
16
16
17
17
// https://apx-mods.e-com.plus/api/v1/create_transaction/response_schema.json?store_id=100
@@ -45,7 +45,9 @@ exports.post = ({ appSdk }, req, res) => {
45
45
payment_method : 'credit_card' ,
46
46
amount : Math . floor ( finalAmount * 100 ) ,
47
47
installments : installmentsNumber ,
48
- card_hash : params . credit_card && params . credit_card . hash
48
+ card_hash : params . credit_card && params . credit_card . hash ,
49
+ recurrence_model : installmentsNumber ? 'installment' : 'standing_order' ,
50
+ initiated_type : 'PartialShipment'
49
51
}
50
52
} else if ( params . payment_method . code === 'account_deposit' ) {
51
53
const finalAmount = amount . total
@@ -82,7 +84,7 @@ exports.post = ({ appSdk }, req, res) => {
82
84
const parseDatePagarme = ms => {
83
85
const timeMs = ms . getTime ( ) - ( 180000 * 60 )
84
86
const newDate = new Date ( timeMs )
85
- const pad = n => `${ Math . floor ( Math . abs ( n ) ) } ` . padStart ( 2 , '0' ) ;
87
+ const pad = n => `${ Math . floor ( Math . abs ( n ) ) } ` . padStart ( 2 , '0' )
86
88
return date . getFullYear ( ) +
87
89
'-' + pad ( newDate . getMonth ( ) + 1 ) +
88
90
'-' + pad ( newDate . getDate ( ) )
@@ -154,7 +156,7 @@ exports.post = ({ appSdk }, req, res) => {
154
156
address : parseAddress ( params . billing_address )
155
157
}
156
158
}
157
-
159
+
158
160
pagarmeTransaction . items = [ ]
159
161
items . forEach ( item => {
160
162
if ( item . quantity > 0 ) {
@@ -201,7 +203,7 @@ exports.post = ({ appSdk }, req, res) => {
201
203
if ( data . customer && data . customer . id ) {
202
204
transaction . intermediator . buyer_id = String ( data . customer . id )
203
205
}
204
-
206
+
205
207
if ( transaction . banking_billet ) {
206
208
if ( data . boleto_barcode ) {
207
209
transaction . banking_billet . code = data . boleto_barcode
@@ -230,14 +232,15 @@ exports.post = ({ appSdk }, req, res) => {
230
232
}
231
233
}
232
234
}
233
-
235
+
234
236
transaction . status = {
237
+ // eslint-disable-next-line promise/always-return
235
238
updated_at : data . date_created || data . date_updated || new Date ( ) . toISOString ( ) ,
236
239
current : parseStatus ( data . status )
237
240
}
238
241
res . send ( { transaction } )
239
242
} )
240
-
243
+
241
244
. catch ( error => {
242
245
console . log ( error )
243
246
// try to debug request error
0 commit comments