ExLinePay
A LINE Pay client for Elixir.
Installation
def deps do
[
{:ex_line_pay, "~> 0.1.0"}
]
endUsage
Set your credentials
ex_line_pay defaults to try read credentials from environment variables or configuration.
export LINE_PAY_CHANNEL_ID=1234567890
export LINE_PAY_CHANNEL_SECRET_KEY=your_channel_secret_keyconfig.exs
config :ex_line_pay, channel_id: "1234567890",
channel_secret_key: "your_channel_secret_key"Set environment
dev.exs
config :ex_line_pay, sandbox: trueprod.exs
config :ex_line_pay, sandbox: falsePayment
- Reserve a payment
# Proceed sales with capture
params = %{
amount: 1000,
confirmUrl: "myapp://line_pay",
currency: "JPY",
orderId: "#1",
productName: "foobar"
}
{:ok, payment} = LinePay.Payments.reserve(params)
# If you want to separate the authorization process, specify `capture` to `false`.
params = %{
amount: 1000,
confirmUrl: "myapp://line_pay",
currency: "JPY",
orderId: "#1",
productName: "foobar",
capture: false
}
{:ok, payment} = LinePay.Payments.reserve(params)- Confirm a payment
params = %{amount: 1000, currency: "JPY"}
{:ok, payment} = LinePay.Payments.confirm("transaction_id", params)- Capture a payment
params = %{amount: 1000, currency: "JPY"}
{:ok, payment} = LinePay.Payments.capture("transaction_id", params)- Refund a payment
{:ok, payment} = LinePay.Payments.refund("transaction_id")- Partially refund a payment
{:ok, payment} = LinePay.Payments.refund("transaction_id", %{refundAmount: 500})- Invalidate the authorized payment
{:ok, payment} = LinePay.Payments.void("transaction_id")- Get payments detail.
# Get payments by transaction id
{:ok, payment} = LinePay.Payments.get(transactionId: 2017101800001000)
# Get payments by order id
{:ok, payment} = LinePay.Payments.get(orderId: "#5")
# You can specify both transaction id and order id
{:ok, payment} = LinePay.Payments.get(orderId: "#5", transactionId: 2017101800001000)TODO
- Add VCR Tests
Contributing
- Fork it
-
Create your feature branch (
git checkout -b my-new-feature) -
Commit your changes (
git commit -am 'Add some feature') -
Push to the branch (
git push origin my-new-feature) - Create new Pull Request
License
MIT