Loading config/schema/commerce_viva.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -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' src/Plugin/Commerce/PaymentGateway/OffsiteRedirect.php +10 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ class OffsiteRedirect extends OffsitePaymentGatewayBase { 'website_code' => '', 'client_id' => '', 'client_secret' => '', 'brand_color' => '', ] + parent::defaultConfiguration(); } Loading Loading @@ -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; } Loading @@ -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']; } } Loading src/PluginForm/OffsiteRedirect/VivaOffsiteForm.php +8 −2 Original line number Diff line number Diff line Loading @@ -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' Loading Loading @@ -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; } Loading Loading
config/schema/commerce_viva.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -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'
src/Plugin/Commerce/PaymentGateway/OffsiteRedirect.php +10 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ class OffsiteRedirect extends OffsitePaymentGatewayBase { 'website_code' => '', 'client_id' => '', 'client_secret' => '', 'brand_color' => '', ] + parent::defaultConfiguration(); } Loading Loading @@ -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; } Loading @@ -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']; } } Loading
src/PluginForm/OffsiteRedirect/VivaOffsiteForm.php +8 −2 Original line number Diff line number Diff line Loading @@ -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' Loading Loading @@ -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; } Loading