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 8fcfed22 authored by Rik ter Beek's avatar Rik ter Beek

Store billing agreement after Terminal API transaction

parent 48b45ef5
...@@ -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'];
} }
if ($contractDetail['cardHolderName']) {
$label = __( $label = __(
'%1, %2, **** %3', '%1, %2, **** %3',
$ccType, $ccType,
$contractDetail['cardHolderName'], $contractDetail['cardHolderName'],
$contractDetail['cardSummary'] $contractDetail['cardSummary']
); );
} else {
$label = __(
'%1, **** %2',
$ccType,
$contractDetail['cardSummary']
);
}
$this->setAgreementLabel($label); $this->setAgreementLabel($label);
} }
$expiryDate = explode('/', $contractDetail['expiryDate']); $expiryDate = explode('/', $contractDetail['expiryDate']);
if (!empty($contractDetail['pos_payment'])) {
$recurringType = $this->adyenHelper->getAdyenPosCloudConfigData('recurring_type');
} else {
$recurringType = $this->adyenHelper->getRecurringTypeFromOneclickRecurringSetting(); $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>
......
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