We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday 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
private $adyenLogger;
/**
* PaymentDataBuilder constructor.
* PaymentPosCloudHandler constructor.
*
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
......@@ -74,6 +74,42 @@ class PaymentPosCloudHandler implements HandlerInterface
// do not send order confirmation mail
$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)
if (!empty($paymentResponse['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID'])) {
$pspReference = $paymentResponse['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID'];
......
......@@ -184,17 +184,31 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
$ccType = $ccTypes[$ccType]['name'];
}
if ($contractDetail['cardHolderName']) {
$label = __(
'%1, %2, **** %3',
$ccType,
$contractDetail['cardHolderName'],
$contractDetail['cardSummary']
);
} else {
$label = __(
'%1, **** %2',
$ccType,
$contractDetail['cardSummary']
);
}
$this->setAgreementLabel($label);
}
$expiryDate = explode('/', $contractDetail['expiryDate']);
if (!empty($contractDetail['pos_payment'])) {
$recurringType = $this->adyenHelper->getAdyenPosCloudConfigData('recurring_type');
} else {
$recurringType = $this->adyenHelper->getRecurringTypeFromOneclickRecurringSetting();
}
$agreementData = [
'card' => [
......@@ -207,6 +221,10 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
'contractTypes' => explode(',', $recurringType)
];
if (!empty($contractDetail['pos_payment'])) {
$agreementData['posPayment'] = true;
}
$this->setAgreementData($agreementData);
return $this;
......
......@@ -75,6 +75,7 @@
<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>
<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>
<group id="adyen_pos_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="210">
<label>Country Specific Settings</label>
......
......@@ -170,7 +170,7 @@
<can_cancel>1</can_cancel>
<pos_timeout>30</pos_timeout>
<total_timeout>120</total_timeout>
<recurring_type>ONECLICK</recurring_type>
<recurring_type>NONE</recurring_type>
<group>adyen</group>
</adyen_pos_cloud>
<adyen_pay_by_mail>
......
......@@ -85,6 +85,7 @@ define(
var card = checkout.create('card', {
originKey: self.getOriginKey(),
loadingContext: self.getLoadingContext(),
type: 'card',
hasHolderName: true,
holderNameRequired: true,
......
......@@ -216,6 +216,7 @@ define(
var oneClickCard = checkout
.create('card', {
originKey: self.getOriginKey(),
loadingContext: self.getLoadingContext(),
type: self.agreement_data.variant,
oneClick: true,
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