We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit ab506db2 authored by Alessio Zampatti's avatar Alessio Zampatti Committed by GitHub

PW-1880: Implement ComboCards in creditcards section (#601)

* Add combo card for Brazilian shoppers

* PW-1880: set ['paymentMethod']['type'], check if billingaddress is BR and currency BRL

* PW-1918: added EOLs

* PW-1880: removed logger

* PW-1880: add installments if they are set(not only on Credit), unset them if Debit

* PW-1880: move combocards check to the frontend

* PW-1880: fix for other debit cards
parent ca9405d0
......@@ -63,13 +63,37 @@ class CcAuthorizationDataBuilder implements BuilderInterface
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_SECURITY_CODE);
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::HOLDER_NAME);
// if installments is set add it into the request
if ($payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS) &&
$payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS) > 0
) {
$requestBody['installments']['value'] = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS);
// if installments is set and card type is credit card add it into the request
$numberOfInstallments = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS) ?: 0;
$comboCardType = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::COMBO_CARD_TYPE) ?: 'credit';
if ($numberOfInstallments > 0) {
$requestBody['installments']['value'] = $numberOfInstallments;
}
// if card type is debit then change the issuer type and unset the installments field
if ($comboCardType == 'debit') {
if ($selectedDebitBrand = $this->getSelectedDebitBrand($payment->getAdditionalInformation('cc_type'))) {
$requestBody['additionalData']['overwriteBrand'] = true;
$requestBody['selectedBrand'] = $selectedDebitBrand;
$requestBody['paymentMethod']['type'] = $selectedDebitBrand;
}
unset($requestBody['installments']);
}
$request['body'] = $requestBody;
return $request;
}
/**
* @param string $brand
* @return string
*/
private function getSelectedDebitBrand($brand)
{
if ($brand == 'VI') {
return 'electron';
}
if ($brand == 'MC') {
return 'maestro';
}
return null;
}
}
\ No newline at end of file
......@@ -173,7 +173,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
}
/**
* Retrieve availables credit card types
* Retrieve available credit card types
*
* @return array
*/
......@@ -195,9 +195,8 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
}
/**
* Retrieve availables credit card type codes by alt code
* Retrieve available credit card type codes by alt code
*
* @param string $methodCode
* @return array
*/
protected function getCcAvailableTypesByAlt()
......@@ -293,3 +292,4 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
return $this->_request;
}
}
......@@ -47,6 +47,7 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
const TIMEZONE_OFFSET = 'timezone_offset';
const LANGUAGE = 'language';
const GUEST_EMAIL = 'guestEmail';
const COMBO_CARD_TYPE = 'combo_card_type';
/**
* @var array
......@@ -67,7 +68,8 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
self::SCREEN_HEIGHT,
self::TIMEZONE_OFFSET,
self::LANGUAGE,
self::GUEST_EMAIL
self::GUEST_EMAIL,
self::COMBO_CARD_TYPE
];
/**
......
......@@ -64,7 +64,7 @@
</field>
<field id="sepa_flow" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Sepa Payment flow</label>
<tooltip>If you are not sure just leave it at 'Sale’. Sale means it is always immidiate capture with auth/cap it will follow the Capture Delay. If you want to enable 'Auth/Capt' for SEPA Direct Debit, please contact support@adyen.com</tooltip>
<tooltip>If you are not sure just leave it at 'Sale’. Sale means it is always immediate capture with auth/cap it will follow the Capture Delay. If you want to enable 'Auth/Capt' for SEPA Direct Debit, please contact support@adyen.com</tooltip>
<source_model>Adyen\Payment\Model\Config\Source\SepaFlow</source_model>
<config_path>payment/adyen_abstract/sepa_flow</config_path>
</field>
......
......@@ -53,3 +53,6 @@
"Continue to Adyen App", "Continue to Adyen App"
"Do not use Installments", "Do not use Installments"
"(Please provide a card with the type from the list above)", "(Please provide a card with the type from the list above)"
"Select debit or credit card","Select debit or credit card"
"Credit","Credit"
"Debit","Debit"
\ No newline at end of file
......@@ -47,6 +47,7 @@ define(
return Component.extend({
// need to duplicate as without the button will never activate on first time page view
isPlaceOrderActionAllowed: ko.observable(quote.billingAddress() != null),
comboCardOption: ko.observable('credit'),
defaults: {
template: 'Adyen_Payment/payment/cc-form',
......@@ -294,7 +295,8 @@ define(
'screen_width': browserInfo.screenWidth,
'screen_height': browserInfo.screenHeight,
'timezone_offset': browserInfo.timeZoneOffset,
'language': browserInfo.language
'language': browserInfo.language,
'combo_card_type': this.comboCardOption()
}
};
this.vaultEnabler.visitAdditionalData(data);
......@@ -468,11 +470,19 @@ define(
: false
},
hasInstallments: function () {
return window.checkoutConfig.payment.adyenCc.hasInstallments;
return this.comboCardOption() === 'credit' && window.checkoutConfig.payment.adyenCc.hasInstallments;
},
getAllInstallments: function () {
return window.checkoutConfig.payment.adyenCc.installments;
},
areComboCardsEnabled: function () {
if (quote.billingAddress() === null) {
return false;
}
var countryId = quote.billingAddress().countryId;
var currencyCode = quote.totals().quote_currency_code;
return currencyCode === "BRL" && countryId === "BR";
},
setPlaceOrderHandler: function (handler) {
this.placeOrderHandler = handler;
},
......
......@@ -73,6 +73,24 @@
<br/>
<!-- /ko -->
<!-- ko if: (areComboCardsEnabled())-->
<div class="field required">
<label for="adyen-combo-card-select">
<!--ko text: $t('Select debit or credit card')--><!-- /ko -->
</label>
<div class="control">
<select id="adyen-combo-card-select"
class="select"
name="payment[combo_card_method]"
data-bind="value: comboCardOption"
>
<option value="credit"><!--ko text: $t('Credit Card')--><!-- /ko --></option>
<option value="debit"><!--ko text: $t('Debit Card')--><!-- /ko --></option>
</select>
</div>
</div>
<!-- /ko -->
<div class="field number cardContainerField">
<div class="checkout-component-dock" afterRender="renderSecureFields()" data-bind="attr: { id: 'cardContainer'}"></div>
</div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment