chengkun
2025-09-19 d48eff069585e2be1bd02b1299e1fe7581cb6dad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
 
 
namespace Alipay\EasySDK\Test\marketing\pass;
 
 
use Alipay\EasySDK\Kernel\Factory;
use Alipay\EasySDK\Test\TestAccount;
use PHPUnit\Framework\TestCase;
 
class ClientTest extends TestCase
{
    public function __construct($name = null, array $data = [], $dataName = '')
    {
        parent::__construct($name, $data, $dataName);
        $account = new TestAccount();
        Factory::setOptions($account->getTestAccount());
    }
 
    public function testCreateTemplate()
    {
        $result = Factory::marketing()->pass()->createTemplate("1234567890", $this->getTplContent());
        $this->assertEquals('10000', $result->code);
        $this->assertEquals('Success', $result->msg);
    }
 
    public function testUpdateTemplate()
    {
        $result = Factory::marketing()->pass()->updateTemplate("2020012014534017917956080", $this->getTplContent());
        $this->assertEquals('10000', $result->code);
        $this->assertEquals('Success', $result->msg);
    }
 
    public function testAddInstance()
    {
        $result = Factory::marketing()->pass()->addInstance("2020012014534017917956080", "{}",
            "1", "{\"partner_id\":\"2088102114633762\",\"out_trade_no\":\"1234567\"}");
        $this->assertEquals('40004', $result->code);
        $this->assertEquals('Business Failed', $result->msg);
        $this->assertEquals('KP.AE_ALIPASS_APPID_NOSUPPORT', $result->subCode);
        $this->assertEquals('该AppId不支持', $result->subMsg);
    }
 
    public function testUpdateInstance()
    {
        $result = Factory::marketing()->pass()->updateInstance("209919213",
            "2088918273", "{}", "USED", "8612231273", "wave");
        $this->assertEquals('40004', $result->code);
        $this->assertEquals('Business Failed', $result->msg);
        $this->assertEquals('KP.AE_ALIPASS_NOTEXIST', $result->subCode);
        $this->assertEquals('卡券不存在', $result->subMsg);
    }
 
    private function getTplContent()
    {
        return '{"logo": "http://img01.taobaocdn.com/top/i1/LB1NDJuQpXXXXbYXFXXXXXXXXXX","strip": null,"icon": null,"content": {
        "evoucherInfo": {
            "goodsId": "",
            "title": "test",
            "type": "boardingPass",
            "product": "air",
            "startDate": "2020-01-20 13:45:56",
            "endDate": "2020-01-25 13:45:56",
            "operation": [{
                "message": {
                    "img": "http://img01.taobaocdn.com/top/i1/LB1NDJuQpXXXXbYXFXXXXXXXXXX",
                    "target": ""
                },
                "format": "img",
                "messageEncoding": "utf-8",
                "altText": ""
            }],
            "einfo": {
                "logoText": "test",
                "headFields": [{"key": "test","label": "测试","value": "","type": "text"}],
                "primaryFields": [{"key": "from","label": "测试","value": "","type": "text"},{"key": "to","label": "测试","value": "","type": "text"}],
                "secondaryFields": [{"key": "fltNo","label": "航班号","value": "CA123","type": "text"}],
                "auxiliaryFields": [{"key": "test","label": "测试","value": "","type": "text"}],
                "backFields": []
            },
            "locations": []
        },
        "merchant": {"mname": "君泓","mtel": "","minfo": ""},
        "platform": {
            "channelID": "2088201564809153",
            "webServiceUrl": "https://alipass.alipay.com/builder/syncRecord.htm?tempId=2020012013442621326446216"
        },
        "style": {"backgroundColor": "RGB(26,150,219)"},
        "fileInfo": {
            "formatVersion": "2",
            "canShare": true,
            "canBuy": false,
            "canPresent": true,
            "serialNumber": "2020012013520759738677158",
            "supportTaxi": "true",
            "taxiSchemaUrl": ""
        },
        "appInfo": {"app": {"android_appid": "","ios_appid": "","android_launch": "","ios_launch": "","android_download": "","ios_download": ""},"label": "测试","message": ""},
        "source": "alipassprod",
        "alipayVerify": ["qrcode"]}}';
    }
}