Skip to content
Snippets Groups Projects
Commit 66323222 authored by Anas Mawlawi's avatar Anas Mawlawi Committed by Anas Mawlawi
Browse files

Issue #3364255 by Anas_maw: Make hyperpay url as a configuration to support multiple links

parent 54cba127
No related branches found
Tags 1.0.0-alpha17
No related merge requests found
......@@ -4,6 +4,9 @@ commerce_payment.commerce_payment_gateway.plugin.hyperpay_gateway_checkout:
test_mode_type:
type: string
label: "Test Mode Type"
server:
type: string
label: "Server"
allowed_cards:
type: sequence
label: "Allowed Cards"
......
......@@ -135,6 +135,7 @@ class HyperPayCopyAndPay extends OffsitePaymentGatewayBase implements HyperPayIn
public function defaultConfiguration() {
return [
'test_mode_type' => 'EXTERNAL',
'server' => 'default',
'allowed_cards' => [],
'auth_bearer' => '',
'entity_id' => '',
......@@ -166,6 +167,15 @@ class HyperPayCopyAndPay extends OffsitePaymentGatewayBase implements HyperPayIn
],
],
];
$form['server'] = [
'#type' => 'select',
'#title' => $this->t('Server'),
'#default_value' => $this->configuration['server'],
'#options' => [
'default' => 'Default (oppwa.com)',
'eu' => 'Europe (eu-prod.oppwa.com)',
],
];
$form['allowed_cards'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Allowed Cards'),
......@@ -240,6 +250,7 @@ class HyperPayCopyAndPay extends OffsitePaymentGatewayBase implements HyperPayIn
$this->configuration['reuse_payment_method'] = $values['reuse_payment_method'];
$this->configuration['entity_id_recurring'] = $values['entity_id_recurring'];
$this->configuration['mode'] = $values['mode'];
$this->configuration['server'] = $values['server'];
$this->configuration['test_mode_type'] = $values['test_mode_type'];
$this->configuration['widget_style'] = $values['widget_style'];
}
......@@ -427,7 +438,7 @@ class HyperPayCopyAndPay extends OffsitePaymentGatewayBase implements HyperPayIn
// Create payment method if it's allowed.
if ($this->configuration['reuse_payment_method']) {
$payment_method_storage = $this->entityTypeManager->getStorage('commerce_payment_method');
// assert($payment_method_storage instanceof PaymentMethodStorageInterface);
// assert($payment_method_storage instanceof PaymentMethodStorageInterface);.
$payment_method = $payment_method_storage->createForCustomer(
'credit_card',
$this->parentEntity->id(),
......@@ -495,11 +506,15 @@ class HyperPayCopyAndPay extends OffsitePaymentGatewayBase implements HyperPayIn
* {@inheritdoc}
*/
public function getApiUrl() {
if ($this->getMode() == 'test') {
return 'https://test.oppwa.com';
}
else {
return 'https://oppwa.com';
switch ($this->configuration['server']) {
case 'default':
return $this->getMode() == 'test' ? 'https://test.oppwa.com' : 'https://oppwa.com';
break;
case 'eu':
return $this->getMode() == 'test' ? 'https://eu-test.oppwa.com' : 'https://eu-prod.oppwa.com';
break;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment