WechatPay.Plug.Payment (WechatPay v0.10.0) View Source

Plug behaviour to handle Payment Notification from Wechat's Payment Gateway.

Official document: https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7

Example

Define a handler

See WechatPay.Plug.Handler for how to implement a handler.

defmodule MyApp.WechatHandler do
  use WechatPay.Plug.Handler

  @impl WechatPay.Plug.Handler
  def handle_data(conn, data) do
    :ok
  end
end

Plug in

In your app's lib/my_app_web/router.ex:

post "/wechat_pay/notification/payment", WechatPay.Plug.Payment, [handler: MyApp.WechatHandler, api_key: "my-api-key", sign_type: :md5]

Link to this section Summary

Link to this section Functions

Specs

call(Plug.Conn.t(),
  api_key: binary(),
  handler: binary(),
  sign_type: :md5 | :sha256
) :: Plug.Conn.t()

Specs

init(keyword()) :: [
  api_key: binary(),
  handler: binary(),
  sign_type: :md5 | :sha256
]