GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

PaySetterTrait::setCharset()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
/**
3
 * Trait PaySetterTrait
4
 *
5
 * @link https://www.icy2003.com/
6
 * @author icy2003 <[email protected]>
7
 * @copyright Copyright (c) 2017, icy2003
8
 */
9
namespace icy2003\php\iapis\alipay;
10
11
use icy2003\php\I;
12
13
/**
14
 * Pay setter
15
 */
16
trait PaySetterTrait
17
{
18
19
    /**
20
     * 支付宝分配给开发者的应用ID
21
     *
22
     * @var string
23
     */
24
    protected $_appId;
25
26
    /**
27
     * 私钥
28
     *
29
     * @var string
30
     */
31
    protected $_rsaPrivateKey;
32
33
    /**
34
     * 发送的数据
35
     *
36
     * @var array
37
     */
38
    protected $_options = [
39
        'biz_content' => [],
40
    ];
41
42
    /**
43
     * 支付类型
44
     *
45
     * @var string
46
     */
47
    protected $_tradeType;
48
49
    /**
50
     * 定义支付类型
51
     *
52
     * - APP 支付:@link https://docs.open.alipay.com/api_1/alipay.trade.app.pay
53
     *
54
     * @param string $tradeType
55
     *
56
     * @return static
57
     */
58
    public function setTradeType($tradeType)
59
    {
60
        $this->_tradeType = $tradeType;
61
        return $this;
62
    }
63
64
    /**
65
     * 仅支持JSON
66
     *
67
     * @param string $format
68
     *
69
     * @return static
70
     */
71
    public function setFormat($format)
72
    {
73
        $this->_options['format'] = $format;
74
        return $this;
75
    }
76
77
    /**
78
     * HTTP/HTTPS开头字符串
79
     *
80
     * @param string $returnUrl
81
     *
82
     * @return static
83
     */
84
    public function setReturnUrl($returnUrl)
85
    {
86
        $this->_options['return_url'] = $returnUrl;
87
        return $this;
88
    }
89
90
    /**
91
     * 请求使用的编码格式,如utf-8,gbk,gb2312等
92
     *
93
     * @param string $charset
94
     *
95
     * @return static
96
     */
97
    public function setCharset($charset)
98
    {
99
        $this->_options['charset'] = $charset;
100
        return $this;
101
    }
102
103
    /**
104
     * 商户生成签名字符串所使用的签名算法类型
105
     *
106
     * - 目前支持RSA2和RSA
107
     * - 推荐使用RSA2
108
     *
109
     * @param string $signType
110
     *
111
     * @return static
112
     */
113
    public function setSignType($signType)
114
    {
115
        $this->_options['sign_type'] = $signType;
116
        return $this;
117
    }
118
119
    /**
120
     * 发送请求的时间,格式"yyyy-MM-dd HH:mm:ss"
121
     *
122
     * @param string $timestamp
123
     *
124
     * @return static
125
     */
126
    public function setTimestamp($timestamp)
127
    {
128
        $this->_options['timestamp'] = $timestamp;
129
        return $this;
130
    }
131
132
    /**
133
     * 支付宝服务器主动通知商户服务器里指定的页面http/https路径
134
     *
135
     * @param string $notifyUrl
136
     *
137
     * @return static
138
     */
139
    public function setNotifyUrl($notifyUrl)
140
    {
141
        $this->_options['notify_url'] = $notifyUrl;
142
        return $this;
143
    }
144
145
    /**
146
     * 第三方应用授权 TOKEN
147
     *
148
     * - 详见[应用授权概述](https://docs.open.alipay.com/20160728150111277227/intro)
149
     *
150
     * @param string $appAuthToken
151
     *
152
     * @return static
153
     */
154
    public function setAppAuthToken($appAuthToken)
155
    {
156
        $this->_options['app_auth_token'] = $appAuthToken;
157
        return $this;
158
    }
159
160
    /**
161
     * 请求参数的集合,最大长度不限,除公共参数外所有请求参数都必须放在这个参数中传递,具体参照各产品快速接入文档
162
     *
163
     * @param string $key
164
     * @param string|array $value
165
     *
166
     * @return static
167
     */
168
    public function setBizContent($key, $value)
169
    {
170
        $this->_options['biz_content'][$key] = $value;
171
        return $this;
172
    }
173
174
    /**
175
     * 该笔订单允许的最晚付款时间,逾期将关闭交易
176
     *
177
     * - 取值范围:1m~15d。m-分钟,h-小时,d-天,1c-当天(1c-当天的情况下,无论交易何时创建,都在0点关闭)
178
     * - 该参数数值不接受小数点, 如 1.5h,可转换为 90m
179
     *
180
     * @param string $timeoutExpress
181
     *
182
     * @return static
183
     */
184
    public function setBizContentTimeoutExpress($timeoutExpress)
185
    {
186
        return $this->setBizContent('timeout_express', $timeoutExpress);
187
    }
188
189
    /**
190
     * 订单总金额
191
     *
192
     * - 单位为元,精确到小数点后两位,取值范围[0.01,100000000]
193
     *
194
     * @param double $totalAmount
195
     *
196
     * @return static
197
     */
198
    public function setBizContentTotalAmount($totalAmount)
199
    {
200
        $totalAmount = number_format($totalAmount, 2, '.', '');
201
        return $this->setBizContent('total_amount', $totalAmount);
202
    }
203
204
    /**
205
     * 销售产品码,商家和支付宝签约的产品码
206
     *
207
     * @param string $productCode
208
     *
209
     * @return static
210
     */
211
    public function setBizContentProductCode($productCode)
212
    {
213
        return $this->setBizContent('product_code', $productCode);
214
    }
215
216
    /**
217
     * 对一笔交易的具体描述信息
218
     *
219
     * - 如果是多种商品,请将商品描述字符串累加传给body
220
     *
221
     * @param string $body
222
     *
223
     * @return static
224
     */
225
    public function setBizContentBody($body)
226
    {
227
        return $this->setBizContent('body', $body);
228
    }
229
230
    /**
231
     * 商品的标题/交易标题/订单标题/订单关键字等
232
     *
233
     * @param string $subject
234
     *
235
     * @return static
236
     */
237
    public function setBizContentSubject($subject)
238
    {
239
        return $this->setBizContent('subject', $subject);
240
    }
241
242
    /**
243
     * 商户网站唯一订单号
244
     *
245
     * @param string $outTradeNo
246
     *
247
     * @return static
248
     */
249
    public function setBizContentOutTradeNo($outTradeNo)
250
    {
251
        return $this->setBizContent('out_trade_no', $outTradeNo);
252
    }
253
254
    /**
255
     * 绝对超时时间,格式为yyyy-MM-dd HH:mm
256
     *
257
     * @param string $timeExpire
258
     *
259
     * @return static
260
     */
261
    public function setBizContentTimeExpire($timeExpire)
262
    {
263
        return $this->setBizContent('time_expire', $timeExpire);
264
    }
265
266
    /**
267
     * 商品主类型
268
     *
269
     * - 0:虚拟类商品
270
     * - 1:实物类商品
271
     *
272
     * @param string $goodsType
273
     *
274
     * @return static
275
     */
276
    public function setBizContentGoodsType($goodsType)
277
    {
278
        return $this->setBizContent('goods_type', $goodsType);
279
    }
280
281
    /**
282
     * 优惠参数
283
     *
284
     * - 仅与支付宝协商后可用
285
     *
286
     * @param string $promoParams
287
     *
288
     * @return static
289
     */
290
    public function setBizContentPromoParams($promoParams)
291
    {
292
        return $this->setBizContent('promo_params', $promoParams);
293
    }
294
295
    /**
296
     * 公用回传参数
297
     *
298
     * - 如果请求时传递了该参数,则返回给商户时会回传该参数
299
     * - 支付宝只会在同步返回(包括跳转回商户网站)和异步通知时将该参数原样返回
300
     * - 本参数必须进行UrlEncode之后才可以发送给支付宝
301
     *
302
     * @param string $passbackParams
303
     *
304
     * @return static
305
     */
306
    public function setBizContentPassbackParams($passbackParams)
307
    {
308
        return $this->setBizContent('passback_params', $passbackParams);
309
    }
310
311
    /**
312
     * 业务扩展参数
313
     *
314
     * @param string $key
315
     * @param string $value
316
     *
317
     * @return static
318
     */
319
    public function setBizContentExtendParams($key, $value)
320
    {
321
        $array = (array)I::get($this->_options, 'biz_content.extend_params', []);
322
        $array[$key] = $value;
323
        return $this->setBizContent('extend_params', $array);
324
    }
325
326
    /**
327
     * 系统商编号
328
     *
329
     * - 该参数作为系统商返佣数据提取的依据,请填写系统商签约协议的PID
330
     *
331
     * @param string $extendParamsSysServiceProviderId
332
     *
333
     * @return static
334
     */
335
    public function setBizContentExtendParamsSysServiceProviderId($extendParamsSysServiceProviderId)
336
    {
337
        return $this->setBizContentExtendParams('sys_service_provider_id', $extendParamsSysServiceProviderId);
338
    }
339
340
    /**
341
     * 使用花呗分期要进行的分期数
342
     *
343
     * @param string $extendParamsHbFqNum
344
     *
345
     * @return static
346
     */
347
    public function setBizContentExtendParamsHbFqNum($extendParamsHbFqNum)
348
    {
349
        return $this->setBizContentExtendParams('hb_fq_num', $extendParamsHbFqNum);
350
    }
351
352
    /**
353
     * 使用花呗分期需要卖家承担的手续费比例的百分值,传入100代表100%
354
     *
355
     * @param string $extendParamsHbFqSellerPercent
356
     *
357
     * @return static
358
     */
359
    public function setBizContentExtendParamsHbFqSellerPercent($extendParamsHbFqSellerPercent)
360
    {
361
        return $this->setBizContentExtendParams('hb_fq_seller_percent', $extendParamsHbFqSellerPercent);
362
    }
363
364
    /**
365
     * 行业数据回流信息, 详见:地铁支付接口参数补充说明
366
     *
367
     * @param string $extendParamsIndustryRefluxInfo
368
     *
369
     * @return static
370
     */
371
    public function setBizContentExtendParamsIndustryRefluxInfo($extendParamsIndustryRefluxInfo)
372
    {
373
        return $this->setBizContentExtendParams('industry_reflux_info', $extendParamsIndustryRefluxInfo);
374
    }
375
376
    /**
377
     * 卡类型
378
     *
379
     * @param string $extendParamsCardType
380
     *
381
     * @return static
382
     */
383
    public function setBizContentExtendParamsCardType($extendParamsCardType)
384
    {
385
        return $this->setBizContentExtendParams('card_type', $extendParamsCardType);
386
    }
387
388
    /**
389
     * 商户原始订单号
390
     *
391
     * - 最大长度限制32位
392
     *
393
     * @param string $merchantOrderNo
394
     *
395
     * @return static
396
     */
397
    public function setBizContentMerchantOrderNo($merchantOrderNo)
398
    {
399
        return $this->setBizContent('merchant_order_no', $merchantOrderNo);
400
    }
401
402
    /**
403
     * 可用渠道,用户只能在指定渠道范围内支付
404
     *
405
     * - 当有多个渠道时用“,”分隔
406
     * - 与disable_pay_channels互斥
407
     *
408
     * @param string $enablePayChannels
409
     *
410
     * @return static
411
     */
412
    public function setBizContentEnablePayChannels($enablePayChannels)
413
    {
414
        return $this->setBizContent('enable_pay_channels', $enablePayChannels);
415
    }
416
417
    /**
418
     * 商户门店编号
419
     *
420
     * @param string $storeId
421
     *
422
     * @return static
423
     */
424
    public function setBizContentStoreId($storeId)
425
    {
426
        return $this->setBizContent('store_id', $storeId);
427
    }
428
429
    /**
430
     * 指定渠道
431
     *
432
     * - 目前仅支持传入pcredit
433
     * - 若由于用户原因渠道不可用,用户可选择是否用其他渠道支付
434
     * - 该参数不可与花呗分期参数同时传入
435
     *
436
     * @param string $specifiedChannel
437
     *
438
     * @return static
439
     */
440
    public function setBizContentSpecifiedChannel($specifiedChannel)
441
    {
442
        return $this->setBizContent('specified_channel', $specifiedChannel);
443
    }
444
445
    /**
446
     * 禁用渠道
447
     *
448
     * - 用户不可用指定渠道支付
449
     * - 当有多个渠道时用“,”分隔
450
     * - 与enable_pay_channels互斥
451
     *
452
     * @param string $disablePayChannels
453
     *
454
     * @return static
455
     */
456
    public function setBizContentDisablePayChannels($disablePayChannels)
457
    {
458
        return $this->setBizContent('disable_pay_channels', $disablePayChannels);
459
    }
460
461
    /**
462
     * 外部指定买家
463
     *
464
     * @param string $key
465
     * @param string $value
466
     *
467
     * @return static
468
     */
469
    public function setBizContentExtUserInfo($key, $value)
470
    {
471
        $array = (array)I::get($this->_options, 'biz_content.ext_user_info', []);
472
        $array[$key] = $value;
473
        return $this->setBizContent('ext_user_info', $array);
474
    }
475
476
    /**
477
     * 姓名
478
     *
479
     * - need_check_info=T时该参数才有效
480
     *
481
     * @param string $extUserInfoName
482
     *
483
     * @return static
484
     */
485
    public function setBizContentExtUserInfoName($extUserInfoName)
486
    {
487
        return $this->setBizContentExtUserInfo('name', $extUserInfoName);
488
    }
489
490
    /**
491
     * 手机号
492
     *
493
     * - 该参数暂不校验
494
     *
495
     * @param string $extUserInfoMobile
496
     *
497
     * @return static
498
     */
499
    public function setBizContentExtUserInfoMobile($extUserInfoMobile)
500
    {
501
        return $this->setBizContentExtUserInfo('mobile', $extUserInfoMobile);
502
    }
503
504
    /**
505
     * 证件类型
506
     *
507
     * - 身份证:IDENTITY_CARD
508
     * - 护照:PASSPORT
509
     * - 军官证:OFFICER_CARD
510
     * - 士兵证:SOLDIER_CARD
511
     * - 户口本:HOKOU
512
     * - need_check_info=T时该参数才有效
513
     *
514
     * @param string $extUserInfoCertType
515
     *
516
     * @return static
517
     */
518
    public function setBizContentExtUserInfoCertType($extUserInfoCertType)
519
    {
520
        return $this->setBizContentExtUserInfo('cert_type', $extUserInfoCertType);
521
    }
522
523
    /**
524
     * 证件号
525
     *
526
     * - eed_check_info=T时该参数才有效
527
     *
528
     * @param string $extUserInfoCertNo
529
     *
530
     * @return static
531
     */
532
    public function setBizContentExtUserInfoCertNo($extUserInfoCertNo)
533
    {
534
        return $this->setBizContentExtUserInfo('cert_no', $extUserInfoCertNo);
535
    }
536
537
    /**
538
     * 允许的最小买家年龄,买家年龄必须大于等于所传数值
539
     *
540
     * - need_check_info=T时该参数才有效
541
     * - min_age为整数,必须大于等于0
542
     *
543
     * @param string $extUserInfoMinAge
544
     *
545
     * @return static
546
     */
547
    public function setBizContentExtUserInfoMinAge($extUserInfoMinAge)
548
    {
549
        return $this->setBizContentExtUserInfo('min_age', $extUserInfoMinAge);
550
    }
551
552
    /**
553
     * 是否强制校验付款人身份信息
554
     *
555
     * - T:强制校验
556
     * - F:不强制
557
     *
558
     * @param string $extUserInfoFixBuyer
559
     *
560
     * @return static
561
     */
562
    public function setBizContentExtUserInfoFixBuyer($extUserInfoFixBuyer)
563
    {
564
        return $this->setBizContentExtUserInfo('fix_buyer', $extUserInfoFixBuyer);
565
    }
566
567
    /**
568
     * 是否强制校验身份信息
569
     *
570
     * - T:强制校验
571
     * - F:不强制
572
     *
573
     * @param string $extUserInfoNeedCheckInfo
574
     *
575
     * @return static
576
     */
577
    public function setBizContentExtUserInfoNeedCheckInfo($extUserInfoNeedCheckInfo)
578
    {
579
        return $this->setBizContentExtUserInfo('need_check_info', $extUserInfoNeedCheckInfo);
580
    }
581
582
    /**
583
     * 商户传入业务信息
584
     *
585
     * - 具体值要和支付宝约定,应用于安全,营销等参数直传场景,格式为json格式
586
     *
587
     * @param string $businessParams
588
     *
589
     * @return static
590
     */
591
    public function setBizContentBusinessParams($businessParams)
592
    {
593
        return $this->setBizContent('business_params', $businessParams);
594
    }
595
596
}
597