Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade omise-node api to v2019 #220

Merged
merged 15 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
OMISE_PUBLIC_KEY=""
OMISE_SECRET_KEY=""
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ yarn.lock
pids
*.pid
*.seed
.env

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
Expand Down
5 changes: 1 addition & 4 deletions examples/as_promises.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';

let omise = require('../index')({
'publicKey': process.env.OMISE_PUBLIC_KEY,
'secretKey': process.env.OMISE_SECRET_KEY,
});
const omise = require('./index');

let cardDetails = {
card: {
Expand Down
10 changes: 3 additions & 7 deletions examples/charge_schedule.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
'use strict';

// More information: https://www.omise.co/charge-schedules-api
let omise = require('../index')({
'publicKey': 'pkey_test_1234',
'secretKey': 'skey_test_1234',
});
const omise = require('./index');

// Charge every 2 days
let chargeEvery2Days = {
Expand All @@ -27,7 +23,7 @@ omise.schedules.create(chargeEvery2Days, function(err, schedule) {
}

// Print out schedules
console.log(schedule.next_occurrence_dates);
console.log(schedule.next_occurrences_on);
});

// Charge on eery Monday and Friday
Expand All @@ -54,5 +50,5 @@ omise.schedules.create(monthlyCharge, function(err, schedule) {
}

// Print out schedules
console.log(schedule.next_occurrence_dates);
console.log(schedule.next_occurrences_on);
});
5 changes: 1 addition & 4 deletions examples/create_customer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';

let omise = require('../index')({
'publicKey': process.env.OMISE_PUBLIC_KEY,
'secretKey': process.env.OMISE_SECRET_KEY,
});
const omise = require('./index');

let customer = {
email: '[email protected]',
Expand Down
5 changes: 1 addition & 4 deletions examples/create_link.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';

let omise = require('../index')({
'publicKey': process.env.OMISE_PUBLIC_KEY,
'secretKey': process.env.OMISE_SECRET_KEY,
});
const omise = require('./index');

let link = {
'amount': 19000,
Expand Down
20 changes: 20 additions & 0 deletions examples/create_recipient.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

const omise = require('./index');

const recipientBody = {
name: 'Recipient name',
email: '[email protected]',
type: 'individual',
bank_account: {
bank_code: 'bbl',
number: '123456789',
name: 'Reci Pient',
},
};
omise.recipients.create(recipientBody, (err, resp) => {
if (err) {
console.log(err)
}
console.log(resp);
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
'use strict';

exports.__esModule = true;
const omise = require('./index');

let amount = 500000;
let currency = 'thb';
let omise = require('../index')({
'publicKey': process.env.OMISE_PUBLIC_KEY,
'secretKey': process.env.OMISE_SECRET_KEY,
});

let source = {
'type': 'internet_banking_bbl',
'amount': 500000,
Expand Down
8 changes: 3 additions & 5 deletions examples/create_token.js → examples/create_token_charge.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';

let omise = require('../index')({
'publicKey': process.env.OMISE_PUBLIC_KEY,
'secretKey': process.env.OMISE_SECRET_KEY,
});
const omise = require('./index');

let cardDetails = {
card: {
Expand All @@ -12,7 +9,8 @@ let cardDetails = {
'postal_code': 10160,
'number': '4532156433142865',
'expiration_month': 8,
'expiration_year': 2022,
'expiration_year': 2032,
'email': '[email protected]'
},
};

Expand Down
16 changes: 16 additions & 0 deletions examples/create_transfer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

const omise = require('./index');

const reqBody = {
amount: 40000,
recipient: 'recp_60w95drhxsfzbkr89c4',
fail_fast: true
};

omise.transfers.create(reqBody, (err, resp) => {
if (err) {
console.log(err)
}
console.log(resp);
});
10 changes: 5 additions & 5 deletions examples/destroy_customer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

let omise = require('../index')({
'publicKey': process.env.OMISE_PUBLIC_KEY,
'secretKey': process.env.OMISE_SECRET_KEY,
});
const omise = require('./index');

omise.customers.destroy('cust_test_4yxn6vblxh83h605oxz', function(err, resp) {
omise.customers.destroy('cust_60458v5p9fhyx3z4yp7', function(err, resp) {
if (err) {
console.log(err);
}
console.log(resp);
});
10 changes: 10 additions & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const dotenv = require("dotenv");
dotenv.config();

const omise = require("../index")({
publicKey: process.env.OMISE_PUBLIC_KEY,
secretKey: process.env.OMISE_SECRET_KEY,
host: process.env.OMISE_NODE_HOST,
});

module.exports = omise;
20 changes: 11 additions & 9 deletions examples/list_cards.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
'use strict';
"use strict";

let omise = require('../index')({
'publicKey': process.env.OMISE_PUBLIC_KEY,
'secretKey': process.env.OMISE_SECRET_KEY,
});
const omise = require("./index");

omise.customers.listCards('cust_test_53reuowpjglur236wm7',
{'order': 'reverse_chronological'},
function(e, resp) {
omise.customers.listCards(
"cust_60dw2h7vc8pwuiy9hag",
{ order: "reverse_chronological" },
function (err, resp) {
if (err) {
console.log(err);
}
console.log(resp);
});
}
);
5 changes: 1 addition & 4 deletions examples/list_charges.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';

let omise = require('../index')({
'publicKey': process.env.OMISE_PUBLIC_KEY,
'secretKey': process.env.OMISE_SECRET_KEY,
});
const omise = require('./index');

omise.charges.list({limit: 2}, function(err, resp) {
console.log(resp);
Expand Down
7 changes: 2 additions & 5 deletions examples/list_customers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
'use strict';

let omise = require('../index')({
'publicKey': process.env.OMISE_PUBLIC_KEY,
'secretKey': process.env.OMISE_SECRET_KEY,
});
const omise = require('./index');

omise.customers.list(function(err, resp) {
omise.customers.list({limit: 2}, function(err, resp) {
console.log(resp);
});
7 changes: 7 additions & 0 deletions examples/list_recipients.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

const omise = require('./index');

omise.recipients.list({limit: 2}, function(err, resp) {
console.log(resp);
});
11 changes: 11 additions & 0 deletions examples/list_schedules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

const omise = require('./index');

omise.schedules.retrieve((err, resp) => {
if (err) {
console.log('error', err);
return;
}
console.log(resp);
});
10 changes: 10 additions & 0 deletions examples/retrieve_balance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

const omise = require('./index');

omise.balance.retrieve((err, resp) => {
if (err) {
console.log(err);
}
console.log(resp);
});
7 changes: 2 additions & 5 deletions examples/retrieve_customer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
'use strict';

let omise = require('../index')({
'publicKey': process.env.OMISE_PUBLIC_KEY,
'secretKey': process.env.OMISE_SECRET_KEY,
});
const omise = require('./index');

omise.customers.retrieve('cust_test_4z33o46lqreryhqua8w', function(err, resp) {
omise.customers.retrieve('cust_60dw2h7vc8pwuiy9hag', function(err, resp) {
console.log(resp);
});
18 changes: 9 additions & 9 deletions examples/update_customer.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';
"use strict";

let omise = require('../index')({
'publicKey': process.env.OMISE_PUBLIC_KEY,
'secretKey': process.env.OMISE_SECRET_KEY,
});
const omise = require("./index");

let updateParams = {description: 'the other description'};
let updateParams = { description: "the other description" };

omise.customers.update('cust_test_4z2owmajzsb3c527wj7', updateParams,
function(err, resp) {
omise.customers.update(
"cust_60dw2h7vc8pwuiy9hag",
updateParams,
function (err, resp) {
console.log(resp);
});
}
);
Loading
Loading