View Source ExWechatpay.Client (ex_wechatpay v0.1.1)
微信支付客户端behaviour
Summary
Functions
create miniapp payform with a prepay_id
create a new client instance
verify the response or notify from wechatpay
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()} )
Functions
https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_2.shtml
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
:name
(atom/0
) - name of this process The default value isExWechatpay.Client
.:appid
(String.t/0
) - Required. 第三方用户唯一凭证:mchid
(String.t/0
) - Required. 商户号:service_host
(String.t/0
) - 微信支付服务域名 The default value is"api.mch.weixin.qq.com"
.:notify_url
(String.t/0
) - Required. 通知地址:apiv3_key
(String.t/0
) - APIv3密钥, see https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay3_2.shtml for more details The default value is""
.:wx_pubs
(list ofterm/0
) - 微信平台证书列表, see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/wechatpay5_1.shtml for more details The default value is[{"wechatpay-serial", "pem"}]
.:client_serial_no
(String.t/0
) - Required. 商户API证书序列号, see https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay7_0.shtml for more details:client_key
(String.t/0
) - Required. 商户API证书私钥, see https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay7_0.shtml for more details:client_cert
(String.t/0
) - Required. 商户API证书, see https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay7_0.shtml for more details:http_client
(term/0
) - Required. http client instance, default: ExWechatpay.Wechat.Http.Default.new()
@spec request(t(), ExWechatpay.Request.t(), ExWechatpay.Typespecs.opts()) :: {:ok, ExWechatpay.Http.Response.t()} | {:error, ExWechatpay.Error.t()}
@spec start_link(ExWechatpay.Typespecs.opts()) :: ExWechatpay.Typespecs.on_start()
@spec verify(t(), ExWechatpay.Typespecs.headers(), ExWechatpay.Typespecs.body()) :: boolean()
verify the response or notify from wechatpay
Examples
true = verify(client, [{"header-key", "header-val"}], "notify body")