### Create Payment Request Source: https://github.com/dicrtarasov/yii2-payparts/blob/master/README.md Create a payment request to initiate a 'Payment in installments' transaction. This involves specifying order details, product information, and the desired number of installments. The response contains a token and a redirect URL for customer checkout. ```php /** @var PayPartsModule $module получаем модуль оплат */ $module = Yii::$app->getModule('payparts'); // запрос на создание платежа $request = $module->paymentRequest([ 'orderId' => $orderId, // номер заказа в интернет-магазине 'merchantType' => PayParts::MERCHANT_TYPE_PP, // сервис "оплата частями" 'partsCount' => 2, // кол-во частей 'products' => [ ['name' => 'Рулон бумаги', 'price' => 0.01, 'count' => 2], ['name' => 'Автомобиль', 'price' => 123, 'count' => 1], ['name' => 'Талоны на Интернет', 'price' => 123.123, 'count' => 3] ] ]); // отправляем запрос и получаем токен $response = $request->send(); echo 'Token: ' . $response->token . "\n"; echo 'Redirect URL: ' . $response->paymentUrl . "\n"; // переадресация покупателя на страницу оплаты $response->redirectCheckout(); ``` -------------------------------- ### Get Payment State Source: https://github.com/dicrtarasov/yii2-payparts/blob/master/README.md If a callback handler is not configured, you can retrieve the payment status by sending a state request. This is useful for verifying the transaction status after a payment attempt. ```php // запрос состояния платежа $request = $module->createStateRequest([ 'orderId' => $orderId // номер заказа ]); // проверяем состояние платежа $response = $request->send(); echo 'PaymentState: ' . $response->paymentState . "\n"; ``` -------------------------------- ### Configure Payparts Module Source: https://github.com/dicrtarasov/yii2-payparts/blob/master/README.md Configure the Payparts module in your Yii2 application's config. Essential settings include storeId and password. An optional callback handler can be specified to process payment status changes. ```php [ 'modules' => [ 'payparts' => [ 'class' => dicr\payparts\PayPartsModule::class, 'storeId' => '* мой storeId *', 'password' => '* мой password *', // обработчик состояний платежей (опционально) 'callbackHandler' => static function(dicr\payparts\PayPartsResponse $response) { Order::setPayed($response->orderId); } ] ] ]; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.