Mercurial Hosting > luan
comparison stripe/src/luan/modules/stripe/Stripe.luan @ 503:92c3d22745b8
make _ENV optional
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 20 May 2015 23:24:46 -0600 |
parents | 56c23aa70045 |
children | ca169567ce07 |
comparison
equal
deleted
inserted
replaced
502:d3183a330ff5 | 503:92c3d22745b8 |
---|---|
5 local Table = require "luan:Table" | 5 local Table = require "luan:Table" |
6 local Stripe = require "java:com.stripe.Stripe" | 6 local Stripe = require "java:com.stripe.Stripe" |
7 local Customer = require "java:com.stripe.model.Customer" | 7 local Customer = require "java:com.stripe.model.Customer" |
8 local Charge = require "java:com.stripe.model.Charge" | 8 local Charge = require "java:com.stripe.model.Charge" |
9 | 9 |
10 currency = "usd" | 10 local M = {} |
11 | 11 |
12 function init(api_key) | 12 M.currency = "usd" |
13 | |
14 function M.init(api_key) | |
13 Stripe.apiKey = api_key | 15 Stripe.apiKey = api_key |
14 end | 16 end |
15 | 17 |
16 | 18 |
17 local function customer_table(java_customer) | 19 local function customer_table(java_customer) |
51 | 53 |
52 return this | 54 return this |
53 end | 55 end |
54 | 56 |
55 | 57 |
56 function create_customer(params) | 58 function M.create_customer(params) |
57 local java_customer = Customer.create(params) | 59 local java_customer = Customer.create(params) |
58 return customer_table(java_customer) | 60 return customer_table(java_customer) |
59 end | 61 end |
60 | 62 |
61 function retrieve_customer(id) | 63 function M.retrieve_customer(id) |
62 local java_customer = Customer.retrieve(id) | 64 local java_customer = Customer.retrieve(id) |
63 return customer_table(java_customer) | 65 return customer_table(java_customer) |
64 end | 66 end |
65 | 67 |
66 function create_charge(params) | 68 function M.create_charge(params) |
67 params.amount or error "missing parameter 'amount'" | 69 params.amount or error "missing parameter 'amount'" |
68 params.amount = assert_integer(params.amount) | 70 params.amount = assert_integer(params.amount) |
69 params.currency = params.currency or currency | 71 params.currency = params.currency or M.currency |
70 local java_charge = Charge.create(params) | 72 local java_charge = Charge.create(params) |
71 return charge_table(java_charge) | 73 return charge_table(java_charge) |
72 end | 74 end |
73 | 75 |
76 return M | |
77 | |
74 -- http://javadox.com/com.stripe/stripe-java/1.2.1/overview-summary.html | 78 -- http://javadox.com/com.stripe/stripe-java/1.2.1/overview-summary.html |