在基于 riverslei/payment 实现支付宝手机网页支付时,报错:implode(): Passing glue string after array is deprecated. Swap the parameters
1、在基于 riverslei/payment 实现支付宝手机网页支付时,报错:implode(): Passing glue string after array is deprecated. Swap the parameters。如图1
2、查看 vendor/riverslei/payment/src/Gateways/Alipay/WapCharge.php 的第 59 行 implode(self::$config->get(‘limit_pay’, ”), ‘,’)
$bizContent = [ 'body' => $requestParams['body'] ?? '', 'subject' => $requestParams['subject'] ?? '', 'out_trade_no' => $requestParams['trade_no'] ?? '', 'timeout_express' => $timeoutExp, 'time_expire' => $timeExpire ? date('Y-m-d H:i', $timeExpire) : '', 'total_amount' => $requestParams['amount'] ?? '', 'auth_token' => $requestParams['auth_token'] ?? '', 'goods_type' => $requestParams['goods_type'] ?? '', 'passback_params' => $requestParams['return_params'] ?? '', 'quit_url' => $requestParams['quit_url'] ?? '', 'product_code' => 'QUICK_WAP_WAY', 'promo_params' => $requestParams['promo_params'] ?? '', 'extend_params' => $requestParams['extend_params'] ?? '', // 使用禁用列表 //'enable_pay_channels' => '', 'disable_pay_channels' => implode(self::$config->get('limit_pay', ''), ','), 'store_id' => $requestParams['store_id'] ?? '', 'specified_channel' => $requestParams['specified_channel'] ?? 'pcredit', //支付宝原因,当前仅支持 pcredit 'business_params' => $requestParams['business_params'] ?? '', 'ext_user_info' => $requestParams['ext_user_info'] ?? '', ];
3、我本地环境是 PHP 7.4.33,预期是不会报此错误的。这个弃用(deprecation warning)是从 PHP 8.2 才开始引入的。在 PHP 7.4 中,implode($array, ‘,’) 虽然参数顺序是反的,但依然是合法的写法,不会触发警告。
$aliConfig = [ 'use_sandbox' => true, // 是否使用沙盒模式 'app_id' => $payee->ali_app_id, 'sign_type' => $payee->ali_sign_type, // RSA RSA2 // 支付宝公钥字符串 'ali_public_key' => $payee->ali_public_key, // 自己生成的密钥字符串 'rsa_private_key' => $payee->ali_rsa_private_key, 'limit_pay' => [ 'balance', // 余额 'moneyFund', // 余额宝 'debitCardExpress', // 借记卡快捷 // 'creditCard', // 信用卡 // 'creditCardExpress', // 信用卡快捷 // 'creditCardCartoon', // 信用卡卡通 // 'credit_group', // 信用支付类型(包含信用卡卡通、信用卡快捷、花呗、花呗分期) ], // 用户不可用指定渠道支付当有多个渠道时用“,”分隔 // 与业务相关参数 // 'notify_url' => 'https://api.kuaihuiwu.com/payment/alipay-notify-ticket-order/' . $order->id, 'notify_url' => 'https://api.kuaihuiwu.com/payment/alipay-notify-ticket-order/' . $order->id, 'return_url' => $this->request->post('return_url', ''), 'fee_type' => 'CNY', // 货币类型 当前仅支持该字段 ];
4、虽然 PHP 7.4 默认不报这个 warning,但一些框架(比如 Yii2)或 ErrorHandler 类可能手动检查并抛出这类 warning 用于兼容未来版本。#0 [internal function]: yii\base\ErrorHandler->handleError(8192, …
5、最终决定编辑 php.ini,临时修复。后续计划使用 cweagans/composer-patches 维护 patch,或 fork 这个库修复之后使用自己的版本。
error_reporting = E_ALL & ~E_DEPRECATED
近期评论