From 34c136ce70b11a1b2ffaefdfaa969ee571f0f41d Mon Sep 17 00:00:00 2001 From: Alexander Viktorchik Date: Fri, 5 Jul 2024 11:02:28 +0300 Subject: [PATCH 1/5] qst create api inerfaces, classes, example --- src/ApiRequest.php | 7 + src/ApiRequestInterface.php | 7 + src/Examples/qstCreate.php | 89 +++++++ src/Qst.php | 55 +++++ src/QstInterface.php | 30 +++ src/QstSchema.php | 336 ++++++++++++++++++++++++++ src/QstSchemaActualAddress.php | 27 +++ src/QstSchemaAddressAbstract.php | 111 +++++++++ src/QstSchemaAddressInterface.php | 74 ++++++ src/QstSchemaBankAccount.php | 64 +++++ src/QstSchemaBankAccountInterface.php | 47 ++++ src/QstSchemaCeo.php | 96 ++++++++ src/QstSchemaCeoInterface.php | 63 +++++ src/QstSchemaCheckableTrait.php | 31 +++ src/QstSchemaIdentityDoc.php | 116 +++++++++ src/QstSchemaIdentityDocInterface.php | 75 ++++++ src/QstSchemaInterface.php | 266 ++++++++++++++++++++ src/QstSchemaLegalAddress.php | 12 + src/QstSchemaOwner.php | 49 ++++ src/QstSchemaOwnerInterface.php | 30 +++ src/QstSchemaPostAddress.php | 27 +++ src/QstToArrayInterface.php | 13 + 22 files changed, 1625 insertions(+) create mode 100644 src/Examples/qstCreate.php create mode 100644 src/Qst.php create mode 100644 src/QstInterface.php create mode 100644 src/QstSchema.php create mode 100644 src/QstSchemaActualAddress.php create mode 100644 src/QstSchemaAddressAbstract.php create mode 100644 src/QstSchemaAddressInterface.php create mode 100644 src/QstSchemaBankAccount.php create mode 100644 src/QstSchemaBankAccountInterface.php create mode 100644 src/QstSchemaCeo.php create mode 100644 src/QstSchemaCeoInterface.php create mode 100644 src/QstSchemaCheckableTrait.php create mode 100644 src/QstSchemaIdentityDoc.php create mode 100644 src/QstSchemaIdentityDocInterface.php create mode 100644 src/QstSchemaInterface.php create mode 100644 src/QstSchemaLegalAddress.php create mode 100644 src/QstSchemaOwner.php create mode 100644 src/QstSchemaOwnerInterface.php create mode 100644 src/QstSchemaPostAddress.php create mode 100644 src/QstToArrayInterface.php diff --git a/src/ApiRequest.php b/src/ApiRequest.php index f88b65c..6452470 100644 --- a/src/ApiRequest.php +++ b/src/ApiRequest.php @@ -24,6 +24,7 @@ class ApiRequest implements ApiRequestInterface const REPORT_ORDERS_API_V4 = '/api/v4/reports/orders'; const REPORT_ORDER_DETAILS_API = '/api/v4/reports/order-details'; const PODELI_MERCHANT_REGISTRATION_API = '/api/v4/registration/merchant/podeli'; + const QST_CREATE_API = '/api/v4/qst/create'; const HOST = 'https://secure.ypmn.ru'; const SANDBOX_HOST = 'https://sandbox.ypmn.ru'; const LOCAL_HOST = 'http://127.0.0.1'; @@ -594,4 +595,10 @@ public function sendPodeliRegistrationMerchantRequest(PodeliMerchant $merchant): { return $this->sendPostRequest($merchant, self::PODELI_MERCHANT_REGISTRATION_API); } + + /** @inheritdoc */ + public function sendQstCreateRequest(QstInterface $qst): array + { + return $this->sendPostRequest($qst, self::QST_CREATE_API); + } } diff --git a/src/ApiRequestInterface.php b/src/ApiRequestInterface.php index ad54168..f39610e 100644 --- a/src/ApiRequestInterface.php +++ b/src/ApiRequestInterface.php @@ -146,4 +146,11 @@ public function setHost(string $host) : self; * @return array */ public function sendPodeliRegistrationMerchantRequest(PodeliMerchant $merchant): array; + + /** + * Отправить запрос на создание и отправку анкеты (по добавлению продавцов) на проверку + * @param Qst $qst + * @return array + */ + public function sendQstCreateRequest(QstInterface $qst): array; } diff --git a/src/Examples/qstCreate.php b/src/Examples/qstCreate.php new file mode 100644 index 0000000..50e9ced --- /dev/null +++ b/src/Examples/qstCreate.php @@ -0,0 +1,89 @@ +setInn('7750005806'); + +/* Данные продавца */ +$qstSchema = new QstSchema(); +$qstSchema->addPhone('+7 495 1234567, доб. 123'); +$qstSchema->addPhone('+7 499 7654321, доб. 321'); +$qstSchema->addEmail('example@ypmn.com'); + +$qstLegalAddress = (new QstSchemaLegalAddress()) + ->setZip('123456') + ->setRegion('Москва') + ->setCity('Москва') + ->setStreet('ул. Арбат') + ->setHouse('10'); +$qstSchema->setLegalAddress($qstLegalAddress); + +$qstActualAddress = (new QstSchemaActualAddress())->setChecked(true); +$qstSchema->setActualAddress($qstActualAddress); + +$qstCeoIdentityDoc = (new QstSchemaIdentityDoc()) + ->setSeries('1234') + ->setNumber('123456') + ->setIssueDate('2000-01-30') + ->setIssuedBy('МВД') + ->setIssuedByKP('123-456'); + +$qstCeo = (new QstSchemaCeo()) + ->setIdentityDoc($qstCeoIdentityDoc) + ->setBirthDate('1990-01-30') + ->setBirthPlace('Москва') + ->setRegistrationAddress('г. Москва, ул. Ленина, д. 1, кв. 1'); +$qstSchema->setCeo($qstCeo); + +$qstOwner = (new QstSchemaOwner())->setOwner('Иванов Иван Иванович')->setShare('100'); +$qstSchema->addOwner($qstOwner); + +$qstBankAccount = (new QstSchemaBankAccount()) + ->setBankBIK('044525974') + ->setBankCorAccount('30101810145250000974') + ->setBankAccount('40817810400002911811'); + +$qstSchema->addBankAccount($qstBankAccount); + +$qstSchema->setAdditionalFieldByKey(1, 'Доп. поле'); + +$qst->setSchema($qstSchema); + +/* Создадим HTTP-запрос к API */ +$apiRequest = new ApiRequest($merchant); + +// Включить режим отладки (закомментируйте или удалите в рабочей программе!) // +$apiRequest->setDebugMode(); +// Переключиться на тестовый сервер (закомментируйте или удалите в рабочей программе!) // +$apiRequest->setLocalMode(); + +// Отправим запрос // +$responseData = $apiRequest->sendQstCreateRequest($qst); + +/* Преобразуем ответ из JSON в массив */ +try { + $responseData = json_decode((string) $responseData["response"], true); + echo "Анкета #{$responseData['id']} создана и отправлена на проверка"; +} catch (Exception $exception) { + echo "Ошибка запроса: {$exception->getMessage()}"; + throw new Exception($exception->getMessage()); +} diff --git a/src/Qst.php b/src/Qst.php new file mode 100644 index 0000000..0c80513 --- /dev/null +++ b/src/Qst.php @@ -0,0 +1,55 @@ +inn; + } + + /** @inheritdoc */ + public function setInn(string $inn): self + { + $this->inn = $inn; + return $this; + } + + /** @inheritdoc */ + public function getSchema(): QstSchemaInterface + { + return $this->schema; + } + + /** @inheritdoc */ + public function setSchema(QstSchemaInterface $schema): self + { + $this->schema = $schema; + return $this; + } + + /** + * @return string + */ + public function jsonSerialize(): string + { + $requestData = [ + 'inn' => $this->getInn(), + 'schema' => $this->getSchema()->toArray() + ]; + + return json_encode($requestData, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_LINE_TERMINATORS); + } +} diff --git a/src/QstInterface.php b/src/QstInterface.php new file mode 100644 index 0000000..a443863 --- /dev/null +++ b/src/QstInterface.php @@ -0,0 +1,30 @@ +foreignName; + } + + /** @inheritdoc */ + public function setForeignName(string $foreignName): self + { + $this->foreignName = $foreignName; + return $this; + } + + /** @inheritdoc */ + public function getPhones(): array + { + return $this->phones; + } + + /** @inheritdoc */ + public function addPhone(string $phone): self + { + $this->phones[] = compact('phone'); + return $this; + } + + /** @inheritdoc */ + public function getEmails(): array + { + return $this->emails; + } + + /** @inheritdoc */ + public function addEmail(string $email): self + { + $this->emails[] = compact('email'); + return $this; + } + + /** @inheritdoc */ + public function getLegalAddress(): QstSchemaAddressInterface + { + return $this->legalAddress; + } + + /** @inheritdoc */ + public function setLegalAddress(QstSchemaAddressInterface $legalAddress): self + { + $this->legalAddress = $legalAddress; + return $this; + } + + /** @inheritdoc */ + public function getPostAddress(): ?QstSchemaAddressInterface + { + return $this->postAddress; + } + + /** @inheritdoc */ + public function setPostAddress(QstSchemaAddressInterface $postAddress): self + { + $this->postAddress = $postAddress; + return $this; + } + + /** @inheritdoc */ + public function getActualAddress(): QstSchemaAddressInterface + { + return $this->actualAddress; + } + + /** @inheritdoc */ + public function setActualAddress(QstSchemaAddressInterface $actualAddress): self + { + $this->actualAddress = $actualAddress; + return $this; + } + + /** @inheritdoc */ + public function getCeo(): QstSchemaCeoInterface + { + return $this->ceo; + } + + /** @inheritdoc */ + public function setCeo(QstSchemaCeoInterface $ceo): self + { + $this->ceo = $ceo; + return $this; + } + + /** @inheritdoc */ + public function getOwners(): array + { + return $this->owners; + } + + /** @inheritdoc */ + public function addOwner(QstSchemaOwnerInterface $owner): self + { + $this->owners[] = $owner; + return $this; + } + + /** @inheritdoc */ + public function getBoardOfDirectors(): ?string + { + return $this->boardOfDirectors; + } + + /** @inheritdoc */ + public function setBoardOfDirectors(string $boardOfDirectors): self + { + $this->boardOfDirectors = $boardOfDirectors; + return $this; + } + + /** @inheritdoc */ + public function getManagementBoard(): ?string + { + return $this->managementBoard; + } + + /** @inheritdoc */ + public function setManagementBoard(string $managementBoard): self + { + $this->managementBoard = $managementBoard; + return $this; + } + + /** @inheritdoc */ + public function getOtherManagementBodies(): ?string + { + return $this->otherManagementBodies; + } + + /** @inheritdoc */ + public function setOtherManagementBodies(string $otherManagementBodies): self + { + $this->otherManagementBodies = $otherManagementBodies; + return $this; + } + + /** @inheritdoc */ + public function getAddressLocation(): ?string + { + return $this->addressLocation; + } + + /** @inheritdoc */ + public function setAddressLocation(string $addressLocation): self + { + $this->addressLocation = $addressLocation; + return $this; + } + + /** @inheritdoc */ + public function getBirthDate(): ?string + { + return $this->birthDate; + } + + /** @inheritdoc */ + public function setBirthDate(string $birthDate): self + { + $this->birthDate = $birthDate; + return $this; + } + + /** @inheritdoc */ + public function getBirthPlace(): ?string + { + return $this->birthPlace; + } + + /** @inheritdoc */ + public function setBirthPlace(string $birthPlace): self + { + $this->birthPlace = $birthPlace; + return $this; + } + + /** @inheritdoc */ + public function getIdentityDoc(): ?QstSchemaIdentityDocInterface + { + return $this->identityDoc; + } + + /** @inheritdoc */ + public function setIdentityDoc(QstSchemaIdentityDocInterface $identityDoc): self + { + $this->identityDoc = $identityDoc; + return $this; + } + + /** @inheritdoc */ + public function getBankAccounts(): array + { + return $this->bankAccounts; + } + + /** @inheritdoc */ + public function addBankAccount(QstSchemaBankAccountInterface $bankAccount): self + { + $this->bankAccounts[] = $bankAccount; + return $this; + } + + /** @inheritdoc */ + public function getLicense(): ?string + { + return $this->license; + } + + /** @inheritdoc */ + public function setLicense(string $license): self + { + $this->license = $license; + return $this; + } + + /** @inheritdoc */ + public function getActionInFavor(): ?string + { + return $this->actionInFavor; + } + + /** @inheritdoc */ + public function setActionInFavor(string $actionInFavor): self + { + $this->actionInFavor = $actionInFavor; + return $this; + } + + /** @inheritdoc */ + public function getCommission(): ?string + { + return $this->commission; + } + + /** @inheritdoc */ + public function setCommission(string $commission): self + { + $this->commission = $commission; + return $this; + } + + /** @inheritdoc */ + public function getAdditionalFields(): array + { + return $this->additionalFields; + } + + /** @inheritdoc */ + public function getAdditionalFieldByKey(int $key): ?string + { + return $this->additionalFields[$key] ?? null; + } + + /** @inheritdoc */ + public function setAdditionalFieldByKey(int $key, string $value): self + { + $this->additionalFields[$key] = $value; + + return $this; + } + + /** @inheritdoc */ + public function toArray(): array + { + $array = [ + 'foreignName' => $this->getForeignName(), + 'phones' => $this->getPhones(), + 'emails' => $this->getEmails(), + 'legalAddress' => $this->getLegalAddress()->toArray(), + 'postAddress' => $this->getPostAddress()->toArray(), + 'actualAddress' => $this->getPostAddress()->toArray(), + 'ceo' => $this->getCeo()->toArray(), + 'owners' => array_map(static fn (QstSchemaOwnerInterface $owner) => $owner->toArray(), $this->getOwners()), + 'boardOfDirectors' => $this->getBoardOfDirectors(), + 'managementBoard' => $this->getManagementBoard(), + 'otherManagementBodies' => $this->getOtherManagementBodies(), + 'addressLocation' => $this->getAddressLocation(), + 'birthDate' => $this->getBirthDate(), + 'birthPlace' => $this->getBirthPlace(), + 'identityDoc' => $this->getIdentityDoc() ? $this->getIdentityDoc()->toArray() : null, + 'bankAccounts' => array_map( + static fn (QstSchemaBankAccountInterface $bankAccount) => ['bankAccount' => $bankAccount->toArray()], + $this->getOwners() + ), + 'license' => $this->getLicense(), + 'actionInFavor' => $this->getActionInFavor(), + 'commission' => $this->getCommission(), + ]; + + foreach ($this->additionalFields as $key => $value) { + $array['additionalField' . $key] = $value; + } + + return array_filter($array, static fn ($value) => $value !== null); + } +} diff --git a/src/QstSchemaActualAddress.php b/src/QstSchemaActualAddress.php new file mode 100644 index 0000000..72cf490 --- /dev/null +++ b/src/QstSchemaActualAddress.php @@ -0,0 +1,27 @@ +isChecked()) { + return [ + 'isChecked' => true + ]; + } + + return parent::toArray(); + } +} diff --git a/src/QstSchemaAddressAbstract.php b/src/QstSchemaAddressAbstract.php new file mode 100644 index 0000000..65b93d0 --- /dev/null +++ b/src/QstSchemaAddressAbstract.php @@ -0,0 +1,111 @@ +zip; + } + + /** @inheritdoc */ + public function setZip(string $zip): self + { + $this->zip = $zip; + return $this; + } + + /** @inheritdoc */ + public function getRegion(): string + { + return $this->region; + } + + /** @inheritdoc */ + public function setRegion(string $region): self + { + $this->region = $region; + return $this; + } + + /** @inheritdoc */ + public function getCity(): string + { + return $this->city; + } + + /** @inheritdoc */ + public function setCity(string $city): self + { + $this->city = $city; + return $this; + } + + /** @inheritdoc */ + public function getStreet(): string + { + return $this->street; + } + + /** @inheritdoc */ + public function setStreet(string $street): self + { + $this->street = $street; + return $this; + } + + /** @inheritdoc */ + public function getHouse(): string + { + return $this->house; + } + + /** @inheritdoc */ + public function setHouse(string $house): self + { + $this->house = $house; + return $this; + } + + /** @inheritdoc */ + public function getFlat(): ?string + { + return $this->flat; + } + + /** @inheritdoc */ + public function setFlat(string $flat): self + { + $this->flat = $flat; + return $this; + } + + /** @inheritdoc */ + public function toArray(): ?array + { + $array = [ + 'zip' => $this->getZip(), + 'region' => $this->getRegion(), + 'city' => $this->getCity(), + 'street' => $this->getStreet(), + 'house' => $this->getHouse(), + 'flat' => $this->getFlat() + ]; + + return array_filter($array, static fn ($value) => $value !== null); + } +} diff --git a/src/QstSchemaAddressInterface.php b/src/QstSchemaAddressInterface.php new file mode 100644 index 0000000..7d8a6b2 --- /dev/null +++ b/src/QstSchemaAddressInterface.php @@ -0,0 +1,74 @@ +bankBIK; + } + + /** @inheritdoc */ + public function setBankBIK(string $bankBIK): self + { + $this->bankBIK = $bankBIK; + return $this; + } + + /** @inheritdoc */ + public function getBankCorAccount(): string + { + return $this->bankCorAccount; + } + + /** @inheritdoc */ + public function setBankCorAccount(string $bankCorAccount): self + { + $this->bankCorAccount = $bankCorAccount; + return $this; + } + + /** @inheritdoc */ + public function getBankAccount(): string + { + return $this->bankAccount; + } + + /** @inheritdoc */ + public function setBankAccount(string $bankAccount): self + { + $this->bankAccount = $bankAccount; + return $this; + } + + /** @inheritdoc */ + public function toArray(): array + { + return [ + 'bankBIK' => $this->getBankBIK(), + 'bankCorAccount' => $this->getBankAccount(), + 'bankAccount' => $this->getBankAccount() + ]; + } +} \ No newline at end of file diff --git a/src/QstSchemaBankAccountInterface.php b/src/QstSchemaBankAccountInterface.php new file mode 100644 index 0000000..7725f42 --- /dev/null +++ b/src/QstSchemaBankAccountInterface.php @@ -0,0 +1,47 @@ +citizenship; + } + + /** @inheritdoc */ + public function setCitizenship(string $citizenship): self + { + $this->citizenship = $citizenship; + return $this; + } + + /** @inheritdoc */ + public function getBirthDate(): string + { + return $this->birthDate; + } + + /** @inheritdoc */ + public function setBirthDate(string $birthDate): self + { + $this->birthDate = $birthDate; + return $this; + } + + /** @inheritdoc */ + public function getBirthPlace(): string + { + return $this->birthPlace; + } + + /** @inheritdoc */ + public function setBirthPlace(string $birthPlace): self + { + $this->birthPlace = $birthPlace; + return $this; + } + + /** @inheritdoc */ + public function getIdentityDoc(): QstSchemaIdentityDocInterface + { + return $this->identityDoc; + } + + /** @inheritdoc */ + public function setIdentityDoc(QstSchemaIdentityDocInterface $identityDoc): self + { + $this->identityDoc = $identityDoc; + return $this; + } + + /** @inheritdoc */ + public function getRegistrationAddress(): string + { + return $this->registrationAddress; + } + + /** @inheritdoc */ + public function setRegistrationAddress(string $registrationAddress): self + { + $this->registrationAddress = $registrationAddress; + return $this; + } + + /** @inheritdoc */ + public function toArray(): ?array + { + $array = [ + 'citizenship' => $this->getCitizenship(), + 'birthDate' => $this->getBirthDate(), + 'birthPlace' => $this->getBirthPlace(), + 'identityDoc' => $this->getIdentityDoc()->toArray(), + 'registrationAddress' => $this->getRegistrationAddress() + ]; + + return array_filter($array, static fn ($value) => $value !== null); + } +} \ No newline at end of file diff --git a/src/QstSchemaCeoInterface.php b/src/QstSchemaCeoInterface.php new file mode 100644 index 0000000..4c921ad --- /dev/null +++ b/src/QstSchemaCeoInterface.php @@ -0,0 +1,63 @@ +checked; + } + + /** + * @param bool|null $checked + * @return $this + */ + public function setChecked(bool $checked) + { + $this->checked = $checked; + return $this; + } +} diff --git a/src/QstSchemaIdentityDoc.php b/src/QstSchemaIdentityDoc.php new file mode 100644 index 0000000..cb57624 --- /dev/null +++ b/src/QstSchemaIdentityDoc.php @@ -0,0 +1,116 @@ + 'PASSPORT', + 'other' => 'OTHER' + ]; + + private ?string $type = null; + private string $series; + private string $number; + private string $issueDate; + private string $issuedBy; + private string $issuedByKP; + + /** @inheritdoc */ + public function getType(): ?string + { + return $this->type; + } + + /** @inheritdoc */ + public function setType(string $type): self + { + $this->type = $type; + return $this; + } + + /** @inheritdoc */ + public function getSeries(): string + { + return $this->series; + } + + /** @inheritdoc */ + public function setSeries(string $series): self + { + $this->series = $series; + return $this; + } + + /** @inheritdoc */ + public function getNumber(): string + { + return $this->number; + } + + /** @inheritdoc */ + public function setNumber(string $number): self + { + $this->number = $number; + return $this; + } + + /** @inheritdoc */ + public function getIssueDate(): string + { + return $this->issueDate; + } + + /** @inheritdoc */ + public function setIssueDate(string $issueDate): self + { + $this->issueDate = $issueDate; + return $this; + } + + /** @inheritdoc */ + public function getIssuedBy(): string + { + return $this->issuedBy; + } + + /** @inheritdoc */ + public function setIssuedBy(string $issuedBy): self + { + $this->issuedBy = $issuedBy; + return $this; + } + + /** @inheritdoc */ + public function getIssuedByKP(): string + { + return $this->issuedByKP; + } + + /** @inheritdoc */ + public function setIssuedByKP(string $issuedByKP): self + { + $this->issuedByKP = $issuedByKP; + return $this; + } + + /** @inheritdoc */ + public function toArray(): ?array + { + $array = [ + 'type' => $this->getType(), + 'series' => $this->getSeries(), + 'number' => $this->getNumber(), + 'issueDate' => $this->getIssueDate(), + 'issuedBy' => $this->getIssuedBy(), + 'issuedByKP' => $this->getIssuedByKP() + ]; + + return array_filter($array, static fn ($value) => $value !== null); + } +} \ No newline at end of file diff --git a/src/QstSchemaIdentityDocInterface.php b/src/QstSchemaIdentityDocInterface.php new file mode 100644 index 0000000..05ea002 --- /dev/null +++ b/src/QstSchemaIdentityDocInterface.php @@ -0,0 +1,75 @@ +owner; + } + + /** @inheritdoc */ + public function setOwner(string $owner): self + { + $this->owner = $owner; + return $this; + } + + /** @inheritdoc */ + public function getShare(): string + { + return $this->share; + } + + /** @inheritdoc */ + public function setShare(string $share): self + { + $this->share = $share; + return $this; + } + + /** @inheritdoc */ + public function toArray(): array + { + return [ + 'owner' => $this->getOwner(), + 'share' => $this->getShare(), + ]; + } +} \ No newline at end of file diff --git a/src/QstSchemaOwnerInterface.php b/src/QstSchemaOwnerInterface.php new file mode 100644 index 0000000..63a6e1a --- /dev/null +++ b/src/QstSchemaOwnerInterface.php @@ -0,0 +1,30 @@ +isChecked()) { + return [ + 'isChecked' => true + ]; + } + + return parent::toArray(); + } +} diff --git a/src/QstToArrayInterface.php b/src/QstToArrayInterface.php new file mode 100644 index 0000000..9aa88f4 --- /dev/null +++ b/src/QstToArrayInterface.php @@ -0,0 +1,13 @@ + Date: Fri, 5 Jul 2024 19:17:21 +0300 Subject: [PATCH 2/5] qst create IP, status, print, list api --- example.php | 6 ++ example_list.php | 32 ++++++- src/ApiRequest.php | 88 +++++++++++++++++- src/ApiRequestInterface.php | 33 +++++++ src/Examples/getToken.php | 2 +- src/Examples/qstCreateIp.php | 89 +++++++++++++++++++ .../{qstCreate.php => qstCreateOrg.php} | 27 +++--- src/Examples/qstList.php | 19 ++++ src/Examples/qstPrint.php | 22 +++++ src/Examples/qstStatus.php | 22 +++++ src/QstSchema.php | 17 ++-- src/QstSchemaBankAccount.php | 2 +- src/QstSchemaInterface.php | 4 +- 13 files changed, 336 insertions(+), 27 deletions(-) create mode 100644 src/Examples/qstCreateIp.php rename src/Examples/{qstCreate.php => qstCreateOrg.php} (78%) create mode 100644 src/Examples/qstList.php create mode 100644 src/Examples/qstPrint.php create mode 100644 src/Examples/qstStatus.php diff --git a/example.php b/example.php index 11e9ab9..0bb7cb0 100644 --- a/example.php +++ b/example.php @@ -53,6 +53,12 @@ case 'getFasterPayment': case 'getBindingFasterPayment': case 'paymentByFasterBinding': + case 'qstCreateOrg': + case 'qstCreateIp': + case 'qstStatus': + case 'qstPrint': + case 'SOMGetPaymentLink': + case 'qstList': require './src/Examples/start.php'; @include './src/Examples/'.$_GET['function'] . '__prepend.php'; require './src/Examples/'.$_GET['function'] . '.php'; diff --git a/example_list.php b/example_list.php index f280a35..0f1d9a7 100644 --- a/example_list.php +++ b/example_list.php @@ -131,9 +131,39 @@ 'link' => '', ], 'SOMGetPaymentLink' => [ - 'name' => 'Самая простая кнопка оплаты', + 'name' => 'Оплата зарубежными картами', 'about' => 'В этом примере показана простая реализация оплаты заказа зарубежной картой.', 'docLink' => 'https://ypmn.ru/ru/documentation/#tag/payment-api', 'link' => '', ], + 'qstCreateOrg' => [ + 'name' => 'Подключение продавца-организации по API (отправка анкеты)', + 'about' => 'В этом примере показана реализация отправки анкеты подключаемого продавца-организации на проверку в YPMN.', + 'docLink' => 'https://ypmn.ru/ru/documentation/#tag/qst-api/paths/~1v4~1qst~1create/post', + 'link' => '', + ], + 'qstCreateIp' => [ + 'name' => 'Подключение продавца-ИП по API (отправка анкеты)', + 'about' => 'В этом примере показана реализация отправки анкеты подключаемого продавца-ИП на проверку в YPMN.', + 'docLink' => 'https://ypmn.ru/ru/documentation/#tag/qst-api/paths/~1v4~1qst~1create/post', + 'link' => '', + ], + 'qstStatus' => [ + 'name' => 'Получение статуса анкеты', + 'about' => 'В этом примере показано получение статуса анкеты по её ID.

ID анкеты возвращается при отправке анкеты на проверку.', + 'docLink' => 'https://ypmn.ru/ru/documentation/#tag/qst-api/paths/~1v4~1qst~1status~1%7Bid%7D/get', + 'link' => '', + ], + 'qstPrint' => [ + 'name' => 'Печать анкеты', + 'about' => 'В этом примере показано получение заполненной pdf версии анкеты по её ID.

ID анкеты возвращается при отправке анкеты на проверку.

Распечатать можно только одобренную анкету - в статусе approved.', + 'docLink' => 'https://ypmn.ru/ru/documentation/#tag/qst-api/paths/~1v4~1qst~1print~1%7Bid%7D/get', + 'link' => '', + ], + 'qstList' => [ + 'name' => 'Список анкет', + 'about' => 'В этом примере показано получение списка анкет.', + 'docLink' => 'https://ypmn.ru/ru/documentation/#tag/qst-api/paths/~1v4~1qst~1list/get', + 'link' => '', + ], ]; diff --git a/src/ApiRequest.php b/src/ApiRequest.php index 6452470..7a9aab8 100644 --- a/src/ApiRequest.php +++ b/src/ApiRequest.php @@ -25,6 +25,9 @@ class ApiRequest implements ApiRequestInterface const REPORT_ORDER_DETAILS_API = '/api/v4/reports/order-details'; const PODELI_MERCHANT_REGISTRATION_API = '/api/v4/registration/merchant/podeli'; const QST_CREATE_API = '/api/v4/qst/create'; + const QST_STATUS_API = '/api/v4/qst/status'; + const QST_PRINT_API = '/api/v4/qst/print'; + const QST_LIST_API = '/api/v4/qst/list'; const HOST = 'https://secure.ypmn.ru'; const SANDBOX_HOST = 'https://sandbox.ypmn.ru'; const LOCAL_HOST = 'http://127.0.0.1'; @@ -41,6 +44,9 @@ class ApiRequest implements ApiRequestInterface /** @var bool Режим Отладки (вывод системных сообщений) */ private bool $debugModeIsOn = false; + /** @var bool Отображать заголовки ответа в режим отладки */ + private bool $debugShowResponseHeaders = true; + /** @var bool Формат результата в режиме отладки */ private bool $jsonDebugResponse = true; @@ -221,6 +227,12 @@ private function sendGetRequest(string $api): array ] ]; + $headers = []; + + if ($this->getDebugShowResponseHeaders()) { + $this->addCurlOptHeaderFunction($setopt_array, $headers); + } + curl_setopt_array($curl, $setopt_array); $response = curl_exec($curl); @@ -232,11 +244,16 @@ private function sendGetRequest(string $api): array $this->echoDebugMessage($this->getHost() . $api); $this->echoDebugMessage('Ответ от сервера Ypmn:'); if ($this->getJsonDebugResponse()) { - $this->echoDebugMessage(json_encode(json_decode($response), JSON_PRETTY_PRINT)); + $this->echoDebugMessage(json_encode(json_decode($response), JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE)); } else { $this->echoDebugMessage($response); } + if ($this->getDebugShowResponseHeaders()) { + $this->echoDebugMessage('Заголовки ответа от сервера Ypmn:'); + $this->echoDebugMessage(implode("\n", $headers)); + } + if (mb_strlen($err) > 0) { $this->echoDebugMessage('Ошибка'); echo '
Вы можете отправить запрос на поддержку на itsupport@ypmn.ru'; @@ -297,7 +314,7 @@ public function sendPostRequest($data, string $api): array $date = (new DateTime())->format(DateTimeInterface::ATOM); $requestHttpVerb = 'POST'; - curl_setopt_array($curl, [ + $setOptArray = [ CURLOPT_URL => $this->getHost() . $api, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', @@ -319,7 +336,15 @@ public function sendPostRequest($data, string $api): array $encodedJsonDataHash ) ] - ]); + ]; + + $headers = []; + + if ($this->getDebugShowResponseHeaders()) { + $this->addCurlOptHeaderFunction($setOptArray, $headers); + } + + curl_setopt_array($curl, $setOptArray); $response = curl_exec($curl); $err = curl_error($curl); @@ -329,7 +354,12 @@ public function sendPostRequest($data, string $api): array $this->echoDebugMessage('POST-Запрос к серверу Ypmn:'); $this->echoDebugMessage($encodedJsonData); $this->echoDebugMessage('Ответ от сервера Ypmn:'); - $this->echoDebugMessage(json_encode(json_decode($response), JSON_PRETTY_PRINT)); + $this->echoDebugMessage(json_encode(json_decode($response), JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE)); + + if ($this->getDebugShowResponseHeaders()) { + $this->echoDebugMessage('Заголовки ответа от сервера Ypmn:'); + $this->echoDebugMessage(implode("\n", $headers)); + } if (mb_strlen($err) > 0) { $this->echoDebugMessage('Ошибка'); @@ -601,4 +631,54 @@ public function sendQstCreateRequest(QstInterface $qst): array { return $this->sendPostRequest($qst, self::QST_CREATE_API); } + + /** @inheritdoc */ + public function sendQstStatusRequest(int $qstId): array + { + return $this->sendGetRequest(self::QST_STATUS_API . '/' . $qstId); + } + + /** @inheritdoc */ + public function sendQstPrintRequest(int $qstId): array + { + return $this->sendGetRequest(self::QST_PRINT_API . '/' . $qstId); + } + + /** @inheritdoc */ + public function sendQstListRequest(): array + { + return $this->sendGetRequest(self::QST_LIST_API); + } + + /** @inheritdoc */ + public function getDebugShowResponseHeaders(): bool + { + return $this->debugShowResponseHeaders; + } + + /** @inheritdoc */ + public function setDebugShowResponseHeaders(bool $debugShowResponseHeaders = true): self + { + $this->debugShowResponseHeaders = $debugShowResponseHeaders; + return $this; + } + + /** + * @param array $curlOptArr + * @param array $headers + * @return void + */ + private function addCurlOptHeaderFunction(array &$curlOptArr, array &$headers): void + { + $curlOptArr += [ + CURLOPT_HEADERFUNCTION => static function($curl, $header) use (&$headers) + { + if (strlen(trim($header)) > 0) { + $headers[] = trim($header); + } + + return strlen($header); + } + ]; + } } diff --git a/src/ApiRequestInterface.php b/src/ApiRequestInterface.php index f39610e..eaed9f5 100644 --- a/src/ApiRequestInterface.php +++ b/src/ApiRequestInterface.php @@ -153,4 +153,37 @@ public function sendPodeliRegistrationMerchantRequest(PodeliMerchant $merchant): * @return array */ public function sendQstCreateRequest(QstInterface $qst): array; + + /** + * Получить статус анкеты + * @param int $qstId + * @return array + */ + public function sendQstStatusRequest(int $qstId): array; + + /** + * Распечатать анкету + * @param int $qstId + * @return array + */ + public function sendQstPrintRequest(int $qstId): array; + + /** + * Получить список анкет + * @return array + */ + public function sendQstListRequest(): array; + + /** + * Получить установлен ли режим показывать заголовки ответа в режиме отладки + * @return bool + */ + public function getDebugShowResponseHeaders(): bool; + + /** + * Установить показывать заголовки ответа в режиме отладки + * @param bool $debugShowResponseHeaders + * @return self + */ + public function setDebugShowResponseHeaders(bool $debugShowResponseHeaders = true): self; } diff --git a/src/Examples/getToken.php b/src/Examples/getToken.php index cfc8250..efac48b 100644 --- a/src/Examples/getToken.php +++ b/src/Examples/getToken.php @@ -33,7 +33,7 @@

Вот он: ' . $responseData['token'] . '
-
Тперь его можно использовать в платежах вместо данных карты +
Теперь его можно использовать в платежах вместо данных карты ', ]); } diff --git a/src/Examples/qstCreateIp.php b/src/Examples/qstCreateIp.php new file mode 100644 index 0000000..ec03f68 --- /dev/null +++ b/src/Examples/qstCreateIp.php @@ -0,0 +1,89 @@ +setInn('773200328662'); + +/* Данные продавца */ +$qstSchema = new QstSchema(); +$qstSchema->addPhone('+7 495 1234567, доб. 123'); +$qstSchema->addEmail('example@ypmn.com'); + +$qstLegalAddress = (new QstSchemaLegalAddress()) + ->setZip('123456') + ->setRegion('Москва') + ->setCity('Москва') + ->setStreet('ул. Охотный ряд') + ->setHouse('1'); +$qstSchema->setLegalAddress($qstLegalAddress); + +$qstActualAddress = (new QstSchemaActualAddress())->setChecked(true); +$qstSchema->setActualAddress($qstActualAddress); + +$qstPostAddress = (new QstSchemaPostAddress())->setChecked(true); +$qstSchema->setPostAddress($qstPostAddress); + +$qstIdentityDoc = (new QstSchemaIdentityDoc()) + ->setSeries('1234') + ->setNumber('123456') + ->setIssueDate('2000-01-30') + ->setIssuedBy('МВД') + ->setIssuedByKP('123-456'); + +$qstSchema + ->setBirthDate('1969-02-23') + ->setBirthPlace('Москва') + ->setIdentityDoc($qstIdentityDoc); + +$qstBankAccount = (new QstSchemaBankAccount()) + ->setBankBIK('044525700') + ->setBankCorAccount('30101810200000000700') + ->setBankAccount('40702810100002400756'); + +$qstSchema->addBankAccount($qstBankAccount); + +$qstSchema->setAdditionalFieldByKey(1, 'Доп. поле'); + +$qst->setSchema($qstSchema); + +/* Создадим HTTP-запрос к API */ +$apiRequest = new ApiRequest($merchant); + +// Включить режим отладки (закомментируйте или удалите в рабочей программе!) // +$apiRequest->setDebugMode(); +// Переключиться на тестовый сервер (закомментируйте или удалите в рабочей программе!) // +$apiRequest->setSandboxMode(); + +/* Запрос на отправку анкеты */ +$responseData = $apiRequest->sendQstCreateRequest($qst); + +/* Преобразуем ответ из JSON в массив */ +try { + $responseData = json_decode((string) $responseData["response"], true); + if (isset($responseData['id'])) { + echo "Анкета #{$responseData['id']} создана и отправлена на проверку"; + } else { + echo "Анкета не создана, см. причину в ответа от сервера YPMN"; + } +} catch (Exception $exception) { + echo "Ошибка запроса: {$exception->getMessage()}"; + throw new Exception($exception->getMessage()); +} diff --git a/src/Examples/qstCreate.php b/src/Examples/qstCreateOrg.php similarity index 78% rename from src/Examples/qstCreate.php rename to src/Examples/qstCreateOrg.php index 50e9ced..4a062fd 100644 --- a/src/Examples/qstCreate.php +++ b/src/Examples/qstCreateOrg.php @@ -21,7 +21,7 @@ $qst = new Qst(); /* ИНН продавца */ -$qst->setInn('7750005806'); +$qst->setInn('7704217370'); /* Данные продавца */ $qstSchema = new QstSchema(); @@ -30,11 +30,12 @@ $qstSchema->addEmail('example@ypmn.com'); $qstLegalAddress = (new QstSchemaLegalAddress()) - ->setZip('123456') + ->setZip('123112') ->setRegion('Москва') ->setCity('Москва') - ->setStreet('ул. Арбат') - ->setHouse('10'); + ->setStreet('Пресненская наб.') + ->setHouse('д. 10') + ->setFlat('эт. 41, Пом. I, комн. 6'); $qstSchema->setLegalAddress($qstLegalAddress); $qstActualAddress = (new QstSchemaActualAddress())->setChecked(true); @@ -49,7 +50,7 @@ $qstCeo = (new QstSchemaCeo()) ->setIdentityDoc($qstCeoIdentityDoc) - ->setBirthDate('1990-01-30') + ->setBirthDate('1980-01-30') ->setBirthPlace('Москва') ->setRegistrationAddress('г. Москва, ул. Ленина, д. 1, кв. 1'); $qstSchema->setCeo($qstCeo); @@ -58,9 +59,9 @@ $qstSchema->addOwner($qstOwner); $qstBankAccount = (new QstSchemaBankAccount()) - ->setBankBIK('044525974') - ->setBankCorAccount('30101810145250000974') - ->setBankAccount('40817810400002911811'); + ->setBankBIK('044525700') + ->setBankCorAccount('30101810200000000700') + ->setBankAccount('40702810100002400756'); $qstSchema->addBankAccount($qstBankAccount); @@ -74,15 +75,19 @@ // Включить режим отладки (закомментируйте или удалите в рабочей программе!) // $apiRequest->setDebugMode(); // Переключиться на тестовый сервер (закомментируйте или удалите в рабочей программе!) // -$apiRequest->setLocalMode(); +$apiRequest->setSandboxMode(); -// Отправим запрос // +/* Запрос на отправку анкеты */ $responseData = $apiRequest->sendQstCreateRequest($qst); /* Преобразуем ответ из JSON в массив */ try { $responseData = json_decode((string) $responseData["response"], true); - echo "Анкета #{$responseData['id']} создана и отправлена на проверка"; + if (isset($responseData['id'])) { + echo "Анкета #{$responseData['id']} создана и отправлена на проверку"; + } else { + echo "Анкета не создана, см. причину в ответа от сервера YPMN"; + } } catch (Exception $exception) { echo "Ошибка запроса: {$exception->getMessage()}"; throw new Exception($exception->getMessage()); diff --git a/src/Examples/qstList.php b/src/Examples/qstList.php new file mode 100644 index 0000000..28ef173 --- /dev/null +++ b/src/Examples/qstList.php @@ -0,0 +1,19 @@ +setDebugMode(); +// Переключиться на тестовый сервер (закомментируйте или удалите в рабочей программе!) // +$apiRequest->setSandboxMode(); + +/* Запрос на получение списка анкет */ +$responseData = $apiRequest->sendQstListRequest(); diff --git a/src/Examples/qstPrint.php b/src/Examples/qstPrint.php new file mode 100644 index 0000000..c01d100 --- /dev/null +++ b/src/Examples/qstPrint.php @@ -0,0 +1,22 @@ +setDebugMode(); +// Переключиться на тестовый сервер (закомментируйте или удалите в рабочей программе!) // +$apiRequest->setSandboxMode(); + +/* id анкеты, полученный при создании анкеты */ +$qstId = 1; + +/* Запрос на получение pdf анкеты */ +$apiRequest->sendQstPrintRequest($qstId); diff --git a/src/Examples/qstStatus.php b/src/Examples/qstStatus.php new file mode 100644 index 0000000..37d4f1d --- /dev/null +++ b/src/Examples/qstStatus.php @@ -0,0 +1,22 @@ +setDebugMode(); +// Переключиться на тестовый сервер (закомментируйте или удалите в рабочей программе!) // +$apiRequest->setSandboxMode(); + +/* id анкеты, полученный при создании анкеты */ +$qstId = 1; + +/* Запрос на получение статуса анкеты */ +$responseData = $apiRequest->sendQstStatusRequest($qstId); diff --git a/src/QstSchema.php b/src/QstSchema.php index 8985dba..1fa1669 100644 --- a/src/QstSchema.php +++ b/src/QstSchema.php @@ -15,7 +15,7 @@ class QstSchema implements QstSchemaInterface private QstSchemaAddressInterface $legalAddress; private ?QstSchemaAddressInterface $postAddress = null; private QstSchemaAddressInterface $actualAddress; - private QstSchemaCeoInterface $ceo; + private ?QstSchemaCeoInterface $ceo = null; /** @var QstSchemaOwnerInterface[] */ private array $owners = []; private ?string $boardOfDirectors = null; @@ -111,7 +111,7 @@ public function setActualAddress(QstSchemaAddressInterface $actualAddress): self } /** @inheritdoc */ - public function getCeo(): QstSchemaCeoInterface + public function getCeo(): ?QstSchemaCeoInterface { return $this->ceo; } @@ -307,10 +307,13 @@ public function toArray(): array 'phones' => $this->getPhones(), 'emails' => $this->getEmails(), 'legalAddress' => $this->getLegalAddress()->toArray(), - 'postAddress' => $this->getPostAddress()->toArray(), - 'actualAddress' => $this->getPostAddress()->toArray(), - 'ceo' => $this->getCeo()->toArray(), - 'owners' => array_map(static fn (QstSchemaOwnerInterface $owner) => $owner->toArray(), $this->getOwners()), + 'postAddress' => $this->getPostAddress() ? $this->getPostAddress()->toArray() : null, + 'actualAddress' => $this->getActualAddress()->toArray(), + 'ceo' => $this->getCeo() ? $this->getCeo()->toArray() : null, + 'owners' => + !empty($this->getOwners()) + ? array_map(static fn (QstSchemaOwnerInterface $owner) => $owner->toArray(), $this->getOwners()) + : null, 'boardOfDirectors' => $this->getBoardOfDirectors(), 'managementBoard' => $this->getManagementBoard(), 'otherManagementBodies' => $this->getOtherManagementBodies(), @@ -320,7 +323,7 @@ public function toArray(): array 'identityDoc' => $this->getIdentityDoc() ? $this->getIdentityDoc()->toArray() : null, 'bankAccounts' => array_map( static fn (QstSchemaBankAccountInterface $bankAccount) => ['bankAccount' => $bankAccount->toArray()], - $this->getOwners() + $this->getBankAccounts() ), 'license' => $this->getLicense(), 'actionInFavor' => $this->getActionInFavor(), diff --git a/src/QstSchemaBankAccount.php b/src/QstSchemaBankAccount.php index f48f62d..f6a909d 100644 --- a/src/QstSchemaBankAccount.php +++ b/src/QstSchemaBankAccount.php @@ -57,7 +57,7 @@ public function toArray(): array { return [ 'bankBIK' => $this->getBankBIK(), - 'bankCorAccount' => $this->getBankAccount(), + 'bankCorAccount' => $this->getBankCorAccount(), 'bankAccount' => $this->getBankAccount() ]; } diff --git a/src/QstSchemaInterface.php b/src/QstSchemaInterface.php index 12d7c0f..d8c15ca 100644 --- a/src/QstSchemaInterface.php +++ b/src/QstSchemaInterface.php @@ -73,9 +73,9 @@ public function getActualAddress(): QstSchemaAddressInterface; public function setActualAddress(QstSchemaAddressInterface $actualAddress): self; /** - * @return QstSchemaCeoInterface + * @return QstSchemaCeoInterface|null */ - public function getCeo(): QstSchemaCeoInterface; + public function getCeo(): ?QstSchemaCeoInterface; /** * @param QstSchemaCeoInterface $ceo From 22c5b13c78b17864e43af23ceb5fc2b36e33e965 Mon Sep 17 00:00:00 2001 From: Alexander Viktorchik Date: Fri, 5 Jul 2024 19:39:43 +0300 Subject: [PATCH 3/5] qst api - add descriptions for methods --- src/QstInterface.php | 4 ++++ src/QstSchemaAddressInterface.php | 12 ++++++++++++ src/QstSchemaCeo.php | 4 ++-- src/QstSchemaCeoInterface.php | 10 ++++++++++ src/QstSchemaCheckableTrait.php | 5 ++--- src/QstSchemaIdentityDocInterface.php | 17 ++++++++++++++++- src/QstSchemaInterface.php | 22 +++++++++++++++++++--- src/QstSchemaOwnerInterface.php | 4 ++++ 8 files changed, 69 insertions(+), 9 deletions(-) diff --git a/src/QstInterface.php b/src/QstInterface.php index a443863..ac4bfb2 100644 --- a/src/QstInterface.php +++ b/src/QstInterface.php @@ -7,22 +7,26 @@ interface QstInterface { /** + * ИНН продавца * @return string */ public function getInn(): string; /** + * ИНН продавца * @param string $inn * @return $this */ public function setInn(string $inn): self; /** + * Данные продавца * @return QstSchemaInterface */ public function getSchema(): QstSchemaInterface; /** + * Данные продавца * @param QstSchemaInterface $schema * @return $this */ diff --git a/src/QstSchemaAddressInterface.php b/src/QstSchemaAddressInterface.php index 7d8a6b2..bfbe68d 100644 --- a/src/QstSchemaAddressInterface.php +++ b/src/QstSchemaAddressInterface.php @@ -7,66 +7,78 @@ interface QstSchemaAddressInterface extends QstToArrayInterface { /** + * Индекс * @return string */ public function getZip(): string; /** + * Индекс * @param string $zip * @return $this */ public function setZip(string $zip): self; /** + * Регион * @return string */ public function getRegion(): string; /** + * Регион * @param string $region * @return $this */ public function setRegion(string $region): self; /** + * Город * @return string */ public function getCity(): string; /** + * Город * @param string $city * @return $this */ public function setCity(string $city): self; /** + * Улица * @return string */ public function getStreet(): string; /** + * Улица * @param string $street * @return $this */ public function setStreet(string $street): self; /** + * Дом * @return string */ public function getHouse(): string; /** + * Дом * @param string $house * @return $this */ public function setHouse(string $house): self; /** + * Офис / квартира * @return string|null */ public function getFlat(): ?string; /** + * Офис / квартира * @param string $flat * @return $this */ diff --git a/src/QstSchemaCeo.php b/src/QstSchemaCeo.php index 7600cf5..c4a60dd 100644 --- a/src/QstSchemaCeo.php +++ b/src/QstSchemaCeo.php @@ -4,8 +4,8 @@ namespace Ypmn; -/* - * Руководитель продавца в анкете +/** + * Данные о руководителе в анкете */ class QstSchemaCeo implements QstSchemaCeoInterface { diff --git a/src/QstSchemaCeoInterface.php b/src/QstSchemaCeoInterface.php index 4c921ad..2f44d30 100644 --- a/src/QstSchemaCeoInterface.php +++ b/src/QstSchemaCeoInterface.php @@ -7,55 +7,65 @@ interface QstSchemaCeoInterface extends QstToArrayInterface { /** + * Гражданство * @return string|null */ public function getCitizenship(): ?string; /** + * Гражданство * @param string $citizenship * @return $this */ public function setCitizenship(string $citizenship): self; /** + * Дата рождения * @return string */ public function getBirthDate(): string; /** + * Дата рождения * @param string $birthDate * @return $this */ public function setBirthDate(string $birthDate): self; /** + * Место рождения * @return string */ public function getBirthPlace(): string; /** + * Место рождения * @param string $birthPlace * @return $this */ public function setBirthPlace(string $birthPlace): self; /** + * Документ удостоверяющий личность * @return QstSchemaIdentityDocInterface */ public function getIdentityDoc(): QstSchemaIdentityDocInterface; /** + * Документ удостоверяющий личность * @param QstSchemaIdentityDocInterface $identityDoc * @return $this */ public function setIdentityDoc(QstSchemaIdentityDocInterface $identityDoc): self; /** + * Адрес регистрации * @return string */ public function getRegistrationAddress(): string; /** + * Адрес регистрации * @param string $registrationAddress * @return $this */ diff --git a/src/QstSchemaCheckableTrait.php b/src/QstSchemaCheckableTrait.php index 652affd..54e8cbd 100644 --- a/src/QstSchemaCheckableTrait.php +++ b/src/QstSchemaCheckableTrait.php @@ -4,14 +4,12 @@ namespace Ypmn; -/** - * Это класс адреса продавца в анкете - **/ trait QstSchemaCheckableTrait { private bool $checked = false; /** + * Получить свойство isChecked для поля в анкете * @return bool|null */ public function isChecked(): bool @@ -20,6 +18,7 @@ public function isChecked(): bool } /** + * Установить свойство isChecked для поля в анкете * @param bool|null $checked * @return $this */ diff --git a/src/QstSchemaIdentityDocInterface.php b/src/QstSchemaIdentityDocInterface.php index 05ea002..aa4da1d 100644 --- a/src/QstSchemaIdentityDocInterface.php +++ b/src/QstSchemaIdentityDocInterface.php @@ -7,67 +7,82 @@ interface QstSchemaIdentityDocInterface extends QstToArrayInterface { /** - * + * Тип документа: + * - PASSPORT - паспорт РФ; + * - OTHER - иной документ, удостоверяющий личность * @return string|null */ public function getType(): ?string; /** + * Тип документа: + * - PASSPORT - паспорт РФ; + * - OTHER - иной документ, удостоверяющий личность * @param string $type * @return $this */ public function setType(string $type): self; /** + * Серия документа * @return string|null */ public function getSeries(): string; /** + * Серия документа * @param string $series * @return $this */ public function setSeries(string $series): self; /** + * Номер документа * @return string|null */ public function getNumber(): string; /** + * Номер документа * @param string $number * @return $this */ public function setNumber(string $number): self; /** + * Дата выдачи документа * @return string|null */ public function getIssueDate(): string; /** + * Дата выдачи документа * @param string $issueDate * @return $this */ public function setIssueDate(string $issueDate): self; /** + * Кем выдан документ * @return string|null */ public function getIssuedBy(): string; /** + * Кем выдан документ * @param string $issuedBy * @return $this */ public function setIssuedBy(string $issuedBy): self; /** + * Кем выдан документ (к/п) * @return string|null */ public function getIssuedByKP(): string; /** + * Кем выдан документ (к/п) * @param string $issuedByKP * @return $this */ diff --git a/src/QstSchemaInterface.php b/src/QstSchemaInterface.php index d8c15ca..0790830 100644 --- a/src/QstSchemaInterface.php +++ b/src/QstSchemaInterface.php @@ -7,88 +7,104 @@ interface QstSchemaInterface extends QstToArrayInterface { /** + * Наименование на иностранном языке * @return string|null */ public function getForeignName(): ?string; /** + * Наименование на иностранном языке * @param string $foreignName * @return $this */ public function setForeignName(string $foreignName): self; /** + * Список телефонов * @return array */ public function getPhones(): array; /** + * Добавить телефон * @param string $phone * @return $this */ public function addPhone(string $phone): self; /** + * Список email * @return array */ public function getEmails(): array; /** + * Добавить email * @param string $email * @return $this */ public function addEmail(string $email): self; /** + * Юридический адрес * @return QstSchemaAddressInterface */ public function getLegalAddress(): QstSchemaAddressInterface; /** + * Юридический адрес * @param QstSchemaAddressInterface $legalAddress * @return $this */ public function setLegalAddress(QstSchemaAddressInterface $legalAddress): self; /** + * Почтовый адрес * @return QstSchemaAddressInterface|null */ public function getPostAddress(): ?QstSchemaAddressInterface; /** + * Почтовый адрес * @param QstSchemaAddressInterface $postAddress * @return $this */ public function setPostAddress(QstSchemaAddressInterface $postAddress): self; /** + * Фактический адрес * @return QstSchemaAddressInterface */ public function getActualAddress(): QstSchemaAddressInterface; /** + * Фактический адрес * @param QstSchemaAddressInterface $actualAddress * @return $this */ public function setActualAddress(QstSchemaAddressInterface $actualAddress): self; /** + * Данные о руководителе * @return QstSchemaCeoInterface|null */ public function getCeo(): ?QstSchemaCeoInterface; /** + * Данные о руководителе * @param QstSchemaCeoInterface $ceo * @return $this */ public function setCeo(QstSchemaCeoInterface $ceo): self; /** + * Список собственников * @return QstSchemaOwnerInterface[] */ public function getOwners(): array; /** + * Список собственников * @param QstSchemaOwnerInterface $owner * @return $this */ @@ -244,20 +260,20 @@ public function getCommission(): ?string; public function setCommission(string $commission): self; /** - * Доп. поля в анкете + * Получить доп. поля в анкете * @return array */ public function getAdditionalFields(): array; /** - * Доп. поля в анкете + * Получить доп. поле в анкете по индексу поля * @param int $key * @return string|null */ public function getAdditionalFieldByKey(int $key): ?string; /** - * Доп. поля в анкете + * Установить значение доп. поля в анкете по индексу поля * @param int $key * @param string $value * @return $this diff --git a/src/QstSchemaOwnerInterface.php b/src/QstSchemaOwnerInterface.php index 63a6e1a..7423f1a 100644 --- a/src/QstSchemaOwnerInterface.php +++ b/src/QstSchemaOwnerInterface.php @@ -7,22 +7,26 @@ interface QstSchemaOwnerInterface extends QstToArrayInterface { /** + * Имя собственника * @return string */ public function getOwner(): string; /** + * Имя собственника * @param string $owner * @return $this */ public function setOwner(string $owner): self; /** + * Доля собственника * @return string */ public function getShare(): string; /** + * Доля собственника * @param string $share * @return $this */ From 1c3a06796b4ffbe16705cc48a052633780b3eb72 Mon Sep 17 00:00:00 2001 From: Alexander Viktorchik Date: Fri, 19 Jul 2024 16:45:08 +0300 Subject: [PATCH 4/5] qst - update params names --- src/QstSchemaActualAddress.php | 2 +- src/QstSchemaPostAddress.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/QstSchemaActualAddress.php b/src/QstSchemaActualAddress.php index 72cf490..5331a78 100644 --- a/src/QstSchemaActualAddress.php +++ b/src/QstSchemaActualAddress.php @@ -18,7 +18,7 @@ public function toArray(): ?array { if ($this->isChecked()) { return [ - 'isChecked' => true + 'isEqualToLegalAddress' => true ]; } diff --git a/src/QstSchemaPostAddress.php b/src/QstSchemaPostAddress.php index 0f81a0f..25d146c 100644 --- a/src/QstSchemaPostAddress.php +++ b/src/QstSchemaPostAddress.php @@ -18,7 +18,7 @@ public function toArray(): ?array { if ($this->isChecked()) { return [ - 'isChecked' => true + 'isEqualToLegalAddress' => true ]; } From 4c1aaf59021711f69e09a4a47239463ec357bd7a Mon Sep 17 00:00:00 2001 From: Alexander Viktorchik Date: Fri, 19 Jul 2024 16:53:03 +0300 Subject: [PATCH 5/5] qst - update readme --- README.md | 7 +++++++ example_list.php | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a376ddd..5a188fc 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,13 @@ docker compose up --detach ##### 9. [Страница после оплаты](src/Examples/returnPage.php) +##### 10. Подключение продавцов +1. [Подключение продавца-организации (отправка анкеты)](src/Examples/qstCreateOrg.php) +2. [Подключение продавца-ИП (отправка анкеты)](src/Examples/qstCreateIp.php) +3. [Получение статуса анкеты](src/Examples/qstStatus.php) +4. [Печать анкеты](src/Examples/qstPrint.php) +5. [Список анкет](src/Examples/qstList.php) + ## Ссылки - [НКО «Твои Платежи»](https://YPMN.ru/) - [Докуметация API](https://ypmn.ru/ru/documentation/) diff --git a/example_list.php b/example_list.php index 0f1d9a7..58b635e 100644 --- a/example_list.php +++ b/example_list.php @@ -137,13 +137,13 @@ 'link' => '', ], 'qstCreateOrg' => [ - 'name' => 'Подключение продавца-организации по API (отправка анкеты)', + 'name' => 'Подключение продавца-организации (отправка анкеты)', 'about' => 'В этом примере показана реализация отправки анкеты подключаемого продавца-организации на проверку в YPMN.', 'docLink' => 'https://ypmn.ru/ru/documentation/#tag/qst-api/paths/~1v4~1qst~1create/post', 'link' => '', ], 'qstCreateIp' => [ - 'name' => 'Подключение продавца-ИП по API (отправка анкеты)', + 'name' => 'Подключение продавца-ИП (отправка анкеты)', 'about' => 'В этом примере показана реализация отправки анкеты подключаемого продавца-ИП на проверку в YPMN.', 'docLink' => 'https://ypmn.ru/ru/documentation/#tag/qst-api/paths/~1v4~1qst~1create/post', 'link' => '',