omise / omise-node Goto Github PK
View Code? Open in Web Editor NEWOmise Node.js Library
Home Page: https://docs.opn.ooo
Omise Node.js Library
Home Page: https://docs.opn.ooo
Trying to destroy a schedule with omise.schedules.destroy
shows a TypeScript warning because the destroy method is not defined on the ISchedulesAPI
interface in https://github.com/omise/omise-node/blob/master/types/index.d.ts
JSCS has been merged with eslint and isn't updated for over a year. I think we should also migrate to eslint too.
Eslint also go beyond code style checking by checking for potential bug such as detecting for unused variables too.
I need to config the Omise API host for load testing purposes.
While I am trying to create test to cover #50, I found that the current test is failing on 2 cases. Here is the information:
35 passing (12s)
2 failing
1) Omise #Charges should be able to reverse a charge:
Uncaught TypeError: Cannot read property 'object' of undefined
at test/test_omise_charges.js:111:20
at tryCatcher (node_modules/bluebird/js/main/util.js:26:23)
at Promise.errorAdapter (node_modules/bluebird/js/main/nodeify.js:36:34)
at Promise._settlePromiseAt (node_modules/bluebird/js/main/promise.js:582:21)
at Promise._settlePromises (node_modules/bluebird/js/main/promise.js:700:14)
at Async._drainQueue (node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues [as _onImmediate] (node_modules/bluebird/js/main/async.js:15:14)
2) Omise #Events should be able to retrieve an event:
Uncaught TypeError: Cannot read property 'object' of undefined
at test/test_omise_events.js:25:20
at tryCatcher (node_modules/bluebird/js/main/util.js:26:23)
at Promise.errorAdapter (node_modules/bluebird/js/main/nodeify.js:36:34)
at Promise._settlePromiseAt (node_modules/bluebird/js/main/promise.js:582:21)
at Promise._settlePromises (node_modules/bluebird/js/main/promise.js:700:14)
at Async._drainQueue (node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues [as _onImmediate] (node_modules/bluebird/js/main/async.js:15:14)
Maybe there's something about API versioning.
Line 147 in a12b4d8
interface ICharge
Not yet update with latest Charge API Doc
I've to create a source and then create a charge after that. I think the library should support create a charge with source. And source seems not up to date because it can't create installment.
Omise.Schedules.ICreateSchedule
does not specify an optional field for charge
which is required by Omise API to create a charge schedule.
This results in Typescript errors if you attempt to add the charge
field in the options
object of the Omise.Schedules.ISchedulesAPI.create
method.
i try to call create schedule api from SDK with out "on" property. like a charge every 2 day example. i will get only this { object: 'error', location: 'https://www.omise.co/api-errors#bad-request', code: 'bad_request', message: 'on must be an object and on must contain one of these keys: days_of_month, weekday_of_month' }
error.
I have found that IDE suggests a wrong attribute for Account API, it should be omise.account
.
May need to change this line of code.
Line 19 in 2a364b9
Hi, when submitting the following request
omise.charges.create({
amount:5067,
capture:false,
card:"tokn_test_***",
currency:"thb"
})
.then(function(result){
// ...
})
the result object says
{
// ...
capture:true,
captured:true,
// ...
}
however the http body passed here seems correct, thus I suspect the error comes from the backend.
How can I make sure my transaction has been authorized only ? (ie not captured)
Note: I am working with livemode=false and with test credit card 4111111111111111
regards,
Laurent.R
Recently I tried using this library with Next.js API Routes, but was unable to do so because the Webpack bundling (which Next.js uses for both frontend and backend by default) did not work properly.
The issue occurs because this library uses 'dependency expressions' - file names are generated and required using a function meaning Webpack cannot resolve them statically.
Specifically, this happens at https://github.com/omise/omise-node/blob/master/lib/apiResources.js#L6
function resourceName(name) {
return require(['./resources/', name].join(''))(omiseConfig);
}
The fix is to require
the files using their full names hardcoded e.g.
require('./resources/Source`)
Slightly more code, but should enable the use of this library with Webpack and therefore Next.js.
I'm testing omise services and while I can retrieve customers/cards fine, I cannot create/retrieve token. The error is
{ object: 'error',
location: 'https://www.omise.co/api-errors#authentication-failure',
code: 'authentication_failure',
message: 'authentication failed' }
and i was using the same secret key when I test customer (actually run in one-go)
Is there a different key to use with token API?
CircleCI 1.0 is deprecated and we should migrate to CircleCI 1.0
I followed the documentation but got this error
omise.schedules.create({
'every': 2,
'period': 'day',
'start_date': '2017-05-01',
'end_date': '2018-05-01',
'charge': {
'customer': 'cust_test_57m2wcnfx96k634rkqq',
'card': 'card_test_57m2w8iemdovs4f92m2',
'amount': 100000,
'description': 'Membership fee'
}
}, function(error, schedule) {
/* Response. */
});
TypeError: Cannot read property 'retrieve' of undefined
Hi again,
I am having weird bug right now, which is hard to reproduce. The detail as follows
card tokn_test_55tsnhljnyn2d8ye0br was not found
when trying to charge a cardHappened to me 2 times this week. I am running the library on nodejs v5 the code looks like this
const omise = require('omise')({
secretKey: 'xxx',
omiseVersion: '2015-11-17'
});
...
app.get('charge', (req, res) => {
Promise.resolve({
amount: req.query.amount,
card: req.query.token,
currency: 'THB',
})
.then(omise.charges.create)
.then((response) => {
// check for error
})
.then((data) => res.send(data))
.catch((err) => res.error(err));
})
And I am suspecting that omise
object is persisted for too long and somehow is mutated, then the bug occurs. I will try to move omise
inside the (req, res) => { ... }
and see if the bug still occur.
Please let me know if you have any idea about this issue.
Thanks!
PanJ
I think I spot out a mistake in the nodejs lib.
At the moment it s not possible to use the paging parameter ( from https://www.omise.co/api-pagination )
because the https://github.com/omise/omise-node/blob/master/lib/apiResources.js
at line 56 :
list: function(callback) {
return api.get(_makeOptions(options, path()), callback);
},
is missing data, it should be
list: function(data,callback) {
To been able to use the pagination parameters as :
omisePromise = omise.charges.list({"limit": 5});
I know that I should have provided a PR, but I am a bit lazy to do it.
Beside, I believe that the unit testing should also integrate the paging parameters, and it sounds like a bit of work ;-)
Anyway, I have fixed it on my side, but I would really appreciate if you could add fix it in the official package :-)
return status attribute same as the document
https://docs.opn.ooo/charges-api
no status attribute in ICharge
Look at the types/index.d.ts file at line 225
No response
No response
"omise": "0.12.0"
Unit test with mock data or npm test
works fine.
But remote test or NOCK_OFF=true
failed miserably due to expecting mock data.
Working with a React Native app now, and previous suggestions have been to make use of this node library to create the token.
Running into 2 issues
apiResources.js
has a require that is dynamicapi.js
requires bluebird
and https
which the React Native library can't handle tooWanted to check if there are possible solutions for integrating Omise into a React Native app other than writing our own native modules, or using a webview with Omise.js
I am unable to charge the added card for the customer.
My scenario :
1 and 2 points are working but I am unable to do the payment with a card.
Can you please provide me the code for that?
I have a card id, customer id what parameter I sent to the charge API?
Thanks,
Up until version 6.0.0, the agent-base package was patching https.request. As a result, it could completely break requests made with the (url, options, callback) signature, as specified by the core https
package. As this patch affects HTTPS requests made globally, unrelated code can be severely affected.
Fix: update to the latest version of https-proxy-agent (5.0.0) to fix this issue.
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;
};
I use TypeScript as primary node project. It can be good if omise-node support TypeScript by default.
My idea is writing the declaration file to make TypeScript can check the type when compile.
If you agree with this feature. I can make a pull request to finish it.
I'm creating a hybrid mobile app with payment feature using Ionic 2 framework. I tried omise.js via CDN which worked perfectly when serving in desktop browser (using ionic serve
command). However, when I run the app on actual device (in this case, iPhone) the Omise.createToken() gave request timeout error.
After some searching I found a hint in an omise.js issue that omise-node should work with hybrid mobile apps and can be installed via NPM. So I tried importing the module like following:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import Omise from 'omise';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController) {
var omise = new Omise({
'publicKey': MY_PUBLIC_KEY
});
}
}
This results in the following error:
ERROR Error: Uncaught (in promise): Error: Cannot find module "."
Error: Cannot find module "."
at d (polyfills.js:3)
at webpackMissingModule (main.js:136768)
at resourceName (main.js:136768)
at Object.module.exports.omiseResources (main.js:136799)
at new module.exports (main.js:136649)
at new HomePage (main.js:58694)
at createClass (main.js:11066)
at createDirectiveInstance (main.js:10905)
at createViewNodes (main.js:12255)
at createRootView (main.js:12160)
at callWithDebugContext (main.js:13291)
at Object.debugCreateRootView [as createRootView] (main.js:12752)
at ComponentFactory_.create (main.js:10096)
...
Since Omise
is not undefined, I think the problem is omise-node's index.js couldn't get reference from another file by require() function. I know it is not exactly this repo's issue but I hope someone who had done this successfully might be able to point out what did I do wrong here.
Hi,
We got this Unexpected end of JSON input
error in about 1% of the transaction. I have tried to investigate the library itself but could not find anything. I will try again with DEBUG_OMISE=true
and wait for the issue to occur. I'm still not sure if the problem is the library itself or the response from the server is invalid JSON format.
Here's error message.
error: SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at IncomingMessage.<anonymous> (/app/node_modules/omise/lib/api.js:20:23)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:188:7)
at endReadableNT (_stream_readable.js:975:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
I want to get the most recent using order=reverse_chronological option. It seems that omise-node does not have this option.
Version 0.8.1
https://www.omise.co/refunds-api -> Create a refund
omise.charges.createRefund(
'chrg_test_4ype2jynk2len88i4er',
{'amount': 10000},
function(error, refund) {
/* Response. */
}
);
From the example, it provides 3 arguments required; however, when calling this function, getting the error as following.
Expected 1-2 arguments, but got 3.ts(2554)
calling customers.retrieve(customerId) return the list of all customers. Expected to return a user with the customerId
Fix case receive uncaught exception error when cannot call dns server which is the cause of node server down.
ex:
Error: getaddrinfo ENOTFOUND api.omise.co api.omise.co:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
fix by handle event error
in function _responseHandler
Lines 13 to 36 in bce1acb
function _responseHandler(req) {
return new Promise(function(resolve, reject) {
req
.on('response', function(res) {
var resp = '';
res.setEncoding('utf8');
res.on('data', function(chunk) {
resp += chunk;
});
res.on('end', function() {
try {
logger.log('info', resp);
resp = JSON.parse(resp);
if (resp.object === 'error') {
reject(resp);
} else {
resolve(resp);
}
} catch (err) {
reject(err);
}
});
})
.on('error', function(err) { // add this line
reject(err);
});
});
}
when I use currency usd sometime i found error
{location: 'https://www.omise.co/api-errors#invalid-charge',
code: 'invalid_charge',
message: 'amount must be an integer' }
this is amount error such as 257.12 (25712),267.10 (26710),25.77 (2577),123.66 (12366) and another amount are fraction unsuitable
but sometime is passed such as 250.20 (25020),78.25 (7825),156.75 (15675),144.50(14450)
How to fix it?
thanks
Getting the error when running tsc
command - "node_modules/omise/types/index.d.ts(39,26): error TS2304: Cannot find name 'IRequest'."
index.d.ts
- updateAccount(req: IRequest, callback?: ResponseCallback<IAccount>): Bluebird<IAccount>;
Dear Support,
I attempted to integrate Omise Internet Banking as a payment option, but I encountered an issue with the authorize_uri upon creating a charge. The error message displayed is as follows:
"Failed to launch 'krungsri-kma://map.payment?tokenId=7de8c5b6d2f44a36a196443d225c80f7' because the scheme does not have a registered handler."
To troubleshoot the problem, I performed the following validations:
[x] Verified the usage of Omise JS (2017 version).
[x] Confirmed successful creation of the charge request (see attached image:
).
[x] Ensured that the backend was able to retrieve the Omise object response code, which displayed the following information:
{status: 'pending', status_code: 'redirect', authorize_uri: 'krungsri-kma://map.payment?tokenId=7de8c5b6d2f44a36a196443d225c80f7'}
Despite these validations, I encountered the aforementioned error when attempting to redirect the URL. I have tried both in a browser and a Flutter app's webview.
I kindly request your assistance and guidance in resolving this matter.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.