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 0611a071 authored by Rik ter Beek's avatar Rik ter Beek Committed by GitHub

Merge pull request #368 from Adyen/feature/PW-837

Store billing agreement after Terminal API transaction
parents 48b45ef5 33c5e77a
...@@ -40,7 +40,7 @@ class PaymentPosCloudHandler implements HandlerInterface ...@@ -40,7 +40,7 @@ class PaymentPosCloudHandler implements HandlerInterface
private $adyenLogger; private $adyenLogger;
/** /**
* PaymentDataBuilder constructor. * PaymentPosCloudHandler constructor.
* *
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger * @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
...@@ -74,6 +74,42 @@ class PaymentPosCloudHandler implements HandlerInterface ...@@ -74,6 +74,42 @@ class PaymentPosCloudHandler implements HandlerInterface
// do not send order confirmation mail // do not send order confirmation mail
$payment->getOrder()->setCanSendNewEmailFlag(false); $payment->getOrder()->setCanSendNewEmailFlag(false);
if (!empty($paymentResponse['Response']) &&
!empty($paymentResponse['Response']['AdditionalResponse'])
) {
$pairs = explode('&', $paymentResponse['Response']['AdditionalResponse']);
foreach ($pairs as $pair) {
$nv = explode('=', $pair);
if ($nv[0] == 'recurring.recurringDetailReference') {
$recurringDetailReference = $nv[1];
break;
}
}
if (!empty($recurringDetailReference) &&
!empty($paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData'])
) {
$maskedPan = $paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData']['MaskedPan'];
$expiryDate = $paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData']['SensitiveCardData']['ExpiryDate']; // 1225
$expiryDate = substr($expiryDate, 0, 2) . '/' . substr($expiryDate, 2, 2);
$brand = $paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData']['PaymentBrand'];
// create additionalData so we can use the helper
$additionalData = [];
$additionalData['recurring.recurringDetailReference'] = $recurringDetailReference;
$additionalData['cardBin'] = $recurringDetailReference;
$additionalData['cardHolderName'] = '';
$additionalData['cardSummary'] = substr($maskedPan, -4);
$additionalData['expiryDate'] = $expiryDate;
$additionalData['paymentMethod'] = $brand;
$additionalData['recurring.recurringDetailReference'] = $recurringDetailReference;
$additionalData['pos_payment'] = true;
$this->adyenHelper->createAdyenBillingAgreement($payment->getOrder(), $additionalData);
}
}
// set transaction(status) // set transaction(status)
if (!empty($paymentResponse['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID'])) { if (!empty($paymentResponse['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID'])) {
$pspReference = $paymentResponse['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID']; $pspReference = $paymentResponse['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID'];
......
...@@ -184,17 +184,31 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -184,17 +184,31 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
$ccType = $ccTypes[$ccType]['name']; $ccType = $ccTypes[$ccType]['name'];
} }
$label = __( if ($contractDetail['cardHolderName']) {
'%1, %2, **** %3', $label = __(
$ccType, '%1, %2, **** %3',
$contractDetail['cardHolderName'], $ccType,
$contractDetail['cardSummary'] $contractDetail['cardHolderName'],
); $contractDetail['cardSummary']
);
} else {
$label = __(
'%1, **** %2',
$ccType,
$contractDetail['cardSummary']
);
}
$this->setAgreementLabel($label); $this->setAgreementLabel($label);
} }
$expiryDate = explode('/', $contractDetail['expiryDate']); $expiryDate = explode('/', $contractDetail['expiryDate']);
$recurringType = $this->adyenHelper->getRecurringTypeFromOneclickRecurringSetting(); if (!empty($contractDetail['pos_payment'])) {
$recurringType = $this->adyenHelper->getAdyenPosCloudConfigData('recurring_type');
} else {
$recurringType = $this->adyenHelper->getRecurringTypeFromOneclickRecurringSetting();
}
$agreementData = [ $agreementData = [
'card' => [ 'card' => [
...@@ -207,6 +221,10 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -207,6 +221,10 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
'contractTypes' => explode(',', $recurringType) 'contractTypes' => explode(',', $recurringType)
]; ];
if (!empty($contractDetail['pos_payment'])) {
$agreementData['posPayment'] = true;
}
$this->setAgreementData($agreementData); $this->setAgreementData($agreementData);
return $this; return $this;
......
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
<tooltip>You can set different value for POS because you have to have the permission of the customer</tooltip> <tooltip>You can set different value for POS because you have to have the permission of the customer</tooltip>
<source_model>Adyen\Payment\Model\Config\Source\RecurringType</source_model> <source_model>Adyen\Payment\Model\Config\Source\RecurringType</source_model>
<config_path>payment/adyen_pos_cloud/recurring_type</config_path> <config_path>payment/adyen_pos_cloud/recurring_type</config_path>
<comment>If you want to store the credentials for ONECLICK or RECURRING or combination of these two you need to contact support@adyen.com and ask if they can enable to store cards on company level. Changing this setting without doing this will lead to failed payments!</comment>
</field> </field>
<group id="adyen_pos_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="210"> <group id="adyen_pos_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="210">
<label>Country Specific Settings</label> <label>Country Specific Settings</label>
......
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
<can_cancel>1</can_cancel> <can_cancel>1</can_cancel>
<pos_timeout>30</pos_timeout> <pos_timeout>30</pos_timeout>
<total_timeout>120</total_timeout> <total_timeout>120</total_timeout>
<recurring_type>ONECLICK</recurring_type> <recurring_type>NONE</recurring_type>
<group>adyen</group> <group>adyen</group>
</adyen_pos_cloud> </adyen_pos_cloud>
<adyen_pay_by_mail> <adyen_pay_by_mail>
......
...@@ -85,6 +85,7 @@ define( ...@@ -85,6 +85,7 @@ define(
var card = checkout.create('card', { var card = checkout.create('card', {
originKey: self.getOriginKey(), originKey: self.getOriginKey(),
loadingContext: self.getLoadingContext(),
type: 'card', type: 'card',
hasHolderName: true, hasHolderName: true,
holderNameRequired: true, holderNameRequired: true,
......
...@@ -216,6 +216,7 @@ define( ...@@ -216,6 +216,7 @@ define(
var oneClickCard = checkout var oneClickCard = checkout
.create('card', { .create('card', {
originKey: self.getOriginKey(), originKey: self.getOriginKey(),
loadingContext: self.getLoadingContext(),
type: self.agreement_data.variant, type: self.agreement_data.variant,
oneClick: true, oneClick: true,
hideCVC: hideCVC, hideCVC: hideCVC,
......
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