Created
July 14, 2016 03:19
-
-
Save tomykaira/462a20ccb9b530ee3a79e9a96b2778d4 to your computer and use it in GitHub Desktop.
How to use webpay node module from typescript.
This file contains hidden or 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
npm install -g typescript | |
mkdir test | |
npm install webpay | |
tsc test.ts | |
node test.js |
This file contains hidden or 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
/// <reference path="./typings/webpay/webpay.d.ts" /> | |
import * as WebPay from "webpay"; | |
var webpay = new WebPay('test_secret_eHn4TTgsGguBcW764a2KA8Yd'); | |
webpay.charge.create({ | |
amount: 400, | |
currency: "jpy", | |
card: "tok_SampleCardToken", | |
description: "" | |
}, function(err, res) { | |
console.log(err, res); | |
}); |
This file contains hidden or 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
// place as typings/webpay/webpay.d.ts | |
declare interface WebPay { | |
charge: Charge; | |
} | |
declare interface Charge { | |
create: (params: any, callback: (err: any, res: any) => void) => void; | |
} | |
declare var WebPay: { | |
new (token: string): WebPay; | |
} | |
declare module 'webpay' { | |
export = WebPay; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment