如何将likeshop商城小程序接入富友第三方支付?

2026-03-27 06:031阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计681个文字,预计阅读时间需要3分钟。

如何将likeshop商城小程序接入富友第三方支付?

likeshop商城小程序接入富友支付功能,需使用富友第三方插件。开发步骤:一、订单支付插件接口;二、封装报文;三、打开富友插件。详情:https://mp.weixin.qq.com/wxopen/wxopen%E2%80%9D

likeshop商城小程序接入富友支付的小程序支付功能需要用到富友的第三方插件

一、开发步骤
第一步:订单支付插件接口-封装报文;
第二步:打开富友插件:mp.weixin.qq.com/wxopen/plugindevdoc?appid=wxe2ae77d4cbb8abf0&token=158753519&lang=zh_CN,
第三步:小程序加入富友插件代码,把第一步封装的密文报文丢进插件方法体里面-插件方法里有示例
第四步:就可以拉起支付了


二、likeshop前端代码修改:

1.uniapp\manifest.json文件里153行加入

"plugins" : { "fuiou-pay" : { "version" : "latest", "provider" : "富友小程序的APPID" } },

2.uniapp/utils/pay.js文件里的最底部112行加入:

如何将likeshop商城小程序接入富友第三方支付?

//富友支付 export function getFuioupay(opt) { const plugin = requirePlugin('fuiou-pay') plugin.fuioupay({ fee: opt.amount, // 支付金额(分为单位)传1就是1分钱 mchnt_cd: opt.mchnt_cd, // 商家id message: opt.message, // 加密参数(通过接口获取) log: true, // 是否开启组件内log }) .then(res => { console.log(res) console.log("支付成功!"); }) .catch(e => { // e.message 代码错误 console.error(e); }) }

3.uniapp/pages/payment/payment.vue文件里加入

import { wxpay, alipay, getFuioupay } from "@/utils/pay";

161行:

case 30001: this.handleFuiouPay(data); break;

173行:

// 富友支付 handleFuiouPay(data) { getFuioupay(data) .then((res) => { console.log(res); console.log("支付成功了"); //支付成功 this.handPayResult("success"); }) .catch((err) => { console.log("支付失败了"); console.log(err); }); },

三、likeshop后端代码修改:

1.在server\app\api\controller里的pay.php文件的89行加入:

case OrderEnum::PAY_WAY_FUIOUPAY://富友支付 $result = PayLogic::fuiouPay($post['order_id'], $post['from'],$this->client); $data = [ 'code' => 30001, 'msg' => '发起成功', 'data' => $result, 'show' => 0, ]; return json($data); break;

2.在server\app\api\logic里的OrderLogic.php文件的1752行加入:

if ($item['code'] == 'fuioupay') { $item['extra'] = '富友支付'; $item['pay_way'] = PayEnum::FUIOU_PAY; }

3.在server\app\api\logic里的PayLogic.php文件的385行加入:

/** * @notes 富友支付 * @param $order_id * @param $from * @param $client * @return bool|string * @author kinko */ public static function fuiouPay($order_id, $form, $client) { switch ($form) { case "trade": $order = OrderTrade::find($order_id); if (self::checkPayStatus($order_id)) { $order['pay_status'] = PayEnum::ISPAID; } break; case "order": $order = Order::where([ ['del', '=', 0], ['id', '=', $order_id] ])->find(); break; case "recharge": $order = RechargeOrder::where([ ['id', '=', $order_id] ])->find(); break; case "integral": $order = IntegralOrder::where(['del' => 0, 'id' => $order_id])->find(); break; } if (empty($order)) { return JsonServer::error('订单不存在'); } if (isset($order['pay_status']) && $order['pay_status'] == PayEnum::ISPAID) { return JsonServer::error('订单已支付'); } // 富友支付 $fuiouPay = new FuiouPayServer(); $res = $fuiouPay->pay($from , $order , $client); return $res; if (false === $res) { return JsonServer::error(WeChatPayServer::getError()); } if ((is_object($res) || is_string($res)) && $client != Client_::pc) { $res = (array)($res); } if (is_string($res)) { $data = [ 'code' => 1, 'msg' => '富友支付发起成功', 'show' => 0, 'data' => $res ]; return json($data); } return JsonServer::success('富友支付发起成功', $res, 1); }

四、整体流程图

标签:第三方

本文共计681个文字,预计阅读时间需要3分钟。

如何将likeshop商城小程序接入富友第三方支付?

likeshop商城小程序接入富友支付功能,需使用富友第三方插件。开发步骤:一、订单支付插件接口;二、封装报文;三、打开富友插件。详情:https://mp.weixin.qq.com/wxopen/wxopen%E2%80%9D

likeshop商城小程序接入富友支付的小程序支付功能需要用到富友的第三方插件

一、开发步骤
第一步:订单支付插件接口-封装报文;
第二步:打开富友插件:mp.weixin.qq.com/wxopen/plugindevdoc?appid=wxe2ae77d4cbb8abf0&token=158753519&lang=zh_CN,
第三步:小程序加入富友插件代码,把第一步封装的密文报文丢进插件方法体里面-插件方法里有示例
第四步:就可以拉起支付了


二、likeshop前端代码修改:

1.uniapp\manifest.json文件里153行加入

"plugins" : { "fuiou-pay" : { "version" : "latest", "provider" : "富友小程序的APPID" } },

2.uniapp/utils/pay.js文件里的最底部112行加入:

如何将likeshop商城小程序接入富友第三方支付?

//富友支付 export function getFuioupay(opt) { const plugin = requirePlugin('fuiou-pay') plugin.fuioupay({ fee: opt.amount, // 支付金额(分为单位)传1就是1分钱 mchnt_cd: opt.mchnt_cd, // 商家id message: opt.message, // 加密参数(通过接口获取) log: true, // 是否开启组件内log }) .then(res => { console.log(res) console.log("支付成功!"); }) .catch(e => { // e.message 代码错误 console.error(e); }) }

3.uniapp/pages/payment/payment.vue文件里加入

import { wxpay, alipay, getFuioupay } from "@/utils/pay";

161行:

case 30001: this.handleFuiouPay(data); break;

173行:

// 富友支付 handleFuiouPay(data) { getFuioupay(data) .then((res) => { console.log(res); console.log("支付成功了"); //支付成功 this.handPayResult("success"); }) .catch((err) => { console.log("支付失败了"); console.log(err); }); },

三、likeshop后端代码修改:

1.在server\app\api\controller里的pay.php文件的89行加入:

case OrderEnum::PAY_WAY_FUIOUPAY://富友支付 $result = PayLogic::fuiouPay($post['order_id'], $post['from'],$this->client); $data = [ 'code' => 30001, 'msg' => '发起成功', 'data' => $result, 'show' => 0, ]; return json($data); break;

2.在server\app\api\logic里的OrderLogic.php文件的1752行加入:

if ($item['code'] == 'fuioupay') { $item['extra'] = '富友支付'; $item['pay_way'] = PayEnum::FUIOU_PAY; }

3.在server\app\api\logic里的PayLogic.php文件的385行加入:

/** * @notes 富友支付 * @param $order_id * @param $from * @param $client * @return bool|string * @author kinko */ public static function fuiouPay($order_id, $form, $client) { switch ($form) { case "trade": $order = OrderTrade::find($order_id); if (self::checkPayStatus($order_id)) { $order['pay_status'] = PayEnum::ISPAID; } break; case "order": $order = Order::where([ ['del', '=', 0], ['id', '=', $order_id] ])->find(); break; case "recharge": $order = RechargeOrder::where([ ['id', '=', $order_id] ])->find(); break; case "integral": $order = IntegralOrder::where(['del' => 0, 'id' => $order_id])->find(); break; } if (empty($order)) { return JsonServer::error('订单不存在'); } if (isset($order['pay_status']) && $order['pay_status'] == PayEnum::ISPAID) { return JsonServer::error('订单已支付'); } // 富友支付 $fuiouPay = new FuiouPayServer(); $res = $fuiouPay->pay($from , $order , $client); return $res; if (false === $res) { return JsonServer::error(WeChatPayServer::getError()); } if ((is_object($res) || is_string($res)) && $client != Client_::pc) { $res = (array)($res); } if (is_string($res)) { $data = [ 'code' => 1, 'msg' => '富友支付发起成功', 'show' => 0, 'data' => $res ]; return json($data); } return JsonServer::success('富友支付发起成功', $res, 1); }

四、整体流程图

标签:第三方