Skip to content

ziazek/hit_pay

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HitPay

An Elixir client for HitPay Payment Gateway

Installation

Add to your mix.exs the following lines

def deps do
  [
    {:hit_pay, "~> 0.2.3"}
  ]
end

Configuration

To use HitPay API, we need to setup a dashboard account and configure api key and salt.

config :hit_pay,
  api_key: System.get_env("HIT_PAY_API_KEY"),
  salt: {MyApp.Config, :hit_pay_salt, []},
  environment: "sandbox" # or "production"

or

config :hit_pay,
  api_key: {:system, "HIT_PAY_API_KEY"},
  salt: {:system, "HIT_PAY_SALT"},
  environment: {:system, "HIT_PAY_ENVIRONMENT"}

You can also use the JSON libary of your choice, Jason is used by default

config :hit_pay, json_library: Poison

Using the API

To create a payment request

params = %{
  email: "[email protected]",
  redirect_url: "https://packargo.thekirinlab.com/hitpay/success",
  webhook: "https://packargo.thekirinlab.com/hitpay/webhook",
  amount: "599",
  currency: "SGD"
}
HitPay.create_payment_request(params)

To get payment status

request_id = "93e61239-4334-42fc-be25-6c221b982699"
HitPay.get_payment_status(request_id)

To delete a payment request

request_id = "93e61239-4334-42fc-be25-6c221b982699"
HitPay.delete_payment_request(request_id)

To verify webhook

%{
  "amount" => "35.00",
  "currency" => "SGD",
  "hmac" => "8ae5832ebc8ff5e794815e06b99cb7593dfa3e7b9e5f027f19e9af7f8442a55f",
  "payment_id" => "93e85e66-7579-4144-b478-dedc79054385",
  "payment_request_id" => "93e85e4f-101c-4947-bd93-e6392423c3d2",
  "phone" => "",
  "reference_number" => "FWBGCKSA",
  "status" => "completed"
} |> HitPay.verify_webhook?()

Documentation

More info can be found at https://hexdocs.pm/hit_pay.

About

Elixir client for HitPay

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 100.0%