Skip to content

Commit

Permalink
Klarna feature added for 2.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chandan-PS committed Aug 1, 2021
1 parent 9651af2 commit 532a3d7
Show file tree
Hide file tree
Showing 114 changed files with 3,649 additions and 1,467 deletions.
15 changes: 7 additions & 8 deletions Block/Addnewcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,24 @@ public function getExpiryYears()
return self::$_expiryYears;
}

public function getDisclaimerMessageEnable()
public function getDisclaimerMessageEnable()
{

return (bool) $this->_scopeConfig->getValue('worldpay/tokenization/configure_disclaimer'
. '/stored_credentials_message_enable', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);

return (bool) $this->_scopeConfig->getValue('worldpay/tokenization/configure_disclaimer'
. '/stored_credentials_message_enable', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
}
public function getDisclaimerText()
{

return $this->_scopeConfig->getValue('worldpay/tokenization/configure_disclaimer/'
. 'stored_credentials_disclaimer_message', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);

}

public function getDisclaimerMessageMandatory()
{

return (bool) $this->_scopeConfig->getValue('worldpay/tokenization/configure_disclaimer/'
. 'stored_credentials_flag', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);

}

public function getStoredCredentialsEnabledValue()
Expand All @@ -191,6 +188,8 @@ public function getStoredCredentialsEnabledValue()
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}


public function getCreditCardSpecificexception($execptionCode)
{
return $this->worldpayHelper->getCreditCardSpecificexception($execptionCode);
}
}
3 changes: 2 additions & 1 deletion Block/Adminhtml/Order/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public function isWorldpayPayment()

$paymentMethod= $this->getPaymentMethod();
if ($paymentMethod=='worldpay_cc' || $paymentMethod=='worldpay_apm'
|| $paymentMethod=='worldpay_moto' || $paymentMethod=='worldpay_cc_vault' || $paymentMethod=='worldpay_wallets') {
|| $paymentMethod=='worldpay_moto' || $paymentMethod=='worldpay_cc_vault'
|| $paymentMethod=='worldpay_wallets') {
return true;
}

Expand Down
2 changes: 2 additions & 0 deletions Block/Checkout/Hpp/Iframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Iframe extends \Magento\Framework\View\Element\Template
* @param \Magento\Backend\Block\Template\Context $context
* @param array $data
*/
// @codingStandardsIgnoreLine
public function __construct(
\Magento\Backend\Block\Template\Context $context,
array $data = []
Expand All @@ -22,6 +23,7 @@ public function __construct(
/**
* Disable block output when integration mode is other than iframe
*/
// @codingStandardsIgnoreLine
protected function _beforeToHtml()
{
return parent::_beforeToHtml();
Expand Down
7 changes: 7 additions & 0 deletions Block/Sales/Order/Email/Items/Order/DefaultOrderPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public function __construct(\Sapient\Worldpay\Helper\Recurring $recurringHelper)
*/
public function afterGetItemOptions(\Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder $subject, $result)
{

foreach ($subject->getOrder()->getAllItems() as $item) {
if ($item->getProductType() == 'grouped') {
return;
}
}

return array_merge(
$this->recurringHelper->prepareOrderItemOptions($subject->getItem()),
$result
Expand Down
4 changes: 4 additions & 0 deletions Block/Webpayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,8 @@ public function getSessionId()
{
return $this->session->getSessionId();
}
public function is3DsEnabled()
{
return $this->_helper->is3DSecureEnabled() || $this->_helper->isDynamic3DEnabled();
}
}
7 changes: 4 additions & 3 deletions Controller/Adminhtml/Recurring/Plan/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ public function execute()
{
$data = $this->getRequest()->getPostValue();
//$productId = $this->getRequest()->getParam('product_id');
$url = parse_url($this->_redirect->getRefererUrl());
// @codingStandardsIgnoreLine
$url = parse_url($this->_redirect->getRefererUrl());
$path_parts=explode('/', $url['path']);
if (in_array('id',$path_parts)) {
$key = array_search('id',$path_parts);
if (in_array('id', $path_parts)) {
$key = array_search('id', $path_parts);
$productId = $path_parts[$key+1];
}
$store=$this->storeManager->getWebsite($data['website_id'])->getCode();
Expand Down
10 changes: 6 additions & 4 deletions Controller/Applepay/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function execute()
if ($validation_url == 'getTotal') {

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');
$cart = $objectManager->get(\Magento\Checkout\Model\Cart::class);

$subTotal = $cart->getQuote()->getSubtotal();
$grandTotal = $cart->getQuote()->getGrandTotal();
Expand All @@ -83,6 +83,7 @@ public function execute()
define('PRODUCTION_CERTIFICATE_KEY_PASS', $certificationPassword);

define('PRODUCTION_MERCHANTIDENTIFIER', openssl_x509_parse(
// @codingStandardsIgnoreLine
file_get_contents(PRODUCTION_CERTIFICATE_PATH)
)['subject']['UID']);
define('PRODUCTION_DOMAINNAME', $domainName);
Expand All @@ -92,18 +93,18 @@ public function execute()
try {

$validation_url = $this->request->getParam('u');

// @codingStandardsIgnoreStart
if ("https" == parse_url($validation_url, PHP_URL_SCHEME) && substr(
parse_url($validation_url, PHP_URL_HOST),
-10
) == ".apple.com") {

// create a new cURL resource
$ch = curl_init();

$data = '{"merchantIdentifier":"'.PRODUCTION_MERCHANTIDENTIFIER.'", '
. '"domainName":"'.PRODUCTION_DOMAINNAME.'", "displayName":"'.PRODUCTION_DISPLAYNAME.'"}';

curl_setopt($ch, CURLOPT_URL, $validation_url);
curl_setopt($ch, CURLOPT_SSLCERT, PRODUCTION_CERTIFICATE_PATH);
curl_setopt($ch, CURLOPT_SSLKEY, PRODUCTION_CERTIFICATE_KEY);
Expand All @@ -115,6 +116,7 @@ public function execute()
$result = curl_exec($ch);
//var_dump($result);
curl_close($ch);
// @codingStandardsIgnoreEnd

$resultJson = '';

Expand Down
2 changes: 2 additions & 0 deletions Controller/Button/PlaceOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public function execute()
if ($dfReferenceId) {
$this->checkoutSession->setDfReferenceId($dfReferenceId);
$this->checkoutSession->setInstantPurchaseOrder(true);
$this->checkoutSession->setInstantPurchaseRedirectUrl($this->_redirect->getRefererUrl());
}
}
try {
Expand Down Expand Up @@ -175,6 +176,7 @@ public function execute()
$threeDSecureChallengeParams = $this->checkoutSession->get3Ds2Params();
$this->messageManager->getMessages(true);
if ($threeDSecureChallengeParams || ($redirectData = $this->checkoutSession->get3DSecureParams())) {
$this->checkoutSession->setInstantPurchaseRedirectUrl($this->_redirect->getRefererUrl());
$this->checkoutSession->setInstantPurchaseMessage($message);
$message = __('');
} else {
Expand Down
24 changes: 13 additions & 11 deletions Controller/Hostedpaymentpage/Challenge.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ public function __construct(

public function execute()
{
if(isset($_COOKIE['PHPSESSID'])){
$phpsessId = $_COOKIE['PHPSESSID'];
$domain = parse_url($this->_url->getUrl(), PHP_URL_HOST);
setcookie("PHPSESSID", $phpsessId, [
'expires' => time() + 3600,
'path' => '/',
'domain' => $domain,
'secure' => true,
'httponly' => true,
'samesite' => 'None',
]);
// @codingStandardsIgnoreStart
if (isset($_COOKIE['PHPSESSID'])) {
$phpsessId = $_COOKIE['PHPSESSID'];
$domain = parse_url($this->_url->getUrl(), PHP_URL_HOST);
setcookie("PHPSESSID", $phpsessId, [
// @codingStandardsIgnoreEnd
'expires' => time() + 3600,
'path' => '/',
'domain' => $domain,
'secure' => true,
'httponly' => true,
'samesite' => 'None',
]);
}

return $this->_pageFactory->create();
Expand Down
13 changes: 9 additions & 4 deletions Controller/Notification/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Index extends \Magento\Framework\App\Action\Action
*/
protected $historyNotification;

private $abstractMethod;
private $abstractMethod;

const RESPONSE_OK = '[OK]';
const RESPONSE_FAILED = '[FAILED]';
Expand Down Expand Up @@ -79,7 +79,8 @@ public function execute()
}
} catch (Exception $e) {
$this->wplogger->error($e->getMessage());
if ($e->getMessage() == 'invalid state transition' || $e->getMessage() == 'same state') {
if ($e->getMessage() == 'invalid state transition' || $e->getMessage() == 'same state'
|| $e->getMessage() == 'Notification received for Partial Captutre') {
return $this->_returnOk();
} else {
return $this->_returnFailure();
Expand All @@ -90,6 +91,7 @@ public function execute()
public function _getRawBody()
{
if (null === $this->_rawBody) {
// @codingStandardsIgnoreLine
$body = file_get_contents('php://input');

if (strlen(trim($body)) > 0) {
Expand All @@ -106,6 +108,9 @@ public function _getRawBody()
*/
private function _createPaymentUpdate($xmlRequest)
{
$this->wplogger->info('########## Received notification ##########');
$this->wplogger->info($this->_getRawBody());
$this->paymentservice->getPaymentUpdateXmlForNotification($this->_getRawBody());
$this->_paymentUpdate = $this->paymentservice
->createPaymentUpdateFromWorldPayXml($xmlRequest);

Expand All @@ -114,8 +119,8 @@ private function _createPaymentUpdate($xmlRequest)

private function _logNotification()
{
$this->wplogger->info('########## Received notification ##########');
$this->wplogger->info($this->_getRawBody());
// $this->wplogger->info('########## Received notification ##########');
// $this->wplogger->info($this->_getRawBody());
$this->wplogger->info('########## Payment update of type: ' .
get_class($this->_paymentUpdate). ' created ##########');
}
Expand Down
3 changes: 1 addition & 2 deletions Controller/Redirectresult/Cancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function execute()

$this->wplogger->info('worldpay returned cancel url');
if (!$this->orderservice->getAuthorisedOrder()) {
return $this->resultRedirectFactory->create()->setPath('checkout/cart', ['_current' => true]);
return $this->resultRedirectFactory->create()->setPath('checkout/cart', ['_current' => true]);
}
$order = $this->orderservice->getAuthorisedOrder();
$magentoorder = $order->getOrder();
Expand All @@ -72,7 +72,6 @@ private function _getCancellationNoticeForOrder($order)
{

$incrementId = $order->getIncrementId();

$message = $incrementId === null
? __('Order Cancelled')
: __('Order #'. $incrementId.' Cancelled');
Expand Down
2 changes: 1 addition & 1 deletion Controller/Redirectresult/Iframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function execute()
$currenturl = $this->_url->getCurrentUrl();
$redirecturl = str_replace("iframe/status/", "", $currenturl);
}

// @codingStandardsIgnoreLine
print_r('<script>window.top.location.href = "'.$redirecturl.'";</script>');
}

Expand Down
21 changes: 13 additions & 8 deletions Controller/Samsungpay/CallBack.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ public function execute()
$environmentMode = $this->scopeConfig->
getValue('worldpay/general_config/environment_mode', $storeScope);


if ($environmentMode == 'Test Mode') {
$serviceUrl = "https://api-ops.stg.mpay.samsung.com/ops/v1/transactions/paymentCredentials/" . $refId . '?serviceId=' . $serviceId;
$serviceUrl = "https://api-ops.stg.mpay.samsung.com/ops/v1/transactions/paymentCredentials/"
. $refId . '?serviceId=' . $serviceId;
} else {
$serviceUrl = "https://api-ops.mpay.samsung.com/ops/v1/transactions/paymentCredentials/" . $refId . '?serviceId=' . $serviceId;
$serviceUrl = "https://api-ops.mpay.samsung.com/ops/v1/transactions/paymentCredentials/"
. $refId . '?serviceId=' . $serviceId;
}

$orderCode = $order->getIncrementId();
Expand All @@ -99,10 +100,11 @@ public function execute()
$item = $wpp->loadByPaymentId($orderCode);

$worldpayOrderId = $item->getWorldpayOrderId();
$this->_checkoutSession->setauthenticatedOrderId($orderCode);

if ($refId != '') {
try {

// @codingStandardsIgnoreStart
$curl = curl_init();

curl_setopt_array($curl, [
Expand All @@ -119,17 +121,17 @@ public function execute()
"serviceId: $serviceId"
],
]);

$json = curl_exec($curl);

curl_close($curl);
// @codingStandardsIgnoreEnd


$response = json_decode($json, true);

if ($response['resultMessage'] == 'SUCCESS') {

//response is success, collect the order details and send request to worldpay with this reponse from samsung
//response is success, collect the order details and
//send request to worldpay with this reponse from samsung

//$order = $this->orderFactory->create()->loadByIncrementId($orderId);
//$orderDetails = $order->getData();
Expand Down Expand Up @@ -158,11 +160,13 @@ public function execute()
if ($lastEvent[0] == 'AUTHORISED') {
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('worldpay/wallets/success');
$this->_checkoutSession->unsauthenticatedOrderId();
return $resultRedirect;
} else {
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('worldpay/Redirectresult/cancel');
$this->orderManagement->cancel($orderId);
$this->_checkoutSession->restoreQuote();
return $resultRedirect;
}
}
Expand All @@ -173,6 +177,7 @@ public function execute()
$this->orderManagement->cancel($orderId);
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('worldpay/Redirectresult/cancel');
$this->_checkoutSession->restoreQuote();
return $resultRedirect;
}
}
Expand Down
7 changes: 4 additions & 3 deletions Controller/Samsungpay/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(
}

public function execute()
{
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;

$serviceId = $this->scopeConfig->
Expand Down Expand Up @@ -102,7 +102,8 @@ public function execute()

$postFieldsJson = (json_encode($postFields));

try {
try {
// @codingStandardsIgnoreStart
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $serviceUrl,
Expand All @@ -122,7 +123,7 @@ public function execute()
$response = curl_exec($curl);

curl_close($curl);

// @codingStandardsIgnoreEnd
$resultJson = '';
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($response);
Expand Down
Loading

0 comments on commit 532a3d7

Please sign in to comment.