omise/omise-node

When trying to create resource omise.sources.create(source) giving me authentication failure error

Closed this issue · 4 comments

Hi,
When i try to create internet banking resource omise.sources.create(source) then it is giving me authentication error rest of the API is working fine for example omise.charges.create() etc it is giving me authentication failure only when i use omise.sources.create(source)

omise: ^0.5.4
node: v8.11.3

my code is

const omise = require('omise')({
  'secretKey': 'my_secret_key',
  'omiseVersion': '2017-11-02'
});

let service = {};

service.createSource = function(type, amount, orderID) {
  const promise = new Promise((resolve, reject) => {
    const source = {
      type, 
      amount,
      currency: 'thb'
    };
    omise.sources.create(source, function(err, resSource) {
      if (err) {  
        return reject(err);
      }
      omise.charges.create({
        'description': `Charge for Order ID: ${orderID}`,
        'amount': amount, 
        'currency': 'thb',
        'source': resSource.id,
        'return_uri': 'http://www.example.com/orders/3947/complete'
      }, function(err, resp) {
        if (err) {
          return reject(err);
        }
        return resolve(resp);
      });
    });
  });
  return promise;
};

{ object: 'error',
  location: 'https://www.omise.co/api-errors#authentication-failure',
  code: 'authentication_failure',
  message: 'authentication failed' }

With source api, you have to use public key ie: pub_ as your secret key.

yes, it works with publicKey. Thank you!

@umerbaig Your welcome.