Skip to content

Commit

Permalink
Issue #3276099 by voleger, dimKarp: Brand color configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
voleger committed Apr 20, 2022
1 parent 4a5ff06 commit b818d54
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions config/schema/commerce_viva.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 10 additions & 0 deletions src/Plugin/Commerce/PaymentGateway/OffsiteRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public function defaultConfiguration() {
'website_code' => '',
'client_id' => '',
'client_secret' => '',
'brand_color' => '',
] + parent::defaultConfiguration();
}

Expand Down Expand Up @@ -139,6 +140,14 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
'#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;
}

Expand All @@ -154,6 +163,7 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s
$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'];
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/PluginForm/OffsiteRedirect/VivaOffsiteForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function vivawalletOrderCode(): ?string {

$customer_info = [
'email' => $order->getEmail(),
'fullName' => $address->getGivenName(),
'fullName' => $address->getGivenName() . ' ' . $address->getFamilyName(),
// 'phone' => '',
// 'countryCode' => '',
// 'requestLang' => 'en-GB'
Expand Down Expand Up @@ -115,8 +115,14 @@ public function vivawalletOrderCode(): ?string {
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;

}

Expand Down

0 comments on commit b818d54

Please sign in to comment.