open-pay / openpay-node

Openpay Node.js bindings
29 stars 16 forks source link

Error: data.callback is not a function #9

Closed gustavomanolo closed 5 years ago

gustavomanolo commented 5 years ago

Hi, i'm trying to create a charge with the following code:

`openpay.customers.charges.create( { source_id: paymentDetails['card_id'], method: 'card', amount: totalFinal, description: description, device_session_id: paymentDetails['device_session_id'], customer: { name: 'John', last_name: 'Doe', email: 'test@gmail.com' } }, function(error, charge) { if (error) { // There was an error with the charge console.error('Error processing card payment', error)

              fResult.msg = 'Lo sentimos, no se pudo procesar el pago'
              return reject(fResult)
            } else {
              // All was ok with carge
              console.log('-> All ok charge', charge)
            }
          }
        )`

But i'm getting the following error: TypeError: data.callback is not a function at Request._callback (/Users/gustavomanolo/Documents/webapps/uchiti/node_modules/openpay/lib/openpay.js:797:10)

oswaldopenpay commented 5 years ago

Hi @gustavomanolo, The problem is the method openpay.customers.charges.create(...) requires three parameters customerId, cardChargeRequest, callback if you do not have a customer id you can use the method openpay.charges.create(...)

Regards