ITS-29: upload module (#1)

* ITS-29: upload module

* ITS-29: update module

* ITS-29: update url-s

* ITS-29: uncomment currency
This commit is contained in:
Anatoly Cherkasov 2018-05-21 19:21:56 +03:00 committed by Anton Kuranda
parent e256803fb6
commit 6ad22314bc
13 changed files with 942 additions and 1 deletions

53
.gitignore vendored Normal file
View File

@ -0,0 +1,53 @@
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
*.DS_Store
*.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr
*.iws
## Plugin-specific files:
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
# Target folder
target

View File

@ -1 +1,15 @@
# rbkmoney-cms-magento
# rbkmoney-cms-magento
### Инструкция по установке
- Скопировать содержимое `app` в соответствующую папку `app/`
- Установленный модуль заработает сразу после его настройки в админке:
```
"Система - Конфигурация - Продажи - Методы оплаты"
(System - Configuration - Sales - Payment Methods)
```
- Параметры для заполнения можно получить на сайте платёжной системы [RBKmoney](https://dashboard.rbk.money)
- В качестве URL для уведомления о смене статуса инвойса в личном кабинете указать:
```
http{s}://{your-site}/rbkmoney/payment/notification
```

View File

@ -0,0 +1,49 @@
<?php
/**
* Fieldset renderer for RBKmoney payform solutions group
*/
class RBKmoney_Payform_Block_Adminhtml_System_Config_Fieldset_Group
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
{
/**
* Return header comment part of html for fieldset
*
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
protected function _getHeaderCommentHtml($element)
{
$groupConfig = $this->getGroup($element)->asArray();
if (empty($groupConfig['help_url']) || !$element->getComment()) {
return parent::_getHeaderCommentHtml($element);
}
$html = '<div class="comment">' . $element->getComment()
. ' <a target="_blank" href="' . $groupConfig['help_url'] . '">'
. Mage::helper('payform')->__('Help') . '</a></div>';
return $html;
}
/**
* Return collapse state
*
* @param Varien_Data_Form_Element_Abstract $element
* @return bool
*/
protected function _getCollapseState($element)
{
$extra = Mage::getSingleton('admin/session')->getUser()->getExtra();
if (isset($extra['configState'][$element->getId()])) {
return $extra['configState'][$element->getId()];
}
if ($element->getExpanded() !== null) {
return 1;
}
return false;
}
}

View File

@ -0,0 +1,10 @@
<?php
class RBKmoney_Payform_Block_Form_Payform extends Mage_Payment_Block_Form
{
protected function _construct()
{
parent::_construct();
$this->setTemplate('payform/form/payform.phtml');
}
}

View File

@ -0,0 +1,17 @@
<?php
class RBKmoney_Payform_Block_Info_Payform extends Mage_Payment_Block_Info
{
protected function _prepareSpecificInformation($transport = null)
{
if (null !== $this->_paymentSpecificInformation)
{
return $this->_paymentSpecificInformation;
}
$data = array();
$transport = parent::_prepareSpecificInformation($transport);
return $transport->setData(array_merge($data, $transport->getData()));
}
}

View File

@ -0,0 +1,286 @@
<?php
class RBKmoney_Payform_Helper_Data extends Mage_Core_Helper_Data
{
const COMMON_PATH = 'payment/payform/';
/**
* Payment form
*/
const PAYMENT_FORM_URL = 'https://checkout.rbk.money/checkout.js';
const API_URL = 'https://api.rbk.money/v1/';
/**
* Create invoice settings
*/
const CREATE_INVOICE_TEMPLATE_DUE_DATE = 'Y-m-d\TH:i:s\Z';
const CREATE_INVOICE_DUE_DATE = '+1 days';
/**
* HTTP status code
*/
const HTTP_CODE_OK = 200;
const HTTP_CODE_CREATED = 201;
const HTTP_CODE_BAD_REQUEST = 400;
/**
* Constants fields settings
*/
const SETTINGS_SHOP_ID = 'shop_id';
const SETTINGS_PAYMENT_FORM_LOGO = 'payment_form_logo';
const SETTINGS_PAYMENT_FORM_COMPANY_NAME = 'payment_form_company_name';
const SETTINGS_PAYMENT_FORM_BUTTON_LABEL = 'payment_form_button_label';
const SETTINGS_PAYMENT_FORM_DESCRIPTION = 'payment_form_description';
const SETTINGS_PAYMENT_FORM_CSS_BUTTON = 'payment_form_css_button';
const SETTINGS_PRIVATE_KEY = 'private_key';
const SETTINGS_CALLBACK_PUBLIC_KEY = 'callback_public_key';
const SETTINGS_DEBUG = 'debug';
public function getShopId()
{
return (int)Mage::getStoreConfig(static::COMMON_PATH . static::SETTINGS_SHOP_ID);
}
public function getPrivateKey()
{
return trim(Mage::getStoreConfig(static::COMMON_PATH . static::SETTINGS_PRIVATE_KEY));
}
public function getCallbackPublicKey()
{
return trim(Mage::getStoreConfig(static::COMMON_PATH . static::SETTINGS_CALLBACK_PUBLIC_KEY));
}
public function getPaymentFormLogo()
{
return trim(Mage::getStoreConfig(static::COMMON_PATH . static::SETTINGS_PAYMENT_FORM_LOGO));
}
public function getPaymentFormCompanyName()
{
return trim(strip_tags(Mage::getStoreConfig(static::COMMON_PATH . static::SETTINGS_PAYMENT_FORM_COMPANY_NAME)));
}
public function getPaymentFormButtonLabel()
{
return trim(strip_tags(Mage::getStoreConfig(static::COMMON_PATH . static::SETTINGS_PAYMENT_FORM_BUTTON_LABEL)));
}
public function getPaymentFormDescription()
{
return trim(strip_tags(Mage::getStoreConfig(static::COMMON_PATH . static::SETTINGS_PAYMENT_FORM_DESCRIPTION)));
}
public function getPaymentFormCssButton()
{
return trim(strip_tags(Mage::getStoreConfig(static::COMMON_PATH . static::SETTINGS_PAYMENT_FORM_CSS_BUTTON)));
}
public function getDebug()
{
return Mage::getStoreConfig(static::COMMON_PATH . static::SETTINGS_DEBUG);
}
public function getSuccessUrl()
{
return Mage::getUrl('checkout/onepage/success', array('_secure' => false));
}
public function getFailUrl()
{
return Mage::getUrl('checkout/onepage/error', array('_secure' => false));
}
/**
* Create invoice access token
*
* @param $invoice_id
*
* @return string
* @throws Exception
*/
public function createInvoiceAccessToken($invoice_id)
{
$url = $this->_prepareApiUrl('processing/invoices/' . $invoice_id . '/access_tokens');
$response = $this->_send($url, $this->_getHeaders(), '', 'access_tokens');
if ($response['http_code'] != static::HTTP_CODE_CREATED) {
throw new Exception('An error occurred while creating Invoice Access Token');
}
$response_decode = json_decode($response['body'], true);
$access_token = !empty($response_decode['payload']) ? $response_decode['payload'] : '';
return $access_token;
}
/**
* Create invoice
*
* @param $order
*
* @return string
* @throws Exception
*/
public function createInvoice(Mage_Sales_Model_Order $order)
{
$data = [
'shopID' => $this->getShopId(),
'amount' => $this->prepareAmount(number_format($order->getGrandTotal(), 2)),
'metadata' => $this->_prepareMetadata($order),
'dueDate' => $this->_prepareDueDate(),
'currency' => $order->getBaseCurrency()->getCode(),
'product' => $order->getId(),
'description' => "",
];
$url = $this->_prepareApiUrl('processing/invoices');
$response = $this->_send($url, $this->_getHeaders(), json_encode($data), 'init_invoice');
if ($response['http_code'] != static::HTTP_CODE_CREATED) {
$message = 'An error occurred while creating invoice';
throw new Exception($message);
}
$response_decode = json_decode($response['body'], true);
$invoice_id = !empty($response_decode['id']) ? $response_decode['id'] : '';
return $invoice_id;
}
/**
* Send request
*
* @param string $url
* @param array $headers
* @param string $data
*
* @return array
*/
function _send($url = '', $headers = [], $data = '')
{
$logs = array(
'url' => $url,
'headers' => $headers,
'data' => $data,
);
$logs['request'] = $logs;
$message = 'send: ';
$this->log($message, $logs);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$body = curl_exec($curl);
$info = curl_getinfo($curl);
$curlErrNo = curl_errno($curl);
$response = [
'http_code' => $info['http_code'],
'body' => $body,
'error' => $curlErrNo,
];
$logs['response'] = $response;
$this->log($message, $logs);
curl_close($curl);
return $response;
}
/**
* Get headers
*
* @return array
*/
private function _getHeaders()
{
$headers = [];
$headers[] = 'X-Request-ID: ' . uniqid();
$headers[] = 'Authorization: Bearer ' . $this->getPrivateKey();
$headers[] = 'Content-type: application/json; charset=utf-8';
$headers[] = 'Accept: application/json';
return $headers;
}
/**
* Prepare metadata
*
* @param Mage_Sales_Model_Order $order Object
*
* @return array
*/
private function _prepareMetadata(Mage_Sales_Model_Order $order)
{
return [
'cms' => 'Magento',
'cms_version' => Mage::getVersion(),
'module' => 'rbkmoney',
'order_id' => $order->getId(),
];
}
/**
* Prepare due date
*
* @return string
*/
private function _prepareDueDate()
{
date_default_timezone_set('UTC');
return date(static::CREATE_INVOICE_TEMPLATE_DUE_DATE, strtotime(static::CREATE_INVOICE_DUE_DATE));
}
/**
* Prepare amount (e.g. 124.24 -> 12424)
*
* @param $amount int
*
* @return int
*/
public function prepareAmount($amount)
{
return $amount * 100;
}
/**
* Prepare api URL
*
* @param string $path
* @param array $query_params
*
* @return string
*/
private function _prepareApiUrl($path = '', $query_params = [])
{
$url = rtrim(static::API_URL, '/') . '/' . $path;
if (!empty($query_params)) {
$url .= '?' . http_build_query($query_params);
}
return $url;
}
public function log($message, $logs = array(), $level = Zend_Log::INFO, $fileName = "rbkmoney.log")
{
if (!empty($this->getDebug())) {
Mage::log($message . ' ' . print_r($logs, true), $level, $fileName);
}
}
}

View File

@ -0,0 +1,29 @@
<?php
class RBKmoney_Payform_Model_Paymentmethod extends Mage_Payment_Model_Method_Abstract {
protected $_code = 'payform';
protected $_formBlockType = 'payform/form_payform';
protected $_infoBlockType = 'payform/info_payform';
public function assignData($data)
{
$info = $this->getInfoInstance();
return $this;
}
public function validate()
{
parent::validate();
return $this;
}
public function getOrderPlaceRedirectUrl()
{
return Mage::getUrl('payform/payment/redirect', array('_secure' => false));
}
}

View File

@ -0,0 +1,199 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: avcherkasov
* Date: 20/04/2017
* Time: 13:10
*/
class RBKmoney_Payform_PaymentController extends Mage_Core_Controller_Front_Action
{
/**
* Constants for Callback
*/
const SIGNATURE = 'HTTP_CONTENT_SIGNATURE';
const SIGNATURE_ALG = 'alg';
const SIGNATURE_DIGEST = 'digest';
const SIGNATURE_PATTERN = "|alg=(\S+);\sdigest=(.*)|i";
const EVENT_TYPE = 'eventType';
const INVOICE = 'invoice';
const INVOICE_ID = 'id';
const INVOICE_SHOP_ID = 'shopID';
const INVOICE_METADATA = 'metadata';
const INVOICE_STATUS = 'status';
const INVOICE_AMOUNT = 'amount';
const ORDER_ID = 'order_id';
/**
* Openssl verify
*/
const OPENSSL_VERIFY_SIGNATURE_IS_CORRECT = 1;
/**
* e.g. http{s}://{your-site}/rbkmoney/payment/redirect
*/
public function redirectAction()
{
$this->loadLayout();
$block = $this->getLayout()->createBlock('Mage_Core_Block_Template', 'payform', array('template' => 'payform/redirect.phtml'));
$this->getLayout()->getBlock('content')->append($block);
$this->renderLayout();
}
/**
* e.g. http{s}://{your-site}/rbkmoney/payment/notification
*/
public function notificationAction()
{
$content = file_get_contents('php://input');
$logs = array(
'content' => $content,
'method' => $_SERVER['REQUEST_METHOD'],
);
/** @var RBKmoney_Payform_Helper_Data $payform */
$payform = Mage::helper("payform");
if (empty($_SERVER[static::SIGNATURE])) {
$message = 'Webhook notification signature missing';
static::outputWithExit($message, $logs);
}
$logs['signature'] = $_SERVER[static::SIGNATURE];
$params_signature = $this->getParametersContentSignature($_SERVER[static::SIGNATURE]);
if (empty($params_signature[static::SIGNATURE_ALG])) {
$message = 'Missing required parameter ' . static::SIGNATURE_ALG;
static::outputWithExit($message, $logs);
}
if (empty($params_signature[static::SIGNATURE_DIGEST])) {
$message = 'Missing required parameter ' . static::SIGNATURE_DIGEST;
static::outputWithExit($message, $logs);
}
$signature = $this->urlSafeB64decode($params_signature[static::SIGNATURE_DIGEST]);
if (!$this->verificationSignature($content, $signature, $payform->getCallbackPublicKey())) {
$message = 'Webhook notification signature mismatch';
static::outputWithExit($message, $logs);
}
$required_fields = [static::INVOICE, static::EVENT_TYPE];
$data = json_decode($content, TRUE);
foreach ($required_fields as $field) {
if (empty($data[$field])) {
$message = 'One or more required fields are missing';
static::outputWithExit($message, $logs);
}
}
$current_shop_id = (int)$payform->getShopId();
if ($data[static::INVOICE][static::INVOICE_SHOP_ID] != $current_shop_id) {
$message = static::INVOICE_SHOP_ID . ' is missing';
static::outputWithExit($message, $logs);
}
if (empty($data[static::INVOICE][static::INVOICE_METADATA][static::ORDER_ID])) {
$message = static::ORDER_ID . ' is missing';
static::outputWithExit($message, $logs);
}
$orderId = $data[static::INVOICE][static::INVOICE_METADATA][static::ORDER_ID];
/** @var Mage_Sales_Model_Order $order */
$order = Mage::getModel('sales/order')->load($orderId);
if (empty($order)) {
$message = 'Order ' . $orderId . ' is missing';
static::outputWithExit($message, $logs);
}
$order_amount = (int)$payform->prepareAmount(number_format($order->getGrandTotal(), 2));
$invoice_amount = (int)$data[static::INVOICE][static::INVOICE_AMOUNT];
if ($order_amount != $invoice_amount) {
$message = 'Received amount vs Order amount mismatch';
static::outputWithExit($message, $logs);
}
if ($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING) {
switch ($data[static::INVOICE][static::INVOICE_STATUS]) {
case 'paid':
$order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, 'Payment Success.');
$order->getPayment()->setLastTransId($data[static::INVOICE][static::INVOICE_ID]);
$order->getPayment()->setAdditionalInformation($data);
$order->save();
static::outputWithExit('OK, paid', $logs, $payform::HTTP_CODE_OK);
break;
case 'cancelled':
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Payment Cancelled.');
$order->save();
static::outputWithExit('OK, cancelled', $logs, $payform::HTTP_CODE_OK);
break;
default:
// nothing
}
}
static::outputWithExit('OK', $logs, $payform::HTTP_CODE_OK);
}
private function urlSafeB64decode($string)
{
$data = str_replace(array('-', '_'), array('+', '/'), $string);
$mod4 = strlen($data) % 4;
if ($mod4) {
$data .= substr('====', $mod4);
}
return base64_decode($data);
}
private function getParametersContentSignature($content_signature)
{
preg_match_all(static::SIGNATURE_PATTERN, $content_signature, $matches, PREG_PATTERN_ORDER);
$params = array();
$params[static::SIGNATURE_ALG] = !empty($matches[1][0]) ? $matches[1][0] : '';
$params[static::SIGNATURE_DIGEST] = !empty($matches[2][0]) ? $matches[2][0] : '';
return $params;
}
/**
* Verification signature
*
* @param string $data
* @param string $signature
* @param string $public_key
*
* @return bool
*/
private function verificationSignature($data = '', $signature = '', $public_key = '')
{
if (empty($data) || empty($signature) || empty($public_key)) {
return FALSE;
}
$public_key_id = openssl_get_publickey($public_key);
if (empty($public_key_id)) {
return FALSE;
}
$verify = openssl_verify($data, $signature, $public_key_id, OPENSSL_ALGO_SHA256);
return ($verify == static::OPENSSL_VERIFY_SIGNATURE_IS_CORRECT);
}
private static function outputWithExit($message, $logs, $header = RBKmoney_Payform_Helper_Data::HTTP_CODE_BAD_REQUEST)
{
/** @var RBKmoney_Payform_Helper_Data $payform */
$payform = Mage::helper("payform");
$response = ['message' => $message];
http_response_code($header);
$payform->log($message, $logs);
echo json_encode($response);
exit();
}
}

View File

@ -0,0 +1,71 @@
<?xml version="1.0"?>
<config>
<modules>
<RBKmoney_Payform>
<version>1.0.0.0</version>
</RBKmoney_Payform>
</modules>
<global>
<helpers>
<payform>
<class>RBKmoney_Payform_Helper</class>
</payform>
</helpers>
<blocks>
<payform>
<class>RBKmoney_Payform_Block</class>
</payform>
</blocks>
<models>
<payform>
<class>RBKmoney_Payform_Model</class>
</payform>
</models>
<resources>
<payform_setup>
<setup>
<module>RBKmoney_Payform</module>
</setup>
</payform_setup>
</resources>
</global>
<default>
<payment>
<payform>
<active>1</active>
<model>payform/paymentmethod</model>
<order_status>pending</order_status>
<title>RBKmoney</title>
<allowspecific>0</allowspecific>
<payment_action>sale</payment_action>
<shop_id>1</shop_id>
<payment_form_logo></payment_form_logo>
<payment_form_company_name></payment_form_company_name>
<payment_form_button_label></payment_form_button_label>
<payment_form_description></payment_form_description>
<payment_form_css_button></payment_form_css_button>
<private_key></private_key>
<callback_public_key></callback_public_key>
<notification_url>http{s}://{your-site}/rbkmoney/payment/notification</notification_url>
<debug>0</debug>
</payform>
</payment>
</default>
<frontend>
<routers>
<payform>
<use>standard</use>
<args>
<module>RBKmoney_Payform</module>
<frontName>rbkmoney</frontName>
</args>
</payform>
</routers>
</frontend>
</config>

View File

@ -0,0 +1,150 @@
<?xml version="1.0"?>
<config>
<sections>
<payment>
<groups>
<payform translate="label comment" module="payform">
<label>RBKmoney payment</label>
<sort_order>1000</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<expanded>1</expanded>
<frontend_class>complex</frontend_class>
<frontend_model>payform/adminhtml_system_config_fieldset_group</frontend_model>
<comment>Process payments using your own internet merchant account.</comment>
<help_url>https://rbkmoney.github.io/docs/</help_url>
<fields>
<title translate="label">
<label>Title</label>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<sort_order>1</sort_order>
</title>
<active translate="label">
<label>Enabled</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<sort_order>2</sort_order>
</active>
<order_status translate="label">
<label>New order status</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_order_status</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<sort_order>3</sort_order>
</order_status>
<allowspecific translate="label">
<label>Payment from applicable countries</label>
<frontend_type>allowspecific</frontend_type>
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<sort_order>4</sort_order>
</allowspecific>
<specificcountry translate="label">
<label>Payment from Specific countries</label>
<frontend_type>multiselect</frontend_type>
<source_model>adminhtml/system_config_source_country</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<sort_order>5</sort_order>
</specificcountry>
<shop_id translate="label">
<label>Shop ID:</label>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<sort_order>6</sort_order>
</shop_id>
<private_key translate="label">
<label>Private key:</label>
<frontend_type>textarea</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<sort_order>7</sort_order>
</private_key>
<callback_public_key translate="label">
<label>Callback public key:</label>
<frontend_type>textarea</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<sort_order>8</sort_order>
</callback_public_key>
<payment_form_css_button translate="label">
<label>CSS style payment button:</label>
<frontend_type>textarea</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<sort_order>8</sort_order>
</payment_form_css_button>
<payment_form_logo translate="label">
<label>Logo in payment form:</label>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<sort_order>9</sort_order>
</payment_form_logo>
<payment_form_company_name translate="label">
<label>Company name in payment form:</label>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<sort_order>10</sort_order>
</payment_form_company_name>
<payment_form_button_label translate="label">
<label>Button label in payment form:</label>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<sort_order>10</sort_order>
</payment_form_button_label>
<payment_form_description translate="label">
<label>Description in payment form:</label>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<sort_order>10</sort_order>
</payment_form_description>
<notification_url translate="label">
<label>Notification URL</label>
<frontend_type>label</frontend_type>
<comment></comment>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<sort_order>11</sort_order>
</notification_url>
<debug translate="label">
<label>Debug on/off</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<sort_order>12</sort_order>
</debug>
</fields>
</payform>
</groups>
</payment>
</sections>
</config>

View File

@ -0,0 +1,5 @@
<div class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
</div>
<div>
<?php echo $this->getMethod()->getConfigData('message'); ?>
</div>

View File

@ -0,0 +1,45 @@
<?php
$order = new Mage_Sales_Model_Order();
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order->loadByIncrementId($orderId);
/*** @var RBKmoney_Payform_Helper_Data $data */
$data = Mage::helper("payform");
$dataLogo = !empty($data->getPaymentFormLogo()) ? 'data-logo="' . $data->getPaymentFormLogo() . '"' : '';
$companyName = !empty($data->getPaymentFormCompanyName()) ? 'data-name="' . $data->getPaymentFormCompanyName() . '"' : '';
$buttonLabel = !empty($data->getPaymentFormButtonLabel()) ? 'data-label="' . $data->getPaymentFormButtonLabel() . '"' : '';
$description = !empty($data->getPaymentFormDescription()) ? 'data-description="' . $data->getPaymentFormDescription() . '"' : '';
$style = !empty($data->getPaymentFormCssButton()) ? '<style>' . $data->getPaymentFormCssButton() . '</style>' : '';
try {
if(empty($_SESSION['order']) || $_SESSION['order']['id'] != $orderId) {
$invoice_id = $data->createInvoice($order);
$_SESSION['order']['id'] = $orderId;
$_SESSION['order']['invoice_id'] = $invoice_id;
} else {
$invoice_id = $_SESSION['order']['invoice_id'];
}
$invoice_access_token = $data->createInvoiceAccessToken($invoice_id);
} catch (Exception $ex) {
die($ex->getMessage());
}
?>
<h2><?php echo $this->__('RBKmoney payment') ?></h2>
<?php echo $style; ?>
<form action="<?php echo $data->getSuccessUrl(); ?>" method="POST">
<script src="<?php echo $data::PAYMENT_FORM_URL; ?>" class="rbkmoney-checkout"
data-invoice-id="<?php echo $invoice_id; ?>"
data-invoice-access-token="<?php echo $invoice_access_token; ?>"
<?php echo $dataLogo; ?>
<?php echo $companyName; ?>
<?php echo $buttonLabel; ?>
<?php echo $description; ?>
>
</script>
</form>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<config>
<modules>
<RBKmoney_Payform>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Payment />
</depends>
</RBKmoney_Payform>
</modules>
</config>