View Source ExWechatpay.Client (ex_wechatpay v0.1.5)

微信支付客户端behaviour

Summary

Types

@type client_options() ::
  keyword(
    {:name, atom()}
    | {:appid, binary()}
    | {:mchid, binary()}
    | {:service_host, binary()}
    | {:notify_url, binary()}
    | {:apiv3_key, binary()}
    | {:wx_pubs, [term()]}
    | {:client_serial_no, binary()}
    | {:client_key, binary()}
    | {:client_cert, binary()}
    | {:http_client, term()}
  )
@type t() :: %ExWechatpay.Client{
  apiv3_key: term(),
  appid: term(),
  client_cert: term(),
  client_key: term(),
  client_serial_no: term(),
  http_client: term(),
  mchid: term(),
  name: term(),
  notify_url: term(),
  service_host: term(),
  wx_pubs: term()
}

Functions

@spec decrypt(t(), map()) :: binary() | {:error, term()}

https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_2.shtml

Link to this function

miniapp_payform(client, prepay_id)

View Source
@spec miniapp_payform(t(), String.t()) :: %{required(String.t()) => String.t()}

create miniapp payform with a prepay_id

Examples

%{
  "appid" => "wxefd6b215fca0cacd",
  "nonceStr" => "ODnHX8RwAlw0",
  "package" => "prepay_id=wx28094533993528b1d687203f4f48e20000",
  "paySign" => "xxxx",
  "signType" => "RSA",
  "timeStamp" => 1624844734
} = miniapp_payform(client, "wx28094533993528b1d687203f4f48e20000")
@spec new(client_options()) :: t()

create a new client instance

Options

Link to this function

request(client, req, opts \\ [])

View Source
Link to this function

verify(client, headers, body)

View Source

verify the response or notify from wechatpay

Examples

true = verify(client, [{"header-key", "header-val"}], "notify body")