-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade omise-node api to v2019 (#220)
## Description - Upgrade library to support API version 2019-05-29 ### More information (if any) - Added setup to run the typescript examples - Refactored example scripts - Updated resource fields according to api v 2019-05-29 ### Documentation (if any) <!-- Link to the updated documentation, if any. Else, remove this section. --> ### Related links: <!-- Provide links, related issues, and PRs, if any. Else, remove this section. --> - Issue ID: <github-issue-id> ## Decision(s) <!-- Describe any decisions you made in this PR using the following template --> <!-- E.g. In the context of Super New Feature, facing how to load the required data, we decided to use raw SQL, to achieve fastest performance, accepting this is more code than if we had used the ORM. --> In the context of < use case / user story >, facing < concern > we decided for < option > to achieve < quality / goal >, accepting < downside >. ***NOTE: If the change introduces a new feature flag, please mention: *** - ***When / Conditions to remove feature flag*** - ***Please add label "FeatureFlag" to feature flag removal story*** ## Business impact (if any) <!-- Describe the business impact if any. For example, rolling out the change will involve a short downtime of an hour. Else, remove this section --> ## Pre- or post-deployment steps (if any) <!-- Describe the manual steps, if any, that need to be done before or after the deployment. Else, remove this section. --> ## Rollback procedure <!-- Describe the Rollback procedure. If none/default, update with `default rollback procedure` -->
- Loading branch information
Showing
125 changed files
with
1,290 additions
and
783 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
OMISE_PUBLIC_KEY="" | ||
OMISE_SECRET_KEY="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
const omise = require('./index'); | ||
|
||
const chargeId = 'chrg_611rj6nuzljvtrudfks' | ||
omise.charges.capture(chargeId, function(err, response) { | ||
if (err) { | ||
console.log('error', err); | ||
return; | ||
} | ||
console.log(response) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
examples/create_customer.js → examples/javascript/create_customer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
const omise = require('./index'); | ||
|
||
const chargeId = 'chrg_611ra3ab9wmcrm5wmue'; | ||
omise.charges.createRefund(chargeId, { amount: 200000 }, function(err, resp) { | ||
if(err) { | ||
console.log(err) | ||
} | ||
console.log(resp); | ||
}); |
8 changes: 2 additions & 6 deletions
8
examples/create_source.js → examples/javascript/create_source_charge.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
const omise = require('./index'); | ||
|
||
let cardDetails = { | ||
card: { | ||
name: "Gaurav", | ||
number: "4242424242424242", | ||
expiration_month: 2, | ||
expiration_year: 2025, | ||
security_code: "123", | ||
}, | ||
}; | ||
|
||
omise.tokens.create(cardDetails, function(err, token) { | ||
if (err) { | ||
console.log('error', err); | ||
return; | ||
} | ||
|
||
omise.charges.create({ | ||
amount: 900000, | ||
currency: 'thb', | ||
return_uir: 'http://example.com', | ||
card: token.id, | ||
}, function(err, charge) { | ||
if (err) { | ||
console.log('error', err); | ||
return; | ||
} | ||
|
||
console.log('charge', charge); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
const omise = require('./index'); | ||
|
||
omise.customers.destroy('cust_60458v5p9fhyx3z4yp7', function(err, resp) { | ||
if (err) { | ||
console.log(err); | ||
} | ||
console.log(resp); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
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, | ||
vaultHost: process.env.OMISE_VAULT_HOST, | ||
}); | ||
|
||
module.exports = omise; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"use strict"; | ||
|
||
const omise = require("./index"); | ||
|
||
omise.customers.listCards( | ||
"cust_60dw2h7vc8pwuiy9hag", | ||
{ order: "reverse_chronological" }, | ||
function (err, resp) { | ||
if (err) { | ||
console.log(err); | ||
} | ||
console.log(resp); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
const omise = require('./index'); | ||
|
||
omise.charges.list({limit: 2}, function(err, resp) { | ||
console.log(resp); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
const omise = require('./index'); | ||
|
||
omise.customers.list({limit: 2}, function(err, resp) { | ||
console.log(resp); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
const omise = require('./index'); | ||
|
||
omise.customers.retrieve('cust_60dw2h7vc8pwuiy9hag', function(err, resp) { | ||
console.log(resp); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
const omise = require('./index'); | ||
|
||
const chargeId = 'chrg_611rkd55yyxy6a8vs3c' | ||
omise.charges.reverse(chargeId, function(err, response) { | ||
if (err) { | ||
console.log('error', err); | ||
return; | ||
} | ||
console.log(response) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"use strict"; | ||
|
||
const omise = require("./index"); | ||
|
||
let updateParams = { description: "the other description" }; | ||
|
||
omise.customers.update( | ||
"cust_60dw2h7vc8pwuiy9hag", | ||
updateParams, | ||
function (err, resp) { | ||
console.log(resp); | ||
} | ||
); |
Oops, something went wrong.