Skip to content

Commit c272e13

Browse files
committed
new Podeli credit service
1 parent 3ae382d commit c272e13

File tree

5 files changed

+320
-0
lines changed

5 files changed

+320
-0
lines changed

src/ApiRequest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class ApiRequest implements ApiRequestInterface
2121
const SESSION_API = '/api/v4/payments/sessions';
2222
const REPORT_CHART_API = '/api/v4/reports/chart';
2323
const REPORT_GENERAL_API = '/api/v4/reports/general';
24+
const PODELI_MERCHANT_REGISTRATION_API = '/api/v4/registration/merchant/podeli';
2425
const HOST = 'https://secure.ypmn.ru';
2526
const SANDBOX_HOST = 'https://sandbox.ypmn.ru';
2627
const LOCAL_HOST = 'http://127.0.0.1';
@@ -566,4 +567,9 @@ class="w-100 d-block"
566567
}
567568
}
568569

570+
/** @inheritdoc */
571+
public function sendPodeliRegistrationMerchantRequest(PodeliMerchant $merchant): array
572+
{
573+
return $this->sendPostRequest($merchant, self::PODELI_MERCHANT_REGISTRATION_API);
574+
}
569575
}

src/ApiRequestInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,11 @@ public function getHost() : string;
127127
* @throws PaymentException
128128
*/
129129
public function setHost(string $host) : self;
130+
131+
/**
132+
* Отправить запрос на регистрацию мерчанта
133+
* @param PodeliMerchant $merchant
134+
* @return array
135+
*/
136+
public function sendPodeliRegistrationMerchantRequest(PodeliMerchant $merchant): array;
130137
}

src/PodeliMerchant.php

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Ypmn;
4+
5+
use JsonSerializable;
6+
7+
class PodeliMerchant implements JsonSerializable
8+
{
9+
/**
10+
* @notBlank
11+
*
12+
*/
13+
private string $login;
14+
15+
/** @notBlank */
16+
private string $name;
17+
18+
/** @notBlank */
19+
private string $legalEntity;
20+
21+
/** @notBlank */
22+
private string $inn;
23+
24+
/** @notBlank */
25+
private string $mcc;
26+
27+
/** @notBlank */
28+
private string $email;
29+
30+
/** @notBlank */
31+
private string $siteUrl;
32+
33+
/** @notBlank */
34+
private string $agreementSignDate;
35+
36+
/**
37+
* @isLinkType
38+
*/
39+
private PodeliMerchantBankDetails $requisite;
40+
41+
/**
42+
* @isLinkType
43+
*/
44+
private PodeliMerchantAddress $address;
45+
46+
public function getLogin(): string
47+
{
48+
return $this->login;
49+
}
50+
51+
public function setLogin(string $login): PodeliMerchant
52+
{
53+
$this->login = $login;
54+
55+
return $this;
56+
}
57+
58+
public function getName(): string
59+
{
60+
return $this->name;
61+
}
62+
63+
public function setName(string $name): PodeliMerchant
64+
{
65+
$this->name = $name;
66+
67+
return $this;
68+
}
69+
70+
public function getLegalEntity(): string
71+
{
72+
return $this->legalEntity;
73+
}
74+
75+
public function setLegalEntity(string $legalEntity): PodeliMerchant
76+
{
77+
$this->legalEntity = $legalEntity;
78+
79+
return $this;
80+
}
81+
82+
public function getInn(): string
83+
{
84+
return $this->inn;
85+
}
86+
87+
public function setInn(string $inn): PodeliMerchant
88+
{
89+
$this->inn = $inn;
90+
91+
return $this;
92+
}
93+
94+
public function getMcc(): string
95+
{
96+
return $this->mcc;
97+
}
98+
99+
public function setMcc(string $mcc): PodeliMerchant
100+
{
101+
$this->mcc = $mcc;
102+
103+
return $this;
104+
}
105+
106+
public function getEmail(): string
107+
{
108+
return $this->email;
109+
}
110+
111+
public function setEmail(string $email): PodeliMerchant
112+
{
113+
$this->email = $email;
114+
115+
return $this;
116+
}
117+
118+
public function getSiteUrl(): string
119+
{
120+
return $this->siteUrl;
121+
}
122+
123+
public function setSiteUrl(string $siteUrl): PodeliMerchant
124+
{
125+
$this->siteUrl = $siteUrl;
126+
127+
return $this;
128+
}
129+
130+
public function getAgreementSignDate(): string
131+
{
132+
return $this->agreementSignDate;
133+
}
134+
135+
public function setAgreementSignDate(string $agreementSignDate): PodeliMerchant
136+
{
137+
$this->agreementSignDate = $agreementSignDate;
138+
139+
return $this;
140+
}
141+
142+
public function getBankDetails(): PodeliMerchantBankDetails
143+
{
144+
return $this->requisite;
145+
}
146+
147+
public function setBankDetails(PodeliMerchantBankDetails $requisite): PodeliMerchant
148+
{
149+
$this->requisite = $requisite;
150+
151+
return $this;
152+
}
153+
154+
public function getAddress(): PodeliMerchantAddress
155+
{
156+
return $this->address;
157+
}
158+
159+
public function setAddress(PodeliMerchantAddress $address): PodeliMerchant
160+
{
161+
$this->address = $address;
162+
163+
return $this;
164+
}
165+
166+
public function getAsArray(): array
167+
{
168+
return array_filter([
169+
'login' => $this->login,
170+
'name' => $this->name,
171+
'legalEntity' => $this->legalEntity,
172+
'inn' => $this->inn,
173+
'mcc' => $this->mcc,
174+
'email' => $this->email,
175+
'siteUrl' => $this->siteUrl,
176+
'agreementSignDate' => $this->agreementSignDate,
177+
'requisite' => $this->requisite->getAsArray(),
178+
'address' => $this->address->getAsArray(),
179+
], fn($value) => !is_null($value));
180+
}
181+
182+
#[\ReturnTypeWillChange]
183+
public function jsonSerialize()
184+
{
185+
return json_encode($this->getAsArray(), JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_LINE_TERMINATORS);
186+
}
187+
}

src/PodeliMerchantAddress.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Ypmn;
4+
5+
class PodeliMerchantAddress
6+
{
7+
/** @notBlank */
8+
private string $index;
9+
10+
/** @notBlank */
11+
private string $city;
12+
13+
public function getIndex(): string
14+
{
15+
return $this->index;
16+
}
17+
18+
public function setIndex(string $index): PodeliMerchantAddress
19+
{
20+
$this->index = $index;
21+
22+
return $this;
23+
}
24+
25+
public function getCity(): string
26+
{
27+
return $this->city;
28+
}
29+
30+
public function setCity(string $city): PodeliMerchantAddress
31+
{
32+
$this->city = $city;
33+
34+
return $this;
35+
}
36+
37+
public function getAsArray(): array
38+
{
39+
return array_filter([
40+
'index' => $this->index,
41+
'city' => $this->city,
42+
], fn($value) => !is_null($value));
43+
}
44+
}

src/PodeliMerchantBankDetails.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Ypmn;
4+
5+
class PodeliMerchantBankDetails
6+
{
7+
/** @notBlank */
8+
private string $bankName;
9+
10+
/** @notBlank */
11+
private string $bankIdentifierCode;
12+
13+
/** @notBlank */
14+
private string $correspondingAccount;
15+
16+
/** @notBlank */
17+
private string $paymentAccount;
18+
19+
public function getBankName(): string
20+
{
21+
return $this->bankName;
22+
}
23+
24+
public function setBankName(string $bankName): PodeliMerchantBankDetails
25+
{
26+
$this->bankName = $bankName;
27+
28+
return $this;
29+
}
30+
31+
public function getBankIdentifierCode(): string
32+
{
33+
return $this->bankIdentifierCode;
34+
}
35+
36+
public function setBankIdentifierCode(string $bankIdentifierCode): PodeliMerchantBankDetails
37+
{
38+
$this->bankIdentifierCode = $bankIdentifierCode;
39+
40+
return $this;
41+
}
42+
43+
public function getCorrespondingAccount(): string
44+
{
45+
return $this->correspondingAccount;
46+
}
47+
48+
public function setCorrespondingAccount(string $correspondingAccount): PodeliMerchantBankDetails
49+
{
50+
$this->correspondingAccount = $correspondingAccount;
51+
52+
return $this;
53+
}
54+
55+
public function getPaymentAccount(): string
56+
{
57+
return $this->paymentAccount;
58+
}
59+
60+
public function setPaymentAccount(string $paymentAccount): PodeliMerchantBankDetails
61+
{
62+
$this->paymentAccount = $paymentAccount;
63+
64+
return $this;
65+
}
66+
67+
public function getAsArray(): array
68+
{
69+
return array_filter([
70+
'bankName' => $this->bankName,
71+
'bankIdentifierCode' => $this->bankIdentifierCode,
72+
'correspondingAccount' => $this->correspondingAccount,
73+
'paymentAccount' => $this->paymentAccount,
74+
], fn($value) => !is_null($value));
75+
}
76+
}

0 commit comments

Comments
 (0)