WechatPay v0.7.0 WechatPay View Source
WechatPay provide toolkit for Wechat Payment Platform.
Setup
You need to define you own pay module, then use
WechatPay:
defmodule MyPay do
use WechatPay, otp_app: :my_app
end
Then config your app in config/config.exs
:
config :my_app, MyPay,
appid: "the-appid",
mch_id: "the-mch-id",
apikey: "the-apikey",
ssl_cacert: File.read!("fixture/certs/rootca.pem"),
ssl_cert: File.read!("fixture/certs/apiclient_cert.pem"),
ssl_key: File.read!("fixture/certs/apiclient_key.pem")
If this does not fit your needs, you might want to check Configuration.
NOTE: WechatPay provide
Mix.Tasks.WechatPay.GetSandboxSignkey
to fetch the Sandbox API Key.
Payment methods
When use
WechatPay in MyPay
module, it will generate following
modules for you:
MyPay.App
- Implements theWechatPay.App.Behaviour
behaviourMyPay.JSAPI
- Implements theWechatPay.JSAPI.Behaviour
behaviourMyPay.Native
- Implements theWechatPay.Native.Behaviour
behaviour
Plug
WechatPay will also generate some Plugs to simplify the process of handling notification from Wechat’s Payment Gateway:
MyPay.Plug.Payment
- Implements theWechatPay.Plug.Payment
behaviourMyPay.Plug.Refund
- Implements theWechatPay.Plug.Refund
behaviour
JSON Encoder
By default, WechatPay
use Jason
to encode JSON, if you want to use Poison
,
you can configure :wechat_pay
application with:
config :wechat_pay, :json_library, Poison