| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace common\enums;
- use common\models\user\User;
- /**
- * 微信支付类型
- *
- *
- * Class WechatPayTypeEnum
- * @package common\enums
- */
- class WechatPayTypeEnum extends BaseEnum
- {
- const JS = 'js';
- const APP = 'app';
- const NATIVE = 'native';
- const POS = 'pos';
- const M_WEB = 'mweb';
- const MINI_PROGRAM = 'mini_program';
- // pem文件配置字段
- const CERT_PEM = 'wechat_cert_pem';
- const KEY_PEM = 'wechat_key_pem';
- const WECHAT_TRANSFER_V3 = '3';
- const WECHAT_TRANSFER_V2 = '2';
- /**
- * @return array|string[]
- */
- public static function getMap(): array
- {
- return [
- self::JS => 'H5',
- self::APP => 'app',
- self::NATIVE => '扫码',
- self::POS => '刷卡',
- self::M_WEB => '手机',
- self::MINI_PROGRAM => '小程序',
- ];
- }
- /**
- * 根据环境获取微信交易类型
- * @param $platform
- * @return mixed|string
- */
- public static function getTypeByPlatform($platform)
- {
- $arr = [
- User::PLATFORM_MP_WX => self::MINI_PROGRAM,
- User::PLATFORM_WECHAT => self::JS,
- User::PLATFORM_APP => self::APP,
- User::PLATFORM_H5 => self::M_WEB,
- ];
- return $arr[$platform] ?? '';
- }
- /**
- * 获取pem文件对应的配置内容
- * @Author: lun
- * @DateTime: 2021/10/19 0019 15:24
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $key
- * @return array|string[]
- */
- public static function getPemFileName($key)
- {
- $arr = [
- self::CERT_PEM => [
- 'file' => 'apiclient_cert.pem',
- 'key' => 'wechat_cert_pem_file',
- ],
- self::KEY_PEM => [
- 'file' => 'apiclient_key.pem',
- 'key' => 'wechat_key_pem_file',
- ],
- ];
- return $arr[$key] ?? [];
- }
- /**
- * pem数组
- * @Author: lun
- * @DateTime: 2021/10/19 0019 15:25
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return array|string[]
- */
- public static function pemMap():array
- {
- return [
- self::CERT_PEM,
- self::KEY_PEM,
- ];
- }
- }
|