public class PaymentProxy extends MerchantProxy
Description:
weixinPayAccount, weixinSignatureweixinRequestClient| 构造器和说明 |
|---|
PaymentProxy(WeixinPayAccount weixinAccount) |
| 限定符和类型 | 方法和说明 |
|---|---|
RefundResult |
applyRefund(IdQuery idQuery,
String outRefundNo,
double totalFee)
退款申请(全额退款)
|
RefundResult |
applyRefund(IdQuery idQuery,
String outRefundNo,
double totalFee,
double refundFee,
CurrencyType refundFeeType,
String opUserId,
String refundDesc,
RefundAccountType refundAccountType)
申请退款(请求需要双向证书)
当交易发生之后一段时间内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付款退还给买家,微信支付将在收到退款请求并且验证成功之后,
按照退款规则将支付款按原路退到买家帐号上。
|
OpenidResult |
authCode2openId(String authCode)
授权码查询OPENID接口
|
MerchantResult |
closeOrder(String outTradeNo)
关闭订单
商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;系统下单后,用户支付超时,系统退出不再受理,避免用户继续
,请调用关单接口,如果关单失败,返回已完 成支付请按正常支付处理。
|
String |
createAddressRequestJSON(String url,
String oauthToken)
生成编辑地址请求
err_msg edit_address:ok获取编辑收货地址成功 edit_address:fail获取编辑收货地址失败
userName 收货人姓名 telNumber 收货人电话 addressPostalCode 邮编
proviceFirstStageName 国标收货地址第一级地址 addressCitySecondStageName
国标收货地址第二级地址 addressCountiesThirdStageName 国标收货地址第三级地址
addressDetailInfo 详细收货地址信息nationalCode 收货地址国家码
|
MerchantPaymentRequest |
createAppPayRequest(String body,
String outTradeNo,
double totalFee,
String notifyUrl,
String createIp,
String attach,
SceneInfoStore store)
创建APP支付请求对象
|
MerchantPaymentRequest |
createJSPayRequest(String openId,
String body,
String outTradeNo,
double totalFee,
String notifyUrl,
String createIp,
String attach)
创建JSAPI支付请求对象
|
MerchantPaymentRequest |
createMicroPayRequest(String authCode,
String body,
String outTradeNo,
double totalFee,
String createIp,
String attach,
SceneInfoStore store)
提交被扫支付
|
String |
createNativePayRequest(String productId)
创建Native支付(扫码支付)链接【模式一】
|
MerchantPaymentRequest |
createNativePayRequest(String productId,
String body,
String outTradeNo,
double totalFee,
String notifyUrl,
String createIp,
String attach)
创建Native支付(扫码支付)链接【模式二】
|
NativePaymentResponse |
createNativePayResponse(String productId,
String body,
String outTradeNo,
double totalFee,
String notifyUrl,
String createIp,
String attach)
创建Native支付(扫码支付)回调对象【模式一】
|
MerchantPaymentRequest |
createPayRequest(MerchantPaymentPackage payPackage)
创建支付请求对象
|
PrePayment |
createPrePay(MerchantPaymentPackage payPackage)
统一下单接口
除被扫支付场景以外,商户系统先调用该接口在微信支付服务后台生成预支付交易单,返回正确的预支付交易回话标识后再按扫码、JSAPI
、APP等不同场景生成交易串调起支付。
|
MerchantPaymentRequest |
createWapPayRequest(String body,
String outTradeNo,
double totalFee,
String notifyUrl,
String createIp,
String attach,
SceneInfoApp app)
创建WAP支付请求对象:正常流程用户支付完成后会返回至发起支付的页面,如需返回至指定页面,
则可以在MWEB_URL后拼接上redirect_url参数,来指定回调页面
|
void |
downloadBill(Date billDate,
BillType billType,
OutputStream outputStream,
ZipType tarType)
下载对账单
1.微信侧未成功下单的交易不会出现在对账单中。 |
String |
getShorturl(String url)
native支付URL转短链接:用于扫码原生支付模式一中的二维码链接转成短链接(weixin://wxpay/s/XXXXXX),减小二维码数据量
,提升扫描速度和精确度。
|
Order |
queryOrder(IdQuery idQuery)
订单查询
当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知; 调用支付接口后,返回系统错误或未知交易状态情况;
调用被扫支付API,返回USERPAYING的状态; 调用关单或撤销接口API之前,需确认支付状态;
|
RefundRecord |
queryRefund(IdQuery idQuery)
退款查询
提交退款申请后,通过调用该接口查询退款状态。
|
ApiXmlResult |
reportInterface(String interfaceUrl,
int executeTime,
String outTradeNo,
String ip,
Date time,
ApiXmlResult returnXml)
接口上报
|
MerchantResult |
reverseOrder(IdQuery idQuery)
冲正订单(需要证书)当支付返回失败,或收银系统超时需要取消交易,可以调用该接口 接口逻辑:支
付失败的关单,支付成功的撤销支付7天以内的单可撤销,其他正常支付的单
如需实现相同功能请调用退款接口 调用扣款接口后请勿立即调用撤销,需要等待5秒以上。
|
createBaseRequestMap, declareMerchant, getWeixinSignature, getWeixinSSLExecutorpublic PaymentProxy(WeixinPayAccount weixinAccount)
public PrePayment createPrePay(MerchantPaymentPackage payPackage) throws WeixinException
payPackage - 包含订单信息的对象WeixinExceptionMerchantPaymentPackage,
PrePayment,
统一下单接口
public MerchantPaymentRequest createPayRequest(MerchantPaymentPackage payPackage) throws WeixinException
public MerchantPaymentRequest createJSPayRequest(String openId, String body, String outTradeNo, double totalFee, String notifyUrl, String createIp, String attach) throws WeixinException
openId - 用户IDbody - 订单描述outTradeNo - 订单号totalFee - 订单总额(元)notifyUrl - 支付通知地址createIp - ip地址attach - 附加数据 非必填WeixinExceptionJsapiPaymentRequestpublic String createAddressRequestJSON(String url, String oauthToken)
生成编辑地址请求
err_msg edit_address:ok获取编辑收货地址成功 edit_address:fail获取编辑收货地址失败 userName 收货人姓名 telNumber 收货人电话 addressPostalCode 邮编 proviceFirstStageName 国标收货地址第一级地址 addressCitySecondStageName 国标收货地址第二级地址 addressCountiesThirdStageName 国标收货地址第三级地址 addressDetailInfo 详细收货地址信息nationalCode 收货地址国家码url - 当前访问页的URLoauthToken - oauth授权时产生的tokenpublic String createNativePayRequest(String productId)
public NativePaymentResponse createNativePayResponse(String productId, String body, String outTradeNo, double totalFee, String notifyUrl, String createIp, String attach) throws WeixinException
productId - 商品IDbody - 商品描述outTradeNo - 商户内部唯一订单号totalFee - 商品总额 单位元notifyUrl - 支付回调URLcreateIp - 订单生成的机器 IPattach - 附加数据 非必填WeixinExceptionNativePaymentResponse,
扫码支付
,
模式一
public MerchantPaymentRequest createNativePayRequest(String productId, String body, String outTradeNo, double totalFee, String notifyUrl, String createIp, String attach) throws WeixinException
productId - 商品IDbody - 商品描述outTradeNo - 商户内部唯一订单号totalFee - 商品总额 单位元notifyUrl - 支付回调URLcreateIp - 订单生成的机器 IPattach - 附加数据 非必填WeixinExceptionNativePaymentRequest,
扫码支付
,
模式二
public MerchantPaymentRequest createAppPayRequest(String body, String outTradeNo, double totalFee, String notifyUrl, String createIp, String attach, SceneInfoStore store) throws WeixinException
body - 商品描述outTradeNo - 商户内部唯一订单号totalFee - 商品总额 单位元notifyUrl - 支付回调URLcreateIp - 订单生成的机器 IPattach - 附加数据 非必填store - 门店信息 非必填WeixinExceptionSceneInfoStore,
AppPaymentRequest,
APP支付public MerchantPaymentRequest createWapPayRequest(String body, String outTradeNo, double totalFee, String notifyUrl, String createIp, String attach, SceneInfoApp app) throws WeixinException
body - 商品描述outTradeNo - 商户内部唯一订单号totalFee - 商品总额 单位元notifyUrl - 支付回调URLcreateIp - 订单生成的机器 IPattach - 附加数据 非必填app - 应用信息WeixinExceptionSceneInfoApp,
WapPaymentRequest,
WAP支付
public MerchantPaymentRequest createMicroPayRequest(String authCode, String body, String outTradeNo, double totalFee, String createIp, String attach, SceneInfoStore store) throws WeixinException
authCode - 扫码支付授权码 ,设备读取用户微信中的条码或者二维码信息body - 商品描述outTradeNo - 商户内部唯一订单号totalFee - 商品总额 单位元createIp - 订单生成的机器 IPattach - 附加数据 非必填store - 门店信息 非必填WeixinExceptionMicroPaymentRequest,
Order,
SceneInfoStore,
提交被扫支付APIpublic Order queryOrder(IdQuery idQuery) throws WeixinException
当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知; 调用支付接口后,返回系统错误或未知交易状态情况; 调用被扫支付API,返回USERPAYING的状态; 调用关单或撤销接口API之前,需确认支付状态;
idQuery - 商户系统内部的订单号, transaction_id、out_trade_no 二 选一,如果同时存在优先级:
transaction_id > out_trade_noWeixinExceptionOrder,
订单查询APIpublic RefundResult applyRefund(IdQuery idQuery, String outRefundNo, double totalFee, double refundFee, CurrencyType refundFeeType, String opUserId, String refundDesc, RefundAccountType refundAccountType) throws WeixinException
当交易发生之后一段时间内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付款退还给买家,微信支付将在收到退款请求并且验证成功之后, 按照退款规则将支付款按原路退到买家帐号上。
idQuery - 商户系统内部的订单号, transaction_id 、 out_trade_no 二选一,如果同时存在优先级:
transaction_id > out_trade_nooutRefundNo - 商户系统内部的退款单号,商 户系统内部唯一,同一退款单号多次请求只退一笔totalFee - 订单总金额,单位为元refundFee - 退款总金额,单位为元,可以做部分退款refundFeeType - 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNYopUserId - 操作员帐号, 默认为商户号refundDesc - 退款原因,若商户传入,会在下发给用户的退款消息中体现退款原因refundAccountType - 退款资金来源,默认使用未结算资金退款:REFUND_SOURCE_UNSETTLED_FUNDSWeixinExceptionRefundResult,
申请退款APIpublic RefundResult applyRefund(IdQuery idQuery, String outRefundNo, double totalFee) throws WeixinException
idQuery - 商户系统内部的订单号, transaction_id 、 out_trade_no 二选一,如果同时存在优先级:
transaction_id > out_trade_nooutRefundNo - 商户系统内部的退款单号,商 户系统内部唯一,同一退款单号多次请求只退一笔totalFee - 订单总金额,单位为元WeixinExceptionapplyRefund(IdQuery, String, double, double, CurrencyType, String, String, RefundAccountType)public MerchantResult reverseOrder(IdQuery idQuery) throws WeixinException
idQuery - 商户系统内部的订单号, transaction_id 、 out_trade_no 二选一,如果同时存在优先级:
transaction_id > out_trade_noWeixinExceptionpublic String getShorturl(String url) throws WeixinException
url - 具有native标识的支付URLWeixinExceptionpublic MerchantResult closeOrder(String outTradeNo) throws WeixinException
商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;系统下单后,用户支付超时,系统退出不再受理,避免用户继续 ,请调用关单接口,如果关单失败,返回已完 成支付请按正常支付处理。如果出现银行掉单,调用关单成功后,微信后台会主动发起退款。
outTradeNo - 商户系统内部的订单号WeixinExceptionpublic void downloadBill(Date billDate, BillType billType, OutputStream outputStream, ZipType tarType) throws WeixinException
billDate - 下载对账单的日期billType - 下载对账单的类型 ALL,返回当日所有订单信息, 默认值 SUCCESS,返回当日成功支付的订单
REFUND,返回当日退款订单outputStream - 输出流tarType - 非必传参数,固定值:GZIP,返回格式为.gzip的压缩包账单。不传则默认为数据流形式。WeixinExceptionpublic RefundRecord queryRefund(IdQuery idQuery) throws WeixinException
提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账,银行卡支付的退款3个工作日后重新查询退款状态。
idQuery - 单号 refund_id、out_refund_no、 out_trade_no 、 transaction_id
四个参数必填一个,优先级为:
refund_id > out_refund_no > transaction_id > out_trade_noWeixinExceptionRefundRecord,
RefundDetail,
退款查询APIpublic ApiXmlResult reportInterface(String interfaceUrl, int executeTime, String outTradeNo, String ip, Date time, ApiXmlResult returnXml) throws WeixinException
interfaceUrl - 上报对应的接口的完整 URL, 类似: https://api.mch.weixin.q
q.com/pay/unifiedorderexecuteTime - 接口耗时情况,单位为毫秒outTradeNo - 商户系统内部的订单号,商 户可以在上报时提供相关商户订单号方便微信支付更好 的提高服务质量。ip - 发起接口调用时的机器 IPtime - 商户调用该接口时商户自己 系统的时间returnXml - 调用接口返回的基本数据WeixinExceptionpublic OpenidResult authCode2openId(String authCode) throws WeixinException
authCode - 扫码支付授权码,设备读取用户微信中的条码或者二维码信息WeixinExceptionOpenidResult,
授权码查询OPENIDCopyright © 2019. All rights reserved.