Skip to content

Latest commit

 

History

History
97 lines (74 loc) · 2.38 KB

README.md

File metadata and controls

97 lines (74 loc) · 2.38 KB

lua-payssion

LUA api for payssion.com payment gateway.

Payssion is payment gateway provider based in HK. What make payssion attractive compare to paypal or stripe is that it support wide range of online banking payment, which is more popular in SEA where credit card ownership is a luxury.

Installation

#luarocks install lua-payssion 

API

new (api_key, api_secret, sandboxed)

create new payssion object param

  • api_key string from payssion account
  • secret_key string from payssion account
  • sandboxed sandbox or live, default true

create (pm_id, order_id, amount, currency, desc)

submit new payment request for processing param

  • pm_id payment method as provided by payssion
  • order_id unique string to refer to transaction
  • amount total amount charged
  • currency abbr of currency
  • desc description of the transaction

details (transaction_id, order_id)

Get the transaction details params

  • transaction_id payssion transaction_id
  • order_id payment ref

get_transaction_state (transaction_id, order_id)

Get the transaction details params

  • transaction_id payssion transaction_id
  • order_id payment ref

check_signature (transaction_id, order_id, notify_sig)

validate the notification message params

  • transaction_id payssion transaction_id
  • order_id order id
  • notify_sig signature passed by payssion

Example usage

  local payssion = require 'payssion'
  local pay = payssion({
    api_key = 'xxx',
    secret_key = 'xxx'
  })

  -- create payment
  local res, err = pay:create(pm_id, order_id, amount, currency, desc)
  if res not nil then
    -- save res.order_id
    -- redirect to res.redirect_url
  end

  -- alternatively using params as documented in https://payssion.com/en/docs/#api-reference-payment-request
  local res, err = pay:create({
    pm_id = pm_id,
    amount = amount,
    currency = 'MYR',
    description = 'My test order'
  })

  if res not nil then
    -- save res.order_id
    -- redirect to res.redirect_url
  end

  -- process payment notification
  if pay:check_signature(trans_id, order_id, notify_sig) then
    -- update payment status
  end

  -- get payment details
  local info = pay:get_transaction_state(transaction_id, order_id)
  if info then
    -- show payment info
  end
  

Reference

Payssion API