Skip to content

Commit 8ecec90

Browse files
authored
Merge pull request #4 from alipay/xufangjie_dev
[feature aot and merchant registration] 商户报备sdk
2 parents 571c314 + 6efae49 commit 8ecec90

17 files changed

+960
-1
lines changed

example/RegistrationTest.php

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<?php
2+
set_include_path(__DIR__ . '/..');
3+
4+
require_once "request/merchant/AlipayMerchantRegistrationRequest.php";
5+
require_once "model/MerchantRegistrationInfo.php";
6+
require_once "model/Logo.php";
7+
require_once "model/Address.php";
8+
require_once "model/RegistrationDetail.php";
9+
require_once "model/Attachment.php";
10+
require_once "model/ContactInfo.php";
11+
require_once "model/WebSite.php";
12+
require_once "model/ProductCodeType.php";
13+
require_once "DefaultAlipayClient.php";
14+
require_once "request/merchant/AlipayMerchantRegistrationStatusQueryRequest.php";
15+
require_once "request/merchant/AlipayMerchantRegistrationInfoQueryRequest.php";
16+
17+
18+
$merchantPrivateKey = file_get_contents(__DIR__ . "/../private-pkcs1.pem");
19+
20+
$alipayPublicKey = file_get_contents(__DIR__ . "/../public.pem");
21+
$alipayClient = new DefaultAlipayClient("https://open-na.alipay.com", $merchantPrivateKey, $alipayPublicKey);
22+
/**
23+
* build your clientId
24+
*/
25+
$clientId = "T_385XSM502Y108602A";
26+
/**
27+
* build your requestId
28+
*/
29+
$registrationRequestId = "";
30+
/**
31+
* build your merchantId
32+
*/
33+
$referenceMerchantId = "";
34+
/**
35+
* step1.register merchant
36+
*/
37+
$merchantRegistrationRequest = new AlipayMerchantRegistrationRequest();
38+
$merchantRegistrationRequest -> setPath("/ams/sandbox/api/v1/merchants/registration");
39+
$merchantRegistrationRequest -> setClientId($clientId);
40+
41+
$merchant = new MerchantRegistrationInfo();
42+
$merchant -> setMerchantMCC("merchantMCC");
43+
$merchant -> setReferenceMerchantId($referenceMerchantId);
44+
$logo = new Logo();
45+
$logo -> setLogoName("logoName");
46+
$logo -> setLogoUrl("https://www.logo.com");
47+
$merchant -> setLogo($logo);
48+
$address = new Address();
49+
$address -> setAddress1("38 Leighton Road, ****");
50+
$address -> setAddress2("40 Leighton Road, ****");
51+
$address -> setCity("hong kong");
52+
$address -> setLabel("label");
53+
$address -> setRegion("HK");
54+
$address -> setState("HK");
55+
$address -> setZipCode("zipCode");
56+
$merchant -> setMerchantAddress($address);
57+
$merchant -> setMerchantDisplayName("Same_mer");
58+
$detail = new RegistrationDetail();
59+
$attachment1 = new Attachment();
60+
$attachment1 -> setAttachmentName("attachmentName1");
61+
$attachment1 -> setAttachmentType("ARTICLES_OF_ASSOCIATION");
62+
$attachment1 -> setFile("testFile");
63+
$attachment2 = new Attachment();
64+
$attachment2 -> setAttachmentName("attachmentName2");
65+
$attachment2 -> setAttachmentType("ARTICLES_OF_ASSOCIATION");
66+
$attachment2 -> setFile("testFile");
67+
$attachments[0] = $attachment1;
68+
$attachments[1] = $attachment2;
69+
$detail -> setAttachments($attachments);
70+
71+
$detail -> setBusinessType("ENTERPRISE");
72+
$contactInfo = new ContactInfo();
73+
$contactInfo -> setContactNo("contactNo123");
74+
$contactInfo -> setContactType("MOBILE_PHONE");
75+
$contactInfos[0] = $contactInfo;
76+
$detail -> setContactInfo($contactInfos);
77+
$detail -> setLegalName("Example Legal Name");
78+
79+
$registrationAddress = new Address();
80+
$registrationAddress -> setRegion("HK");
81+
82+
$detail -> setRegistrationAddress($registrationAddress);
83+
$detail -> setRegistrationEffectiveDate("2020-01-01T12:08:55+08:00");
84+
$detail -> setRegistrationExpireDate("2020-01-01T12:08:55+08:00");
85+
$detail -> setRegistrationNo("registration*****");
86+
$detail -> setRegistrationType("ENTERPRISE_REGISTRATION_NO");
87+
88+
$merchant -> setRegistrationDetail($detail);
89+
$website = new WebSite();
90+
$website -> setDesc("this is webSite desc");
91+
$website -> setName("webName");
92+
$website -> setUrl("http://www.webSite.com");
93+
$websites[0] = $website;
94+
$merchant -> setWebsites($websites);
95+
96+
97+
$merchantRegistrationRequest -> setMerchantInfo($merchant);
98+
$merchantRegistrationRequest -> setPassThroughInfo("{\"extraInfo\":\"extra\"}");
99+
$productCodes[0] = ProductCodeType::CASHIER_PAYMENT;
100+
$merchantRegistrationRequest -> setProductCodes($productCodes);
101+
$merchantRegistrationRequest -> setRegistrationNotifyURL("https://merchant/example");
102+
$merchantRegistrationRequest -> setRegistrationRequestId($registrationRequestId);
103+
104+
105+
$registrationResponse = $alipayClient->execute($merchantRegistrationRequest);
106+
107+
print(json_encode($merchantRegistrationRequest));
108+
print('<br>-----------------------------------------------------------------------------<br>');
109+
print(json_encode($registrationResponse));
110+
111+
/**
112+
* step.2 query registration status
113+
*/
114+
115+
$registrationStatusQueryRequest = new AlipayMerchantRegistrationStatusQueryRequest();
116+
$registrationStatusQueryRequest -> setClientId($clientId);
117+
$registrationStatusQueryRequest -> setPath("/ams/sandbox/api/v1/merchants/inquiryRegistrationStatus");
118+
$registrationStatusQueryRequest -> setRegistrationRequestId($registrationRequestId);
119+
$registrationStatusResponse = $alipayClient->execute($registrationStatusQueryRequest);
120+
121+
print(json_encode($registrationStatusQueryRequest));
122+
print('<br>-----------------------------------------------------------------------------<br>');
123+
print(json_encode($registrationStatusResponse));
124+
125+
/**
126+
* step3.query merchant registrationInfo
127+
*/
128+
$registrationInfoQueryRequest = new AlipayMerchantRegistrationInfoQueryRequest();
129+
$registrationInfoQueryRequest -> setClientId($clientId);
130+
$registrationInfoQueryRequest -> setPath("/ams/sandbox/api/v1/merchants/inquiryRegistrationInfo");
131+
$registrationInfoQueryRequest -> setReferenceMerchantId($referenceMerchantId);
132+
133+
$registrationInfoResponse = $alipayClient->execute($registrationInfoQueryRequest);
134+
135+
print(json_encode($registrationInfoQueryRequest));
136+
print('<br>-----------------------------------------------------------------------------<br>');
137+
print(json_encode($registrationInfoResponse));

model/Address.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Address{
77
public $address1;
88
public $address2;
99
public $zipCode;
10-
10+
public $label;
1111
/**
1212
* @return String
1313
*/
@@ -92,4 +92,21 @@ public function setZipCode($zipCode){
9292
$this->zipCode = $zipCode;
9393
}
9494

95+
/**
96+
* @return mixed
97+
*/
98+
public function getLabel()
99+
{
100+
return $this->label;
101+
}
102+
103+
/**
104+
* @param mixed $label
105+
*/
106+
public function setLabel($label)
107+
{
108+
$this->label = $label;
109+
}
110+
111+
95112
}

model/Attachment.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
class Attachment {
4+
5+
public $attachmentType;
6+
public $file;
7+
public $attachmentName;
8+
9+
/**
10+
* @return mixed
11+
*/
12+
public function getAttachmentType()
13+
{
14+
return $this->attachmentType;
15+
}
16+
17+
/**
18+
* @param mixed $attachmentType
19+
*/
20+
public function setAttachmentType($attachmentType)
21+
{
22+
$this->attachmentType = $attachmentType;
23+
}
24+
25+
/**
26+
* @return mixed
27+
*/
28+
public function getFile()
29+
{
30+
return $this->file;
31+
}
32+
33+
/**
34+
* @param mixed $file
35+
*/
36+
public function setFile($file)
37+
{
38+
$this->file = $file;
39+
}
40+
41+
/**
42+
* @return mixed
43+
*/
44+
public function getAttachmentName()
45+
{
46+
return $this->attachmentName;
47+
}
48+
49+
/**
50+
* @param mixed $attachmentName
51+
*/
52+
public function setAttachmentName($attachmentName)
53+
{
54+
$this->attachmentName = $attachmentName;
55+
}
56+
57+
58+
}

model/ContactInfo.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
class ContactInfo {
4+
5+
public $contactNo;
6+
public $contactType;
7+
8+
/**
9+
* @return mixed
10+
*/
11+
public function getContactNo()
12+
{
13+
return $this->contactNo;
14+
}
15+
16+
/**
17+
* @param mixed $contactNo
18+
*/
19+
public function setContactNo($contactNo)
20+
{
21+
$this->contactNo = $contactNo;
22+
}
23+
24+
/**
25+
* @return mixed
26+
*/
27+
public function getContactType()
28+
{
29+
return $this->contactType;
30+
}
31+
32+
/**
33+
* @param mixed $contactType
34+
*/
35+
public function setContactType($contactType)
36+
{
37+
$this->contactType = $contactType;
38+
}
39+
40+
41+
}

model/Logo.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
class Logo {
4+
5+
public $logoName;
6+
public $logoUrl;
7+
8+
/**
9+
* @return mixed
10+
*/
11+
public function getLogoName()
12+
{
13+
return $this->logoName;
14+
}
15+
16+
/**
17+
* @param mixed $logoName
18+
*/
19+
public function setLogoName($logoName)
20+
{
21+
$this->logoName = $logoName;
22+
}
23+
24+
/**
25+
* @return mixed
26+
*/
27+
public function getLogoUrl()
28+
{
29+
return $this->logoUrl;
30+
}
31+
32+
/**
33+
* @param mixed $logoUrl
34+
*/
35+
public function setLogoUrl($logoUrl)
36+
{
37+
$this->logoUrl = $logoUrl;
38+
}
39+
40+
41+
}

model/Merchant.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Merchant{
99
public $merchantAddress;
1010
public $merchantRegisterDate;
1111
public $store;
12+
public $merchantType;
1213

1314
/**
1415
* @return String
@@ -108,5 +109,22 @@ public function setStore($store){
108109
$this->store = $store;
109110
}
110111

112+
/**
113+
* @return mixed
114+
*/
115+
public function getMerchantType()
116+
{
117+
return $this->merchantType;
118+
}
119+
120+
/**
121+
* @param mixed $merchantType
122+
*/
123+
public function setMerchantType($merchantType)
124+
{
125+
$this->merchantType = $merchantType;
126+
}
127+
128+
111129

112130
}

0 commit comments

Comments
 (0)