PayFactory.php 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2017/3/17
  6. * Time: 下午1:34
  7. */
  8. namespace app\common\services;
  9. use app\common\exceptions\AppException;
  10. use app\common\services\alipay\AlipayFacePayService;
  11. use app\common\services\alipay\AlipayJsapiPayService;
  12. use app\common\services\alipay\AlipayScanPayService;
  13. use app\common\services\payment\WechatMinPay;
  14. use app\common\services\wechat\HkScanPayService;
  15. use app\common\services\wechat\WechatJsapiPayService;
  16. use Yunshop\DianBangScan\services\DianBangScanService;
  17. use app\common\services\wechat\WechatFacePayService;
  18. use app\common\services\wechat\WechatScanPayService;
  19. use Yunshop\HkPay\services\HkScanAliPayService;
  20. use Yunshop\LoveSpeedPool\service\LSPPay;
  21. use Yunshop\MinApp\Common\Services\WeChatAppletPay;
  22. use Yunshop\StoreBalance\services\StoreBalancePay;
  23. use Yunshop\AppSet\common\services\WeChatAppPay;
  24. class PayFactory
  25. {
  26. /**
  27. * 微信
  28. */
  29. const PAY_WEACHAT = 1;
  30. /**
  31. * 支付宝
  32. */
  33. const PAY_ALIPAY = 2;
  34. /**
  35. * 余额
  36. */
  37. const PAY_CREDIT = 3;
  38. /**
  39. * 后台付款
  40. */
  41. const PAY_BACKEND = 5;
  42. /**
  43. * 云收银-微信
  44. */
  45. const PAY_CLOUD_WEACHAT = 6;
  46. /**
  47. * 云收银-支付宝
  48. */
  49. const PAY_CLOUD_ALIPAY = 7;
  50. /**
  51. * 现金支付
  52. */
  53. const PAY_CASH = 8;
  54. /**
  55. * APP-微信
  56. */
  57. const PAY_APP_WEACHAT = 9;
  58. /**
  59. * APP-支付宝
  60. */
  61. const PAY_APP_ALIPAY = 10;
  62. /**
  63. * 门店支付
  64. */
  65. const PAY_STORE = 11;
  66. /**
  67. * 微信-YZ
  68. */
  69. const PAY_YUN_WEACHAT = 12;
  70. /**
  71. * 支付宝-YZ
  72. */
  73. const PAY_YUN_ALIPAY = 15;
  74. /**
  75. * 转账
  76. */
  77. const PAY_REMITTANCE = 16;
  78. /**
  79. * 货到付款
  80. */
  81. const PAY_COD = 17;
  82. /**
  83. * 环迅快捷支付
  84. */
  85. const PAY_Huanxun_Quick = 18;
  86. /**
  87. * EUP-支付
  88. */
  89. const PAY_EUP = 19;
  90. /**
  91. *威富通公众号支付
  92. */
  93. const WFT_PAY = 20;
  94. /**
  95. *威富通支付宝支付
  96. */
  97. const WFT_ALIPAY = 21;
  98. /**
  99. * 环迅微信支付
  100. */
  101. const PAY_Huanxun_Wx = 22;
  102. /**
  103. * PLD-支付 达人链
  104. */
  105. const PAY_PLD = 23;
  106. /**
  107. * DIANBANG-支付 店帮扫码支付
  108. */
  109. const PAY_DIANBANG = 24;
  110. /**
  111. * 店帮支付的分账
  112. */
  113. const PAY_SEPARATE = 25;
  114. /**
  115. * 易宝支付
  116. */
  117. const YOP = 26;
  118. /**
  119. * Usdt支付
  120. */
  121. const PAY_Usdt = 27;
  122. /**
  123. * 微信支付-HJ(汇聚)
  124. */
  125. const PAY_WECHAT_HJ = 28;
  126. /**
  127. * 支付宝支付-HJ(汇聚)
  128. */
  129. const PAY_ALIPAY_HJ = 29;
  130. const PAY_WE_CHAT_APPLET = 30;
  131. /**
  132. * 团队奖励预存款支付
  133. */
  134. const PAY_TEAM_DEPOSIT = 31;
  135. /**
  136. * 易宝用户扫码支付宝支付
  137. */
  138. const YOP_ALIPAY = 32;
  139. /**
  140. * 崛企 微信端支付
  141. */
  142. const PAY_WECHAT_JUEQI = 33;
  143. /**
  144. * 微信扫码支付-HJ(汇聚)客户主扫
  145. */
  146. const PAY_WECHAT_SCAN_HJ = 34;
  147. /**
  148. * 支付宝扫码支付-HJ(汇聚)客户主扫
  149. */
  150. const PAY_ALIPAY_SCAN_HJ = 35;
  151. /**
  152. * 微信人脸支付-HJ(汇聚)
  153. */
  154. const PAY_WECHAT_FACE_HJ = 36;
  155. /**
  156. * 支付宝人脸支付-HJ(汇聚)
  157. */
  158. const PAY_ALIPAY_FACE_HJ = 37;
  159. /**
  160. * 微信扫码支付 客户主扫
  161. */
  162. const WECHAT_SCAN_PAY = 38;
  163. /**
  164. * 微信人脸支付
  165. */
  166. const WECHAT_FACE_PAY = 39;
  167. /**
  168. * 支付宝扫码支付 客户主扫
  169. */
  170. const ALIPAY_SCAN_PAY = 40;
  171. /**
  172. * 支付宝人脸支付
  173. */
  174. const ALIPAY_FACE_PAY = 41;
  175. /**
  176. * 为农 电子钱包-余额支付
  177. */
  178. const LCG_BALANCE = 42;
  179. /**
  180. * 为农 电子钱包-绑定卡支付
  181. */
  182. const LCG_BANK_CARD = 43;
  183. /**
  184. * 微信扫码支付-(易宝)客户主扫
  185. */
  186. const YOP_WECHAT_SCAN = 44;
  187. /**
  188. * 支付宝扫码支付-(易宝)客户主扫
  189. */
  190. const YOP_ALIPAY_SCAN = 45;
  191. /**
  192. * 微信人脸支付-HJ(易宝)
  193. */
  194. const YOP_WECHAT_FACE = 46;
  195. /**
  196. * 支付宝人脸支付-HJ(易宝)
  197. */
  198. const YOP_ALIPAY_FACE = 47;
  199. /**
  200. * 微信JSAPI支付(服务商)
  201. */
  202. const WECHAT_JSAPI_PAY = 48;
  203. /**
  204. * 支付宝JSAPI支付(服务商)
  205. */
  206. const ALIPAY_JSAPI_PAY = 49;
  207. /**
  208. * 微信H5支付
  209. */
  210. const WECHAT_H5 = 50;
  211. /**
  212. * 头条--微信支付
  213. */
  214. const PAY_WECHAT_TOUTIAO = 51;
  215. /**
  216. * 头条--支付宝支付
  217. */
  218. const PAY_ALIPAY_TOUTIAO = 52;
  219. /**
  220. * 会员卡--余额支付
  221. */
  222. const MEMBER_CARD_PAY = 53;
  223. /**
  224. * 确认支付(支付金额为0)
  225. */
  226. const CONFIRM_PAY = 54;
  227. /**
  228. * 微信小程序支付
  229. */
  230. const WECHAT_MIN_PAY = 55;
  231. /**
  232. * 港版支付(微信扫码支付)
  233. */
  234. const HK_SCAN_PAY = 56;
  235. /**
  236. * 微信扫码支付
  237. */
  238. const WECHAT_NATIVE = 57;
  239. /**
  240. * PayPal 支付
  241. */
  242. const PAY_PAL = 58;
  243. /**
  244. * 汇聚快捷支付
  245. */
  246. const CONVERGE_QUICK_PAY = 59;
  247. /**
  248. * 易宝专业版-公众号支付
  249. */
  250. const YOP_PRO_WECHAT = 60;
  251. /**
  252. * 易宝专业版-支宝付扫码支付
  253. */
  254. const YOP_PRO_ALIPAY = 61;
  255. /**
  256. * 港版支付(支付宝扫码支付)
  257. */
  258. const HK_SCAN_ALIPAY = 62;
  259. /**
  260. * 微信支付-聚合支付(门店)
  261. */
  262. const STORE_AGGREGATE_WECHAT = 63;
  263. /**
  264. * 支付宝支付-聚合支付(门店)
  265. */
  266. const STORE_AGGREGATE_ALIPAY = 64;
  267. /**
  268. * 扫码支付-聚合支付(门店)
  269. */
  270. const STORE_AGGREGATE_SCAN = 65;
  271. const PAY_WE_CHAT_APP = 66;
  272. /**
  273. * 易宝代付
  274. */
  275. const YEE_PAY = 67;
  276. /**
  277. * DCM扫码支付
  278. */
  279. const DCM_SCAN_PAY = 68;
  280. /**
  281. * 高灯
  282. */
  283. const HIGH_LIGHT = 69;
  284. /**
  285. * 微信APP支付
  286. */
  287. const WECHAT_CPS_APP_PAY = 71;
  288. /**
  289. * 微信付款码支付
  290. */
  291. const WECHAT_MICRO_PAY = 73;
  292. /**
  293. * 汇聚分账支付
  294. */
  295. const PAY_SEPARATE_HJ = 75; //微信
  296. const PAY_ALI_SEPARATE_HJ = 76; //支付宝
  297. /**
  298. * 商云客聚合支付
  299. */
  300. const XFPAY_WECHAT = 78; // 商云客微信
  301. const XFPAY_ALIPAY = 79; // 商云客支付宝
  302. /**
  303. * 门店余额支付
  304. */
  305. const STORE_BALANCE_PAY = 80;
  306. /**
  307. * 杉德支付
  308. */
  309. const SANDPAY_ALIPAY = 81; // 杉德支付宝
  310. const SANDPAY_WECHAT = 82; // 杉德微信支付
  311. /**
  312. * 拉卡拉支付
  313. */
  314. const LAKALA_WECHAT = 83; // 拉卡拉微信支付
  315. const LAKALA_ALIPAY = 84; // 拉卡拉支付宝支付
  316. /**
  317. * 乐刷支付
  318. */
  319. const LESHUA_ALIPAY = 85; // 乐刷聚合支付-微信
  320. const LESHUA_WECHAT = 86; // 乐刷聚合支付-支付宝
  321. const LESHUA_POS = 87; // 乐刷聚合支付-扫码支付
  322. const LSP_PAY = 88; // 加速池通证支付
  323. const CONVERGE_ALIPAY_H5_PAY = 89; //汇聚支付宝H5支付
  324. const WORK_WITHDRAW_PAY = 90; //好灵工
  325. const CONVERGE_UNION_PAY = 91; //汇聚云闪付支付
  326. const WECHAT_TRADE_PAY = 92; //微信支付(视频号)
  327. const CONVERGE_WECHAT_CARD_PAY = 94; //汇聚支付-微信付款码
  328. const CONVERGE_ALIPAY_CARD_PAY = 95; //汇聚支付-支付宝付款码
  329. /**
  330. * 银典支付
  331. */
  332. const SILVER_POINT_ALIPAY = 96; // 支付宝-银典支付
  333. const SILVER_POINT_WECHAT = 97; // 微信-银典支付
  334. const SILVER_POINT_UNION = 98; // 银联快捷-银典支付
  335. /**
  336. * 码科支付
  337. */
  338. const CODE_SCIENCE_PAY_YU = 99; // 豫章行代金券支付
  339. const EPLUS_ALI_PAY = 100; //智E+支付宝支付
  340. const EPLUS_WECHAT_PAY = 101; //智E+微信公众号支付
  341. const EPLUS_MINI_PAY = 102; //智E+微信小程序支付
  342. const LSP_WALLET_PAY = 103; //加速池爱心值-钱包支付
  343. const JINEPAY = 104; //锦银E付
  344. const AUTH_PAY = 105; //借权支付
  345. const SILVER_POINT_PAYMENT = 106; //银典支付:代付
  346. const THIRD_PARTY_MINI_PAY = 107;//第三方小程序支付(由第三方小程序发起小程序支付,第三方通知我们支付结果)
  347. public static function create($type = null)
  348. {
  349. $className = null;
  350. switch ($type) {
  351. case self::PAY_APP_WEACHAT:
  352. case self::WECHAT_CPS_APP_PAY:
  353. case self::PAY_WEACHAT:
  354. $className = new WechatPay();
  355. break;
  356. case self::WECHAT_MIN_PAY:
  357. $className = new WechatMinPay();
  358. break;
  359. case self::PAY_APP_ALIPAY:
  360. case self::PAY_ALIPAY:
  361. $className = new AliPay();
  362. break;
  363. case self::PAY_CREDIT:
  364. $className = new CreditPay();
  365. break;
  366. case self::PAY_BACKEND:
  367. $className = new BackendPay();
  368. break;
  369. case self::PAY_CASH:
  370. $className = new CashPay();
  371. break;
  372. case self::PAY_CLOUD_WEACHAT:
  373. case self::PAY_CLOUD_ALIPAY:
  374. if (!app('plugins')->isEnabled('cloud-pay')) {
  375. throw new AppException('插件未开启');
  376. }
  377. $className = new \Yunshop\CloudPay\services\CloudPayService();
  378. break;
  379. case self::PAY_STORE:
  380. $className = new StorePay();
  381. break;
  382. case self::PAY_YUN_WEACHAT:
  383. case self::PAY_YUN_ALIPAY:
  384. if (!app('plugins')->isEnabled('yun-pay')) {
  385. throw new AppException('插件未开启');
  386. }
  387. $className = new \Yunshop\YunPay\services\YunPayService();
  388. break;
  389. case self::PAY_Huanxun_Quick:
  390. case self::PAY_Huanxun_Wx:
  391. if (!app('plugins')->isEnabled('huanxun')) {
  392. throw new AppException('插件未开启');
  393. }
  394. $className = new \Yunshop\Huanxun\services\HuanxunPayService();
  395. break;
  396. case self::PAY_EUP:
  397. if (!app('plugins')->isEnabled('eup-pay')) {
  398. throw new AppException('插件未开启');
  399. }
  400. $className = new \Yunshop\EupPay\services\EupWithdrawService();
  401. break;
  402. case self::PAY_REMITTANCE:
  403. $className = new RemittancePay();
  404. break;
  405. case self::PAY_COD:
  406. $className = new CODPay();
  407. break;
  408. case self::WFT_PAY:
  409. if (!app('plugins')->isEnabled('wft-pay')) {
  410. throw new AppException('插件未开启');
  411. }
  412. $className = new \Yunshop\WftPay\services\WftPayService();
  413. break;
  414. case self::WFT_ALIPAY:
  415. if (!app('plugins')->isEnabled('wft-alipay')) {
  416. throw new AppException('插件未开启');
  417. }
  418. $className = new \Yunshop\WftAlipay\services\WftAlipayService();
  419. break;
  420. case self::PAY_WE_CHAT_APP:
  421. if (!app('plugins')->isEnabled('app-set')) {
  422. throw new AppException('APP设置插件未开启');
  423. }
  424. $className = new WeChatAppPay();
  425. break;
  426. case self::PAY_PLD:
  427. if (!app('plugins')->isEnabled('pld-pay')) {
  428. throw new AppException('插件未开启');
  429. }
  430. $className = new \Yunshop\PLdPay\services\PldWithdrawService();
  431. break;
  432. case self::PAY_SEPARATE:
  433. \Log::debug('--------payFactory---------');
  434. if (!app('plugins')->isEnabled('separate')) {
  435. throw new AppException('插件未开启');
  436. }
  437. $className = new \Yunshop\Separate\Common\Services\SeparateAccountService();
  438. break;
  439. case self::PAY_DIANBANG:
  440. if (!app('plugins')->isEnabled('dian-bang-scan')) {
  441. throw new AppException('插件未开启');
  442. }
  443. $className = new \Yunshop\DianBangScan\services\DianBangScanService();
  444. break;
  445. case self::YOP_PRO_WECHAT:
  446. case self::YOP_PRO_ALIPAY:
  447. if (!app('plugins')->isEnabled('yop-pro')) {
  448. throw new AppException('易宝专业版插件未开启');
  449. }
  450. $className = new \Yunshop\YopPro\services\YopProPayService();
  451. break;
  452. case self::YOP:
  453. case self::YOP_ALIPAY:
  454. if (!app('plugins')->isEnabled('yop-pay')) {
  455. throw new AppException('易宝插件未开启');
  456. }
  457. $className = new \Yunshop\YopPay\services\YopPayService();
  458. break;
  459. case self::PAY_Usdt:
  460. if (!app('plugins')->isEnabled('usdtpay')) {
  461. throw new AppException('Usdt插件未开启');
  462. }
  463. $className = new \Yunshop\Usdtpay\services\UsdtpayService();
  464. break;
  465. case self::PAY_WE_CHAT_APPLET:
  466. if (!app('plugins')->isEnabled('min-app')) {
  467. throw new AppException('小程序插件未开启');
  468. }
  469. $className = new WeChatAppletPay();
  470. break;
  471. case self::PAY_TEAM_DEPOSIT:
  472. if (!app('plugins')->isEnabled('team-rewards') && \Setting::get('team-rewards.is_open') != 1) {
  473. throw new AppException('插件未开启');
  474. }
  475. $className = new \Yunshop\TeamRewards\common\services\DepositPayService();
  476. break;
  477. case self:: PAY_WECHAT_JUEQI:
  478. if (!app('plugins')->isEnabled('jueqi-pay') && \Setting::get('plugin.jueqi_pay_set.switch') != 1) {
  479. throw new AppException('插件未开启');
  480. }
  481. $className = new \Yunshop\JueqiPay\services\JueqiPayService();
  482. break;
  483. case self::LCG_BALANCE:
  484. case self::LCG_BANK_CARD:
  485. if (!app('plugins')->isEnabled('dragon-deposit')) {
  486. throw new AppException('龙存管插件未开启');
  487. }
  488. $className = new \Yunshop\DragonDeposit\services\LcgPayService();
  489. break;
  490. //汇聚支付微信-分账
  491. case self::PAY_ALI_SEPARATE_HJ:
  492. case self::PAY_SEPARATE_HJ:
  493. if (!app('plugins')->isEnabled('converge-alloc-funds') && \Setting::get(
  494. 'plugin.ConvergeAllocFunds_set'
  495. ) == false) {
  496. throw new AppException('商城未开启汇聚分账支付');
  497. }
  498. $className = new \Yunshop\ConvergeAllocFunds\services\JoinPayService();
  499. break;
  500. //汇聚支付支付宝-分账
  501. case self::PAY_WECHAT_HJ:
  502. if (!app('plugins')->isEnabled('converge_pay') && \Setting::get(
  503. 'plugin.convergePay_set.wechat'
  504. ) == false) {
  505. throw new AppException('商城未开启汇聚支付插件中微信支付');
  506. }
  507. $className = new \Yunshop\ConvergePay\services\WechatService();
  508. break;
  509. case self::PAY_ALIPAY_HJ:
  510. if (!app('plugins')->isEnabled('converge_pay') && \Setting::get(
  511. 'plugin.convergePay_set.alipay'
  512. ) == false) {
  513. throw new AppException('商城未开启汇聚支付插件中微信支付');
  514. }
  515. $className = new \Yunshop\ConvergePay\services\AlipayService();
  516. break;
  517. case self::PAY_ALIPAY_FACE_HJ:
  518. case self::PAY_ALIPAY_SCAN_HJ:
  519. if (!app('plugins')->isEnabled('converge_pay') && \Setting::get(
  520. 'plugin.convergePay_set.wechat'
  521. ) == false) {
  522. throw new AppException('商城未开启汇聚支付插件中支付宝支付');
  523. }
  524. $className = new \Yunshop\ConvergePay\services\AlipayScanService();
  525. break;
  526. case self::PAY_WECHAT_FACE_HJ:
  527. case self::PAY_WECHAT_SCAN_HJ:
  528. if (!app('plugins')->isEnabled('converge_pay') && \Setting::get(
  529. 'plugin.convergePay_set.wechat'
  530. ) == false) {
  531. throw new AppException('商城未开启汇聚支付插件中微信支付');
  532. }
  533. $className = new \Yunshop\ConvergePay\services\WechatScanService();
  534. break;
  535. //微信扫码支付官方
  536. case self:: WECHAT_FACE_PAY:
  537. case self:: WECHAT_SCAN_PAY:
  538. $className = new WechatScanPayService();
  539. break;
  540. case self:: WECHAT_JSAPI_PAY:
  541. $className = new WechatJsapiPayService();
  542. break;
  543. case self:: ALIPAY_FACE_PAY:
  544. case self:: ALIPAY_SCAN_PAY:
  545. $className = new AlipayScanPayService();
  546. break;
  547. case self::ALIPAY_JSAPI_PAY:
  548. $className = new AlipayJsapiPayService();
  549. break;
  550. case self::YOP_ALIPAY_SCAN:
  551. case self::YOP_WECHAT_FACE:
  552. case self::YOP_ALIPAY_FACE:
  553. case self::YOP_WECHAT_SCAN:
  554. if (!app('plugins')->isEnabled('yop-pay')) {
  555. throw new AppException('易宝插件未开启');
  556. }
  557. $className = new \Yunshop\YopPay\services\YopScanPayService();
  558. break;
  559. case self::PAY_WECHAT_TOUTIAO:
  560. if (!app('plugins')->isEnabled('toutiao-mini') && \Setting::get('plugin.toutiao-mini.wx_switch') != 1) {
  561. throw new AppException('商城未开启头条支付中微信支付');
  562. }
  563. $className = new \Yunshop\ToutiaoMini\services\WechatService();
  564. break;
  565. case self::PAY_ALIPAY_TOUTIAO:
  566. if (!app('plugins')->isEnabled('toutiao-mini') && \Setting::get(
  567. 'plugin.toutiao-mini.alipay_switch'
  568. ) != 1) {
  569. throw new AppException('商城未开启头条支付中支付宝支付');
  570. }
  571. $className = new \Yunshop\ToutiaoMini\services\AlipayService();
  572. break;
  573. case self::MEMBER_CARD_PAY:
  574. if (!app('plugins')->isEnabled('pet') && \Setting::get('plugin.pet.is_open_pet') != 1) {
  575. throw new AppException('商城未开启宠物医院支付中会员卡余额支付');
  576. }
  577. $className = new \YunShop\Pet\services\MemberCardPayService();
  578. break;
  579. case self::HK_SCAN_PAY:
  580. if (!app('plugins')->isEnabled('hk-pay')) {
  581. throw new AppException('商城未开启港版支付插件');
  582. }
  583. $className = new \Yunshop\HkPay\services\HkScanPayService();
  584. break;
  585. case self::PAY_PAL:
  586. if (!app('plugins')->isEnabled('pay-pal')) {
  587. throw new AppException('商城未开启PayPal插件');
  588. }
  589. $className = new \Yunshop\PayPal\services\PayPalService();
  590. break;
  591. case self::CONVERGE_QUICK_PAY:
  592. if (!app('plugins')->isEnabled('converge_pay') && \Setting::get(
  593. 'plugin.convergePay_set.quick_pay.is_open'
  594. ) != 1) {
  595. throw new AppException('商城未开启汇聚支付插件中快捷支付');
  596. }
  597. $className = new \Yunshop\ConvergePay\services\QuickPayService();
  598. break;
  599. case self::HK_SCAN_ALIPAY:
  600. if (!app('plugins')->isEnabled('hk-pay')) {
  601. throw new AppException('商城未开启港版支付插件');
  602. }
  603. $className = new HkScanAliPayService();
  604. break;
  605. case self::CONFIRM_PAY:
  606. $className = new \app\common\services\ConfirmPay();
  607. break;
  608. case self::WECHAT_H5:
  609. $className = new \app\common\services\payment\WechatH5Pay();
  610. break;
  611. case self::STORE_AGGREGATE_WECHAT:
  612. $className = new \Yunshop\StoreAggregatePay\services\WechatPayService();
  613. break;
  614. case self::STORE_AGGREGATE_ALIPAY:
  615. $className = new \Yunshop\StoreAggregatePay\services\AlipayPayService();
  616. break;
  617. case self::STORE_AGGREGATE_SCAN:
  618. $className = new \Yunshop\StoreAggregatePay\services\ScanPayService();
  619. break;
  620. case self::WECHAT_NATIVE:
  621. $className = new \app\common\services\payment\WechatNativePay();
  622. break;
  623. case self::DCM_SCAN_PAY:
  624. $className = new \Yunshop\DcmScanPay\services\ScanPayService();
  625. break;
  626. case self::YEE_PAY:
  627. if (!app('plugins')->isEnabled('yee-pay')) {
  628. throw new AppException('商城未开启易宝代付插件');
  629. }
  630. $className = new \Yunshop\YeePay\services\YeePayService();
  631. break;
  632. case self::HIGH_LIGHT:
  633. if (!app('plugins')->isEnabled('high-light') || !\Yunshop\HighLight\services\SetService::getStatus()) {
  634. throw new AppException('商城未开启高灯提现插件');
  635. }
  636. $className = new \Yunshop\HighLight\services\HighLightService();
  637. break;
  638. case self::STORE_BALANCE_PAY:
  639. if (!app('plugins')->isEnabled('store-balance') || \Setting::get('plugin.store_balance.is_open') != 1) {
  640. throw new AppException('商城未开启门店余额插件');
  641. }
  642. $className = new StoreBalancePay();
  643. break;
  644. case self::WECHAT_MICRO_PAY:
  645. $className = new \app\common\services\payment\WechatPayCodePay();
  646. break;
  647. case self::XFPAY_ALIPAY:
  648. if (!app('plugins')->isEnabled('xfpay') && \Setting::get(
  649. 'plugin.xfpay_set.xfpay.pay_type.alipay.enabled'
  650. ) == 0) {
  651. throw new AppException('商城未开启商云客聚合支付 或 插件中支付宝支付');
  652. }
  653. $className = new \Yunshop\Xfpay\services\AlipayService;
  654. break;
  655. case self::XFPAY_WECHAT:
  656. if (!app('plugins')->isEnabled('xfpay') && \Setting::get(
  657. 'plugin.xfpay_set.xfpay.pay_type.wechat.enabled'
  658. ) == 0) {
  659. throw new AppException('商城未开启商云客聚合支付 或 插件中微信支付');
  660. }
  661. $className = new \Yunshop\Xfpay\services\WechatService;
  662. break;
  663. case self::SANDPAY_ALIPAY:
  664. if (!app('plugins')->isEnabled('sandpay') && \Setting::get(
  665. 'sandpay.set.plugin_enable'
  666. ) && \Setting::get('sandpay.set.alipay.enable') == 0) {
  667. throw new AppException('杉德支付插件未开启 或 插件中微信支付未开启');
  668. }
  669. $className = new \Yunshop\Sandpay\services\Alipay;
  670. break;
  671. case self::SANDPAY_WECHAT:
  672. if (!app('plugins')->isEnabled('sandpay') && \Setting::get(
  673. 'sandpay.set.plugin_enable'
  674. ) && \Setting::get('sandpay.set.wechat.enable') == 0) {
  675. throw new AppException('杉德支付插件未开启 或 插件中支付宝支付未开启');
  676. }
  677. $className = new \Yunshop\Sandpay\services\WechatPay;
  678. break;
  679. case self::LAKALA_ALIPAY:
  680. if (!app('plugins')->isEnabled('lakala_pay') && \Setting::get(
  681. 'lakala_pay.set.plugin_enable'
  682. ) && \Setting::get('lakala_pay.set.alipay_enable') == 0) {
  683. throw new AppException('拉卡拉支付插件未开启 或 插件中支付宝支付未开启');
  684. }
  685. $className = new \Yunshop\LaKaLaPay\services\Alipay;
  686. break;
  687. case self::LAKALA_WECHAT:
  688. if (!app('plugins')->isEnabled('lakala_pay') && \Setting::get(
  689. 'lakala_pay.set.plugin_enable'
  690. ) && \Setting::get('lakala_pay.set.wechat_enable') == 0) {
  691. throw new AppException('拉卡拉支付插件未开启 或 插件中微信支付未开启');
  692. }
  693. $className = new \Yunshop\LaKaLaPay\services\WechatPay;
  694. break;
  695. case self::LESHUA_ALIPAY:
  696. if (!app('plugins')->isEnabled('leshua-pay') && \Setting::get(
  697. 'leshua-pay.set.plugin_enable'
  698. ) && \Setting::get('leshua-pay.set.alipay_enable') == 0) {
  699. throw new AppException('乐刷聚合支付插件未开启 或 插件中支付宝支付未开启');
  700. }
  701. $className = new \Yunshop\LeshuaPay\services\Alipay;
  702. break;
  703. case self::LESHUA_WECHAT:
  704. if (!app('plugins')->isEnabled('leshua-pay') && \Setting::get(
  705. 'leshua-pay.set.plugin_enable'
  706. ) && \Setting::get('leshua-pay.set.wechat_enable') == 0) {
  707. throw new AppException('乐刷聚合支付插件未开启 或 插件中微信支付未开启');
  708. }
  709. $className = new \Yunshop\LeshuaPay\services\WechatPay;
  710. break;
  711. case self::LESHUA_POS:
  712. if (!app('plugins')->isEnabled('leshua-pay') && \Setting::get(
  713. 'leshua-pay.set.plugin_enable'
  714. ) && \Setting::get('leshua-pay.set.pos_enable') == 0) {
  715. throw new AppException('乐刷聚合支付插件未开启 或 插件中商户扫码收款未开启');
  716. }
  717. $className = new \Yunshop\LeshuaPay\services\PosPay;
  718. break;
  719. case self::WECHAT_TRADE_PAY:
  720. $className = new \app\common\services\WechatTradePay;
  721. break;
  722. case self::LSP_PAY:
  723. if (!app('plugins')->isEnabled('love-speed-pool')) {
  724. throw new AppException('商城未开启加速池插件');
  725. }
  726. $className = new LSPPay();
  727. break;
  728. case self::WORK_WITHDRAW_PAY:
  729. if (!app('plugins')->isEnabled(
  730. 'worker-withdraw'
  731. ) || !\Yunshop\WorkerWithdraw\services\SettingService::usable()) {
  732. throw new AppException('商城未开启好灵工插件');
  733. }
  734. $className = new \Yunshop\WorkerWithdraw\services\WorkWithdrawService();
  735. break;
  736. case self::CONVERGE_UNION_PAY:
  737. if (!app('plugins')->isEnabled('converge_pay') && \Setting::get(
  738. 'plugin.convergePay_set.converge_union_pay'
  739. ) != 1) {
  740. throw new AppException('商城未开启汇聚支付插件中汇聚云闪付支付');
  741. }
  742. $className = new \Yunshop\ConvergePay\services\UnionPayService();
  743. break;
  744. case self::CONVERGE_WECHAT_CARD_PAY:
  745. if (!app('plugins')->isEnabled('converge_pay') || !\Setting::get(
  746. 'plugin.convergePay_set.converge_pay_status'
  747. ) || !\Setting::get('plugin.convergePay_set.wechat.wechat_status') || !\Setting::get(
  748. 'plugin.convergePay_set.wechat.wechat_card_status'
  749. )) {
  750. throw new AppException('商城未开启汇聚支付插件中微信支付');
  751. }
  752. $className = new \Yunshop\ConvergePay\services\WechatService();
  753. break;
  754. case self::CONVERGE_ALIPAY_CARD_PAY:
  755. if (!app('plugins')->isEnabled('converge_pay') || !\Setting::get(
  756. 'plugin.convergePay_set.converge_pay_status'
  757. ) || !\Setting::get('plugin.convergePay_set.alipay.alipay_status') || !\Setting::get(
  758. 'plugin.convergePay_set.alipay.alipay_card_status'
  759. )) {
  760. throw new AppException('商城未开启汇聚支付插件中支付宝支付');
  761. }
  762. $className = new \Yunshop\ConvergePay\services\AlipayService();
  763. break;
  764. case self::CONVERGE_ALIPAY_H5_PAY:
  765. if (!app('plugins')->isEnabled('converge_pay') && \Setting::get(
  766. 'plugin.convergePay_set.converge_pay_status'
  767. ) != 1) {
  768. throw new AppException('商城未开启汇聚支付插件中汇聚云闪付支付');
  769. }
  770. $className = new \Yunshop\ConvergePay\services\AlipayH5Service();
  771. break;
  772. case self::SILVER_POINT_ALIPAY:
  773. if (!app('plugins')->isEnabled('silver-point-pay') && \Setting::get(
  774. 'silver-point-pay.set.plugin_enable'
  775. ) && \Setting::get('silver-point-pay.set.alipay_enable') == 0) {
  776. throw new AppException('银典支付插件未开启 或 插件中支付宝支付未开启');
  777. }
  778. $className = new \Yunshop\SilverPointPay\services\Alipay();
  779. break;
  780. case self::SILVER_POINT_WECHAT:
  781. if (!app('plugins')->isEnabled('silver-point-pay') && \Setting::get(
  782. 'silver-point-pay.set.plugin_enable'
  783. ) && \Setting::get('silver-point-pay.set.wechat_enable') == 0) {
  784. throw new AppException('银典支付插件未开启 或 插件中微信支付未开启');
  785. }
  786. $className = new \Yunshop\SilverPointPay\services\WechatPay();
  787. break;
  788. case self::SILVER_POINT_UNION:
  789. if (!app('plugins')->isEnabled('silver-point-pay') && \Setting::get(
  790. 'silver-point-pay.set.plugin_enable'
  791. ) && \Setting::get('silver-point-pay.set.union_enable') == 0) {
  792. throw new AppException('银典支付插件未开启 或 插件中银联快捷支付未开启');
  793. }
  794. $className = new \Yunshop\SilverPointPay\services\UnionPay();
  795. break;
  796. case self::CODE_SCIENCE_PAY_YU:
  797. if (!app('plugins')->isEnabled('code-science-pay') && \Setting::get(
  798. 'code-science-pay.set.plugin_enable'
  799. )) {
  800. throw new AppException('豫章行代金券支付插件未开启');
  801. }
  802. $className = new \Yunshop\CodeSciencePay\services\YzxApp();
  803. break;
  804. case self::EPLUS_WECHAT_PAY:
  805. if (!app('plugins')->isEnabled('eplus-pay') || !\Yunshop\EplusPay\services\SettingService::usable(
  806. 'wechat'
  807. )) {
  808. throw new AppException('智E+支付插件未开启');
  809. }
  810. $className = new \Yunshop\EplusPay\services\EplusPay();
  811. break;
  812. case self::EPLUS_MINI_PAY:
  813. if (!app('plugins')->isEnabled('eplus-pay') || !\Yunshop\EplusPay\services\SettingService::usable(
  814. 'mini'
  815. )) {
  816. throw new AppException('智E+支付插件未开启');
  817. }
  818. $className = new \Yunshop\EplusPay\services\EplusPay();
  819. break;
  820. case self::EPLUS_ALI_PAY:
  821. if (!app('plugins')->isEnabled('eplus-pay') || !\Yunshop\EplusPay\services\SettingService::usable(
  822. 'alipay'
  823. )) {
  824. throw new AppException('智E+支付插件未开启');
  825. }
  826. $className = new \Yunshop\EplusPay\services\EplusPay();
  827. break;
  828. case self::LSP_WALLET_PAY:
  829. if (!app('plugins')->isEnabled('love-speed-pool')) {
  830. throw new AppException('加速池未开启插件');
  831. }
  832. $className = new \Yunshop\LoveSpeedPool\service\LSPWalletPay();
  833. break;
  834. case self::JINEPAY:
  835. if (!app('plugins')->isEnabled('jinepay')) {
  836. throw new AppException('锦银E付未开启');
  837. }
  838. $className = new \Yunshop\Jinepay\services\MobilePay();
  839. break;
  840. case self::SILVER_POINT_PAYMENT:
  841. if (!app('plugins')->isEnabled('silver-point-pay')) {
  842. throw new AppException('银典支付未开启');
  843. }
  844. $className = new \Yunshop\SilverPointPay\services\SilverPointPayment();
  845. break;
  846. case self::AUTH_PAY:
  847. if (!app('plugins')->isEnabled('sub-auth-payment') || !\Setting::get(
  848. 'sub-auth-payment.set.plugin_enable'
  849. )) {
  850. throw new AppException('微信借权支付未开启');
  851. }
  852. $className = new \Yunshop\SubAuthPayment\services\AuthPay();
  853. break;
  854. case self::THIRD_PARTY_MINI_PAY:
  855. if (!app('plugins')->isEnabled('freelogin') || !\Setting::get(
  856. 'plugin.freelogin_set.status'
  857. )) {
  858. throw new AppException('APP免登录未开启');
  859. }
  860. $className = new \Yunshop\Freelogin\common\service\ThirdPartyWechatPay();
  861. break;
  862. default:
  863. $className = null;
  864. }
  865. \Log::debug('--------payFactory---------$className', print_r(get_class($className), 1));
  866. return $className;
  867. }
  868. public static function pay($type, $data)
  869. {
  870. $pay = self::create($type);
  871. if ($type == self::PAY_CLOUD_ALIPAY) {
  872. $data['extra']['pay'] = 'cloud_alipay';
  873. }
  874. $result = $pay->doPay($data, $type);
  875. switch ($type) {
  876. case self::PAY_WEACHAT:
  877. case self::PAY_CREDIT:
  878. if (is_bool($result)) {
  879. $result = (array)$result;
  880. }
  881. $trade = \Setting::get('shop.trade');
  882. $redirect = '';
  883. if (!is_null($trade) && isset($trade['redirect_url']) && !empty($trade['redirect_url'])) {
  884. $redirect = $trade['redirect_url'];
  885. }
  886. $result['redirect'] = $redirect;
  887. }
  888. return $result;
  889. }
  890. }