Constants

GET

GET = 'get'

POST

POST = 'post'

JSON

JSON = 'json'

API_HOST

API_HOST = 'https://api.mch.weixin.qq.com'

API_PAY_ORDER

API_PAY_ORDER = '/pay/micropay'

API_PREPARE_ORDER

API_PREPARE_ORDER = '/pay/unifiedorder'

API_QUERY

API_QUERY = '/pay/orderquery'

API_CLOSE

API_CLOSE = '/pay/closeorder'

API_REVERSE

API_REVERSE = '/secapi/pay/reverse'

API_REFUND

API_REFUND = '/secapi/pay/refund'

API_QUERY_REFUND

API_QUERY_REFUND = '/pay/refundquery'

API_DOWNLOAD_BILL

API_DOWNLOAD_BILL = '/pay/downloadbill'

API_REPORT

API_REPORT = '/payitil/report'

API_URL_SHORTEN

API_URL_SHORTEN = 'https://api.mch.weixin.qq.com/tools/shorturl'

API_AUTH_CODE_TO_OPENID

API_AUTH_CODE_TO_OPENID = 'https://api.mch.weixin.qq.com/tools/authcodetoopenid'

API_SANDBOX_SIGN_KEY

API_SANDBOX_SIGN_KEY = 'https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey'

TRANSACTION_ID

TRANSACTION_ID = 'transaction_id'

OUT_TRADE_NO

OUT_TRADE_NO = 'out_trade_no'

OUT_REFUND_NO

OUT_REFUND_NO = 'out_refund_no'

REFUND_ID

REFUND_ID = 'refund_id'

BILL_TYPE_ALL

BILL_TYPE_ALL = 'ALL'

BILL_TYPE_SUCCESS

BILL_TYPE_SUCCESS = 'SUCCESS'

BILL_TYPE_REFUND

BILL_TYPE_REFUND = 'REFUND'

BILL_TYPE_REVOKED

BILL_TYPE_REVOKED = 'REVOKED'

Properties

$maxRetries

$maxRetries : integer

Type

integer

$sandboxEnabled

$sandboxEnabled : boolean

Sandbox box mode.

Type

boolean

$sandboxSignKey

$sandboxSignKey : string

Sandbox sign key.

Type

string

Methods

setHttp()

setHttp(\EasyWeChat\Core\Http  $http) : $this

Set the http instance.

Parameters

\EasyWeChat\Core\Http $http

Returns

$this

setAccessToken()

setAccessToken(\EasyWeChat\Core\AccessToken  $accessToken) : $this

Set the request token.

Parameters

\EasyWeChat\Core\AccessToken $accessToken

Returns

$this

maxRetries()

maxRetries(integer  $retries) 

Parameters

integer $retries

parseJSON()

parseJSON(string  $method, array  $args) : \EasyWeChat\Support\Collection

Parse JSON from response and check error.

Parameters

string $method
array $args

Returns

\EasyWeChat\Support\Collection

query()

query(string  $orderNo, string  $type = self::OUT_TRADE_NO) : \EasyWeChat\Support\Collection

Query order.

Parameters

string $orderNo
string $type

Returns

\EasyWeChat\Support\Collection

queryByTransactionId()

queryByTransactionId(string  $transactionId) : \EasyWeChat\Support\Collection

Query order by transaction_id.

Parameters

string $transactionId

Returns

\EasyWeChat\Support\Collection

reverse()

reverse(string  $orderNo, string  $type = self::OUT_TRADE_NO) : \EasyWeChat\Support\Collection

Reverse order.

Parameters

string $orderNo
string $type

Returns

\EasyWeChat\Support\Collection

reverseByTransactionId()

reverseByTransactionId(integer  $transactionId) : \EasyWeChat\Support\Collection

Reverse order by transaction_id.

Parameters

integer $transactionId

Returns

\EasyWeChat\Support\Collection

refund()

refund(string  $orderNo, string  $refundNo, float  $totalFee, float  $refundFee = null, string  $opUserId = null, string  $type = self::OUT_TRADE_NO, string  $refundAccount = 'REFUND_SOURCE_UNSETTLED_FUNDS', string  $refundReason = '') : \EasyWeChat\Support\Collection

Make a refund request.

Parameters

string $orderNo
string $refundNo
float $totalFee
float $refundFee
string $opUserId
string $type
string $refundAccount
string $refundReason

Returns

\EasyWeChat\Support\Collection

refundByTransactionId()

refundByTransactionId(string  $orderNo, string  $refundNo, float  $totalFee, float  $refundFee = null, string  $opUserId = null, string  $refundAccount = 'REFUND_SOURCE_UNSETTLED_FUNDS', string  $refundReason = '') : \EasyWeChat\Support\Collection

Refund by transaction id.

Parameters

string $orderNo
string $refundNo
float $totalFee
float $refundFee
string $opUserId
string $refundAccount
string $refundReason

Returns

\EasyWeChat\Support\Collection

queryRefund()

queryRefund(string  $orderNo, string  $type = self::OUT_TRADE_NO) : \EasyWeChat\Support\Collection

Query refund status.

Parameters

string $orderNo
string $type

Returns

\EasyWeChat\Support\Collection

queryRefundByRefundNo()

queryRefundByRefundNo(string  $refundNo) : \EasyWeChat\Support\Collection

Query refund status by out_refund_no.

Parameters

string $refundNo

Returns

\EasyWeChat\Support\Collection

queryRefundByTransactionId()

queryRefundByTransactionId(string  $transactionId) : \EasyWeChat\Support\Collection

Query refund status by transaction_id.

Parameters

string $transactionId

Returns

\EasyWeChat\Support\Collection

queryRefundByRefundId()

queryRefundByRefundId(string  $refundId) : \EasyWeChat\Support\Collection

Query refund status by refund_id.

Parameters

string $refundId

Returns

\EasyWeChat\Support\Collection

downloadBill()

downloadBill(string  $date, string  $type = self::BILL_TYPE_ALL) : \Psr\Http\Message\ResponseInterface

Download bill history as a table file.

Parameters

string $date
string $type

Returns

\Psr\Http\Message\ResponseInterface

urlShorten()

urlShorten(string  $url) : \EasyWeChat\Support\Collection

Convert long url to short url.

Parameters

string $url

Returns

\EasyWeChat\Support\Collection

report()

report(string  $api, integer  $timeConsuming, string  $resultCode, string  $returnCode, array  $other = array()) : \EasyWeChat\Support\Collection

Report API status to WeChat.

Parameters

string $api
integer $timeConsuming
string $resultCode
string $returnCode
array $other

ex: err_code,err_code_des,out_trade_no,user_ip...

Returns

\EasyWeChat\Support\Collection

authCodeToOpenId()

authCodeToOpenId(string  $authCode) : \EasyWeChat\Support\Collection

Get openid by auth code.

Parameters

string $authCode

Returns

\EasyWeChat\Support\Collection

setMerchant()

setMerchant(\EasyWeChat\Payment\Merchant  $merchant) : $this

Merchant setter.

Parameters

\EasyWeChat\Payment\Merchant $merchant

Returns

$this

sandboxMode()

sandboxMode(boolean  $enabled = false) : $this

Set sandbox mode.

Parameters

boolean $enabled

Returns

$this

registerHttpMiddlewares()

registerHttpMiddlewares() 

Register Guzzle middlewares.

accessTokenMiddleware()

accessTokenMiddleware() : \Closure

Attache access token to request query.

Returns

\Closure

logMiddleware()

logMiddleware() : \Closure

Log the request.

Returns

\Closure

retryMiddleware()

retryMiddleware() : \Closure

Return retry middleware.

Returns

\Closure

checkAndThrow()

checkAndThrow(array  $contents) 

Check the array data errors, and Throw exception when the contents contains error.

Parameters

array $contents

Throws

\EasyWeChat\Core\Exceptions\HttpException

request()

request(string  $api, array  $params, string  $method = 'post', array  $options = array(), boolean  $returnResponse = false) : \EasyWeChat\Support\Collection|\Psr\Http\Message\ResponseInterface

Make a API request.

Parameters

string $api
array $params
string $method
array $options
boolean $returnResponse

Returns

\EasyWeChat\Support\Collection|\Psr\Http\Message\ResponseInterface

getSignkey()

getSignkey(string  $api) : string

Return key to sign.

Parameters

string $api

Returns

string

safeRequest()

safeRequest(string  $api, array  $params, string  $method = 'post') : \EasyWeChat\Support\Collection

Request with SSL.

Parameters

string $api
array $params
string $method

Returns

\EasyWeChat\Support\Collection

wrapApi()

wrapApi(string  $resource) : string

Wrap API.

Parameters

string $resource

Returns

string

getSandboxSignKey()

getSandboxSignKey() : string

Get sandbox sign key.

Returns

string