├── VERSION ├── .gitignore ├── example ├── charge │ ├── channel_extra │ │ ├── upacp.php │ │ ├── applepay_upacp.php │ │ ├── balance.php │ │ ├── qpay.php │ │ ├── upacp_pc.php │ │ ├── upacp_wap.php │ │ ├── wx.php │ │ ├── wx_wap.php │ │ ├── mmdpay_wap.php │ │ ├── fqlpay_wap.php │ │ ├── bfb_wap.php │ │ ├── alipay.php │ │ ├── wx_lite.php │ │ ├── wx_pub.php │ │ ├── wx_pub_qr.php │ │ ├── wx_pub_scan.php │ │ ├── alipay_pc_direct.php │ │ ├── cb_alipay.php │ │ ├── cb_wx.php │ │ ├── qgbc_wap.php │ │ ├── cb_wx_pub.php │ │ ├── alipay_wap.php │ │ ├── cb_wx_pub_qr.php │ │ ├── cb_wx_pub_scan.php │ │ ├── cmb_wallet.php │ │ ├── yeepay_wap.php │ │ ├── jdpay_wap.php │ │ ├── isv_scan.php │ │ ├── alipay_scan.php │ │ ├── isv_qr.php │ │ └── isv_wap.php │ ├── retrieve.php │ ├── list.php │ ├── reverse.php │ └── create.php ├── transfer │ ├── channel_extra │ │ ├── balance.php │ │ ├── wx_pub.php │ │ ├── alipay.php │ │ ├── jdpay.php │ │ ├── allinpay.php │ │ └── unionpay.php │ ├── reverse.php │ ├── retrieve.php │ ├── list.php │ └── create.php ├── depository │ ├── id-102.jpg │ ├── user_pic.php │ └── contact.php ├── agreement │ ├── channel_extra │ │ └── qpay.php │ ├── retrieve.php │ ├── list.php │ ├── update.php │ └── create.php ├── wx_lite.php ├── withdrawal │ ├── extra │ │ ├── jdpay.php │ │ ├── wx_pub.php │ │ ├── alipay.php │ │ ├── allinpay.php │ │ └── unionpay.php │ ├── list.php │ ├── cancel.php │ ├── confirm.php │ ├── retrieve.php │ └── create.php ├── settle_account │ ├── recipient │ │ ├── wx_pub.php │ │ ├── alipay.php │ │ └── bank_account.php │ ├── list.php │ ├── delete.php │ ├── retrieve.php │ ├── verify.php │ ├── create.php │ └── update.php ├── split_profit │ ├── retrieve.php │ ├── list.php │ └── create.php ├── event.php ├── your_rsa_public_key.pem ├── pingpp_rsa_public_key.pem ├── profit_transaction │ ├── retrieve.php │ └── list.php ├── batch_transfer │ ├── channel_recipients │ │ ├── balance.php │ │ ├── wx_pub.php │ │ ├── alipay.php │ │ ├── jdpay.php │ │ ├── unionpay.php │ │ └── allinpay.php │ ├── retrieve.php │ ├── list.php │ └── create.php ├── split_receiver │ ├── list.php │ ├── delete.php │ ├── create.php │ └── retrieve.php ├── card_info.php ├── order │ ├── royalty_transaction.php │ ├── royalty.php │ ├── royalty_create_data.php │ ├── royalty_settlement.php │ └── royalty_template.php ├── sub_bank.php ├── refund │ ├── retrieve.php │ ├── list.php │ └── create.php ├── batch_refund │ ├── retrieve.php │ ├── list.php │ └── create.php ├── config.php ├── balance │ ├── balance_transaction.php │ ├── balance_settlements.php │ ├── balance_bonus.php │ └── balance_transfer.php ├── fund_transfer.php ├── sub_app │ ├── sub_app.php │ └── sub_app_channel.php ├── identification.php ├── red_envelope.php ├── your_rsa_private_key.pem ├── customs.php ├── batch_withdrawal │ └── batch_withdrawal.php ├── user.php ├── webhooks.php ├── coupon │ ├── coupon_template.php │ └── coupon.php └── recharge │ └── recharge.php ├── lib ├── Error │ ├── Api.php │ ├── ApiConnection.php │ ├── Authentication.php │ ├── RateLimit.php │ ├── InvalidRequest.php │ ├── Channel.php │ └── Base.php ├── Event.php ├── SubBank.php ├── Contact.php ├── UserPic.php ├── JsonSerializable.php ├── AttachedObject.php ├── Identification.php ├── CardInfo.php ├── BalanceSettlements.php ├── AppBase.php ├── ProfitTransaction.php ├── FundsTransfer.php ├── BalanceTransaction.php ├── RoyaltyTransaction.php ├── Util │ ├── Set.php │ └── RequestOptions.php ├── Customs.php ├── SingletonApiResource.php ├── BalanceBonus.php ├── BalanceTransfer.php ├── SplitProfit.php ├── OrderRefund.php ├── BatchRefund.php ├── BatchTransfer.php ├── Charge.php ├── Transfer.php ├── SplitReceiver.php ├── User.php ├── Royalty.php ├── BatchWithdrawal.php ├── RoyaltySettlement.php ├── Agreement.php ├── RedEnvelope.php ├── SubApp.php ├── RoyaltyTemplate.php ├── Collection.php ├── Coupon.php ├── Withdrawal.php ├── UserBase.php ├── Channel.php ├── Refund.php ├── WxLiteOAuth.php ├── CouponTemplate.php ├── Recharge.php ├── Order.php ├── Pingpp.php └── SettleAccount.php ├── composer.json ├── phpcs.xml ├── LICENSE ├── PingppEnvInspect.php ├── init.php └── CHANGELOG.md /VERSION: -------------------------------------------------------------------------------- 1 | 2.6.0 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea/ 3 | vendor/ 4 | composer.lock 5 | -------------------------------------------------------------------------------- /example/charge/channel_extra/upacp.php: -------------------------------------------------------------------------------- 1 | 'user id' 5 | ]; 6 | -------------------------------------------------------------------------------- /lib/Error/ApiConnection.php: -------------------------------------------------------------------------------- 1 | 'ios', 5 | ]; 6 | -------------------------------------------------------------------------------- /example/agreement/channel_extra/qpay.php: -------------------------------------------------------------------------------- 1 | '签约测试', 5 | ]; 6 | -------------------------------------------------------------------------------- /example/wx_lite.php: -------------------------------------------------------------------------------- 1 | 'http://example.com/success', 5 | ]; 6 | -------------------------------------------------------------------------------- /example/charge/channel_extra/upacp_wap.php: -------------------------------------------------------------------------------- 1 | 'http://example.com/success', 5 | ]; 6 | -------------------------------------------------------------------------------- /example/charge/channel_extra/wx.php: -------------------------------------------------------------------------------- 1 | 'no_credit', 5 | 6 | // 可选,商品标记,代金券或立减优惠功能的参数。 7 | //'goods_tag' => 'your goods_tag', 8 | ]; 9 | -------------------------------------------------------------------------------- /example/charge/channel_extra/wx_wap.php: -------------------------------------------------------------------------------- 1 | 'http://example.com/success', 5 | 6 | // 可选,商品标记,代金券或立减优惠功能的参数。 7 | //'goods_tag' => 'your goods_tag', 8 | ]; 9 | -------------------------------------------------------------------------------- /example/transfer/channel_extra/wx_pub.php: -------------------------------------------------------------------------------- 1 | '张三', 5 | 6 | // 可选,是否强制校验收款人姓名。仅当 user_name 参数不为空时该参数生效。 7 | // 'force_check' => true 8 | ]; 9 | -------------------------------------------------------------------------------- /example/withdrawal/extra/jdpay.php: -------------------------------------------------------------------------------- 1 | '6214850288888888', //必填项 收款人银行卡号或者存折号。 4 | 'name' => '张三', //必填项 收款人姓名。 5 | 'open_bank_code' => '0308', //必填项 开户银行编号。 6 | ]; 7 | -------------------------------------------------------------------------------- /example/withdrawal/extra/wx_pub.php: -------------------------------------------------------------------------------- 1 | 'wxopenid', //必填参数 收款人的 open_id。 4 | 'name' => '张三', //选填参数 收款人姓名。 5 | 'force_check' => false //选填参数 是否强制校验收款人姓名。仅当 name 参数不为空时该参数生效。 6 | ]; 7 | -------------------------------------------------------------------------------- /example/charge/channel_extra/mmdpay_wap.php: -------------------------------------------------------------------------------- 1 | 'your phone', 5 | 6 | // 必须,身份证号。 7 | 'id_no' => 'your id_no', 8 | 9 | // 必须,真实姓名。 10 | 'name' => 'your name', 11 | ]; 12 | -------------------------------------------------------------------------------- /example/charge/channel_extra/fqlpay_wap.php: -------------------------------------------------------------------------------- 1 | 'your c_merch_id', 5 | 6 | // 可选,前端回调地址,交易完成跳转的链接,不能带自定义参数。 7 | 'return_url' => 'http://example.com/success', 8 | ]; 9 | -------------------------------------------------------------------------------- /example/charge/channel_extra/bfb_wap.php: -------------------------------------------------------------------------------- 1 | 'http://example.com/success', 5 | 6 | // 必须,是否需要登录百度钱包来进行支付。 7 | 'bfb_login' => true, 8 | ]; 9 | -------------------------------------------------------------------------------- /example/charge/channel_extra/alipay.php: -------------------------------------------------------------------------------- 1 | '', 5 | 6 | // 可选,是否发起实名校验,T 代表发起实名校验;F 代表不发起实名校验。 7 | 'rn_check' => 'T', 8 | ]; 9 | -------------------------------------------------------------------------------- /example/transfer/channel_extra/alipay.php: -------------------------------------------------------------------------------- 1 | '张三', 5 | 6 | // 可选,收款方账户类型。可取值:1、 ALIPAY_USERID :支付宝账号对应的支付宝唯一用户号。以2088开头的16位纯数字组成。 2、 ALIPAY_LOGONID (默认值):支付宝登录号,支持邮箱和手机号格式。 7 | //'recipient_account_type' => 'ALIPAY_LOGONID' 8 | ]; 9 | -------------------------------------------------------------------------------- /example/withdrawal/extra/alipay.php: -------------------------------------------------------------------------------- 1 | 'user@example.com', //必填 收款人的支付宝账号。 4 | 'name' => '张三', //必填 收款人姓名。 5 | 'account_type' => 'ALIPAY_LOGONID', //选填参数 收款方账户类型。ALIPAY_USERID:支付宝账号对应的支付宝唯一用户号,以 2088 开头的 16 位纯数字组成;ALIPAY_LOGONID:支付宝登录号,支持邮箱和手机号格式。 6 | ]; 7 | -------------------------------------------------------------------------------- /example/charge/channel_extra/wx_lite.php: -------------------------------------------------------------------------------- 1 | 'no_credit', 5 | 6 | // 可选,商品标记,代金券或立减优惠功能的参数。 7 | //'goods_tag' => 'your goods_tag', 8 | 9 | // 必须,用户在商户 appid 下的唯一标识。 10 | 'open_id' => 'openidxxxxxxxxxxxx', 11 | ]; 12 | -------------------------------------------------------------------------------- /example/charge/channel_extra/wx_pub.php: -------------------------------------------------------------------------------- 1 | 'no_credit', 5 | 6 | // 可选,商品标记,代金券或立减优惠功能的参数。 7 | //'goods_tag' => 'your goods_tag', 8 | 9 | // 必须,用户在商户 appid 下的唯一标识。 10 | 'open_id' => 'openidxxxxxxxxxxxx', 11 | ]; 12 | -------------------------------------------------------------------------------- /example/settle_account/recipient/wx_pub.php: -------------------------------------------------------------------------------- 1 | 'wxopenid', //必填参数 接收者 open_id。 4 | 'name' => '张三', //必填参数 收款人姓名。当该参数为空,则不校验收款人姓名。 5 | 'force_check' => false, //选填参数 是否强制校验收款人姓名。仅当 name 参数不为空时该参数生效。 6 | 'type' => 'b2c', // 选填参数 转账类型。b2c:企业向个人付款。 7 | ]; 8 | -------------------------------------------------------------------------------- /example/charge/channel_extra/wx_pub_qr.php: -------------------------------------------------------------------------------- 1 | 'no_credit', 5 | 6 | // 可选,商品标记,代金券或立减优惠功能的参数。 7 | //'goods_tag' => 'your goods_tag', 8 | 9 | // 必须,商品 ID,1-32 位字符串。此 id 为二维码中包含的商品 ID,商户可自定义。 10 | 'product_id' => 'your product id', 11 | ]; 12 | -------------------------------------------------------------------------------- /example/transfer/channel_extra/jdpay.php: -------------------------------------------------------------------------------- 1 | '6228480402564890011', 5 | 6 | // 必须,1~100位,收款人姓名。 7 | 'user_name' => '张三', 8 | 9 | // 必须,4位,开户银行编号,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。 10 | 'open_bank_code' => '0103', 11 | ]; 12 | -------------------------------------------------------------------------------- /example/withdrawal/extra/allinpay.php: -------------------------------------------------------------------------------- 1 | '6214850288888888', //必填项 收款人银行卡号或者存折号。 4 | 'name' => '张三', //必填项 收款人姓名。 5 | 'open_bank_code' => '0308', //必填项 开户银行编号。 6 | 'business_code' => '09900', //选填项 业务代码,根据通联业务人员提供,不填使用通联提供默认值 09900。 7 | 'card_type' => 0, //选填项 银行卡号类型,0:银行卡;1:存折。 8 | ]; 9 | -------------------------------------------------------------------------------- /lib/Error/RateLimit.php: -------------------------------------------------------------------------------- 1 | 'user@example.com', //必填项 接收者支付宝账号。 4 | 'name' => 3000, //必填项 接收者姓名。 5 | 'type' => 'b2c', //选填项 转账类型。b2c:企业向个人付款,b2b:企业向企业付款。 6 | 'account_type' => 'ALIPAY_USERID', //选填项 收款方账户类型。ALIPAY_USERID:支付宝账号对应的支付宝唯一用户号,以 2088 开头的 16 位纯数字组成;ALIPAY_LOGONID:支付宝登录号,支持邮箱和手机号格式。 7 | ]; 8 | -------------------------------------------------------------------------------- /lib/Event.php: -------------------------------------------------------------------------------- 1 | '286801346868493272', 5 | 6 | // 可选,终端号,要求不同终端此号码不一样,会显示在对账单中,如A01、SH008等。 7 | 'terminal_id' => 'SH008', 8 | 9 | // 可选,指定支付方式,指定不能使用信用卡支付可设置为 no_credit 。 10 | 'limit_pay' => 'no_credit', 11 | 12 | // 可选,商品标记,代金券或立减优惠功能的参数。 13 | //'goods_tag' => 'your goods_tag', 14 | ]; 15 | -------------------------------------------------------------------------------- /example/charge/channel_extra/alipay_pc_direct.php: -------------------------------------------------------------------------------- 1 | 'http://example.com/success', 5 | 6 | // 可选,是否开启防钓鱼网站的验证参数(如果已申请开通防钓鱼时间戳验证,则此字段必填)。 7 | 'enable_anti_phishing_key' => false, 8 | 9 | // 可选,客户端 IP ,用户在创建交易时,该用户当前所使用机器的IP(如果商户申请后台开通防钓鱼IP地址检查选项,此字段必填,校验用)。 10 | //'exter_invoke_ip' => '8.8.8.8', 11 | ]; 12 | -------------------------------------------------------------------------------- /example/settle_account/list.php: -------------------------------------------------------------------------------- 1 | 3]); 14 | echo $withdrawals . PHP_EOL; 15 | -------------------------------------------------------------------------------- /lib/Error/InvalidRequest.php: -------------------------------------------------------------------------------- 1 | param = $param; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /example/split_profit/retrieve.php: -------------------------------------------------------------------------------- 1 | '1', 5 | 6 | // 可选,分账列表。 7 | 'split_fund_info' => [ 8 | [ 9 | 'account' => '2088866088886666', // 接受分账资金的支付宝账户ID。 10 | 'amount' => 1, // 分账的金额。 11 | 'desc' => 'split_desc desc', // 分账描述信息。 12 | ] 13 | ], 14 | ]; 15 | -------------------------------------------------------------------------------- /example/settle_account/delete.php: -------------------------------------------------------------------------------- 1 | 'no_credit', 5 | 6 | // 必填,商品列表,字段解释:goods_name:商品名称,goods_num:数量。 7 | 'goods_list' => [ 8 | [ 9 | 'goods_name' => 'iPhone', 10 | 'goods_num' => '1', 11 | ], 12 | [ 13 | 'goods_name' => 'iPad', 14 | 'goods_num' => '2', 15 | ], 16 | ], 17 | ]; 18 | -------------------------------------------------------------------------------- /example/settle_account/retrieve.php: -------------------------------------------------------------------------------- 1 | errcode = $errcode; 17 | $this->param = $param; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /example/withdrawal/retrieve.php: -------------------------------------------------------------------------------- 1 | 'your phone', 5 | 6 | // 可选,交易完成跳转的地址。 7 | 'return_url' => 'http://example.com/success', 8 | 9 | // 可选,分期参数,0 代表不分期,1 代表分 3 期,2 代表分 6 期,3 代表分 9 期,4 代表分 12 期。 10 | 'term' => 0, 11 | 12 | // 可选,账户激活中状态跳转链接。 13 | 'activate_url' => 'http://example.com/activate_url', 14 | 15 | // 可选,是否显示量化派页面顶部 header,即是否显示 H5 顶部标题栏,默认为 true 时显示。 16 | 'has_header' => true, 17 | ]; 18 | -------------------------------------------------------------------------------- /example/your_rsa_public_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2MktxcKBEqdYRi2IgYc 3 | upPQIN5cxgiBL5udCCBJBNBbXPaquOE1qspfhB1KUzHXATnCONiSzubLcBTnwi2t 4 | z0ErRCeJZSERRCpbKx4eu6b1neUTWkga7xpZxWONEvkmZo5Nlhf4fXRPUYnO/bdG 5 | CNGpQ/HSJfWLtzmhCqO1aJwVhcDmDMYz4bTkZavhFBdVyXf/8n7UKylk03eymlKJ 6 | 1swQpeFcxaKfzsk1mJU7mc93mCWjaR+VWkNbw4AQHDyHgbzH+zYARzCluiy5hXdi 7 | xGEP+iO4ZBk48rEs1hKTvGz1k+jhLCdkdpBRjq0pK/htjA3Ce8pF2AJs+fgN6ZUu 8 | mQIDAQAB 9 | -----END PUBLIC KEY----- -------------------------------------------------------------------------------- /lib/SubBank.php: -------------------------------------------------------------------------------- 1 | APP_ID, 15 | 'page' => 1, 16 | 'per_page' => 10, 17 | ]; 18 | $split_profits = \Pingpp\SplitProfit::all($params); 19 | echo $split_profits; 20 | -------------------------------------------------------------------------------- /lib/Contact.php: -------------------------------------------------------------------------------- 1 | 'user_test_01', //必填 接收者用户 ID。 5 | 'amount' => 5000, //必填 金额。 6 | 'description' => 'Your description', //不填默认使用外层参数中的 description,批量付款描述,最多 100 个 Unicode 字符。 7 | 'order_no' => '88888888', //可选 订单号, 1 ~ 64 位不能重复的数字字母组合。 8 | ], 9 | [ 10 | 'user' => 'user_test_02', 11 | 'amount' => 3000, 12 | 'description' => 'Your description', 13 | 'order_no' => '88888889', 14 | ] 15 | ]; 16 | -------------------------------------------------------------------------------- /example/charge/channel_extra/cb_wx_pub.php: -------------------------------------------------------------------------------- 1 | 'no_credit', 5 | 6 | // 必填,用户在商户 appid 下的唯一标识。 7 | 'open_id' => 'openidxxxxxxxxxxxx', 8 | 9 | // 必填,商品列表,字段解释:goods_name:商品名称,goods_num:数量。 10 | 'goods_list' => [ 11 | [ 12 | 'goods_name' => 'iPhone', 13 | 'goods_num' => '1', 14 | ], 15 | [ 16 | 'goods_name' => 'iPad', 17 | 'goods_num' => '2', 18 | ], 19 | ], 20 | ]; 21 | -------------------------------------------------------------------------------- /example/split_receiver/list.php: -------------------------------------------------------------------------------- 1 | APP_ID, 15 | 'page' => 1, 16 | 'per_page' => 10, 17 | ]; 18 | $split_receivers = \Pingpp\SplitReceiver::all($params); 19 | echo $split_receivers . PHP_EOL; 20 | -------------------------------------------------------------------------------- /example/profit_transaction/list.php: -------------------------------------------------------------------------------- 1 | APP_ID, 15 | 'page' => 1, 16 | 'per_page' => 10, 17 | ]; 18 | $profit_transactions = \Pingpp\ProfitTransaction::all($params); 19 | echo $profit_transactions . PHP_EOL; 20 | -------------------------------------------------------------------------------- /example/transfer/channel_extra/allinpay.php: -------------------------------------------------------------------------------- 1 | '6228480402564890011', 5 | 6 | // 必须,1~100位,收款人姓名。 7 | 'user_name' => '张三', 8 | 9 | // 必须,4位,开户银行编号,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。 10 | 'open_bank_code' => '0103', 11 | 12 | // 可选,5位,业务代码,根据通联业务人员提供,不填使用通联提供默认值09900。 13 | // 'business_code' => '09900', 14 | 15 | // 可选,1位,银行卡号类型,0:银行卡、1:存折,不填默认使用银行卡。 16 | // 'card_type' => 0, 17 | ]; 18 | -------------------------------------------------------------------------------- /example/withdrawal/extra/unionpay.php: -------------------------------------------------------------------------------- 1 | '6225210207078888', //必填项 收款人银行卡号或者存折号。 4 | 'name' => '张三', //必填项 收款人姓名。 5 | 'open_bank_code' => '0308', //选填项 开户银行编号,open_bank_code 和 open_bank 必须填写一个,优先推荐填写 open_bank_code。 6 | 'open_bank' => '招商银行', //选填项 开户银行,open_bank_code 和 open_bank 必须填写一个,优先推荐填写 open_bank_code。 7 | 'prov' => '上海', //选填项 省份。 8 | 'city' => '上海', //选填项 城市。 9 | 'sub_bank' => '徐家汇支行', //选填项 开户支行名称。 10 | ]; 11 | -------------------------------------------------------------------------------- /example/charge/channel_extra/alipay_wap.php: -------------------------------------------------------------------------------- 1 | 'http://example.com/success', 5 | 6 | // 可选,支付取消的回调地址, app_pay 为true时,该字段无效,在本地测试不要写 localhost ,请写 127.0.0.1。URL 后面不要加自定义参数。 7 | 'cancel_url' => 'http://example.com/cancel', 8 | 9 | // 可选,2016 年 6 月 16 日之前登录 Ping++ 管理平台填写支付宝手机网站的渠道参数的旧接口商户,需要更新接口时设置此参数值为true,6月16号后接入的新接口商户不需要设置该参数。 10 | //'new_version' => true, 11 | 12 | // 可选,是否使用支付宝客户端支付,该参数为true时,调用客户端支付。 13 | //'app_pay' => true, 14 | ]; 15 | -------------------------------------------------------------------------------- /example/charge/channel_extra/cb_wx_pub_qr.php: -------------------------------------------------------------------------------- 1 | 'no_credit', 5 | 6 | // 必填,商品 ID,1-32 位字符串。此 id 为二维码中包含的商品 ID,商户可自定义。 7 | 'product_id' => 'your product id', 8 | 9 | // 必填,商品列表,字段解释:goods_name:商品名称,goods_num:数量。 10 | 'goods_list' => [ 11 | [ 12 | 'goods_name' => 'iPhone', 13 | 'goods_num' => '1', 14 | ], 15 | [ 16 | 'goods_name' => 'iPad', 17 | 'goods_num' => '2', 18 | ], 19 | ], 20 | ]; 21 | -------------------------------------------------------------------------------- /example/settle_account/verify.php: -------------------------------------------------------------------------------- 1 | 2, 19 | ] 20 | ); 21 | 22 | echo $settle_account; 23 | -------------------------------------------------------------------------------- /example/settle_account/recipient/bank_account.php: -------------------------------------------------------------------------------- 1 | '6214888888888888', // 必填项 接收者银行卡账号。 4 | 'name' => '张三', // 必填项 接收者姓名。 5 | 'type' => 'b2c', // 必填项 转账类型。b2c:企业向个人付款,b2b:企业向企业付款。 6 | 'open_bank_code' => '0308', // 必填项 开户银行编号 7 | 'open_bank' => '招商银行', // 选填项 开户银行。 8 | 'card_type' => 0, // 选填项 银行卡号类型,0:银行卡;1:存折。 9 | // 'prov' => '上海', // 选填项 开户银行所在省份。 10 | // 'city' => '上海', // 选填项 开户银行所在城市。 11 | 'sub_bank' => '招商银行股份有限公司上海陆家嘴支行', // 选填项 开户支行名称。 12 | // 'sub_bank_code' => '308290003773', // 选填,开户银行支行号,部分渠道需要 13 | // 'mobile' => '13822334557', // 部分存管支持 14 | ]; 15 | -------------------------------------------------------------------------------- /example/card_info.php: -------------------------------------------------------------------------------- 1 | APP_ID, // 必填,ping++ app 16 | 'bank_account' => '6228480402564890018', // 必填,银行卡号 17 | ]); 18 | echo $result; 19 | } catch (\Pingpp\Error\Base $e) { 20 | echo $e->getMessage(); 21 | } 22 | -------------------------------------------------------------------------------- /example/order/royalty_transaction.php: -------------------------------------------------------------------------------- 1 | '286801346868493272', 5 | 6 | // 必填,商品列表,字段解释:goods_name:商品名称,goods_num:数量。 7 | 'goods_list' => [ 8 | [ 9 | 'goods_name' => 'iPhone', 10 | 'goods_num' => '1', 11 | ], 12 | [ 13 | 'goods_name' => 'iPad', 14 | 'goods_num' => '2', 15 | ], 16 | ], 17 | 18 | // 可选,终端号,要求不同终端此号码不一样,会显示在对账单中,如A01、SH008等。 19 | 'terminal_id' => 'SH008', 20 | 21 | // 可选,指定支付方式,指定不能使用信用卡支付可设置为 no_credit 。 22 | 'limit_pay' => 'no_credit', 23 | 24 | ]; 25 | -------------------------------------------------------------------------------- /example/settle_account/create.php: -------------------------------------------------------------------------------- 1 | $channel, 19 | 'recipient' => $recipient, 20 | ]); 21 | echo $settle_account; 22 | -------------------------------------------------------------------------------- /lib/AttachedObject.php: -------------------------------------------------------------------------------- 1 | _values), array_keys($properties)); 16 | foreach ($removed as $k) { 17 | unset($this->$k); 18 | } 19 | 20 | foreach ($properties as $k => $v) { 21 | $this->$k = $v; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/Identification.php: -------------------------------------------------------------------------------- 1 | getHttpStatus() != null) { 18 | echo $e->getHttpBody(); 19 | } else { 20 | echo $e->getMessage(); 21 | } 22 | } 23 | exit; 24 | -------------------------------------------------------------------------------- /example/split_receiver/create.php: -------------------------------------------------------------------------------- 1 | APP_ID, 15 | 'type' => 'MERCHANT_ID', //分账接收方类型 16 | 'name' => '示例商户全称', //分账接收方全称 17 | 'account' => '190001001', //分账接收方帐号 18 | 'channel' => 'wx_pub_qr', //分账接收方使用的渠道 19 | ]; 20 | $split_receiver = \Pingpp\SplitReceiver::create($params); 21 | echo $split_receiver; 22 | -------------------------------------------------------------------------------- /example/charge/channel_extra/cmb_wallet.php: -------------------------------------------------------------------------------- 1 | 'http://example.com/success', 5 | 6 | /** 7 | * 对于 p_no, seq , m_uid , mobile 这几个参数: 8 | * 1. 这几个参数是用户自定义的。 9 | * 2. 对于同一个终端用户每次请求 charge 务必使用同一套参数(确保每个参数都不变), 10 | * 任意参数变更都会导致用户重新签约,同一个用户和招行重新签约的次数有限制,超限制就会无法签约 ,导致用户无法使用。 11 | */ 12 | 13 | // 必须,客户协议号,不超过 30 位的纯数字字符串。 14 | 'p_no' => 'your p_no', 15 | 16 | // 必须,协议开通请求流水号,不超过 20 位的纯数字字符串,请保证系统内唯一。 17 | 'seq' => 'your seq', 18 | 19 | // 必须,协议用户 ID,不超过 20 位的纯数字字符串。 20 | 'm_uid' => 'your m_uid', 21 | 22 | // 必须,协议手机号,11 位数字。 23 | 'mobile' => 'your mobile', 24 | ]; 25 | -------------------------------------------------------------------------------- /example/split_receiver/retrieve.php: -------------------------------------------------------------------------------- 1 | getHttpStatus() != null) { 19 | echo $e->getHttpBody(); 20 | } else { 21 | echo $e->getMessage(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/sub_bank.php: -------------------------------------------------------------------------------- 1 | APP_ID, // Ping++ app id,必填 16 | 'channel' => 'chanpay', // transfer 渠道,必填 17 | 'open_bank_code' => '0308', // 银行编号,必填 18 | 'prov' => '浙江省', // 省份,必填 19 | 'city' => '宁波市', // 城市,必填 20 | ]); 21 | echo $sub_banks; 22 | } catch (\Pingpp\Error\Base $e) { 23 | echo $e->getMessage(); 24 | } 25 | -------------------------------------------------------------------------------- /lib/CardInfo.php: -------------------------------------------------------------------------------- 1 | =5.6.0", 19 | "ext-curl": "*", 20 | "ext-json": "*", 21 | "ext-mbstring": "*" 22 | }, 23 | "require-dev": { 24 | }, 25 | "autoload": { 26 | "psr-4": { "Pingpp\\" : "lib/" } 27 | }, 28 | "extra": { 29 | "branch-alias": { 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example/batch_transfer/channel_recipients/wx_pub.php: -------------------------------------------------------------------------------- 1 | 'openidxxxxxxxxxxxx', 6 | 7 | // 必须,金额,单位为分。 8 | 'amount' => 5000, 9 | 10 | // 可选,收款人姓名。当该参数为空,则不校验收款人姓名。 11 | // 'name' => '张三', 12 | 13 | // 可选,批量企业付款描述,最多 99 个英文和数字的组合或最多 33 个中文字符,不可以包含特殊字符。不填默认使用外层参数中的 description。 14 | // 'description' => '描述', 15 | 16 | // 可选,是否强制校验收款人姓名。布尔类型,仅当 name 参数不为空时该参数生效。 17 | // 'force_check' => false, 18 | 19 | // 可选,订单号, 1 ~ 32 位不能重复的数字字母组合。 20 | // 'order_no' => '123456789' 21 | ], 22 | [ 23 | 'open_id' => 'openidxxxxxxxxxxxx', 24 | 'amount' => 5000, 25 | ] 26 | ]; 27 | -------------------------------------------------------------------------------- /example/transfer/reverse.php: -------------------------------------------------------------------------------- 1 | getHttpStatus() != null) { 20 | header('Status: ' . $e->getHttpStatus()); 21 | echo $e->getHttpBody(); 22 | } else { 23 | echo $e->getMessage(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /example/refund/retrieve.php: -------------------------------------------------------------------------------- 1 | getHttpStatus() != null) { 21 | header('Status: ' . $e->getHttpStatus()); 22 | echo $e->getHttpBody(); 23 | } else { 24 | echo $e->getMessage(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/Error/Base.php: -------------------------------------------------------------------------------- 1 | httpStatus = $httpStatus; 17 | $this->httpBody = $httpBody; 18 | $this->jsonBody = $jsonBody; 19 | } 20 | 21 | public function getHttpStatus() 22 | { 23 | return $this->httpStatus; 24 | } 25 | 26 | public function getHttpBody() 27 | { 28 | return $this->httpBody; 29 | } 30 | 31 | public function getJsonBody() 32 | { 33 | return $this->jsonBody; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example/batch_transfer/channel_recipients/alipay.php: -------------------------------------------------------------------------------- 1 | 'account01@alipay.com', 6 | 7 | // 必须,金额,单位为分。 8 | 'amount' => 5000, 9 | 10 | // 必须,接收者姓名。 11 | 'name' => '张三', 12 | 13 | // 可选,批量企业付款描述,最多 200 字节。 14 | // 'description' => '描述', 15 | 16 | // 可选,账户类型,alipay 2.0 渠道会用到此字段,取值范围: 1、ALIPAY_USERID:支付宝账号对应的支付宝唯一用户号。以2088开头的16位纯数字组成。 2、ALIPAY_LOGONID(默认值):支付宝登录号,支持邮箱和手机号格式。 17 | // 'account_type' => 'ALIPAY_LOGONID', 18 | 19 | // 可选,订单号, 1 ~ 64 位不能重复的数字字母组合。 20 | // 'order_no' => '123456789' 21 | ], 22 | [ 23 | 'account' => 'account02@alipay.com', 24 | 'amount' => 3000, 25 | 'name' => '李四' 26 | ] 27 | ]; 28 | -------------------------------------------------------------------------------- /example/charge/retrieve.php: -------------------------------------------------------------------------------- 1 | getHttpStatus() != null) { 21 | header('Status: ' . $e->getHttpStatus()); 22 | echo $e->getHttpBody(); 23 | } else { 24 | echo $e->getMessage(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/BalanceSettlements.php: -------------------------------------------------------------------------------- 1 | getHttpStatus() != null) { 22 | header('Status: ' . $e->getHttpStatus()); 23 | echo $e->getHttpBody(); 24 | } else { 25 | echo $e->getMessage(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /example/batch_transfer/channel_recipients/jdpay.php: -------------------------------------------------------------------------------- 1 | '656565656565656565656565', 6 | 7 | // 必须,金额,单位为分。 8 | 'amount' => 5000, 9 | 10 | // 必须,接收者姓名。 11 | 'name' => '张三', 12 | 13 | // 必须,4位,开户银行编号。具体值参考此链接:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E 14 | 'open_bank_code' => '0308', 15 | 16 | // 可选,批量付款描述,最多 100 个 Unicode 字符。 17 | // 'description' => '描述', 18 | 19 | // 可选,订单号,jdpay 限长1-64位不能重复的数字字母组合。 20 | // 'order_no' => '12345678' 21 | ], 22 | [ 23 | 'account' => '656565656565656565656565', 24 | 'amount' => 3000, 25 | 'name' => '李四', 26 | 'open_bank_code' => '0308', 27 | ] 28 | ]; 29 | -------------------------------------------------------------------------------- /example/transfer/retrieve.php: -------------------------------------------------------------------------------- 1 | getHttpStatus() != null) { 21 | header('Status: ' . $e->getHttpStatus()); 22 | echo $e->getHttpBody(); 23 | } else { 24 | echo $e->getMessage(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /example/charge/channel_extra/yeepay_wap.php: -------------------------------------------------------------------------------- 1 | '1', 5 | 6 | // 必须,用户标识,商户生成的用户账号唯一标识,最长 50 位字符串。 7 | 'identity_id' => 'your identity_id', 8 | 9 | // 必须,用户标识类型,用户标识类型参考链接:https://www.pingxx.com/api#%E6%98%93%E5%AE%9D%E6%94%AF%E4%BB%98%E7%94%A8%E6%88%B7%E6%A0%87%E8%AF%86%E7%B1%BB%E5%9E%8B%E7%A0%81 。 10 | 'identity_type' => 1, 11 | 12 | // 必须,终端类型,对应取值 0:IMEI, 1:MAC, 2:UUID, 3:other。 13 | 'terminal_type' => 1, 14 | 15 | // 必须,终端 ID。 16 | 'terminal_id' => 'your terminal_id', 17 | 18 | // 必须,用户使用的移动终端的 UserAgent 信息。 19 | 'user_ua' => 'your user_ua', 20 | 21 | // 必须,前台通知地址。 22 | 'result_url' => 'http://example.com/success', 23 | ]; 24 | -------------------------------------------------------------------------------- /lib/AppBase.php: -------------------------------------------------------------------------------- 1 | )', 15 | null 16 | ); 17 | } 18 | $appId = Util\Util::utf8(Pingpp::$appId); 19 | return "/v1/apps/${appId}"; 20 | } 21 | 22 | /** 23 | * @return string The API URL for app based objects. 24 | */ 25 | public static function classUrl() 26 | { 27 | $base = static::appBaseUrl(); 28 | $resourceName = static::className(); 29 | return "${base}/${resourceName}s"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/ProfitTransaction.php: -------------------------------------------------------------------------------- 1 | 'http://example.com/success', 5 | 6 | // 必须,支付失败页面跳转路径。 7 | 'fail_url' => 'http://example.com/fail', 8 | 9 | // 可选,用户交易令牌,用于识别用户信息,支付成功后会调用 success_url 返回给商户。商户可以记录这个 token 值,当用户再次支付的时候传入该 token ,用户无需再次输入银行卡信息,直接输入短信验证码进行支付。32 位字符串。 10 | //'token' => 'dsafadsfasdfadsjuyhfnhujkijunhaf', 11 | 12 | // 可选,订单类型,值为0表示实物商品订单,值为 1 代表虚拟商品订单,该参数默认值为 0 。 13 | 'order_type' => 0, 14 | 15 | // 可选,设置是否通过手机端发起支付,值为 true 时调用手机 h5 支付页面,值为 false 时调用 PC 端支付页面,该参数默认值为 true 。 16 | 'is_mobile' => true, 17 | 18 | // 可选,用户账号类型,取值只能为:BIZ。传参存在问题请参考 帮助中心:https://help.pingxx.com/article/1012535/。 19 | //'user_type' => 'BIZ', 20 | 21 | // 可选,商户的用户账号。传参存在问题请参考 帮助中心:https://help.pingxx.com/article/1012535/。 22 | //'user_id' => 'your user_id', 23 | ]; 24 | -------------------------------------------------------------------------------- /example/order/royalty.php: -------------------------------------------------------------------------------- 1 | [ 20 | '170301124238000111', 21 | '170301124238000211' 22 | ], 23 | 'method' => 'manual', //手动标记结算: manual 或 取消手动标记结算:null 24 | 'description' => 'Your description', 25 | ]); 26 | 27 | echo $royalties; 28 | exit; 29 | 30 | //查询分润对象列表 31 | $royalties = \Pingpp\Royalty::all(); 32 | echo $royalties; 33 | exit; 34 | 35 | //查询分润对象 36 | $royalties = \Pingpp\Royalty::retrieve('411170318160900002'); 37 | echo $royalties; 38 | -------------------------------------------------------------------------------- /example/refund/list.php: -------------------------------------------------------------------------------- 1 | 10, 19 | ]); 20 | echo $re_list; // 输出 Ping++ 返回的 refund 对象列表 21 | } catch (\Pingpp\Error\Base $e) { 22 | if ($e->getHttpStatus() != null) { 23 | header('Status: ' . $e->getHttpStatus()); 24 | echo $e->getHttpBody(); 25 | } else { 26 | echo $e->getMessage(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/FundsTransfer.php: -------------------------------------------------------------------------------- 1 | getHttpStatus() != null) { 21 | header('Status: ' . $e->getHttpStatus()); 22 | echo $e->getHttpBody(); 23 | } else { 24 | echo $e->getMessage(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /example/transfer/channel_extra/unionpay.php: -------------------------------------------------------------------------------- 1 | '6228480402564890011', 5 | 6 | // 必须,1~100位,收款人姓名。 7 | 'user_name' => '张三', 8 | 9 | /** 10 | * open_bank_code 和 open_bank 两个参数必传一个,建议使用 open_bank_code ,若都传参则优先使用 open_bank_code 读取规则;prov 和 city 均为可选参数,如果不传参,则使用默认值 "上海" 给渠道接口。 11 | */ 12 | 13 | // 条件可选,4位,开户银行编号,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。 14 | 'open_bank_code' => '0103', 15 | 16 | // 条件可选,1~50位,开户银行,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。 17 | 'open_bank' => '农业银行', 18 | 19 | // 可选,1~20位,省份。 20 | // 'prov' => '上海', 21 | 22 | // 可选,1~40位,城市。 23 | // 'city' => '上海', 24 | 25 | // 可选,1~80位,开户支行名称。 26 | // 'sub_bank' => '上海沪东支行' 27 | ]; 28 | -------------------------------------------------------------------------------- /example/charge/list.php: -------------------------------------------------------------------------------- 1 | ['id' => APP_ID] // 此参数必填 18 | ]; 19 | try { 20 | $charge_all = \Pingpp\Charge::all($search_params); 21 | echo $charge_all; // 输出 Ping++ 返回的 charge 对象列表 22 | } catch (\Pingpp\Error\Base $e) { 23 | if ($e->getHttpStatus() != null) { 24 | header('Status: ' . $e->getHttpStatus()); 25 | echo $e->getHttpBody(); 26 | } else { 27 | echo $e->getMessage(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /example/config.php: -------------------------------------------------------------------------------- 1 | 点击管理平台右上角公司名称->开发信息-> Secret Key 4 | const API_KEY = 'sk_test_ibbTe5jLGCi5rzfH4OqPW9KC'; 5 | // app_id 获取方式:登录 [Dashboard](https://dashboard.pingxx.com)->点击你创建的应用->应用首页->应用 ID(App ID) 6 | const APP_ID = 'app_1Gqj58ynP0mHeX1q'; 7 | 8 | /** 9 | * 设置请求签名密钥,密钥对需要你自己用 openssl 工具生成,如何生成可以参考帮助中心:https://help.pingxx.com/article/123161; 10 | * 生成密钥后,需要在代码中设置请求签名的私钥(rsa_private_key.pem); 11 | * 然后登录 [Dashboard](https://dashboard.pingxx.com)->点击右上角公司名称->开发信息->商户公钥(用于商户身份验证) 12 | * 将你的公钥复制粘贴进去并且保存->先启用 Test 模式进行测试->测试通过后启用 Live 模式 13 | */ 14 | \Pingpp\Pingpp::setApiKey(API_KEY); // 设置 API Key 15 | \Pingpp\Pingpp::setPrivateKeyPath(__DIR__ . '/your_rsa_private_key.pem'); // 设置私钥 16 | \Pingpp\Pingpp::setAppId(APP_ID); // 设置 App ID 17 | 18 | // 设置私钥内容方式2 19 | // \Pingpp\Pingpp::setPrivateKey(file_get_contents(__DIR__ . '/your_rsa_private_key.pem')); 20 | -------------------------------------------------------------------------------- /example/refund/create.php: -------------------------------------------------------------------------------- 1 | 1,// 退款的金额, 单位为对应币种的最小货币单位,例如:人民币为分(如退款金额为 1 元,此处请填 100)。必须小于等于可退款金额,默认为全额退款 20 | 'description' => 'Your Descripton' 21 | ] 22 | ); 23 | echo $re;// 输出 Ping++ 返回的退款对象 Refund 24 | } catch (\Pingpp\Error\Base $e) { 25 | header('Status: ' . $e->getHttpStatus()); 26 | echo($e->getHttpBody()); 27 | } 28 | -------------------------------------------------------------------------------- /example/agreement/list.php: -------------------------------------------------------------------------------- 1 | APP_ID, // 此参数必填 18 | ]; 19 | try { 20 | $agreement_all = \Pingpp\Agreement::all($search_params); 21 | echo $agreement_all; // 输出 Ping++ 返回的 agreement 对象列表 22 | } catch (\Pingpp\Error\Base $e) { 23 | if ($e->getHttpStatus() != null) { 24 | header('Status: ' . $e->getHttpStatus()); 25 | echo $e->getHttpBody(); 26 | } else { 27 | echo $e->getMessage(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/RoyaltyTransaction.php: -------------------------------------------------------------------------------- 1 | getHttpStatus() != null) { 26 | header('Status: ' . $e->getHttpStatus()); 27 | echo $e->getHttpBody(); 28 | } else { 29 | echo $e->getMessage(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /example/batch_transfer/retrieve.php: -------------------------------------------------------------------------------- 1 | getHttpStatus() != null) { 21 | header('Status: ' . $e->getHttpStatus()); 22 | echo $e->getHttpBody(); 23 | } else { 24 | echo $e->getMessage(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/Util/Set.php: -------------------------------------------------------------------------------- 1 | _elts = []; 15 | foreach ($members as $item) { 16 | $this->_elts[$item] = true; 17 | } 18 | } 19 | 20 | public function includes($elt) 21 | { 22 | return isset($this->_elts[$elt]); 23 | } 24 | 25 | public function add($elt) 26 | { 27 | $this->_elts[$elt] = true; 28 | } 29 | 30 | public function discard($elt) 31 | { 32 | unset($this->_elts[$elt]); 33 | } 34 | 35 | public function toArray() 36 | { 37 | return array_keys($this->_elts); 38 | } 39 | 40 | public function getIterator() 41 | { 42 | return new ArrayIterator($this->toArray()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /example/depository/user_pic.php: -------------------------------------------------------------------------------- 1 | "test_user_001", // 用户 ID,首字母必须是英文数字或者 _-@, 必传 16 | "type" => "customer", // 用户类型,customer: 对私,business: 对公 17 | "acc_no" => "2019057929311601000631", // 壹账通用户编号。覆盖的时候使用,新用户不需要该字段 18 | "operate_type" => "00", // 操作类型,00: 新增,01: 修改,02: 增开户。不传默认为新增 19 | // 图片内容,base64 编码 20 | "pic" => base64_encode(file_get_contents(__DIR__ . '/id-102.jpg')), 21 | "pic_fmt" => "jpg", // 图片格式。jpg, png 22 | "pic_type" => "102", // 图片类型,101: 个人身份证信息面,102: 个人身份证国徽面,201: 企业证件照片,202: 法人身份证信息面,203: 法人身份证国徽面 23 | ]); 24 | 25 | echo $user_pic; 26 | -------------------------------------------------------------------------------- /lib/Customs.php: -------------------------------------------------------------------------------- 1 | mergeSignOpts(static::$signOpts); 11 | $instance = new static(null, $opts); 12 | $instance->refresh(); 13 | return $instance; 14 | } 15 | 16 | /** 17 | * @param SingletonApiResource $class 18 | * @return string The endpoint associated with this singleton class. 19 | */ 20 | public static function classUrl() 21 | { 22 | $base = static::className(); 23 | return "/v1/${base}"; 24 | } 25 | 26 | /** 27 | * @return string The endpoint associated with this singleton API resource. 28 | */ 29 | public function instanceUrl() 30 | { 31 | return static::classUrl(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example/transfer/list.php: -------------------------------------------------------------------------------- 1 | ['id' => APP_ID] // 此参数必填 19 | ]; 20 | try { 21 | $tr_all = \Pingpp\Transfer::all($search_params); 22 | echo $tr_all; // 输出 Ping++ 返回的 transfer 对象列表 23 | } catch (\Pingpp\Error\Base $e) { 24 | if ($e->getHttpStatus() != null) { 25 | header('Status: ' . $e->getHttpStatus()); 26 | echo $e->getHttpBody(); 27 | } else { 28 | echo $e->getMessage(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /phpcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Project coding standard 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | lib 16 | example 17 | 18 | 19 | 20 | 21 | 22 | 28 | example/**/*.php 29 | 30 | 31 | vendor/**/*.php 32 | 33 | -------------------------------------------------------------------------------- /example/split_profit/create.php: -------------------------------------------------------------------------------- 1 | APP_ID, 15 | 'charge' => 'ch_aDC44OKyL8yHPG0yX9yzLy5K', //Ping++ 交易成功的 charge ID 16 | 'order_no' => md5(openssl_random_pseudo_bytes(30)), //分账单号,由商家自行生成,规则参照微信分账参数规则 17 | 'recipients' => [ 18 | [ 19 | 'split_receiver' => 'recv_1fRbIo5YgIM4hl', 20 | 'amount' => 6, 21 | 'name' => '示例商户全称', //可选参数, 22 | 'description' => 'Your Description', 23 | ] 24 | ], 25 | 'type' => 'split_normal', //分账类型: split_normal 为普通分账,split_return 为完结分账, 26 | 'metadata' => [], //分账元数据 27 | ]; 28 | $split_profit = \Pingpp\SplitProfit::create($params); 29 | echo $split_profit; 30 | -------------------------------------------------------------------------------- /lib/BalanceBonus.php: -------------------------------------------------------------------------------- 1 | '656565656565656565656565', 6 | 7 | // 必须,金额,单位为分。 8 | 'amount' => 5000, 9 | 10 | // 必须,接收者姓名。 11 | 'name' => '张三', 12 | 13 | // 可选,批量企业付款描述,最多 200 字节。 14 | // 'description' => '描述', 15 | 16 | /** 17 | * open_bank_code 和 open_bank 两个参数必传一个,建议使用 open_bank_code ,若都传参则优先使用 open_bank_code 读取规则。 18 | * 具体值参考此链接:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E 19 | */ 20 | 21 | // 条件可选,1~50位,开户银行。 22 | 'open_bank' => '招商银行', 23 | 24 | // 条件可选,4位,开户银行编号。 25 | 'open_bank_code' => '0308', 26 | 27 | // 可选,订单号, 1 ~ 16 位数字。 28 | // 'order_no' => '123456789' 29 | ], 30 | [ 31 | 'account' => '656565656565656565656565', 32 | 'amount' => 3000, 33 | 'name' => '李四', 34 | 'open_bank' => '招商银行', 35 | 'open_bank_code' => '0308', 36 | ] 37 | ]; 38 | -------------------------------------------------------------------------------- /example/batch_refund/list.php: -------------------------------------------------------------------------------- 1 | 1, //页码,取值范围:1~1000000000;默认值为"1" 18 | 'per_page' => 2 //每页数量,取值范围:1~100;默认值为"20" 19 | ]; 20 | try { 21 | $batch_re_all = \Pingpp\BatchRefund::all($search_params); 22 | echo $batch_re_all; // 输出 Ping++ 返回的 batch refund 对象列表 23 | } catch (\Pingpp\Error\Base $e) { 24 | if ($e->getHttpStatus() != null) { 25 | header('Status: ' . $e->getHttpStatus()); 26 | echo $e->getHttpBody(); 27 | } else { 28 | echo $e->getMessage(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2014- Pingplusplus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /lib/SplitProfit.php: -------------------------------------------------------------------------------- 1 | 1, //页码,取值范围:1~1000000000;默认值为"1" 19 | 'per_page' => 2 //每页数量,取值范围:1~100;默认值为"20" 20 | ]; 21 | try { 22 | $batch_tr_all = \Pingpp\BatchTransfer::all($search_params); 23 | echo $batch_tr_all; // 输出 Ping++ 返回的 batch transfer 对象列表 24 | } catch (\Pingpp\Error\Base $e) { 25 | if ($e->getHttpStatus() != null) { 26 | header('Status: ' . $e->getHttpStatus()); 27 | echo $e->getHttpBody(); 28 | } else { 29 | echo $e->getMessage(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /example/balance/balance_transaction.php: -------------------------------------------------------------------------------- 1 | 3]; 14 | try { 15 | $bt = \Pingpp\BalanceTransaction::all($params); 16 | echo $bt; 17 | } catch (\Pingpp\Error\Base $e) { 18 | if ($e->getHttpStatus() != null) { 19 | header('Status: ' . $e->getHttpStatus()); 20 | echo $e->getHttpBody(); 21 | } else { 22 | echo $e->getMessage(); 23 | } 24 | } 25 | exit; 26 | 27 | // 用户账户交易明细 28 | $txn_id = '310216111501260200000601'; // 用户账户交易明细 ID 29 | try { 30 | $bt = \Pingpp\BalanceTransaction::retrieve($txn_id); 31 | echo $bt; 32 | } catch (\Pingpp\Error\Base $e) { 33 | if ($e->getHttpStatus() != null) { 34 | header('Status: ' . $e->getHttpStatus()); 35 | echo $e->getHttpBody(); 36 | } else { 37 | echo $e->getMessage(); 38 | } 39 | } 40 | exit; 41 | -------------------------------------------------------------------------------- /example/batch_transfer/channel_recipients/allinpay.php: -------------------------------------------------------------------------------- 1 | '656565656565656565656565', 6 | 7 | // 必须,金额,单位为分。 8 | 'amount' => 5000, 9 | 10 | // 必须,接收者姓名。 11 | 'name' => '张三', 12 | 13 | // 必须,4位,开户银行编号。具体值参考此链接:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E 14 | 'open_bank_code' => '0308', 15 | 16 | // 可选,批量付款描述,最多 30 个 Unicode 字符。 17 | // 'description' => '描述', 18 | 19 | // 可选,业务代码,allinpay 渠道会用到此字段,5位,根据通联业务人员提供,不填使用通联提供默认值09900。 20 | // 'business_code' => '09900', 21 | 22 | // 可选,银行卡号类型,allinpay 渠道会用到此字段,0:银行卡、1:存折,不填默认使用银行卡。 23 | // 'card_type' => 0, 24 | 25 | // 可选,订单号, 20 ~ 40 位不能重复的数字字母组合(必须以通联的商户号开头,建议组合格式:通联商户号 + 时间戳 + 固定位数顺序流水号,不包含+号),这里不传的话程序会调用商户的通联商户号加上随机数自动生成 order_no。 26 | // 'order_no' => '321101234554321098765432112' 27 | ], 28 | [ 29 | 'account' => '656565656565656565656565', 30 | 'amount' => 3000, 31 | 'name' => '李四', 32 | 'open_bank_code' => '0308', 33 | ] 34 | ]; 35 | -------------------------------------------------------------------------------- /example/depository/contact.php: -------------------------------------------------------------------------------- 1 | "test_user_001", // 用户 ID 16 | "acc_no" => "2019057929311601000631", // 壹账通用户编号。此编号可在证件上传接口的返回获得 17 | "contact_type" => 1, // 联系人类型,1:第一紧急联系人、2:第二紧急联系人、3:第三紧急联系人、4、法人、5、财务人员(4、5必传) 18 | "contact_name" => "杨真探", // 联系人名称 19 | "contact_cert_type" => "01", // 证件类型:01:身份证、02:企业营业执照、03:护照、04:港澳通行证、05:台湾往来通行证、06:临时身份证 20 | "contact_cert_no" => "310181201402149201", // 联系人证件号 21 | "contact_cert_valid_from" => "2019-01-01", // 联系人证件起始日,格式:“2018-12-21” 22 | "contact_cert_valid_until" => "2028-12-31", // 联系人证件截止日,格式:“2019-12-21”,长期填写:“9999-12-31” 23 | "contact_cert_mobile" => "13500127654", // 联系人手机号 24 | "contact_job_type" => 1, // 联系人工作类型,1:企业主 2:个体工商户 3:全职上班 4:兼职 5: 学生 6:退休 7:无固定职业 8:其他 25 | "contact_relation_ship" => 1, // 联系人与本人关系,1:父母 2:配偶 3:子女 4:兄弟 5:姐妹 6:其他亲属 7:朋友 8:同事 26 | ]); 27 | 28 | echo $contact; 29 | -------------------------------------------------------------------------------- /example/order/royalty_create_data.php: -------------------------------------------------------------------------------- 1 | APP_ID, // 必填,订单应用,对应 app 对象的 id 22 | 'charge' => 'ch_SuTCO4SmHmL050a9OKnj94uH', // 可选,charge id,对于已经成功的 order 必传该字段,若 order 未成功不支持填写 23 | 'royalty_users' => [ // 可选,分润的用户信息列表 24 | [ 25 | 'user' => 'U201908030002', 26 | 'amount' => 100 27 | ] 28 | ] 29 | ] 30 | ); 31 | echo $royalty_data; 32 | } catch (\Pingpp\Error\Base $e) { 33 | if ($e->getHttpStatus() != null) { 34 | header('Status: ' . $e->getHttpStatus()); 35 | echo $e->getHttpBody(); 36 | } else { 37 | echo $e->getMessage(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example/batch_refund/create.php: -------------------------------------------------------------------------------- 1 | APP_ID, 19 | 'batch_no' => uniqid('bre'), //批量退款批次号,3-24位,允许字母和英文 20 | 'description' => 'Your Description', //批量退款详情,最多 255 个 Unicode 字符 21 | 'charges' => [ //需要退款的 charge id 列表,一次最多 100 个 22 | 'ch_Dq5ibDrLurrPO808q1bP4iT8', 23 | 'ch_TanbTO9OmjP4TGW5a1j1mPiL' 24 | ] 25 | ] 26 | ); 27 | echo $batch_re; // 输出 Ping++ 返回的 batch refund 对象 28 | } catch (\Pingpp\Error\Base $e) { 29 | if ($e->getHttpStatus() != null) { 30 | header('Status: ' . $e->getHttpStatus()); 31 | echo $e->getHttpBody(); 32 | } else { 33 | echo $e->getMessage(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example/fund_transfer.php: -------------------------------------------------------------------------------- 1 | 'alipay_fund', 17 | 'order_no' => '20250411000001', 18 | 'amount' => 1000, 19 | 'subject' => '测试充值', 20 | 'description' => 'Your description', 21 | ]); 22 | echo $or; 23 | } catch (\Pingpp\Error\Base $e) { 24 | // 捕获报错信息 25 | if ($e->getHttpStatus() != null) { 26 | echo $e->getHttpStatus() . PHP_EOL; 27 | echo $e->getHttpBody() . PHP_EOL; 28 | } else { 29 | echo $e->getMessage() . PHP_EOL; 30 | } 31 | } 32 | exit; 33 | 34 | //查询资金充值申请订单 35 | try { 36 | $recharge_info = \Pingpp\FundsTransfer::retrieve('7312504116419046403'); 37 | echo $recharge_info; 38 | } catch (\Pingpp\Error\Base $e) { 39 | // 捕获报错信息 40 | if ($e->getHttpStatus() != null) { 41 | echo $e->getHttpStatus() . PHP_EOL; 42 | echo $e->getHttpBody() . PHP_EOL; 43 | } else { 44 | echo $e->getMessage() . PHP_EOL; 45 | } 46 | } 47 | exit; -------------------------------------------------------------------------------- /example/charge/channel_extra/isv_scan.php: -------------------------------------------------------------------------------- 1 | '286801346868493272', 5 | 6 | // 必须,终端号,要求不同终端此号码不一样,会显示在对账单中,如A01、SH008等。 7 | 'terminal_id' => 'SH008', 8 | 9 | // 可选,商品列表,上送格式参照下面示例。 10 | // 字段解释:goods_id:商户定义商品编号(一般商品条码)unified_goods_id:统一商品编号(可选),goods_name:商品名称,goods_num:数量, 11 | // price:单价(单位分),goods_category:商品类目(可选),body:商品描述信息(可选),show_url:商品的展示网址(可选) 12 | 'goods_list' => [ 13 | [ 14 | 'goods_id' => 'iphone6s16G', 15 | 'unified_goods_id' => '1001', 16 | 'goods_name' => 'iPhone6s 16G', 17 | 'goods_num' => '1', 18 | 'price' => '528800', 19 | 'goods_category' => '123456', 20 | 'body' => '苹果手机16G', 21 | 'show_url' => 'https://www.example.com', 22 | ], 23 | [ 24 | 'goods_id' => 'iphone6s32G', 25 | 'unified_goods_id' => '1002', 26 | 'goods_name' => 'iPhone6s 32G', 27 | 'goods_num' => '1', 28 | 'price' => '608800', 29 | 'goods_category' => '123789', 30 | 'body' => '苹果手机32G', 31 | 'show_url' => 'https://www.example.com', 32 | ], 33 | ], 34 | ]; 35 | -------------------------------------------------------------------------------- /example/agreement/update.php: -------------------------------------------------------------------------------- 1 | getHttpStatus() != null) { 22 | header('Status: ' . $e->getHttpStatus()); 23 | echo $e->getHttpBody(); 24 | } else { 25 | echo $e->getMessage(); 26 | } 27 | } 28 | 29 | /** 30 | * 微信解约示例 31 | */ 32 | $agreement_id = 'agr_19EFuCzvtgNZkv'; 33 | $params = [ 34 | 'extra' => [ 35 | 'description' => 'Your description', 36 | ], 37 | ]; 38 | 39 | try { 40 | $agreement = \Pingpp\Agreement::cancel($agreement_id, $params); 41 | echo $agreement; 42 | } catch (\Pingpp\Error\Base $e) { 43 | if ($e->getHttpStatus() != null) { 44 | header('Status: ' . $e->getHttpStatus()); 45 | echo $e->getHttpBody(); 46 | } else { 47 | echo $e->getMessage(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /example/charge/channel_extra/alipay_scan.php: -------------------------------------------------------------------------------- 1 | '286801346868493272', 5 | 6 | // 必填,终端号,要求不同终端此号码不一样,会显示在对账单中,如A01、SH008等。 7 | 'terminal_id' => 'SH008', 8 | 9 | // 可选,商品列表,上送格式参照下面示例。 10 | // 字段解释:goods_id:商户定义商品编号(一般商品条码),goods_name:商品名称,quantity:数量, 11 | // price:单价(单位分),goods_category:商品类目(可选),body:商品描述信息(可选),show_url:商品的展示网址(可选) 12 | 'goods_list' => [ 13 | [ 14 | 'goods_id' => 'iphone', 15 | 'goods_name' => 'iPhone', 16 | 'quantity' => 1, 17 | 'price' => '528800', 18 | 'goods_category' => '123456', 19 | 'body' => '苹果手机', 20 | 'show_url' => 'https://www.example.com', 21 | ], 22 | [ 23 | 'goods_id' => 'ipad', 24 | 'goods_name' => 'ipad', 25 | 'quantity' => 1, 26 | 'price' => '528800', 27 | 'goods_category' => '123456', 28 | 'body' => '苹果 ipad', 29 | 'show_url' => 'https://www.example.com', 30 | ], 31 | ], 32 | 33 | // 可选,商户操作员编号(可包含字母、数字、下划线、中划线) 34 | 'operator_id' => 'yx_001', 35 | 36 | // 可选,商户门店编号(可包含字母、数字、下划线、中划线) 37 | 'store_id' => 'SH_001', 38 | 39 | // 可选,系统商编号 40 | 'sys_service_provider_id' => '2088511833207846', 41 | ]; 42 | -------------------------------------------------------------------------------- /lib/OrderRefund.php: -------------------------------------------------------------------------------- 1 | 'alipay', 5 | 6 | // 必须,终端号,要求不同终端此号码不一样,会显示在对账单中,如A01、SH008等。 7 | 'terminal_id' => 'SH008', 8 | 9 | // 可选,商品列表,上送格式参照下面示例。 10 | // 字段解释:goods_id:商户定义商品编号(一般商品条码)unified_goods_id:统一商品编号(可选),goods_name:商品名称,goods_num:数量, 11 | // price:单价(单位分),goods_category:商品类目(可选),body:商品描述信息(可选),show_url:商品的展示网址(可选) 12 | //'goods_list' => [ 13 | // [ 14 | // 'goods_id' => 'iphone6s16G', 15 | // 'unified_goods_id' => '1001', 16 | // 'goods_name' => 'iPhone6s 16G', 17 | // 'goods_num' => '1', 18 | // 'price' => '528800', 19 | // 'goods_category' => '123456', 20 | // 'body' => '苹果手机16G', 21 | // 'show_url' => 'https://www.example.com', 22 | // ], 23 | // [ 24 | // 'goods_id' => 'iphone6s32G', 25 | // 'unified_goods_id' => '1002', 26 | // 'goods_name' => 'iPhone6s 32G', 27 | // 'goods_num' => '1', 28 | // 'price' => '608800', 29 | // 'goods_category' => '123789', 30 | // 'body' => '苹果手机32G', 31 | // 'show_url' => 'https://www.example.com', 32 | // ], 33 | //], 34 | ]; 35 | -------------------------------------------------------------------------------- /example/sub_app/sub_app.php: -------------------------------------------------------------------------------- 1 | 'sub_app_display_name', 16 | 'user' => 'user_102', 17 | 'metadata' => [ 18 | 'key' => 'value' 19 | ], 20 | 'parent_app' => \Pingpp\Pingpp::getAppId(), //父商户应用 ID,必须为平台或者平台下其他的子商户,默认值为平台 21 | ]); 22 | echo $sub_app; // 返回子商户应用 23 | exit; 24 | 25 | //查询子商户应用 sub_app 26 | $sub_app = \Pingpp\SubApp::retrieve('app_1Gqj58ynP0mHeX1q'); 27 | echo $sub_app; 28 | exit; 29 | 30 | //更新子商户应用 31 | $sub_app = \Pingpp\SubApp::update('app_1Gqj58ynP0mHeX1q', [ 32 | 'display_name' => 'display_name_2', 33 | 'metadata' => [ 34 | 'key' => 'value2' 35 | ], 36 | 'description' => 'Your description', 37 | 'parent_app' => \Pingpp\Pingpp::getAppId(), //父商户应用 ID,必须为平台或者平台下其他的子商户,默认值为平台 38 | ]); 39 | echo $sub_app; 40 | exit; 41 | 42 | //删除子商户应用 43 | $sub_app = \Pingpp\SubApp::delete('app_1Gqj58ynP0mHeX1q'); 44 | echo $sub_app; 45 | exit; 46 | 47 | // 查询子商户应用列表 48 | $sub_app_list = \Pingpp\SubApp::all(); 49 | echo $sub_app_list; 50 | exit; 51 | -------------------------------------------------------------------------------- /example/identification.php: -------------------------------------------------------------------------------- 1 | 'id_card', 22 | 'app' => APP_ID, 23 | 'data' => [ 24 | 'id_name' => '张三', // 姓名 25 | 'id_number' => '310181198910107641', // 身份证号 26 | ] 27 | ]); 28 | echo $result; 29 | } catch (\Pingpp\Error\Base $e) { 30 | echo $e->getMessage(); 31 | } 32 | 33 | // 调用银行卡认证接口 34 | try { 35 | $result = \Pingpp\Identification::identify([ 36 | 'type' => 'bank_card', 37 | 'app' => APP_ID, 38 | 'data' => [ 39 | 'id_name' => '张三', // 姓名 40 | 'id_number' => '310181198910107641', // 身份证号, 41 | 'card_number' => '6201111122223333', // 银行卡号 42 | 'phone_number' => '18623234545', // 银行预留手机号,不支持 178 号段 43 | ] 44 | ]); 45 | echo $result; 46 | } catch (\Pingpp\Error\Base $e) { 47 | echo $e->getMessage(); 48 | } 49 | -------------------------------------------------------------------------------- /example/settle_account/update.php: -------------------------------------------------------------------------------- 1 | [ 19 | 'account' => '6214888888888866', // 银行卡号。 20 | 'name' => '张三', // 接收者姓名。 21 | 'type' => 'b2c', // 转账类型。b2c:企业向个人付款,b2b:企业向企业付款。 22 | 'open_bank_code' => '0308', // 开户银行编号 23 | "open_bank" => "工商银行", 24 | "sub_bank" => "招商银行股份有限公司上海陆家嘴支行", 25 | "sub_bank_code" => "308290003773", 26 | 'card_type' => 0, // 银行卡号类型,0:银行卡;1:存折。 27 | 'mobile' => '13822334557', // 手机号 28 | "city" => "上海市", 29 | "prov" => "上海市", 30 | ], 31 | ] 32 | ); 33 | 34 | echo $settle_account; 35 | 36 | /** 结算账户更新手机号(存管相关) */ 37 | $settle_account = \Pingpp\SettleAccount::updateMobile( 38 | 'user_001', // 用户 ID 39 | '320118012216303200004401', // 结算账户 ID 40 | [ 41 | 'mobile' => '13822334557', 42 | ] 43 | ); 44 | 45 | echo $settle_account; 46 | -------------------------------------------------------------------------------- /lib/BatchRefund.php: -------------------------------------------------------------------------------- 1 | getHttpStatus() != null) { 19 | echo $exception->getHttpStatus() . PHP_EOL; 20 | echo $exception->getHttpBody() . PHP_EOL; 21 | } else { 22 | echo $exception->getMessage() . PHP_EOL; 23 | } 24 | } 25 | exit; 26 | 27 | // 查询 Balance Settlement 对象列表 28 | try { 29 | $params = [ 30 | 'user' => 'user_test_01', // 余额结算 user 对象的 id 31 | 'page' => 1, 32 | 'per_page' => 10, 33 | ]; 34 | $balance_settlements = \Pingpp\BalanceSettlements::all($params); 35 | echo $balance_settlements; 36 | } catch (\Pingpp\Error\Base $exception) { 37 | // 捕获报错信息 38 | if ($exception->getHttpStatus() != null) { 39 | echo $exception->getHttpStatus() . PHP_EOL; 40 | echo $exception->getHttpBody() . PHP_EOL; 41 | } else { 42 | echo $exception->getMessage() . PHP_EOL; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/Charge.php: -------------------------------------------------------------------------------- 1 | 'Your Subject', 20 | 'body' => 'Your Body', 21 | 'amount' => 100,// 订单总金额, 人民币单位:分(如订单总金额为 1 元,此处请填 100,金额限制在 100 ~ 20000 之间,即 1 ~ 200 元) 22 | 'order_no' => date('YmdHis') . (microtime(true) % 1) * 1000 . mt_rand(0, 9999),// 红包使用的商户订单号。wx(新渠道)、wx_pub 规定为 1 ~ 28 位不能重复的数字 23 | 'currency' => 'cny', 24 | 'extra' => [ 25 | 'send_name' => 'Send Name'// 商户名称,最多 32 个字节 26 | ], 27 | 'recipient' => 'Openid',// 接收者 id, 为用户在 wx(新渠道)、wx_pub 下的 open_id 28 | 'channel' => 'wx_pub',// 目前支持 wx(新渠道)、 wx_pub 29 | 'app' => ['id' => APP_ID], 30 | 'description' => 'Your Description' 31 | ] 32 | ); 33 | echo $red;// 输出 Ping++ 返回的红包对象 Red_envelope 34 | } catch (\Pingpp\Error\Base $e) { 35 | header('Status: ' . $e->getHttpStatus()); 36 | echo($e->getHttpBody()); 37 | } 38 | -------------------------------------------------------------------------------- /example/charge/channel_extra/isv_wap.php: -------------------------------------------------------------------------------- 1 | 'alipay', 5 | 6 | // 必须,前台通知地址,支付成功或失败后,需要跳转到的地址URL。 7 | 'result_url' => 'https://www.example.com/payment-result', 8 | 9 | // 必须,终端号,如没有终端概念,可使用00000001。 10 | 'terminal_id' => '00000001', 11 | 12 | // 可选,商品列表,上送格式参照下面示例。 13 | // 字段解释:goods_id:商户定义商品编号(一般商品条码)unified_goods_id:统一商品编号(可选),goods_name:商品名称,goods_num:数量, 14 | // price:单价(单位分),goods_category:商品类目(可选),body:商品描述信息(可选),show_url:商品的展示网址(可选) 15 | //'goods_list' => [ 16 | // [ 17 | // 'goods_id' => 'iphone6s16G', 18 | // 'unified_goods_id' => '1001', 19 | // 'goods_name' => 'iPhone6s 16G', 20 | // 'goods_num' => '1', 21 | // 'price' => '528800', 22 | // 'goods_category' => '123456', 23 | // 'body' => '苹果手机16G', 24 | // 'show_url' => 'https://www.example.com', 25 | // ], 26 | // [ 27 | // 'goods_id' => 'iphone6s32G', 28 | // 'unified_goods_id' => '1002', 29 | // 'goods_name' => 'iPhone6s 32G', 30 | // 'goods_num' => '1', 31 | // 'price' => '608800', 32 | // 'goods_category' => '123789', 33 | // 'body' => '苹果手机32G', 34 | // 'show_url' => 'https://www.example.com', 35 | // ], 36 | //], 37 | ]; 38 | -------------------------------------------------------------------------------- /example/order/royalty_settlement.php: -------------------------------------------------------------------------------- 1 | APP_ID, 20 | 'method' => 'alipay', //分润的方式,余额 balance 或渠道名称,例如 alipay 21 | 'recipient_app' => APP_ID, 22 | 'created' => [ 23 | 'gt' => 1489826451, 24 | 'lt' => 1492418451, 25 | ], 26 | 'source_user' => 'user_002', 27 | //'source_no' => '', 28 | 'min_amount' => 1, 29 | 'metadata' => [ 30 | 'key' => 'value' 31 | ], 32 | 'is_preview' => true, //是否预览,选择预览不会真实创建分润结算对象,也不会修改分润对象的状态 33 | ]); 34 | echo $royalty_settlement; 35 | exit; 36 | 37 | // 查询分润结算对象 38 | $royalty_settlement = \Pingpp\RoyaltySettlement::retrieve('431170318144700001'); 39 | echo $royalty_settlement; 40 | exit; 41 | 42 | // 查询分润结算对象列表 43 | $royalty_settlement_list = \Pingpp\RoyaltySettlement::all([ 44 | 'payer_app' => APP_ID 45 | ]); 46 | echo $royalty_settlement_list; 47 | exit; 48 | 49 | //更新分润结算对象 50 | $royalty_settlement_list = \Pingpp\RoyaltySettlement::update('431170318144700001', [ 51 | 'status' => 'pending' // pending, canceled 52 | ]); 53 | echo $royalty_settlement_list; 54 | exit; 55 | -------------------------------------------------------------------------------- /lib/Transfer.php: -------------------------------------------------------------------------------- 1 | _save($options); 49 | } 50 | 51 | public static function update($user_id, $params, $options = null) 52 | { 53 | $url = self::instanceUrlWithId($user_id); 54 | return static::_directRequest('put', $url, $params, $options); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/Royalty.php: -------------------------------------------------------------------------------- 1 | APP_ID, // App ID 30 | 'contract_no' => 'Your Contract No', // 签约协议号 31 | 'channel' => $channel, // 签约渠道 32 | 'extra' => $extra, // 附加信息 33 | 'metadata' => [], // metadata 元数据 34 | ] 35 | ); 36 | echo $agreement; // 输出 Ping++ 返回的 agreement 37 | } catch (\Pingpp\Error\Base $e) { 38 | // 捕获报错信息 39 | if ($e->getHttpStatus() != null) { 40 | header('Status: ' . $e->getHttpStatus()); 41 | echo $e->getHttpBody(); 42 | } else { 43 | echo $e->getMessage(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/BatchWithdrawal.php: -------------------------------------------------------------------------------- 1 | 'canceled']; 51 | } else { 52 | $params = array_merge($params, ['status' => 'canceled']); 53 | } 54 | return static::_directRequest('put', $url, $params, $options); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /example/batch_transfer/create.php: -------------------------------------------------------------------------------- 1 | 8000, // 批量付款总金额,单位为分。为 recipients 中 amount 的总和。 24 | 'app' => APP_ID, 25 | 'batch_no' => uniqid('btr'), // 批量转账批次号,3-24位,允许字母和英文 26 | 'channel' => $channel, // 渠道。 27 | 'description' => 'Your Description', // 批量转账详情,最多 255 个 Unicode 字符 28 | 'recipients' => $recipients, 29 | 'type' => 'b2c' // 付款类型 (当前 alipay、wx_pub 仅支持: b2c, unionpay、allinpay、jdpay 支持: b2b、b2c) 30 | ] 31 | ); 32 | echo $batch_tr; // 输出 Ping++ 返回的 batch transfer 对象 33 | } catch (\Pingpp\Error\Base $e) { 34 | if ($e->getHttpStatus() != null) { 35 | header('Status: ' . $e->getHttpStatus()); 36 | echo $e->getHttpBody(); 37 | } else { 38 | echo $e->getMessage(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/RedEnvelope.php: -------------------------------------------------------------------------------- 1 | _save($options); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /example/withdrawal/create.php: -------------------------------------------------------------------------------- 1 | 'user_test_01', // 用户 ID 20 | 'amount' => 200, // 转账金额 21 | 'channel' => $channel, //提现使用渠道。银联:unionpay,支付宝:alipay,微信:wx_pub,通联:allinpay,京东:jdpay。 22 | 'user_fee' => 10, //用户需要承担的手续费 23 | 'description' => 'Your Description', //描述。 24 | 'order_no' => time() . mt_rand(100000, 999999), //提现订单号,unionpay 为1~16位的纯数字;alipay 为 1 ~ 64 位不能重复的数字字母组合;allinpay 为通联商户号(10位数字) + 不重复流水号组合(10~30位 字母数字组合);wx_pub 规定为 1 ~ 50 位不能重复的数字字母组合;jdpay为 1~64 位不能重复的数字字母组合; 25 | 'extra' => $extra, //附加参数。 26 | //'settle_account' => '320217022818035400000601', //使用结算账户提现,不需要填写 channel 和 extra 相关参数,同时填写时,结算账号不生效 27 | ]; 28 | $withdrawal = \Pingpp\Withdrawal::create($params); 29 | echo $withdrawal; 30 | } catch (\Pingpp\Error\Base $e) { 31 | if ($e->getHttpStatus() != null) { 32 | header('Status: ' . $e->getHttpStatus()); 33 | echo $e->getHttpBody(); 34 | } else { 35 | echo $e->getMessage(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /example/your_rsa_private_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEAx2MktxcKBEqdYRi2IgYcupPQIN5cxgiBL5udCCBJBNBbXPaq 3 | uOE1qspfhB1KUzHXATnCONiSzubLcBTnwi2tz0ErRCeJZSERRCpbKx4eu6b1neUT 4 | Wkga7xpZxWONEvkmZo5Nlhf4fXRPUYnO/bdGCNGpQ/HSJfWLtzmhCqO1aJwVhcDm 5 | DMYz4bTkZavhFBdVyXf/8n7UKylk03eymlKJ1swQpeFcxaKfzsk1mJU7mc93mCWj 6 | aR+VWkNbw4AQHDyHgbzH+zYARzCluiy5hXdixGEP+iO4ZBk48rEs1hKTvGz1k+jh 7 | LCdkdpBRjq0pK/htjA3Ce8pF2AJs+fgN6ZUumQIDAQABAoIBAFa4MEfRpXGoYjrQ 8 | 3KZ/sg8UKvmgvQkEuetS60GViSym0pXkUuyGRyk5S8HSW3lDvBe0X10KFRAYIXNm 9 | JEa4R1hVJ9REveVWNIRJR83BE+zZ+QnrkDc8FTrZYyIO4lTWOHVyfxxA4Lrv02/L 10 | WFPRWoyLY+tBSf1ohpPyZLCT81rDglT1Z4svX020y8tXvnQqQiOjl4q7Zu4b26HU 11 | TQ463ntMEhM5u7y9MFcxGRaOpF/gARlMGqDu6T8h/oYMiOSLoXOuTR7B80yaX/Mj 12 | RZfUBoZMb5thX9qBLQ7dYnTkwaxwerYPrYvQrW9vtsswZ5NeIbEmCZyorUe8DOmQ 13 | hT1+HmECgYEA/iQERHhZKHXnP0gvhl/uEOGOvLjD5H1D6zClzOHMmOcIF5OuEQb0 14 | VcSMV+8emN7SCp/b/LVgKa27Mla9eXm+EXABRFcI7qGYsYXfbCD7EYX3TaJSp/30 15 | jyLBy+MsHCTEiLeylSh7kHqgTR8tKND8UIzXo9aM7JqwFqleeXGyh7MCgYEAyNiU 16 | EUzyBAv9sui3ZgVYRiVvTilk2HVTY6u61/mMOLsTrX3eYQaqb4GRJJShJO9mmsxX 17 | RHBEZQJvUqqF9PapOsyv8HKuF5+UP6svHnJo7sn9gCvV/h1HTHqzFcYSvUaXnrym 18 | D/0Tthf8CDeuGp5UFWMoFZF14HTr1oQROGAASoMCgYA0bZmzxmAeSLR8CZhEUGX8 19 | dYvMwxEmgfERA+gwbCSZJpA0zPKL8LNXPkT1nw7g2pbaOkBX0dMUxhJoQBy2grcD 20 | QegBATOGhy/I76U32VXyN4DdMy96GJnrLXBtb2AaLjudOMhOnRtgouuO/W+DjBmB 21 | RIz377sC1KafBjHHO/1ooQKBgDQqfJrZv2ppquVTKH9pF/pwMq68daL7JkOXERqT 22 | iGYbwQqozJ+q2Y3Iu2gi6o/rVl0SggAWoM0TitKP0+dCQcYx7+imAK3GFv1KexyP 23 | Xs3WzO8Dc7ti42fr3qPjJG7g7PSfzwoME5iSNjX0MFZdlT1Q2dJwS4uXEsJO3yIj 24 | XS/9AoGBALRApgtUA7Odw4tjCLGvxXuLFnyRkg6hFqoXAP2j8H9bJDOlSSVwQTFd 25 | ahbcIDtQJS57vXUGK2uspbFKLm1WCFzPVyuxDIW6oue/kO+YxxU3NA58zk8oaORq 26 | eA3YvHc7ZmRjVnVkxnXjKofrL6jF5A+lXSXnXchrv2ZYI+1pOsIV 27 | -----END RSA PRIVATE KEY----- -------------------------------------------------------------------------------- /lib/SubApp.php: -------------------------------------------------------------------------------- 1 | 10, 16 | 'description' => '余额赠送描述', 17 | 'user' => 'user_test_01', 18 | 'order_no' => substr(md5(time()), 0, 10), 19 | ]); 20 | echo $balance_bonus; 21 | } catch (\Pingpp\Error\Base $exception) { 22 | // 捕获报错信息 23 | if ($exception->getHttpStatus() != null) { 24 | echo $exception->getHttpStatus() . PHP_EOL; 25 | echo $exception->getHttpBody() . PHP_EOL; 26 | } else { 27 | echo $exception->getMessage() . PHP_EOL; 28 | } 29 | } 30 | 31 | //查询余额赠送 32 | try { 33 | $balance_bonus = \Pingpp\BalanceBonus::retrieve('651170807590953932800000'); 34 | echo $balance_bonus; 35 | } catch (\Pingpp\Error\Base $exception) { 36 | // 捕获报错信息 37 | if ($exception->getHttpStatus() != null) { 38 | echo $exception->getHttpStatus() . PHP_EOL; 39 | echo $exception->getHttpBody() . PHP_EOL; 40 | } else { 41 | echo $exception->getMessage() . PHP_EOL; 42 | } 43 | } 44 | 45 | //查询余额赠送列表 46 | try { 47 | $params = [ 48 | 'page' => 1, 49 | 'per_page' => 10, 50 | 'user' => 'user_test_01', //受赠的用户 ID 51 | ]; 52 | $balance_bonus = \Pingpp\BalanceBonus::all($params); 53 | echo $balance_bonus; 54 | } catch (\Pingpp\Error\Base $exception) { 55 | // 捕获报错信息 56 | if ($exception->getHttpStatus() != null) { 57 | echo $exception->getHttpStatus() . PHP_EOL; 58 | echo $exception->getHttpBody() . PHP_EOL; 59 | } else { 60 | echo $exception->getMessage() . PHP_EOL; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /lib/Collection.php: -------------------------------------------------------------------------------- 1 | extractPathAndUpdateParams($params); 10 | 11 | list($response, $opts) = $this->_request('get', $url, $params, $opts); 12 | return Util\Util::convertToPingppObject($response, $opts); 13 | } 14 | 15 | public function create($params = null, $opts = null) 16 | { 17 | list($url, $params) = $this->extractPathAndUpdateParams($params); 18 | 19 | list($response, $opts) = $this->_request('post', $url, $params, $opts); 20 | return Util\Util::convertToPingppObject($response, $opts); 21 | } 22 | 23 | public function retrieve($id, $params = null, $opts = null) 24 | { 25 | list($url, $params) = $this->extractPathAndUpdateParams($params); 26 | 27 | $id = Util\Util::utf8($id); 28 | $extn = urlencode($id); 29 | list($response, $opts) = $this->_request( 30 | 'get', 31 | "$url/$extn", 32 | $params, 33 | $opts 34 | ); 35 | return Util\Util::convertToPingppObject($response, $opts); 36 | } 37 | 38 | private function extractPathAndUpdateParams($params) 39 | { 40 | $url = parse_url($this->url); 41 | if (!isset($url['path'])) { 42 | throw new Error\Api("Could not parse list url into parts: $url"); 43 | } 44 | 45 | if (isset($url['query'])) { 46 | // If the URL contains a query param, parse it out into $params so they 47 | // don't interact weirdly with each other. 48 | $query = []; 49 | parse_str($url['query'], $query); 50 | // PHP 5.2 doesn't support the ?: operator 51 | $params = array_merge($params ? $params : [], $query); 52 | } 53 | 54 | return [$url['path'], $params]; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /example/customs.php: -------------------------------------------------------------------------------- 1 | APP_ID, 17 | 'charge' => 'ch_L8qn10mLmr1GS8e5OODmHaL4', 18 | 'channel' => 'alipay', 19 | 'trade_no' => '12332132131', // 商户报关订单号,8~20位 20 | 'customs_code' => 'GUANGZHOU', 21 | 'amount' => 8000, 22 | 'transport_amount' => 10, 23 | 'is_split' => true, 24 | 'sub_order_no' => '123456', 25 | 'extra' => [ 26 | 'pay_account' => '1234567890', 27 | 'certif_type' => '02', 28 | 'customer_name' => 'A Name', 29 | 'certif_id' => 'ID Card No', 30 | 'tax_amount' => '10', 31 | ] 32 | ] 33 | ); 34 | echo $cus; // 输出 Ping++ 返回的 custom 对象 35 | } catch (\Pingpp\Error\Base $e) { 36 | if ($e->getHttpStatus() != null) { 37 | header('Status: ' . $e->getHttpStatus()); 38 | echo $e->getHttpBody(); 39 | } else { 40 | echo $e->getMessage(); 41 | } 42 | } 43 | exit; 44 | 45 | 46 | //查询 customs 对象 47 | try { 48 | $cus = \Pingpp\Customs::retrieve('14201609281040220109'); // 报关对象id ,由 Ping++ 生成 49 | echo $cus; // 输出 Ping++ 返回的 custom 对象信息 50 | } catch (\Pingpp\Error\Base $e) { 51 | if ($e->getHttpStatus() != null) { 52 | header('Status: ' . $e->getHttpStatus()); 53 | echo $e->getHttpBody(); 54 | } else { 55 | echo $e->getMessage(); 56 | } 57 | } 58 | exit; 59 | -------------------------------------------------------------------------------- /lib/Coupon.php: -------------------------------------------------------------------------------- 1 | 10, // 用户收到转账的余额,单位:分 17 | 'user_fee' => 0, // 向发起转账的用户额外收取的手续费,单位:分 18 | 'user' => 'user_001', // 发起转账的用户 ID(可以是 C类用户 或 B类用户,但不能填 0) 19 | 'recipient' => '0', // 接收转账的用户 ID(可以是 C类用户 或 B类用户,可以为 0) 20 | 'order_no' => substr(md5(time()), 0, 10), // 商户订单号,必须在商户系统内唯一 21 | 'description' => 'Your description', // 描述 22 | 'metadata' => [], // metadata 元数据 23 | ] 24 | ); 25 | echo $balance_transfer; 26 | } catch (\Pingpp\Error\Base $e) { 27 | // 捕获报错信息 28 | if ($e->getHttpStatus() != null) { 29 | echo $e->getHttpStatus() . PHP_EOL; 30 | echo $e->getHttpBody() . PHP_EOL; 31 | } else { 32 | echo $e->getMessage() . PHP_EOL; 33 | } 34 | } 35 | exit; 36 | 37 | //查询余额转账 38 | try { 39 | $balance_transfer = \Pingpp\BalanceTransfer::retrieve('661170807435256330240000'); 40 | echo $balance_transfer; 41 | } catch (\Pingpp\Error\Base $e) { 42 | // 捕获报错信息 43 | if ($e->getHttpStatus() != null) { 44 | echo $e->getHttpStatus() . PHP_EOL; 45 | echo $e->getHttpBody() . PHP_EOL; 46 | } else { 47 | echo $e->getMessage() . PHP_EOL; 48 | } 49 | } 50 | exit; 51 | 52 | //查询余额转账列表 53 | try { 54 | $params = [ 55 | 'page' => 1, 56 | 'per_page' => 10, 57 | ]; 58 | $balance_transfer = \Pingpp\BalanceTransfer::all($params); 59 | echo $balance_transfer; 60 | } catch (\Pingpp\Error\Base $exception) { 61 | // 捕获报错信息 62 | if ($e->getHttpStatus() != null) { 63 | echo $e->getHttpStatus() . PHP_EOL; 64 | echo $e->getHttpBody() . PHP_EOL; 65 | } else { 66 | echo $e->getMessage() . PHP_EOL; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /example/transfer/create.php: -------------------------------------------------------------------------------- 1 | 100, 25 | 26 | // 付款使用的商户内部订单号。 wx_pub 规定为 1 ~ 50 位不能重复的数字字母组合; alipay 为 1 ~ 64 位不能重复的数字字母组合; unionpay 为1~16位的纯数字。jdpay 限长1-64位不能重复的数字字母组合;allinpay 限长20-40位不能重复的数字字母组合,必须以签约的通联的商户号开头(建议组合格式:通联商户号 + 时间戳 + 固定位数顺序流水号,不包含+号) 27 | 'order_no' => date('mdHis') . mt_rand(1, 9999), 28 | 29 | // 三位 ISO 货币代码,目前仅支持人民币: cny 。 30 | 'currency' => 'cny', 31 | 32 | // 渠道 33 | 'channel' => $channel, 34 | 35 | // 转账使用的 app 对象的 id 36 | 'app' => ['id' => APP_ID], 37 | 38 | // 付款类型,支持 b2c 、b2b 39 | 'type' => 'b2c', 40 | 41 | // 接收者 id, 微信企业付款时为用户在 wx_pub 下的 open_id ;渠道为 alipay 时,若 type 为 b2c,为个人支付宝账号,若 type 为 b2b,为企业支付宝账号。渠道为 unionpay、allinpay、jdpay 时,不需要传该参数。 42 | 'recipient' => 'o9zpMs9jIaLynQY9N6yxcZ', 43 | 44 | // 备注信息。 45 | // 渠道为 unionpay 时,最多 99 个 Unicode 字符; 46 | // 渠道为 wx_pub 时,最多 99 个英文和数字的组合或最多 33 个中文字符,不可以包含特殊字符; 47 | // 渠道为 alipay 时,最多 100 个 Unicode 字符。 48 | // 渠道为 jdpay 最多100个 Unicode 字符。 49 | // 渠道为 allinpay 最多30个 Unicode 字符 50 | 'description' => 'testing', 51 | 52 | // 相关的附加参数 53 | 'extra' => $extra 54 | ] 55 | ); 56 | // 输出 Ping++ 返回的企业付款对象 Transfer 57 | echo $tr; 58 | } catch (\Pingpp\Error\Base $e) { 59 | header('Status: ' . $e->getHttpStatus()); 60 | echo($e->getHttpBody()); 61 | } 62 | -------------------------------------------------------------------------------- /example/charge/create.php: -------------------------------------------------------------------------------- 1 | 'Your Subject', 38 | 'body' => 'Your Body', 39 | 'amount' => $amount, // 订单总金额, 人民币单位:分(如订单总金额为 1 元,此处请填 100) 40 | 'order_no' => $orderNo, // 推荐使用 8-20 位,要求数字或字母,不允许其他字符 41 | 'currency' => 'cny', 42 | 'extra' => $extra, 43 | 'channel' => $channel, // 支付使用的第三方支付渠道取值,请参考:https://www.pingxx.com/api#api-c-new 44 | 'client_ip' => $_SERVER['REMOTE_ADDR'], // 发起支付请求客户端的 IP 地址,格式为 IPV4,如: 127.0.0.1 45 | 'app' => ['id' => APP_ID], 46 | ] 47 | ); 48 | echo $ch; // 输出 Ping++ 返回的支付凭据 Charge 49 | } catch (\Pingpp\Error\Base $e) { 50 | // 捕获报错信息 51 | if ($e->getHttpStatus() != null) { 52 | header('Status: ' . $e->getHttpStatus()); 53 | echo $e->getHttpBody(); 54 | } else { 55 | echo $e->getMessage(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/Withdrawal.php: -------------------------------------------------------------------------------- 1 | 'pending']; 39 | return static::_directRequest('put', $url, $params, $options); 40 | } 41 | 42 | /** 43 | * @param string $id API resource ID 44 | * @param array|string|null $options 45 | * 46 | * @return Withdrawal The canceled withdrawal. 47 | */ 48 | public static function cancel($id, $options = null) 49 | { 50 | $url = static::classUrl().'/'.$id; 51 | $params = ['status' => 'canceled']; 52 | return static::_directRequest('put', $url, $params, $options); 53 | } 54 | 55 | /** 56 | * @param array|null $params 57 | * @param array|string|null $options 58 | * 59 | * @return array An array of Withdrawal. 60 | */ 61 | public static function all($params = null, $options = null) 62 | { 63 | return self::_all($params, $options); 64 | } 65 | 66 | /** 67 | * @param array|null $params 68 | * @param array|string|null $options 69 | * 70 | * @return array An array of batch withdrawals. 71 | */ 72 | public static function batchConfirm($params = null, $options = null) 73 | { 74 | $url = static::appBaseUrl().'/batch_withdrawals'; 75 | return static::_directRequest('post', $url, $params, $options); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /example/batch_withdrawal/batch_withdrawal.php: -------------------------------------------------------------------------------- 1 | [ 18 | '1701611150302360654', 19 | '1701611151015078981' 20 | ] 21 | ]; 22 | try { 23 | $batch_withdrawal = \Pingpp\BatchWithdrawal::cancel($params); 24 | echo $batch_withdrawal; // 输出 Ping++ 返回的 withdrawal 对象 25 | } catch (\Pingpp\Error\Base $e) { 26 | if ($e->getHttpStatus() != null) { 27 | header('Status: ' . $e->getHttpStatus()); 28 | echo $e->getHttpBody(); 29 | } else { 30 | echo $e->getMessage(); 31 | } 32 | } 33 | exit; 34 | 35 | // 批量提现确认 36 | $params = [ 37 | 'withdrawals' => [ 38 | '1701611150302360654', 39 | '1701611151015078981' 40 | ] 41 | ]; 42 | try { 43 | $batch_withdrawal = \Pingpp\BatchWithdrawal::confirm($params); 44 | echo $batch_withdrawal; // 输出 Ping++ 返回的 withdrawal 对象 45 | } catch (\Pingpp\Error\Base $e) { 46 | if ($e->getHttpStatus() != null) { 47 | header('Status: ' . $e->getHttpStatus()); 48 | echo $e->getHttpBody(); 49 | } else { 50 | echo $e->getMessage(); 51 | } 52 | } 53 | exit; 54 | 55 | // 批量提现查询 56 | $batch_withdrawal_id = '1901611151015122025'; 57 | try { 58 | $batch_withdrawal = \Pingpp\BatchWithdrawal::retrieve($batch_withdrawal_id); 59 | echo $batch_withdrawal; 60 | } catch (\Pingpp\Error\Base $e) { 61 | if ($e->getHttpStatus() != null) { 62 | header('Status: ' . $e->getHttpStatus()); 63 | echo $e->getHttpBody(); 64 | } else { 65 | echo $e->getMessage(); 66 | } 67 | } 68 | exit; 69 | 70 | // 批量提现列表查询 71 | $params = ['per_page' => 3]; 72 | try { 73 | $batch_withdrawal = \Pingpp\BatchWithdrawal::all($params); 74 | echo $batch_withdrawal; 75 | } catch (\Pingpp\Error\Base $e) { 76 | if ($e->getHttpStatus() != null) { 77 | header('Status: ' . $e->getHttpStatus()); 78 | echo $e->getHttpBody(); 79 | } else { 80 | echo $e->getMessage(); 81 | } 82 | } 83 | exit; 84 | -------------------------------------------------------------------------------- /example/user.php: -------------------------------------------------------------------------------- 1 | uniqid('uid'), // 用户 ID ,由商户提供 23 | ] 24 | ); 25 | echo $user; 26 | } catch (\Pingpp\Error\Base $e) { 27 | if ($e->getHttpStatus() != null) { 28 | header('Status: ' . $e->getHttpStatus()); 29 | echo $e->getHttpBody(); 30 | } else { 31 | echo $e->getMessage(); 32 | } 33 | } 34 | exit; 35 | 36 | // 查询 user 对象 37 | $uid = 'uid598ae2dabbe71'; 38 | try { 39 | $user = \Pingpp\User::retrieve($uid); 40 | echo $user; 41 | } catch (\Pingpp\Error\Base $e) { 42 | if ($e->getHttpStatus() != null) { 43 | header('Status: ' . $e->getHttpStatus()); 44 | echo $e->getHttpBody(); 45 | } else { 46 | echo $e->getMessage(); 47 | } 48 | } 49 | exit; 50 | 51 | // 更新 user 对象 52 | $uid = 'uid582d35283f628'; 53 | try { 54 | $user = \Pingpp\User::update($uid, [ 55 | 'address' => 'China', 56 | 'name' => strval(mt_rand(1000, 9999)), 57 | 'metadata' => [ 58 | 'key' => 'value' 59 | ], 60 | ]); 61 | echo $user; 62 | } catch (\Pingpp\Error\Base $e) { 63 | if ($e->getHttpStatus() != null) { 64 | header('Status: ' . $e->getHttpStatus()); 65 | echo $e->getHttpBody(); 66 | } else { 67 | echo $e->getMessage(); 68 | } 69 | } 70 | exit; 71 | 72 | // 查询列表 73 | try { 74 | $params = [ 75 | 'page' => 1, 76 | 'per_page' => 10, 77 | ]; 78 | $users = \Pingpp\User::all($params); 79 | echo $users; 80 | } catch (\Pingpp\Error\Base $e) { 81 | if ($e->getHttpStatus() != null) { 82 | header('Status: ' . $e->getHttpStatus()); 83 | echo $e->getHttpBody(); 84 | } else { 85 | echo $e->getMessage(); 86 | } 87 | } 88 | exit; 89 | -------------------------------------------------------------------------------- /lib/UserBase.php: -------------------------------------------------------------------------------- 1 | _save($opts); 49 | } 50 | 51 | /** 52 | * @param $charge_id 53 | * @param $params 54 | * @param $options 55 | * @return array|PingppObject 56 | */ 57 | public static function create($charge_id, $params, $options = null) 58 | { 59 | $url = self::classUrlWithChargeId($charge_id); 60 | return static::_directRequest('post', $url, $params, $options); 61 | } 62 | 63 | /** 64 | * @param $charge_id 65 | * @param $charge_refund_id 66 | * @param $options 67 | * @return array|PingppObject 68 | */ 69 | public static function retrieve($charge_id, $charge_refund_id, $options = null) 70 | { 71 | $url = self::instanceUrlWithRefundId($charge_id, $charge_refund_id); 72 | return static::_directRequest('get', $url, $options); 73 | } 74 | 75 | public static function all($charge_id, $params, $options = null) 76 | { 77 | $url = self::classUrlWithChargeId($charge_id); 78 | return static::_directRequest('get', $url, $params, $options); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /lib/WxLiteOAuth.php: -------------------------------------------------------------------------------- 1 | 'OPENID', 35 | * 'session_key' => 'SESSIONKEY' 36 | * ] 37 | * 38 | * 满足 UnionID 返回条件时返回数组 39 | * [ 40 | * 'openid' => 'OPENID', 41 | * 'session_key' => 'SESSIONKEY', 42 | * 'unionid' => 'UNIONID' 43 | * ] 44 | */ 45 | public static function getSession($app_id, $app_secret, $code) 46 | { 47 | $url_params = [ 48 | 'appid' => $app_id, 49 | 'secret' => $app_secret, 50 | 'js_code' => $code, 51 | 'grant_type'=> 'authorization_code', 52 | ]; 53 | $query_str = http_build_query($url_params); 54 | $url = 'https://api.weixin.qq.com/sns/jscode2session?' . $query_str; 55 | 56 | $res = self::getRequest($url); 57 | if (empty($res)) { 58 | throw new Error\Api("connect error"); 59 | } 60 | $data = json_decode($res, true); 61 | if (!isset($data['openid']) || isset($data['errcode'])) { 62 | throw new Error\Api($res); 63 | } 64 | return $data; 65 | } 66 | 67 | 68 | /** 69 | * GET 请求 70 | */ 71 | private static function getRequest($url) 72 | { 73 | $ch = curl_init(); 74 | curl_setopt($ch, CURLOPT_TIMEOUT, 30); 75 | curl_setopt($ch, CURLOPT_URL, $url); 76 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 77 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 78 | curl_setopt($ch, CURLOPT_HEADER, false); 79 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 80 | $res = curl_exec($ch); 81 | curl_close($ch); 82 | 83 | return $res; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /example/sub_app/sub_app_channel.php: -------------------------------------------------------------------------------- 1 | 'alipay', 16 | 'params' => [ 17 | 'fee_rate' => 60, 18 | 'alipay_pid' => '2088501666666666', 19 | 'alipay_account' => 'account@example.com', 20 | 'alipay_security_key' => 'Your security_key', 21 | 'alipay_mer_app_private_key' => '-----BEGIN RSA PRIVATE KEY----- 22 | MIICXQIBAAKBgQDSBOW3jdthyqSBMNJ8P+BQnfoKpL29BtvACW1gr8YhXh8EqpBU 23 | nUDdQgi8uYnprXBbR5O1DVnIqLKG9loEn3Rc2iqpnj3M3nSShuVByjyJjQ+DAIG2 24 | /cgJjGQknCLo0CKtuEIyD5xBKYVz3GLofLKqCNGDYdUIxwgaBBpssNIDGQIDAQAB 25 | AoGBAKmzw1taiRawA9VQegRkKQF7ZXwMOjTvwcme1H74CYUU5MOEfzOgDbW7kgvN 26 | cJ8dwlg/sh7uNsppZjif/4UUw5R7bSu33m1sIyglmKUYTU7Kw+ETVAPgwkQjJhek 27 | V/pDr143vmchAblD4RqQZTneojTkvYgci4RkHHHIIZ8lClIBAkEA/nEyCKzl0gxU 28 | LWMd0HKLctcwDu6NPWycffFzSg/+k1+h0GlSTp2E8J6DKOYnrlQYvK2/BnbFPfrb 29 | EySi+7c86QJBANNOExrr7xl54JnlZxbXNDnNrql2brPk1DsV/3Lo3Tmt8NuVqiyo 30 | hVE8Vs/CPRqTTSPoTV4TwSscB4Torlox9rECQB9tne+CY7TJPxCIIKOhsmXR/Kar 31 | gpimtMG9tC7ewOQ1OMiEad06CbSq76p6m0YmLxQHJgRHYV+hf7Pin5sV7BkCQQC6 32 | 9KxAuJk/YC9R2r/AXL4vmoU8GLZP4lnIwWjXwaLiwryFfEEp7BywyINCpOgtWED7 33 | UTEK2M2jl9QrSzfgQ66xAkBm2RI+8onm/4PVKtOt8tqLjfsFGMR3g0aUwgSbznc0 34 | Xg9dfU+YUgqfQnyAQHt9jG3/SBdmIrYoWwb7TqJZLkZI 35 | -----END RSA PRIVATE KEY-----', 36 | 'alipay_app_public_key' => '-----BEGIN PUBLIC KEY----- 37 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDSBOW3jdthyqSBMNJ8P+BQnfoK 38 | pL29BtvACW1gr8YhXh8EqpBUnUDdQgi8uYnprXBbR5O1DVnIqLKG9loEn3Rc2iqp 39 | nj3M3nSShuVByjyJjQ+DAIG2/cgJjGQknCLo0CKtuEIyD5xBKYVz3GLofLKqCNGD 40 | YdUIxwgaBBpssNIDGQIDAQAB 41 | -----END PUBLIC KEY-----', 42 | ], 43 | 'banned' => false, 44 | 'banned_msg' => null, 45 | 'description' => 'alipay description', 46 | ]); 47 | 48 | echo $sub_app_channel; 49 | exit; 50 | 51 | 52 | //查询子商户应用支付渠道 53 | $sub_app_channel = \Pingpp\Channel::retrieve('app_1Gqj58ynP0mHeX1q', 'alipay'); 54 | echo $sub_app_channel; 55 | 56 | //更新子商户应用支付渠道 57 | $sub_app_channel = \Pingpp\Channel::update('app_1Gqj58ynP0mHeX1q', 'alipay', [ 58 | 'description' => 'new description', 59 | 'params' => [ 60 | 'fee_rate' => 50, 61 | 'alipay_pid' => 'Your Alipay pid', 62 | 'alipay_account' => 'account@example.com', 63 | ], 64 | ]); 65 | echo $sub_app_channel; 66 | exit; 67 | 68 | //删除子商户应用支付渠道 69 | $sub_app_channel = \Pingpp\Channel::delete('app_1Gqj58ynP0mHeX1q', 'alipay'); 70 | echo $sub_app_channel; 71 | exit; 72 | -------------------------------------------------------------------------------- /lib/CouponTemplate.php: -------------------------------------------------------------------------------- 1 | _save($options); 53 | } 54 | 55 | /** 56 | * @param $id 57 | * @param array|null $params 58 | * @param array|string|null $options 59 | * 60 | * @return coupon 61 | */ 62 | public static function batchCreateCoupons($id, $params = null, $options = null) 63 | { 64 | $url = static::classUrl() . '/' . $id . '/coupons'; 65 | return static::_directRequest('post', $url, $params, $options); 66 | } 67 | 68 | /** 69 | * @param $id 70 | * @param array|null $params 71 | * @param array|string|null $options 72 | * 73 | * @return coupon 74 | */ 75 | public static function couponsList($id, $params = null, $options = null) 76 | { 77 | $url = static::classUrl() . '/' . $id . '/coupons'; 78 | return static::_directRequest('get', $url, $params, $options); 79 | } 80 | 81 | public static function update($id, $params) 82 | { 83 | $url = static::classUrl() . '/' . $id; 84 | return static::_directRequest('put', $url, $params); 85 | } 86 | 87 | /** 88 | * delete coupontemplate 89 | * @param $id 90 | * @param $options 91 | * @return array|PingppObject 92 | */ 93 | public static function delete($id, $options = null) 94 | { 95 | $url = static::classUrl() . '/' . $id; 96 | return static::_directRequest('delete', $url, $options); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /lib/Recharge.php: -------------------------------------------------------------------------------- 1 | _save($opts); 49 | } 50 | 51 | /** 52 | * @param array|null $params 53 | * @param array|string|null $opts 54 | * 55 | * @return Order 56 | */ 57 | public static function pay($order_id, $params = null, $opts = null) 58 | { 59 | $url = static::instanceUrlWithId($order_id) . '/pay'; 60 | return static::_directRequest('post', $url, $params, $opts); 61 | } 62 | 63 | /** 64 | * @param array|null $params 65 | * @param array|string|null $opts 66 | * 67 | * @return Order the canceled order 68 | */ 69 | public static function cancel($order_id, $params = null, $opts = null) 70 | { 71 | $url = static::instanceUrlWithId($order_id); 72 | if (empty($params)) { 73 | $params = ['status' => 'canceled']; 74 | } else { 75 | $params = array_merge($params, ['status' => 'canceled']); 76 | } 77 | return static::_directRequest('put', $url, $params, $opts); 78 | } 79 | 80 | /** 81 | * @param $order_id 82 | * @param $charge_id 83 | * @param null $opts 84 | * @return array|Charge 85 | */ 86 | public static function chargeRetrieve($order_id, $charge_id, $opts = null) 87 | { 88 | $url = static::instanceUrlWithId($order_id) . '/charges/' . $charge_id; 89 | return static::_directRequest('get', $url, null, $opts); 90 | } 91 | 92 | public static function chargeList($order_id, $params = null, $opts = null) 93 | { 94 | $url = static::instanceUrlWithId($order_id) . '/charges'; 95 | return static::_directRequest('get', $url, $params, $opts); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /PingppEnvInspect.php: -------------------------------------------------------------------------------- 1 | $msg) { 21 | if (!function_exists($funcName)) { 22 | throw new Exception($msg); 23 | } 24 | } 25 | static::domainResolveCheck(); 26 | static::connectionCheck(); 27 | echo "Your PHP system passed the runtime environment inspection successfully."; 28 | } 29 | 30 | private static $extFunc 31 | = [ 32 | "curl_init" => 'Pingpp needs the CURL PHP extension.', 33 | "openssl_sign" => 'Pingpp needs the OpenSSL PHP extension.', 34 | "json_decode" => 'Pingpp needs the JSON PHP extension.', 35 | "mb_detect_encoding" => 'Pingpp needs the Multibyte String PHP extension.', 36 | ]; 37 | private static $minPingppVersion = '5.6'; 38 | private static $apiHost; 39 | private static $apiKey = 'sk_test_ibbTe5jLGCi5rzfH4OqPW9KC'; 40 | private static $exampleChargeId = 'ch_100241226608758108160014'; 41 | 42 | private static function versionCheck() 43 | { 44 | $phpVersion = phpversion(); 45 | if (version_compare($phpVersion, static::$minPingppVersion, '<')) { 46 | throw new Exception(sprintf( 47 | 'Your server is running PHP version %1$s but Pingpp version requires %2$s at least.', 48 | $phpVersion, 49 | static::$minPingppVersion 50 | )); 51 | } 52 | } 53 | 54 | private static function domainResolveCheck() 55 | { 56 | if (gethostbyname(static::$apiHost) == static::$apiHost) { 57 | throw new Exception(sprintf( 58 | 'Could not resolve %1$s, please check your network or dns settings.', 59 | static::$apiHost 60 | )); 61 | } 62 | } 63 | 64 | private static function connectionCheck() 65 | { 66 | try { 67 | \Pingpp\Pingpp::setApiKey(static::$apiKey); 68 | \Pingpp\Charge::retrieve(static::$exampleChargeId); 69 | } catch (Exception $e) { 70 | if ($e instanceof \Pingpp\Error\ApiConnection) { 71 | throw $e; 72 | } 73 | } 74 | } 75 | } 76 | 77 | try { 78 | PingppEnvInspect::start(); 79 | } catch (Exception $e) { 80 | echo $e->getMessage(); 81 | } 82 | -------------------------------------------------------------------------------- /init.php: -------------------------------------------------------------------------------- 1 | apiKey = $key; 16 | $this->headers = $headers; 17 | $this->signOpts = $signOpts; 18 | } 19 | 20 | /** 21 | * Unpacks an options array and merges it into the existing RequestOptions 22 | * object. 23 | * @param array|string|null $options a key => value array 24 | * 25 | * @return RequestOptions 26 | */ 27 | public function merge($options) 28 | { 29 | $other_options = self::parse($options); 30 | if ($other_options->apiKey === null) { 31 | $other_options->apiKey = $this->apiKey; 32 | } 33 | $other_options->headers = array_merge($this->headers, $other_options->headers); 34 | return $other_options; 35 | } 36 | 37 | /** 38 | * Unpacks an options array into an RequestOptions object 39 | * @param array|string|null $options a key => value array 40 | * 41 | * @return RequestOptions 42 | */ 43 | public static function parse($options) 44 | { 45 | if ($options instanceof self) { 46 | return $options; 47 | } 48 | 49 | if (is_null($options)) { 50 | return new RequestOptions(null, []); 51 | } 52 | 53 | if (is_string($options)) { 54 | return new RequestOptions($options, []); 55 | } 56 | 57 | if (is_array($options)) { 58 | $headers = []; 59 | $key = null; 60 | $signOpts = []; 61 | if (array_key_exists('api_key', $options)) { 62 | $key = $options['api_key']; 63 | } 64 | if (array_key_exists('pingpp_version', $options)) { 65 | $headers['Pingpp-Version'] = $options['pingpp_version']; 66 | } 67 | if (array_key_exists('sign_opts', $options)) { 68 | $signOpts = $options['sign_opts']; 69 | } 70 | return new RequestOptions($key, $headers, $signOpts); 71 | } 72 | 73 | $message = 'The second argument to Pingpp API method calls is an ' 74 | . 'optional per-request apiKey, which must be a string, or ' 75 | . 'per-request options, which must be an array. (HINT: you can set ' 76 | . 'a global apiKey by "Pingpp::setApiKey()")'; 77 | throw new Error\Api($message); 78 | } 79 | 80 | /** 81 | * @param array $opts The custom options 82 | * @param array $signOpts The sign options 83 | * @return array The merged options 84 | */ 85 | public static function parseWithSignOpts($opts, $signOpts) 86 | { 87 | $options = self::parse($opts); 88 | $options->signOpts = array_merge($options->signOpts, $signOpts); 89 | return $options; 90 | } 91 | 92 | /** 93 | * @param array $signOpts The sign options 94 | * @return array The merged options 95 | */ 96 | public function mergeSignOpts($signOpts) 97 | { 98 | $this->signOpts = array_merge($this->signOpts, $signOpts); 99 | return $this; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # ChangeLog 2 | 3 | ## 2.6.0 4 | 5 | - 新增 transfer 撤销接口 6 | - 新增 资金充值申请创建和查询接口 7 | 8 | ## 2.5.1 9 | 10 | #### 修改 11 | 12 | - 更正本地 CA 证书 13 | 14 | ## 2.5.0 15 | 16 | - 修复charge查询对象转换为字符串时在PHP7.4版本 notice 报错 17 | 18 | ## 2.4.9 19 | 20 | 2019-11-05 21 | 22 | #### 新增 23 | 24 | - 独立创建分润接口 25 | 26 | ## 2.4.8 27 | 28 | 2019-08-05 29 | 30 | #### 新增 31 | 32 | - 存管相关接口,证件上传、添加联系人、更新结算账号、结算账号更新手机号、结算账号验证打款 33 | 34 | ## 2.4.7 35 | 36 | 2019-05-30 37 | 38 | #### 新增 39 | 40 | - 分账接收方接口 41 | - 分账明细接口 42 | - 分账接口 43 | - 支行列表查询接口 (SubBank) 44 | 45 | ## 2.4.6 46 | 47 | 2018-12-28 48 | 49 | #### 修改 50 | 51 | - 更新取消签约接口,添加微信取消签约示例 52 | 53 | ## 2.4.5 54 | 55 | 2018-09-13 56 | 57 | #### 修改 58 | 59 | - 修复主版本号与tag不一致问题 60 | 61 | ## 2.4.4 62 | 63 | 2018-05-22 64 | 65 | #### 修改 66 | 67 | - 修复 sub_app 删除接口报错 68 | 69 | ## 2.4.3 70 | 71 | 2018-05-14 72 | 73 | #### 新增 74 | 75 | - 新增 balance settlements 对象查询和列表接口 76 | - 新增 card info 查询接口 77 | - 添加设置自定义 CA 证书路径方法 78 | - 微信小程序获取 openid 示例 79 | - 新增渠道签约接口 80 | 81 | #### 修改 82 | 83 | - 修复 user 对象id 值为`0` 的情况下转换后对象中没有id 84 | 85 | --- 86 | 87 | ## 2.4.2 88 | 89 | 2018-01-10 90 | 91 | #### 修改 92 | 93 | - 移除 transfer、batch transfer 的 cancel 接口 94 | - 示例:新增 charge 渠道 alipay_scan、wx_pub_scan、cb_alipay、cb_wx、cb_wx_pub、cb_wx_pub_qr、cb_wx_pub_scan 95 | - 示例:移除 order pay balance_amount 字段 96 | 97 | ## 2.4.1 98 | 99 | 2017-12-05 100 | 101 | #### 新增 102 | 103 | - 合并账户系统接口 104 | 105 | --- 106 | 107 | ## 2.2.3 108 | 109 | 2017-06-15 110 | 111 | #### 修改 112 | 113 | - 新增线下渠道 isv_scan、isv_qr、isv_wap 114 | - 新增 charge reverse 接口 115 | 116 | --- 117 | 118 | ## 2.2.2 119 | 120 | 2017-04-25 121 | 122 | #### 修改 123 | 124 | - 独立各个渠道文件并单独说明,提高 SDK 接入体验 125 | 126 | --- 127 | 128 | ## 2.2.1 129 | 130 | 2016-12-29 131 | 132 | #### 新增 133 | 134 | - batch_transfer 接口支持 cancel 操作(unionpay适用) 135 | 136 | --- 137 | 138 | ## 2.2.0 139 | 140 | 2016-12-16 141 | 142 | #### 新增 143 | 144 | - batch_transfer 接口 145 | - batch_refund 接口 146 | - customs 接口 147 | 148 | #### 修改 149 | 150 | - 删除 Customer、Card、CardInfo、Source、Token、SmsCode 151 | 152 | --- 153 | 154 | ## 2.1.5 155 | 156 | #### 新增 157 | 158 | - transfer 更新接口 159 | 160 | ## 2.1.4 161 | 162 | #### 新增 163 | 164 | - identification 接口 165 | 166 | ## 2.1.3 167 | 168 | #### 修改 169 | 170 | - 更正本地 CA 证书 171 | 172 | ## 2.1.2 173 | 174 | #### 修改 175 | 176 | - 更新本地 CA 证书 177 | - 添加请求签名 178 | 179 | ## 2.1.1 180 | 181 | #### 修改 182 | 183 | - 添加 PUT 方法 184 | - 添加 JSON 序列化方法 185 | 186 | ## 2.1.0 187 | 188 | #### 增加 189 | 190 | - 应用内快捷支付对应接口 191 | 192 | ## 2.0.7 193 | 194 | #### 修改 195 | 196 | - 补充 channel_error 错误类型 197 | 198 | ## 2.0.6 199 | 200 | #### 增加 201 | 202 | - 微信企业付款 transfer 203 | 204 | ## 2.0.5 205 | 206 | #### 增加 207 | 208 | - 京东手机网页支付 209 | - event 查询和 event 列表查询 210 | 211 | ## 2.0.4 212 | 213 | #### 更改 214 | 215 | - 微信公众号获取 JS-SDK 签名兼容 nginx 216 | 217 | ## 2.0.3 218 | 219 | #### 增加 220 | 221 | - 增加微信公众号获取 JS-SDK 签名的接口 222 | 223 | ## 2.0.2 224 | 225 | #### 增加 226 | 227 | - 新增微信红包 228 | 229 | ## 2.0.1 230 | 231 | #### 更改 232 | 233 | - 添加 composer 支持,调用方法变更,具体请参考 [example](/example) 234 | 235 | ## 2.0.0 236 | 237 | #### 更改 238 | 239 | - 添加新渠道:百付宝、百付宝WAP、微信公众号支付 240 | 241 | ## 1.0.4 242 | 243 | #### 更改 244 | 245 | - 移除旧的 refund 方法 246 | 247 | ## 1.0.3 248 | 249 | #### 更改 250 | 251 | - 所有 PingPP 改成 Pingpp 252 | - Pingpp_Object 转成 JSON 时,用 stdClass 代替 array 253 | 254 | ## 1.0.2 255 | 256 | #### 更改 257 | 258 | - cURL 使用 TLSv1.x 259 | -------------------------------------------------------------------------------- /example/webhooks.php: -------------------------------------------------------------------------------- 1 | 点击管理平台右上角公司名称->开发信息-> Ping++ 公钥 18 | */ 19 | function verify_signature($raw_data, $signature, $pub_key_path) 20 | { 21 | $pub_key_contents = file_get_contents($pub_key_path); 22 | return openssl_verify($raw_data, base64_decode($signature), $pub_key_contents, 'sha256'); 23 | } 24 | 25 | $raw_data = file_get_contents('php://input'); 26 | // 示例 27 | // $raw_data = '{"id":"evt_eYa58Wd44Glerl8AgfYfd1sL","created":1434368075,"livemode":true,"type":"charge.succeeded","data":{"object":{"id":"ch_bq9IHKnn6GnLzsS0swOujr4x","object":"charge","created":1434368069,"livemode":true,"paid":true,"refunded":false,"app":"app_vcPcqDeS88ixrPlu","channel":"wx","order_no":"2015d019f7cf6c0d","client_ip":"140.227.22.72","amount":100,"amount_settle":0,"currency":"cny","subject":"An Apple","body":"A Big Red Apple","extra":{},"time_paid":1434368074,"time_expire":1434455469,"time_settle":null,"transaction_no":"1014400031201506150354653857","refunds":{"object":"list","url":"/v1/charges/ch_bq9IHKnn6GnLzsS0swOujr4x/refunds","has_more":false,"data":[]},"amount_refunded":0,"failure_code":null,"failure_msg":null,"metadata":{},"credential":{},"description":null}},"object":"event","pending_webhooks":0,"request":"iar_Xc2SGjrbdmT0eeKWeCsvLhbL"}'; 28 | 29 | $headers = \Pingpp\Util\Util::getRequestHeaders(); 30 | // 签名在头部信息的 x-pingplusplus-signature 字段 31 | $signature = isset($headers['X-Pingplusplus-Signature']) ? $headers['X-Pingplusplus-Signature'] : null; 32 | // 示例 33 | // $signature = 'BX5sToHUzPSJvAfXqhtJicsuPjt3yvq804PguzLnMruCSvZ4C7xYS4trdg1blJPh26eeK/P2QfCCHpWKedsRS3bPKkjAvugnMKs+3Zs1k+PshAiZsET4sWPGNnf1E89Kh7/2XMa1mgbXtHt7zPNC4kamTqUL/QmEVI8LJNq7C9P3LR03kK2szJDhPzkWPgRyY2YpD2eq1aCJm0bkX9mBWTZdSYFhKt3vuM1Qjp5PWXk0tN5h9dNFqpisihK7XboB81poER2SmnZ8PIslzWu2iULM7VWxmEDA70JKBJFweqLCFBHRszA8Nt3AXF0z5qe61oH1oSUmtPwNhdQQ2G5X3g=='; 34 | 35 | // Ping++ 公钥,获取路径:登录 [Dashboard](https://dashboard.pingxx.com)->点击管理平台右上角公司名称->开发信息-> Ping++ 公钥 36 | $pub_key_path = __DIR__ . "/pingpp_rsa_public_key.pem"; 37 | 38 | $result = verify_signature($raw_data, $signature, $pub_key_path); 39 | if ($result === 1) { 40 | // 验证通过 41 | } elseif ($result === 0) { 42 | http_response_code(400); 43 | echo 'verification failed'; 44 | exit; 45 | } else { 46 | http_response_code(400); 47 | echo 'verification error'; 48 | exit; 49 | } 50 | 51 | $event = json_decode($raw_data, true); 52 | if ($event['type'] == 'charge.succeeded') { 53 | $charge = $event['data']['object']; 54 | // ... 55 | http_response_code(200); 56 | } elseif ($event['type'] == 'refund.succeeded') { 57 | $refund = $event['data']['object']; 58 | // ... 59 | http_response_code(200); 60 | } else { 61 | /** 62 | * 其它类型 ... 63 | * - summary.daily.available 64 | * - summary.weekly.available 65 | * - summary.monthly.available 66 | * - transfer.succeeded 67 | * - red_envelope.sent 68 | * - red_envelope.received 69 | * ... 70 | */ 71 | http_response_code(200); 72 | 73 | // 异常时返回非 2xx 的返回码 74 | // http_response_code(400); 75 | } 76 | -------------------------------------------------------------------------------- /lib/Pingpp.php: -------------------------------------------------------------------------------- 1 | '25OFF', // 优惠券模板名称 17 | 'type' => 2, // 优惠券模板的类型 1:现金券;2:折扣券 18 | 'percent_off' => 25, // 折扣百分比, 如 20 表示 8 折, 100 表示免费 19 | 'discount_amount_limit' => 10000, // 折扣上限,可选,仅 type 为 折扣券支持 20 | 'amount_available' => 10000, // 订单金额大于等于该值时,优惠券有效(适用于满减);0 表示无限制 21 | 'max_circulation' => 1000, // 优惠券最大生成数量,当已生成数量达到最大值时,不能再生成优惠券;默认 null,表示可以无限生成 22 | 'metadata' => [], // metadata 23 | 'expiration' => null // 优惠券模板过期策略 24 | ] 25 | ); 26 | echo $ct; // 输出 Ping++ 返回的 Coupon template 对象 27 | } catch (\Pingpp\Error\Base $e) { 28 | if ($e->getHttpStatus() != null) { 29 | header('Status: ' . $e->getHttpStatus()); 30 | echo $e->getHttpBody(); 31 | } else { 32 | echo $e->getMessage(); 33 | } 34 | } 35 | exit; 36 | 37 | 38 | //查询 Coupon template 对象 39 | $coupon_tmpl_id = '300216111711073000022301'; // ping++返回的优惠券模板 ID 40 | try { 41 | $ct = \Pingpp\CouponTemplate::retrieve($coupon_tmpl_id); 42 | echo $ct; 43 | } catch (\Pingpp\Error\Base $e) { 44 | if ($e->getHttpStatus() != null) { 45 | header('Status: ' . $e->getHttpStatus()); 46 | echo $e->getHttpBody(); 47 | } else { 48 | echo $e->getMessage(); 49 | } 50 | } 51 | exit; 52 | 53 | //更新 Coupon template 对象 54 | $coupon_tmpl_id = '300216111711073000022301'; // ping++返回的优惠券模板 ID 55 | try { 56 | $ct = \Pingpp\CouponTemplate::update($coupon_tmpl_id, [ 57 | 'metadata' => [ 58 | 'keys' => 'value', 59 | ] 60 | ]); 61 | echo $ret; 62 | } catch (\Pingpp\Error\Base $e) { 63 | if ($e->getHttpStatus() != null) { 64 | header('Status: ' . $e->getHttpStatus()); 65 | echo $e->getHttpBody(); 66 | } else { 67 | echo $e->getMessage(); 68 | } 69 | } 70 | exit; 71 | 72 | 73 | //删除 Coupon template 对象 74 | $coupon_tmpl_id = '300216111711073000022301'; // ping++返回的优惠券模板 ID 75 | try { 76 | $ct = \Pingpp\CouponTemplate::delete($coupon_tmpl_id); 77 | echo $ct; 78 | } catch (\Pingpp\Error\Base $e) { 79 | if ($e->getHttpStatus() != null) { 80 | header('Status: ' . $e->getHttpStatus()); 81 | echo $e->getHttpBody(); 82 | } else { 83 | echo $e->getMessage(); 84 | } 85 | } 86 | exit; 87 | 88 | //查询 Coupon template 对象列表 89 | $search_params = [ //搜索条件,此数组可以为空 90 | 'page' => 1, //页码,取值范围:1~1000000000;默认值为"1" 91 | 'per_page' => 2 //每页数量,取值范围:1~100;默认值为"20" 92 | ]; 93 | try { 94 | $ct_all = \Pingpp\CouponTemplate::all($search_params); 95 | echo $ct_all; // 输出 Ping++ 返回的 Coupon template 对象列表 96 | } catch (\Pingpp\Error\Base $e) { 97 | if ($e->getHttpStatus() != null) { 98 | header('Status: ' . $e->getHttpStatus()); 99 | echo $e->getHttpBody(); 100 | } else { 101 | echo $e->getMessage(); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /example/recharge/recharge.php: -------------------------------------------------------------------------------- 1 | 'user_test_01', 17 | 'charge' => [ 18 | 'amount' => 100, 19 | 'channel' => 'alipay_qr', 20 | 'order_no' => substr(md5(time()), 0, 10), 21 | 'subject' => 'Your subject', 22 | 'body' => 'Your recharge body', 23 | 'time_expire' => time()+ 3600, 24 | 'client_ip' => '127.0.0.1', 25 | 'extra' => [], 26 | ], 27 | // 'user_fee' => 0, 28 | 'balance_bonus' => [ 29 | 'amount' => 10, 30 | ], 31 | 'from_user' => 'user_test_01', 32 | 'description' => 'Your description', 33 | 'metadata' => [], 34 | ]); 35 | echo $or; 36 | } catch (\Pingpp\Error\Base $e) { 37 | // 捕获报错信息 38 | if ($e->getHttpStatus() != null) { 39 | echo $e->getHttpStatus() . PHP_EOL; 40 | echo $e->getHttpBody() . PHP_EOL; 41 | } else { 42 | echo $e->getMessage() . PHP_EOL; 43 | } 44 | } 45 | exit; 46 | 47 | //查询充值订单 48 | try { 49 | $recharge_info = \Pingpp\Recharge::retrieve('221170807730968330240000'); 50 | echo $recharge_info; 51 | } catch (\Pingpp\Error\Base $e) { 52 | // 捕获报错信息 53 | if ($e->getHttpStatus() != null) { 54 | echo $e->getHttpStatus() . PHP_EOL; 55 | echo $e->getHttpBody() . PHP_EOL; 56 | } else { 57 | echo $e->getMessage() . PHP_EOL; 58 | } 59 | } 60 | exit; 61 | 62 | //查询充值订单列表 63 | try { 64 | $params = [ 65 | 'page' => 1, 66 | 'per_page' => 100, 67 | ]; 68 | $recharge_list = \Pingpp\Recharge::all($params); 69 | echo $recharge_list; 70 | } catch (\Pingpp\Error\Base $e) { 71 | // 捕获报错信息 72 | if ($e->getHttpStatus() != null) { 73 | echo $e->getHttpStatus() . PHP_EOL; 74 | echo $e->getHttpBody() . PHP_EOL; 75 | } else { 76 | echo $e->getMessage() . PHP_EOL; 77 | } 78 | } 79 | exit; 80 | 81 | //创建充值退款 82 | try { 83 | $recharge_refund = \Pingpp\Recharge::refund('221170807730968330240000', [ 84 | 'description' => 'Rechage refund description', 85 | 'metadata' => [], 86 | ]); 87 | echo $recharge_refund; 88 | } catch (\Pingpp\Error\Base $e) { 89 | // 捕获报错信息 90 | if ($e->getHttpStatus() != null) { 91 | echo $e->getHttpStatus() . PHP_EOL; 92 | echo $e->getHttpBody() . PHP_EOL; 93 | } else { 94 | echo $e->getMessage() . PHP_EOL; 95 | } 96 | } 97 | exit; 98 | 99 | //查询充值退款 100 | try { 101 | $recharge_refund_info = \Pingpp\Recharge::refundRetrieve('221170807730968330240000', 're_iTqLaTe1WTmHvXjrv9i5C8G4'); 102 | echo $recharge_refund_info; 103 | } catch (\Pingpp\Error\Base $e) { 104 | // 捕获报错信息 105 | if ($e->getHttpStatus() != null) { 106 | echo $e->getHttpStatus() . PHP_EOL; 107 | echo $e->getHttpBody() . PHP_EOL; 108 | } else { 109 | echo $e->getMessage() . PHP_EOL; 110 | } 111 | } 112 | exit; 113 | 114 | //查询充值退款列表 115 | try { 116 | $recharge_refund_info = \Pingpp\Recharge::refundList('221170807730968330240000'); 117 | echo $recharge_refund_info; 118 | } catch (\Pingpp\Error\Base $e) { 119 | // 捕获报错信息 120 | if ($e->getHttpStatus() != null) { 121 | echo $e->getHttpStatus() . PHP_EOL; 122 | echo $e->getHttpBody() . PHP_EOL; 123 | } else { 124 | echo $e->getMessage() . PHP_EOL; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /lib/SettleAccount.php: -------------------------------------------------------------------------------- 1 | '300216111619300600019101', // 优惠券模版 ID 16 | ]; 17 | try { 18 | $cp = \Pingpp\Coupon::create($user_id, $params); 19 | echo $cp; 20 | } catch (\Pingpp\Error\Base $e) { 21 | if ($e->getHttpStatus() != null) { 22 | header('Status: ' . $e->getHttpStatus()); 23 | echo $e->getHttpBody(); 24 | } else { 25 | echo $e->getMessage(); 26 | } 27 | } 28 | exit; 29 | 30 | 31 | //查询 Coupon 对象 32 | $user_id = 'uid582d1756b1650'; // 用户 ID 33 | $coupon_id = '300416111711463500023901'; // 优惠券 ID 34 | try { 35 | $cp = \Pingpp\Coupon::retrieve($user_id, $coupon_id); 36 | echo $cp; 37 | } catch (\Pingpp\Error\Base $e) { 38 | if ($e->getHttpStatus() != null) { 39 | header('Status: ' . $e->getHttpStatus()); 40 | echo $e->getHttpBody(); 41 | } else { 42 | echo $e->getMessage(); 43 | } 44 | } 45 | exit; 46 | 47 | //更新 Coupon 对象 48 | $user_id = 'uid582d1756b1650'; // 用户 ID 49 | $coupon_id = '300416111711571500024101'; // 优惠券 ID 50 | $params = [ 51 | 'metadata' => [ 52 | 'key' => 'value' 53 | ] 54 | ]; 55 | try { 56 | $cp = \Pingpp\Coupon::update($user_id, $coupon_id, $params); 57 | } catch (\Pingpp\Error\Base $e) { 58 | if ($e->getHttpStatus() != null) { 59 | header('Status: ' . $e->getHttpStatus()); 60 | echo $e->getHttpBody(); 61 | } else { 62 | echo $e->getMessage(); 63 | } 64 | } 65 | exit; 66 | 67 | 68 | //删除 Coupon 对象 69 | $user_id = 'uid582d1756b1650'; // 用户 ID 70 | $coupon_id = '300416111711463500023901'; // 优惠券 ID 71 | try { 72 | $cp = \Pingpp\Coupon::delete($user_id, $coupon_id); 73 | } catch (\Pingpp\Error\Base $e) { 74 | if ($e->getHttpStatus() != null) { 75 | header('Status: ' . $e->getHttpStatus()); 76 | echo $e->getHttpBody(); 77 | } else { 78 | echo $e->getMessage(); 79 | } 80 | } 81 | exit; 82 | 83 | //查询 Coupon 对象列表 84 | $user_id = 'uid582d1756b1650'; // 用户 ID 85 | $search_params = [ //搜索条件,此数组可以为空 86 | 'page' => 1, //页码,取值范围:1~1000000000;默认值为"1" 87 | 'per_page' => 2 //每页数量,取值范围:1~100;默认值为"20" 88 | ]; 89 | try { 90 | $cp_all = \Pingpp\Coupon::all($user_id, $search_params); 91 | echo $cp_all; 92 | } catch (\Pingpp\Error\Base $e) { 93 | if ($e->getHttpStatus() != null) { 94 | header('Status: ' . $e->getHttpStatus()); 95 | echo $e->getHttpBody(); 96 | } else { 97 | echo $e->getMessage(); 98 | } 99 | } 100 | exit; 101 | 102 | //批量创建优惠券 103 | $coupon_tmpl_id = '300216111711085500022401'; // ping++返回的优惠券模板 ID 104 | $params = [ 105 | 'users' => [ 106 | 'uid582d1756b1650', 107 | 'user007@gmail.com', 108 | ] 109 | ]; 110 | try { 111 | $cp = \Pingpp\CouponTemplate::batchCreateCoupons($coupon_tmpl_id, $params); 112 | echo $cp; 113 | } catch (\Pingpp\Error\Base $e) { 114 | if ($e->getHttpStatus() != null) { 115 | header('Status: ' . $e->getHttpStatus()); 116 | echo $e->getHttpBody(); 117 | } else { 118 | echo $e->getMessage(); 119 | } 120 | } 121 | exit; 122 | 123 | 124 | //查询优惠券模板下的优惠券列表 125 | $coupon_tmpl_id = '300216111711085500022401'; // ping++返回的优惠券模板 ID 126 | try { 127 | $cp = \Pingpp\CouponTemplate::couponsList($coupon_tmpl_id); 128 | echo $cp; 129 | } catch (\Pingpp\Error\Base $e) { 130 | if ($e->getHttpStatus() != null) { 131 | header('Status: ' . $e->getHttpStatus()); 132 | echo $e->getHttpBody(); 133 | } else { 134 | echo $e->getMessage(); 135 | } 136 | } 137 | exit; 138 | -------------------------------------------------------------------------------- /example/order/royalty_template.php: -------------------------------------------------------------------------------- 1 | \Pingpp\Pingpp::getAppId(), //应用 ID 17 | 'name' => 'royalty_template_name', // 分润模板名称,允许中英文等常用字符 18 | 'rule' => [ 19 | 'royalty_mode' => 'rate', //分润模式。分为按订单金额(包含优惠券金额)的比例 rate 和固定金额 fixed 20 | 'refund_mode' => 'no_refund', //退分润模式。分为退款时不退分润 no_refund、按比例退分润 proportional 和一旦退款分润全退 full_refund 21 | 'allocation_mode' => 'receipt_reserved', //分配模式。指当订单确定的层级如果少于模板配置层级时,模板中多余的分润金额是归属于收款方 receipt_reserved 还是服务方 service_reserved。 22 | 'data' => [ 23 | [ 24 | 'level' => 1, //子商户层级值,0 表示平台, 1 表示一级子商户,取值范围 >=0 25 | 'value' => 30 //分润数值。rate 下取值为 0 - 10000,单位为 0.01 %,fixed 下取值为 0 - 1000000,单位为分 26 | ], 27 | ['level' => 2, 'value' => 20], 28 | ['level' => 3, 'value' => 10], 29 | ], 30 | ], 31 | 'description' => 'Your description', 32 | ] 33 | ); 34 | echo $royalty_template; 35 | } catch (\Pingpp\Error\Base $e) { 36 | // 捕获报错信息 37 | if ($e->getHttpStatus() != null) { 38 | echo $e->getHttpStatus() . PHP_EOL; 39 | echo $e->getHttpBody() . PHP_EOL; 40 | } else { 41 | echo $e->getMessage() . PHP_EOL; 42 | } 43 | } 44 | 45 | try { 46 | $royalty_tpl_info = \Pingpp\RoyaltyTemplate::update('451170807182300001', [ 47 | 'name' => 'royalty_template_name_new', // 分润模板名称,允许中英文等常用字符 48 | 'rule' => [ 49 | 'royalty_mode' => 'fixed', //分润模式。分为按订单金额(包含优惠券金额)的比例 rate 和固定金额 fixed 50 | 'refund_mode' => 'full_refund', //退分润模式。分为退款时不退分润 no_refund、按比例退分润 proportional 和一旦退款分润全退 full_refund 51 | 'allocation_mode' => 'service_reserved', //分配模式。指当订单确定的层级如果少于模板配置层级时,模板中多余的分润金额是归属于收款方 receipt_reserved 还是服务方 service_reserved。 52 | 'data' => [ 53 | [ 54 | 'level' => 1, //子商户层级值,0 表示平台, 1 表示一级子商户,取值范围 >=0 55 | 'value' => 33 //分润数值。rate 下取值为 0 - 10000,单位为 0.01 %,fixed 下取值为 0 - 1000000,单位为分 56 | ], 57 | ['level' => 2, 'value' => 22], 58 | ['level' => 3, 'value' => 11], 59 | ], 60 | ], 61 | 'description' => 'Your description', 62 | ]); 63 | echo $royalty_tpl_info; 64 | } catch (\Pingpp\Error\Base $e) { 65 | // 捕获报错信息 66 | if ($e->getHttpStatus() != null) { 67 | echo $e->getHttpStatus() . PHP_EOL; 68 | echo $e->getHttpBody() . PHP_EOL; 69 | } else { 70 | echo $e->getMessage() . PHP_EOL; 71 | } 72 | } 73 | 74 | try { 75 | $royalty_tpl_info = \Pingpp\RoyaltyTemplate::retrieve('451170807182300001'); 76 | echo $royalty_tpl_info; 77 | } catch (\Pingpp\Error\Base $e) { 78 | // 捕获报错信息 79 | if ($e->getHttpStatus() != null) { 80 | echo $e->getHttpStatus() . PHP_EOL; 81 | echo $e->getHttpBody() . PHP_EOL; 82 | } else { 83 | echo $e->getMessage() . PHP_EOL; 84 | } 85 | } 86 | 87 | try { 88 | $royalty_tpl_info = \Pingpp\RoyaltyTemplate::delete('451170807182300001'); 89 | echo $royalty_tpl_info; 90 | } catch (\Pingpp\Error\Base $e) { 91 | // 捕获报错信息 92 | if ($e->getHttpStatus() != null) { 93 | echo $e->getHttpStatus() . PHP_EOL; 94 | echo $e->getHttpBody() . PHP_EOL; 95 | } else { 96 | echo $e->getMessage() . PHP_EOL; 97 | } 98 | } 99 | 100 | 101 | try { 102 | $params = [ 103 | 'page' => 1, 104 | 'per_page' => 10, 105 | ]; 106 | $royalty_tpl_info = \Pingpp\RoyaltyTemplate::all($params); 107 | echo $royalty_tpl_info; 108 | } catch (\Pingpp\Error\Base $e) { 109 | // 捕获报错信息 110 | if ($e->getHttpStatus() != null) { 111 | echo $e->getHttpStatus() . PHP_EOL; 112 | echo $e->getHttpBody() . PHP_EOL; 113 | } else { 114 | echo $e->getMessage() . PHP_EOL; 115 | } 116 | } 117 | --------------------------------------------------------------------------------