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

#67 removed unused code

parent f54b3df6
...@@ -105,127 +105,6 @@ class PaymentRequest extends DataObject ...@@ -105,127 +105,6 @@ class PaymentRequest extends DataObject
$this->_client = $client; $this->_client = $client;
} }
/**
* @param $payment
* @param $paymentMethodCode
* @return mixed
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function fullApiRequest($payment, $paymentMethodCode)
{
$storeId = null;
if ($this->_appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
$storeId = $payment->getOrder()->getStoreId();
}
$order = $payment->getOrder();
$amount = $order->getGrandTotal();
$customerEmail = $order->getCustomerEmail();
$shopperIp = $order->getRemoteIp();
$orderCurrencyCode = $order->getOrderCurrencyCode();
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$recurringType = $this->_adyenHelper->getAdyenAbstractConfigData('recurring_type', $storeId);
$realOrderId = $order->getRealOrderId();
$customerId = $order->getCustomerId();
$shopperReference = (!empty($customerId)) ? $customerId : self::GUEST_ID . $realOrderId;
// call lib
$service = new \Adyen\Service\Payment($this->_client);
$amount = ['currency' => $orderCurrencyCode,
'value' => $this->_adyenHelper->formatAmount($amount, $orderCurrencyCode)];
$browserInfo = ['userAgent' => $_SERVER['HTTP_USER_AGENT'], 'acceptHeader' => $_SERVER['HTTP_ACCEPT']];
$request = [
"merchantAccount" => $merchantAccount,
"amount" => $amount,
"reference" => $order->getIncrementId(),
"shopperIP" => $shopperIp,
"shopperEmail" => $customerEmail,
"shopperReference" => $shopperReference,
"fraudOffset" => "0",
"browserInfo" => $browserInfo
];
// set the recurring type
$recurringContractType = null;
if ($recurringType) {
$recurringContractType = $recurringType;
}
if ($recurringContractType) {
$recurring = ['contract' => $recurringContractType];
$request['recurring'] = $recurring;
}
$billingAddress = $order->getBillingAddress();
if ($billingAddress) {
$addressArray = $this->_adyenHelper->getStreet($billingAddress);
$requestBilling = ["street" => $addressArray['name'],
"postalCode" => $billingAddress->getPostcode(),
"city" => $billingAddress->getCity(),
"houseNumberOrName" => $addressArray['house_number'],
"stateOrProvince" => $billingAddress->getRegionCode(),
"country" => $billingAddress->getCountryId()
];
// houseNumberOrName is mandatory
if ($requestBilling['houseNumberOrName'] == "") {
$requestBilling['houseNumberOrName'] = "NA";
}
$requestBilling['billingAddress'] = $requestBilling;
$request = array_merge($request, $requestBilling);
}
$deliveryAddress = $order->getDeliveryAddress();
if($deliveryAddress) {
$addressArray = $this->_adyenHelper->getStreet($deliveryAddress);
$requestDelivery = ["street" => $addressArray['name'],
"postalCode" => $deliveryAddress->getPostcode(),
"city" => $deliveryAddress->getCity(),
"houseNumberOrName" => $addressArray['house_number'],
"stateOrProvince" => $deliveryAddress->getRegionCode(),
"country" => $deliveryAddress->getCountryId()
];
// houseNumberOrName is mandatory
if ($requestDelivery['houseNumberOrName'] == "") {
$requestDelivery['houseNumberOrName'] = "NA";
}
$requestDelivery['deliveryAddress'] = $requestDelivery;
$request = array_merge($request, $requestDelivery);
}
$recurringDetailReference = null;
// define the shopper interaction
$shopperInteraction = "Ecommerce";
if ($shopperInteraction) {
$request['shopperInteraction'] = $shopperInteraction;
}
if ($recurringDetailReference && $recurringDetailReference != "") {
$request['selectedRecurringDetailReference'] = $recurringDetailReference;
}
// if it is a sepadirectdebit set selectedBrand to sepadirectdebit in the case of oneclick
if ($payment->getCcType() == "sepadirectdebit") {
$request['selectedBrand'] = "sepadirectdebit";
}
$result = $service->authorise($request);
return $result;
}
/** /**
* @param $payment * @param $payment
* @return mixed * @return mixed
...@@ -260,140 +139,6 @@ class PaymentRequest extends DataObject ...@@ -260,140 +139,6 @@ class PaymentRequest extends DataObject
return $result; return $result;
} }
/**
* Capture payment on Adyen
*
* @param \Magento\Payment\Model\InfoInterface $payment
* @param $amount
* @return mixed
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount)
{
$storeId = $payment->getOrder()->getStoreId();
$pspReference = $this->_getPspReference($payment);
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$currency = $payment->getOrder()->getBaseCurrencyCode();
//format the amount to minor units
$amount = $this->_adyenHelper->formatAmount($amount, $currency);
$modificationAmount = ['currency' => $currency, 'value' => $amount];
$request = [
"merchantAccount" => $merchantAccount,
"modificationAmount" => $modificationAmount,
"reference" => $payment->getOrder()->getIncrementId(),
"originalReference" => $pspReference
];
// call lib
$service = new \Adyen\Service\Modification($this->_client);
$result = $service->capture($request);
if ($result['response'] != '[capture-received]') {
// something went wrong
throw new \Magento\Framework\Exception\LocalizedException(__('The capture action failed'));
}
// save pspreference in additional Data to check for notification if refund is triggerd from inside Magento
$payment->setAdditionalInformation('capture_pspreference', $result['pspReference']);
// set pspReference as TransactionId so you can do an online refund
if (isset($result['pspReference'])) {
$payment->setTransactionId($result['pspReference'])
->setIsTransactionClosed(false)
->setParentTransactionId($payment->getAdditionalInformation('pspReference'));
}
return $result;
}
/**
* Cancel or Refund payment on Adyen
*
* @param \Magento\Payment\Model\InfoInterface $payment
* @return mixed
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function cancelOrRefund(\Magento\Payment\Model\InfoInterface $payment)
{
$storeId = $payment->getOrder()->getStoreId();
$pspReference = $this->_getPspReference($payment);
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$request = [
"merchantAccount" => $merchantAccount,
"reference" => $payment->getOrder()->getIncrementId(),
"originalReference" => $pspReference
];
// call lib
$service = new \Adyen\Service\Modification($this->_client);
$result = $service->cancelOrRefund($request);
if ($result['response'] != '[cancelOrRefund-received]') {
// something went wrong
throw new \Magento\Framework\Exception\LocalizedException(__('The refund action failed'));
}
// set pspReference as TransactionId so you can do an online refund
if (isset($result['pspReference'])) {
$payment->setTransactionId($result['pspReference'])
->setIsTransactionClosed(false)
->setParentTransactionId($payment->getAdditionalInformation('pspReference'));
}
return $result;
}
/**
* (partial)Refund payment on Adyen
*
* @param \Magento\Payment\Model\InfoInterface $payment
* @param $amount
* @return mixed
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount)
{
$storeId = $payment->getOrder()->getStoreId();
$pspReference = $this->_getPspReference($payment);
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$currency = $payment->getOrder()->getBaseCurrencyCode();
//format the amount to minor units
$amount = $this->_adyenHelper->formatAmount($amount, $currency);
$modificationAmount = ['currency' => $currency, 'value' => $amount];
$request = [
"merchantAccount" => $merchantAccount,
"modificationAmount" => $modificationAmount,
"reference" => $payment->getOrder()->getIncrementId(),
"originalReference" => $pspReference
];
// call lib
$service = new \Adyen\Service\Modification($this->_client);
$result = $service->refund($request);
if ($result['response'] != '[refund-received]') {
// something went wrong
throw new \Magento\Framework\Exception\LocalizedException(__('The refund action failed'));
}
// set pspReference as TransactionId so you can do an online refund
if (isset($result['pspReference'])) {
$payment->setTransactionId($result['pspReference'])
->setIsTransactionClosed(false)
->setParentTransactionId($payment->getAdditionalInformation('pspReference'));
}
return $result;
}
/** /**
* @param $shopperReference * @param $shopperReference
* @param $storeId * @param $storeId
...@@ -500,25 +245,4 @@ class PaymentRequest extends DataObject ...@@ -500,25 +245,4 @@ class PaymentRequest extends DataObject
throw new \Magento\Framework\Exception\LocalizedException(__('Failed to disable this contract')); throw new \Magento\Framework\Exception\LocalizedException(__('Failed to disable this contract'));
} }
} }
/**
* Retrieve pspReference from payment object
*
* @param \Magento\Payment\Model\InfoInterface $payment
*/
protected function _getPspReference(\Magento\Payment\Model\InfoInterface $payment)
{
return $payment->getAdyenPspReference();
}
/**
* Decrypt password
*
* @param string $password
* @return string
*/
public function decryptPassword($password)
{
return $this->_encryptor->decrypt($password);
}
} }
\ No newline at end of file
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