Skip to content

paragasu/lua-payssion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

lua api for payssion.com payment gateway.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages