WechatPay.API (WechatPay v0.10.0) View Source
The Core API module.
Link to this section Summary
Functions
Query comments in a batch.
Request to close the order.
Download the bill.
Download the fund flow.
Place an unified order.
Query an order.
Query the refund status.
Request to Refund an order.
Call the payitil/report API.
Link to this section Functions
Specs
batch_query_comments(WechatPay.Client.t(), map(), keyword()) :: {:ok, String.t()} | {:error, HTTPoison.Error.t()}
Query comments in a batch.
⚠️ This requires the ssl config is set.
Examples
iex> WechatPay.API.batch_query_comments(%{
begin_time: "20190222000000",
end_time: "20190224000000",
offset: 0
})
...> {:ok, data}
Specs
close_order(WechatPay.Client.t(), map(), keyword()) :: {:ok, map()} | {:error, WechatPay.Error.t() | HTTPoison.Error.t()}
Request to close the order.
Examples
iex> WechatPay.API.close_order(%{out_trade_no: "1415757673"})
...> {:ok, data}
Specs
download_bill(WechatPay.Client.t(), map(), keyword()) :: {:ok, String.t()} | {:error, HTTPoison.Error.t()}
Download the bill.
Examples
iex> WechatPay.API.download_bill(%{
device_info: "013467007045764",
bill_date: "20140603",
bill_type: "ALL"
})
...> {:ok, data}
Specs
download_fund_flow(WechatPay.Client.t(), map(), keyword()) :: {:ok, String.t()} | {:error, HTTPoison.Error.t()}
Download the fund flow.
⚠️ This requires the ssl config is set.
Examples
iex> WechatPay.API.download_fund_flow(%{
account_type: "Basic",
bill_date: "20140603"
})
...> {:ok, data}
Specs
place_order(WechatPay.Client.t(), map(), keyword()) :: {:ok, map()} | {:error, WechatPay.Error.t() | HTTPoison.Error.t()}
Place an unified order.
Examples
iex> WechatPay.API.place_order(%{
device_info: "WEB",
body: "Wechat-666",
attach: nil,
out_trade_no: "1415757673",
fee_type: "CNY",
total_fee: 709,
spbill_create_ip: "127.0.0.1",
notify_url: "http://example.com/wechat-pay-callback",
time_start: 20091225091010,
time_expire: 20091227091010,
trade_type: "JSAPI",
openid: "oUpF8uMuAJO_M2pxb1Q9zNjWeS6o",
})
...> {:ok, data}
Specs
query_order(WechatPay.Client.t(), map(), keyword()) :: {:ok, map()} | {:error, WechatPay.Error.t() | HTTPoison.Error.t()}
Query an order.
Examples
iex> WechatPay.API.query_order(%{out_trade_no: "1415757673"})
...> {:ok, data}
Specs
query_refund(WechatPay.Client.t(), map(), keyword()) :: {:ok, map()} | {:error, WechatPay.Error.t() | HTTPoison.Error.t()}
Query the refund status.
Examples
iex> WechatPay.API.query_refund(%{
device_info: "WEB",
out_trade_no: "1415757673"
})
...> {:ok, data}
Specs
refund(WechatPay.Client.t(), map(), keyword()) :: {:ok, map()} | {:error, WechatPay.Error.t() | HTTPoison.Error.t()}
Request to Refund an order.
⚠️ This requires the ssl config is set.
Examples
iex> attrs = %{
device_info: "013467007045764",
transaction_id: "1217752501201407033233368018",
out_trade_no: "1217752501201407033233368018",
out_refund_no: "1217752501201407033233368018",
total_fee: 100,
refund_fee: 100,
refund_fee_type: "CNY",
op_user_id: "1900000109",
refund_account: "REFUND_SOURCE_RECHARGE_FUNDS"
}
...> WechatPay.API.refund(attrs, opts)
...> {:ok, data}
Specs
report(WechatPay.Client.t(), map(), keyword()) :: {:ok, map()} | {:error, WechatPay.Error.t() | HTTPoison.Error.t()}
Call the payitil/report API.
Examples
iex> params = %{
device_info: "013467007045764",
interface_url: "https://api.mch.weixin.qq.com/pay/unifiedorder",
execute_time_: 1000,
return_code: "SUCCESS",
return_msg: "签名失败",
result_code: "SUCCESS",
err_code: "SYSTEMERROR",
err_code_des: "系统错误",
out_trade_no: "1217752501201407033233368018",
user_ip: "8.8.8.8",
time: "20091227091010"
}
...> WechatPay.API.report(params)
...> {:ok, data}