class PaymentOffsiteForm in Commerce robokassa 8.2
Hierarchy
- class \Drupal\Core\Plugin\PluginFormBase implements PluginAwareInterface, PluginFormInterface
- class \Drupal\commerce_payment\PluginForm\PaymentGatewayFormBase implements PaymentGatewayFormInterface uses DependencySerializationTrait, StringTranslationTrait
- class \Drupal\commerce_payment\PluginForm\PaymentOffsiteForm
- class \Drupal\commerce_robokassa\PluginForm\OffsiteRedirect\PaymentOffsiteForm
- class \Drupal\commerce_payment\PluginForm\PaymentOffsiteForm
- class \Drupal\commerce_payment\PluginForm\PaymentGatewayFormBase implements PaymentGatewayFormInterface uses DependencySerializationTrait, StringTranslationTrait
Expanded class hierarchy of PaymentOffsiteForm
File
- src/
PluginForm/ OffsiteRedirect/ PaymentOffsiteForm.php, line 12
Namespace
Drupal\commerce_robokassa\PluginForm\OffsiteRedirectView source
class PaymentOffsiteForm extends BasePaymentOffsiteForm {
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
/** @var \Drupal\commerce_payment\Entity\PaymentInterface $payment */
$payment = $this->entity;
$payment
->save();
/** @var \Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\OffsitePaymentGatewayInterface $payment_gateway_plugin */
$payment_gateway_plugin = $payment
->getPaymentGateway()
->getPlugin();
$data = [];
$payment_gateway_configuration = $payment_gateway_plugin
->getConfiguration();
$user_name = $payment_gateway_configuration["MrchLogin"];
$password = $payment_gateway_configuration['pass1'];
$double_staged = !$form['#capture'];
$mode = $payment
->getPaymentGatewayMode() == 'live' ? false : true;
$logging = $payment_gateway_configuration['logging'] == 0 ? false : true;
$timeout = empty($payment_gateway_configuration['timeout']) ? null : $payment_gateway_configuration['timeout'];
$redirect_url = $payment_gateway_configuration['server_url_' . $payment
->getPaymentGatewayMode()];
$form['#action'] = $redirect_url;
$data["MerchantLogin"] = $payment_gateway_configuration['MrchLogin'];
$amount = $payment
->getOrder()
->getTotalPrice();
$data["OutSum"] = number_format($amount
->getNumber(), 2, '.', '');
$data["InvId"] = $payment
->getOrderId();
$data["shp_trx_id"] = $payment
->id();
// For test transactions.
if ($payment
->getPaymentGatewayMode() == 'test') {
$data['IsTest'] = '1';
}
$signature_data = array(
$data["MerchantLogin"],
$data["OutSum"],
$data["InvId"],
$payment_gateway_configuration['pass1'],
'shp_trx_id=' . $data["shp_trx_id"],
);
// Calculate signature.
$data['SignatureValue'] = hash($payment_gateway_configuration['hash_type'], implode(':', $signature_data));
$inv_desc_params = array(
'@order_id' => $payment
->getOrderId(),
'@mail' => $payment
->getOrder()
->getEmail(),
);
$inv_desc = t('Order ID: @order_id, User mail: @mail', $inv_desc_params);
$data['InvDesc'] = Unicode::truncate($inv_desc, 100);
if (isset($payment
->getOrder()
->getData('commerce_robokassa')['IncCurrLabel'])) {
$data['IncCurrLabel'] = $payment
->getOrder()
->getData('commerce_robokassa')['IncCurrLabel'];
}
$payment
->save();
return $this
->buildRedirectForm($form, $form_state, $redirect_url, $data, self::REDIRECT_POST);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
PaymentGatewayFormBase:: |
protected | property | The form entity. | |
PaymentGatewayFormBase:: |
public | function |
Gets the form entity. Overrides PaymentGatewayFormInterface:: |
|
PaymentGatewayFormBase:: |
public | function |
Gets the form element to which errors should be assigned. Overrides PaymentGatewayFormInterface:: |
1 |
PaymentGatewayFormBase:: |
public | function |
Sets the form entity. Overrides PaymentGatewayFormInterface:: |
|
PaymentOffsiteForm:: |
public | function |
Form constructor. Overrides PaymentOffsiteForm:: |
|
PaymentOffsiteForm:: |
protected | function | Builds the redirect form. | |
PaymentOffsiteForm:: |
public static | function | Prepares the complete form for a POST redirect. | |
PaymentOffsiteForm:: |
constant | |||
PaymentOffsiteForm:: |
constant | |||
PaymentOffsiteForm:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
|
PluginFormBase:: |
protected | property | The plugin this form is for. | 3 |
PluginFormBase:: |
public | function |
Sets the plugin for this object. Overrides PluginAwareInterface:: |
1 |
PluginFormBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
2 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |