import { WechatPayPromotionScope, WechatPayPromotionType, WechatPayTradeState, WechatPayTradeType } from '../constants/wechat-pay.constant'; /** 支付者信息 */ interface WechatPayCallbackDataResourcePayer { /** * 用户服务标识 * @description 用户在服务商appid下的唯一标识 * @example oUpF8uMuAJO_M2pxb1Q9zNjWeS6o */ sp_openid: string; /** * 用户子标识 * @description 用户在子商户appid下的唯一标识。 * @example oUpF8uMuAJO_M2pxb1Q9zNjWeS6o */ sub_openid: string; } /** 订单金额信息 */ interface WechatPayCallbackDataResourceAmount { /** * 总金额 * @description 订单总金额,单位为分。 * @example 100 */ total: number; /** * 用户支付金额 * @description 用户支付金额,单位为分。 * @example 100 */ payer_total: number; /** * 货币类型 * @description CNY:人民币,境内商户号仅支持人民币。 * @example CNY */ currency: string; /** * 用户支付币种 * @description 用户支付币种 * @example CNY */ payer_currency: string; } /** 支付场景信息描述 */ interface WechatPayCallbackDataResourceSceneInfo { /** * 商户端设备号 * @description 终端设备号(门店号或收银设备ID)。 * @example 013467007045764 */ device_id?: string; } /** 优惠单品信息 */ interface WechatPayCallbackDataResourcePromotionDetailGoodDetail { /** * 商品编码 * @example M1006 */ goods_id: string; /** * 商品数量 * @description 用户购买的数量 * @example 1 */ quantity: number; /** * 商品单价 * @description 商品单价,单位为分 * @example 100 */ unit_price: number; /** * 商品优惠金额 * @example 0 */ discount_amount: number; /** * 商品备注 * @description 商品备注信息 * @example 商品备注信息 */ goods_remark?: string; } /** 订单优惠信息 */ interface WechatPayCallbackDataResourcePromotionDetail { /** * 券ID * @example 109519 */ coupon_id: string; /** * 优惠名称 * @example 单品惠-6 */ name?: string; /** 优惠范围 */ scope?: WechatPayPromotionScope; /** 优惠类型 */ type?: WechatPayPromotionType; /** * 优惠券面额 * @example 100 */ amount: number; /** * 活动ID * @example 931386 */ stock_id?: string; /** * 微信出资 * @description 微信出资,单位为分 * @example 0 */ wechatpay_contribute?: number; /** * 商户出资 * @description 商户出资,单位为分 * @example 0 */ merchant_contribute?: number; /** * 其他出资 * @description 其他出资,单位为分 * @example 0 */ other_contribute?: number; /** * 优惠币种 * @description CNY:人民币,境内商户号仅支持人民币。 * @example CNY */ currency?: string; /** * 单品列表 * @description 单品列表信息 */ goods_detail?: WechatPayCallbackDataResourcePromotionDetailGoodDetail[]; } /** * 微信支付回调解密资源 * @see https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_5.shtml */ export interface WechatPayCallbackDataResource { /** * 服务商appid * @description 服务商申请的公众号或移动应用appid * @example wxd678efh567hg6787 */ sp_appid: string; /** * 服务商户号 * @description 服务商商户号,由微信支付生成并下发。 * @example 1230000109 */ sp_mchid: string; /** * 子商户应用ID * @description 子商户申请的公众号或移动应用appid。 * @example wxd678efh567hg6787 */ sub_appid: string; /** * 子商户号 * @description 子商户的商户号,由微信支付生成并下发。 * @example 1230000109 */ sub_mchid: string; /** * 商户订单号 * @description 商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一。特殊规则:最小字符长度为6 * @example 1217752501201407033233368018 */ out_trade_no: string; /** * 微信支付订单号 * @description 微信支付系统生成的订单号。 * @example 1217752501201407033233368018 */ transaction_id: string; /** 交易类型 */ trade_type: WechatPayTradeType; /** 交易状态 */ trade_state: WechatPayTradeState; /** * 交易状态描述 * @example 支付成功 */ trade_state_desc: string; /** * 付款银行 * @description 银行类型,采用字符串类型的银行标识,请参考:[银行类型对照表](https://pay.weixin.qq.com/wiki/doc/apiv3/terms_definition/chapter1_1_3.shtml#part-6) * @example CMC */ bank_type: string; /** * 附加数据 * @description 附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用 * @example 自定义数据 */ attach?: string; /** * 支付完成时间 * @description 支付完成时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。 * @example 2018-06-08T10:34:56+08:00 */ success_time: string; /** * 支付者 * @description 支付者信息 */ payer: WechatPayCallbackDataResourcePayer; /** * 订单金额 * @description 订单金额信息 */ amount: WechatPayCallbackDataResourceAmount; /** * 场景信息 * @description 支付场景信息描述 */ scene_info?: WechatPayCallbackDataResourceSceneInfo; /** * 优惠功能 * @description 优惠功能,享受优惠时返回该字段。 */ promotion_detail: WechatPayCallbackDataResourcePromotionDetail; } /** 微信支付回调加密资源 */ export interface WechatPayCallbackDataEncryptResource { /** * 加密算法类型 * @description 对开启结果数据进行加密的加密算法,目前只支持AEAD_AES_256_GCM * @example AEAD_AES_256_GCM */ algorithm: string; /** * 数据密文 * @description Base64编码后的开启/停用结果数据密文 * @example sadsadsadsad */ ciphertext: string; /** * 附加数据 * @example fdasfwqewlkja484w */ associated_data: string; /** * 原始类型 * @description 原始回调类型,为transaction * @example transaction */ original_type: string; /** * 随机串 * @description 加密使用的随机串 * @example fdasflkja484w */ nonce: string; } /** 微信支付回调数据类型 */ export interface WechatPayCallbackData { /** * 通知ID * @description 通知的唯一ID * @example 'EV-2018022511223320873' */ id: string; /** * 通知创建时间 * @description 通知创建的时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示北京时间2015年05月20日13点29分35秒。 * @example '2015-05-20T13:29:35+08:00' */ create_time: string; /** * 通知类型 * @description 通知的类型,支付成功通知的类型为`TRANSACTION.SUCCESS` * @example 'TRANSACTION.SUCCESS' */ event_type: string; /** * 通知数据类型 * @description 通知的资源数据类型,支付成功通知为encrypt-resource * @example 'encrypt-resource' */ resource_type: string; /** * 回调摘要 * @example 支付成功 */ summary: string; /** * 通知数据 * @description 通知资源数据,json格式 */ resource: WechatPayCallbackDataEncryptResource; } export {};