From d89b3730e4315ba480dc6f62b2f08560a967da24 Mon Sep 17 00:00:00 2001 From: vatrcore Date: Tue, 24 Dec 2024 14:22:36 +0300 Subject: [PATCH] FB-1722 add sbp payment --- src/Enum/CloudMethodsEnum.php | 6 +++ src/Library.php | 26 +++++++++++++ src/Request/PaymentsSbp.php | 48 ++++++++++++++++++++++++ src/Request/PaymentsSbpLink.php | 13 +++++++ src/Request/PaymentsSbpQr.php | 13 +++++++ src/Response/Models/SbpBankModel.php | 18 +++++++++ src/Response/Models/TransactionModel.php | 5 +++ src/Response/TransactionResponse.php | 10 +++++ 8 files changed, 139 insertions(+) create mode 100644 src/Request/PaymentsSbp.php create mode 100644 src/Request/PaymentsSbpLink.php create mode 100644 src/Request/PaymentsSbpQr.php create mode 100644 src/Response/Models/SbpBankModel.php diff --git a/src/Enum/CloudMethodsEnum.php b/src/Enum/CloudMethodsEnum.php index 1bca7d4..7e68de0 100644 --- a/src/Enum/CloudMethodsEnum.php +++ b/src/Enum/CloudMethodsEnum.php @@ -43,6 +43,12 @@ class CloudMethodsEnum extends Enum /** Отмена оплаты */ public const PAYMENTS_VOID = 'payments/void'; + /** Генерация платежной ссылки СБП */ + public const PAYMENTS_SBP_LINK = 'payments/qr/sbp/link'; + + /** Генерация QR-кода СБП */ + public const PAYMENTS_SBP_QR = 'payments/qr/sbp/image'; + /** Старт сессии Applepay */ public const APPLEPAY_STARTSESSION = 'applepay/startsession'; diff --git a/src/Library.php b/src/Library.php index 85484e5..a11021b 100644 --- a/src/Library.php +++ b/src/Library.php @@ -17,6 +17,8 @@ use Flowwow\Cloudpayments\Request\PaymentsList; use Flowwow\Cloudpayments\Request\PaymentsListV2; use Flowwow\Cloudpayments\Request\PaymentsRefund; +use Flowwow\Cloudpayments\Request\PaymentsSbpLink; +use Flowwow\Cloudpayments\Request\PaymentsSbpQr; use Flowwow\Cloudpayments\Request\PaymentsVoid; use Flowwow\Cloudpayments\Request\Post3DS; use Flowwow\Cloudpayments\Request\Receipt\CorrectionReceiptData; @@ -343,6 +345,30 @@ public function paymentsTokensList(?TokenList $data = null): TokenArrayResponse return $this->request($method, $data === null ? [] : $data->asArray(), new TokenArrayResponse()); } + /** + * Создание оплаты СБП по ссылке + * @param PaymentsSbpLink $data + * @return TransactionResponse + */ + public function paymentsSbpLink(PaymentsSbpLink $data): TransactionResponse + { + $method = CloudMethodsEnum::PAYMENTS_SBP_LINK; + + return $this->request($method, $data->asArray(), new TransactionResponse()); + } + + /** + * Создание оплаты СБП по QR-коду + * @param PaymentsSbpQr $data + * @return TransactionResponse + */ + public function paymentsSbpQr(PaymentsSbpQr $data): TransactionResponse + { + $method = CloudMethodsEnum::PAYMENTS_SBP_QR; + + return $this->request($method, $data->asArray(), new TransactionResponse()); + } + /** * Метод создания подписки на рекуррентные платежи * @param SubscriptionCreate $data diff --git a/src/Request/PaymentsSbp.php b/src/Request/PaymentsSbp.php new file mode 100644 index 0000000..2658cf0 --- /dev/null +++ b/src/Request/PaymentsSbp.php @@ -0,0 +1,48 @@ +amount = $amount; + $this->currency = $currency; + $this->description = $description; + $this->scheme = 'charge'; + } +} diff --git a/src/Request/PaymentsSbpLink.php b/src/Request/PaymentsSbpLink.php new file mode 100644 index 0000000..a125144 --- /dev/null +++ b/src/Request/PaymentsSbpLink.php @@ -0,0 +1,13 @@ +fill($modelDate); + if (isset($modelDate->Banks->dictionary) && is_array($modelDate->Banks->dictionary)) { + $banks = []; + foreach ($modelDate->Banks->dictionary as $bankValue) { + $bank = new SbpBankModel(); + $bank->fill($bankValue); + $banks[] = $bank; + } + $model->sbpBankModels = $banks; + } $this->model = $model; }