Commit b818d54d authored by Oleh Vehera's avatar Oleh Vehera
Browse files

Issue #3276099 by voleger, dimKarp: Brand color configuration

parent 4a5ff062
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -16,3 +16,6 @@ commerce_viva.commerce_payment_gateway.plugin.viva_redirect_checkout:
    client_secret:
      type: string
      label: 'Client Secret'
    brand_color:
      type: string
      label: 'Brand color'
+10 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ class OffsiteRedirect extends OffsitePaymentGatewayBase {
      'website_code' => '',
      'client_id' => '',
      'client_secret' => '',
      'brand_color' => '',
    ] + parent::defaultConfiguration();
  }

@@ -139,6 +140,14 @@ class OffsiteRedirect extends OffsitePaymentGatewayBase {
      '#required' => TRUE,
    ];

    $form['brand_color'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Brand color'),
      '#description' => $this->t('This is the Brand color for the Viva Wallet smart checkout (Hexadecimal)'),
      '#default_value' => $this->configuration['brand_color'],
      '#required' => FALSE,
    ];

    return $form;
  }

@@ -154,6 +163,7 @@ class OffsiteRedirect extends OffsitePaymentGatewayBase {
      $this->configuration['website_code'] = $values['website_code'];
      $this->configuration['client_id'] = $values['client_id'];
      $this->configuration['client_secret'] = $values['client_secret'];
      $this->configuration['brand_color'] = $values['brand_color'];
    }
  }

+8 −2
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ class VivaOffsiteForm extends BasePaymentOffsiteForm {

    $customer_info = [
      'email' => $order->getEmail(),
      'fullName' => $address->getGivenName(),
      'fullName' => $address->getGivenName() . ' ' . $address->getFamilyName(),
      // 'phone' => '',
      // 'countryCode' => '',
      // 'requestLang' => 'en-GB'
@@ -115,8 +115,14 @@ class VivaOffsiteForm extends BasePaymentOffsiteForm {
  public function generateCheckoutUrl(string $order_code): string {
    $payment = $this->entity;
    $payment_gateway_plugin = $payment->getPaymentGateway()->getPlugin();
    $configuration = $payment_gateway_plugin->getConfiguration();
    $brand_color = $configuration['brand_color'];
    $url = $payment_gateway_plugin->resolveUrl('demo', 'www', '/web/checkout?ref=');
    return $url . $order_code;
    $url .= $order_code;
    if ($brand_color) {
        $url .= '&color=' . $brand_color;
    }
    return $url;

  }