/** * Create Assistant payment form * * @param $orderId * @param $amount * @param string $currency * @param null $description * @param bool|false $isIframe * @param null $paymentSystem * @param bool|false $isRegular * @param null $additionalData * @param string $method * @return MonetaSdkResult * @throws MonetaSdkException */ public function showPaymentFrom($orderId, $amount, $currency = 'RUB', $description = null, $isIframe = false, $paymentSystem = null, $isRegular = false, $additionalData = null, $method = 'POST') { $this->calledMethods[] = __FUNCTION__; $orderId = $orderId ? $orderId : str_replace('.', '', trim(microtime(true))) . rand(1, 99); $isIframe = $isRegular ? false : $isIframe; // pre Execute if (!in_array('processInputData', $this->calledMethods)) { $forwardProcessName = $isIframe ? 'ForwardPaymentFormIframe' : 'ForwardPaymentForm'; $this->processInputData($forwardProcessName); if (isset($this->data['event']) && $this->data['event'] == $forwardProcessName) { return $this->getCurrentMethodResult(); } } // Execute $viewName = $isIframe ? 'PaymentFromIframe' : 'PaymentFrom'; $this->cleanResultData(); $this->checkMonetaServiceConnection(); $amount = number_format($amount, 2, '.', ''); $paymentSystem = $isRegular ? 'plastic' : $this->selectPaymentSystem($paymentSystem); $autoSubmit = false; $transactionId = 0; $paymentSystemParams = $this->getSettingValue('monetasdk_paysys_' . $paymentSystem); if (!isset($additionalData['MNT_FORWARD_FORM']) && ($paymentSystemParams['createInvoice'] || isset($additionalData['additionalParameters_ownerLogin']) || $isRegular)) { $payer = $paymentSystemParams['accountId']; $payee = $this->getSettingValue('monetasdk_account_id'); $transactionId = $this->sdkMonetaCreateInvoice($payer, $payee, $amount, $orderId, $paymentSystem, $isRegular, $additionalData); $additionalData['MNT_FORWARD_FORM'] = true; if ($isRegular) { $notificationEmail = null; if (isset($additionalData['additionalParameters_ownerLogin'])) { $notificationEmail = $additionalData['additionalParameters_ownerLogin']; } $saveInvoiceData = array('invoiceId' => $transactionId, 'payer' => $payer, 'payee' => $payee, 'amount' => $amount, 'orderId' => $orderId, 'paymentSystem' => $paymentSystem, 'invoiceStatus' => self::STATUS_NEW, 'notificationEmail' => $notificationEmail, 'recursion' => 0); $storage = $this->getStorageService(); $storage->createInvoice($saveInvoiceData); } } $action = $this->getSettingValue('monetasdk_demo_mode') ? $this->getSettingValue('monetasdk_demo_url') : $this->getSettingValue('monetasdk_production_url'); $action .= $isIframe ? $this->getSettingValue('monetasdk_assistant_widget_link') : $this->getSettingValue('monetasdk_assistant_link'); if ($transactionId) { if (!$isRegular) { $autoSubmit = true; } $action .= '?operationId=' . $transactionId; } // для форвардинга формы if (!$additionalData && $paymentSystemParams['createInvoice'] || $isRegular && !$transactionId) { $action = ""; } $signature = null; $monetaAccountCode = $this->getSettingValue('monetasdk_account_code'); if ($monetaAccountCode && $monetaAccountCode != '') { $signature = md5($this->getSettingValue('monetasdk_account_id') . $orderId . $amount . $currency . $this->getSettingValue('monetasdk_test_mode') . $monetaAccountCode); } $additionalFields = $this->getAdditionalFieldsByPaymentSystem($paymentSystem); if ($isRegular) { $additionalFields[] = 'additionalParameters_ownerLogin'; } $postData = $this->createPostDataFromArray($this->addAdditionalData($additionalFields)); $sdkFields = array('MNT_ID', 'MNT_TRANSACTION_ID', 'MNT_CURRENCY_CODE', 'MNT_AMOUNT', 'MNT_DESCRIPTION', 'MNT_TEST_MODE', 'MNT_SIGNATURE', 'MNT_SUCCESS_URL', 'MNT_FAIL_URL', 'followup', 'paymentSystem_accountId', 'paymentSystem_unitId', 'paymentSystem_limitIds', 'MNT_PAY_SYSTEM', 'MNT_IS_REGULAR', 'MNT_IS_IFRAME', 'MNT_FORM_METHOD', 'submit', 'additionalParameters_ownerLogin'); $postData = MonetaSdkUtils::placeAdditionalValues($postData, $additionalData); $forwardFields = $this->pvtGetForwardDataArray($postData, $sdkFields); $this->data = array('paySystem' => $paymentSystem, 'orderId' => $orderId, 'amount' => $amount, 'description' => $description, 'currency' => $currency, 'action' => $action, 'method' => $method, 'formName' => $viewName, 'formId' => $viewName . time() . rand(1, 10), 'postData' => $postData, 'additionalData' => $additionalData, 'testMode' => $this->getSettingValue('monetasdk_test_mode'), 'signature' => $signature, 'successUrl' => $this->getSettingValue('monetasdk_success_url'), 'failUrl' => $this->getSettingValue('monetasdk_fail_url'), 'accountId' => $this->getSettingValue('monetasdk_account_id'), 'isRegular' => $isRegular ? '1' : null, 'isIframe' => $isIframe ? '1' : null, 'autoSubmit' => $autoSubmit ? '1' : null, 'operationId' => $transactionId, 'paymentSystemParams' => $paymentSystemParams, 'forwardFields' => $forwardFields); $this->render = MonetaSdkUtils::requireView($viewName, $this->data, $this->getSettingValue('monetasdk_view_files_path')); return $this->getCurrentMethodResult(); }