ExLinePay

A LINE Pay client for Elixir.

Installation

def deps do
  [
    {:ex_line_pay, "~> 0.1.0"}
  ]
end

Usage

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_key

config.exs

config :ex_line_pay, channel_id: "1234567890",
                  channel_secret_key: "your_channel_secret_key"

Set environment

dev.exs

config :ex_line_pay, sandbox: true

prod.exs

config :ex_line_pay, sandbox: false

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)
params = %{amount: 1000, currency: "JPY"}

{:ok, payment} = LinePay.Payments.confirm("transaction_id", params)

params = %{amount: 1000, currency: "JPY"}

{:ok, payment} = LinePay.Payments.capture("transaction_id", params)
{:ok, payment} = LinePay.Payments.refund("transaction_id")
{:ok, payment} = LinePay.Payments.refund("transaction_id", %{refundAmount: 500})
{:ok, payment} = LinePay.Payments.void("transaction_id")
# 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

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

MIT