You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
4.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace ali\alipay\pay;
use Alipay\EasySDK\Kernel\Factory;
class Fund extends \ali\alipay\Base
{
//-----企业开发者若涉及 资金类支出接口 接入,必须使用 公钥证书 方式。个人开发者不涉及到资金类接口,建议使用 公钥方式 进行加签。-----//
/**
* 单笔转账接口接口名称alipay.fund.trans.uni.transfer
* @param string $order_number 商家侧唯一订单号,由商家自定义。对于不同转账请求,商家需保证该订单号在自身系统唯一。
* @param string $ali_pay_account 参与方的唯一标识
* @param string $ali_pay_name 参与方真实姓名如果非空将校验收款支付宝账号姓名一致性。当identity_type=ALIPAY_LOGON_ID时本字段必填。
* @param float $money 订单总金额单位为元精确到小数点后两位STD_RED_PACKET产品取值范围[0.01,100000000]TRANS_ACCOUNT_NO_PWD产品取值范围[0.1,100000000]
* @param string $desc 转账业务的标题,用于在支付宝用户的账单里显示
* @date 2021-10-25
*/
public function transfer($order_number, $ali_pay_account, $ali_pay_name, $money, $desc = '支付宝转账')
{
Factory::setOptions($this->getOptions());
$data = [
'out_biz_no' => $order_number,
'trans_amount' => round($money, 2),
'product_code' => 'TRANS_ACCOUNT_NO_PWD', //业务产品码,单笔无密转账到支付宝账户固定为:TRANS_ACCOUNT_NO_PWD收发现金红包固定为:STD_RED_PACKET
'biz_scene' => 'DIRECT_TRANSFER', //描述特定的业务场景DIRECT_TRANSFER--单笔无密转账到支付宝B2C现金红包 PERSONAL_COLLECTION--C2C现金红包-领红包
'order_title' => $desc,
'payee_info' => [ //收款方信息
'identity_type' => 'ALIPAY_LOGON_ID', //参与方的标识类型,目前支持如下类型 ALIPAY_USER_ID--支付宝的会员ID ALIPAY_LOGON_ID--支付宝登录号,支持邮箱和手机号格式
'identity' => $ali_pay_account,
'name' => $ali_pay_name
]
];
$result = Factory::util()->generic()->execute('alipay.fund.trans.uni.transfer', [], $data);
$result = $result->toMap();
$result['http_body'] = json_decode($result['http_body'], true);
// 记录日志
$uid = defined('UID') ? UID : '';
platformLog($data, $result['http_body']['alipay_fund_trans_uni_transfer_response'], 'alipaysdk_pay_transfer_uid_' . $uid);
return $result['http_body']['alipay_fund_trans_uni_transfer_response'];
}
/**
* 单笔转账接口,通过支付宝userID接口名称alipay.fund.trans.uni.transfer
* @param string $order_number 商家侧唯一订单号,由商家自定义。对于不同转账请求,商家需保证该订单号在自身系统唯一。
* @param string $alipay_openid 参与方的唯一标识
* @param float $money 订单总金额单位为元精确到小数点后两位STD_RED_PACKET产品取值范围[0.01,100000000]TRANS_ACCOUNT_NO_PWD产品取值范围[0.1,100000000]
* @param string $desc 转账业务的标题,用于在支付宝用户的账单里显示
* @date 2021-10-25
*/
public function transferByOpenid($order_number, $alipay_openid, $money, $desc = '支付宝转账')
{
Factory::setOptions($this->getOptions());
$data = [
'out_biz_no' => $order_number,
'trans_amount' => round($money, 2),
'product_code' => 'TRANS_ACCOUNT_NO_PWD', //业务产品码,单笔无密转账到支付宝账户固定为:TRANS_ACCOUNT_NO_PWD收发现金红包固定为:STD_RED_PACKET
'biz_scene' => 'DIRECT_TRANSFER', //描述特定的业务场景DIRECT_TRANSFER--单笔无密转账到支付宝B2C现金红包 PERSONAL_COLLECTION--C2C现金红包-领红包
'order_title' => $desc,
'payee_info' => [ //收款方信息
'identity_type' => 'ALIPAY_USER_ID', //参与方的标识类型,目前支持如下类型 ALIPAY_USER_ID--支付宝的会员ID ALIPAY_LOGON_ID--支付宝登录号,支持邮箱和手机号格式
'identity' => $alipay_openid
]
];
$result = Factory::util()->generic()->execute('alipay.fund.trans.uni.transfer', [], $data);
$result = $result->toMap();
$result['http_body'] = json_decode($result['http_body'], true);
// 记录日志
$uid = defined('UID') ? UID : '';
platformLog($data, $result['http_body']['alipay_fund_trans_uni_transfer_response'], 'alipaysdk_pay_transfer_by_openid_uid_' . $uid);
return $result['http_body']['alipay_fund_trans_uni_transfer_response'];
}
}