Skip to content

Commit

Permalink
optimize Assets
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolorenz committed Feb 20, 2024
1 parent 00d8ef5 commit 46a30c5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/Core/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ final class Module
'currencies' => [],
'constraints' => self::PAYMENT_CONSTRAINTS,
'capturedelay' => true,
'paymentCtrl' => false,
'paymentCtrl' => true,
],
];
}
5 changes: 5 additions & 0 deletions src/Core/ViewConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ public function getAdyenPaymentGooglePayId(): string
return Module::PAYMENT_GOOGLE_PAY_ID;
}

public function getAdyenPaymentApplePayId(): string
{
return Module::PAYMENT_APPLE_PAY_ID;
}

public function getAdyenErrorInvalidSession(): string
{
return Module::ADYEN_ERROR_INVALIDSESSION_NAME;
Expand Down
96 changes: 47 additions & 49 deletions views/frontend/tpl/payment/adyen_assets.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,31 @@
href="https://checkoutshopper-[{$oViewConf->getAdyenOperationMode()}].adyen.com/checkoutshopper/sdk/[{$oViewConf->getAdyenSDKVersion()}]/adyen.css"
integrity="[{$oViewConf->getAdyenIntegrityCSS()}]"
crossorigin="anonymous">
[{if $payment->oxpayments__oxid->value == constant('\OxidSolutionCatalysts\Adyen\Core\Module::PAYMENT_GOOGLE_PAY_ID')}]
<script src="https://pay.google.com/gp/p/js/pay.js"></script>
[{/if}]
[{assign var="sToken" value=$oViewConf->getSessionChallengeToken()}]
[{assign var="sSelfLink" value=$oViewConf->getSslSelfLink()|replace:"&amp;":"&"}]
[{assign var="adyenCreditCard" value=$oViewConf->getAdyenPaymentCreditCardId()}]
[{assign var="adyenPayPal" value=$oViewConf->getAdyenPaymentPayPalId()}]
[{assign var="adyenGooglePay" value=$oViewConf->getAdyenPaymentGooglePayId()}]
[{assign var="adyenApplePay" value=$oViewConf->getAdyenPaymentApplePayId()}]
[{assign var="isPaymentPage" value=false}]
[{assign var="isOrderPage" value=false}]
[{if $oViewConf->getTopActiveClassName() == 'payment'}]
[{assign var="isPaymentPage" value=true}]
[{assign var="paymentID" value=$oView->getCheckedPaymentId()}]
[{elseif $oViewConf->getTopActiveClassName() == 'order'}]
[{assign var="isOrderPage" value=true}]
[{assign var="paymentID" value=$payment->getId()}]
[{/if}]
[{if $isOrderPage && $paymentID == $adyenGooglePay}]
<script src="https://pay.google.com/gp/p/js/pay.js"></script>
[{/if}]
[{if $phpStorm}]<script>[{/if}]
[{capture assign="adyenJS"}]
[{assign var="isLog" value=$oViewConf->isAdyenLoggingActive()}]
[{assign var="isPaymentPage" value=false}]
[{assign var="isOrderPage" value=false}]
[{assign var="templateCheckoutCreateId" value=$oViewConf->getTemplateCheckoutCreateId($payment)}]
[{assign var="templatePayButtonContainerId" value=$oViewConf->getTemplatePayButtonContainerId($payment)}]
let submitForm, submitLink;
[{if $oViewConf->getTopActiveClassName() == 'payment'}]
[{assign var="isPaymentPage" value=true}]
[{assign var="paymentID" value=$oView->getCheckedPaymentId()}]
[{if $isPaymentPage}]
submitForm = document.getElementById('payment');
submitLink = document.getElementById('orderStep');
const nextStepEl = document.getElementById('paymentNextStepBottom');
Expand All @@ -41,9 +47,7 @@
nextStepEl.dataset.adyensubmit = '';
});
});
[{elseif $oViewConf->getTopActiveClassName() == 'order'}]
[{assign var="isOrderPage" value=true}]
[{assign var="paymentID" value=$payment->getId()}]
[{elseif $isOrderPage}]
submitForm = document.getElementById('orderConfirmAgbBottom');
[{/if}]
const adyenPspReferenceEl = document.getElementById('[{$oViewConf->getAdyenHtmlParamPspReferenceName()}]');
Expand All @@ -60,34 +64,38 @@
console.log(checkout.paymentMethodsResponse);
[{/if}]
[{if $isPaymentPage}]
const apple = checkout.create(
'applepay',
{
}
);
apple.isAvailable()
.then(() => { })
.catch(e => {
[{if $isLog}]
console.error('Apple Pay not available');
console.error(e);
[{/if}]
hidePaymentOption();
});
[{/if}]
[{if $isPaymentPage && $oView->isAvailablePayment($adyenCreditCard)}]
const cardComponent = checkout.create(
'card',
{
onFieldValid : function() {
const paymentIdEl = document.getElementById('payment_[{$adyenCreditCard}]');
paymentIdEl.checked = true;
nextStepEl.disabled = true;
},
[{if $oView->isAvailablePayment($adyenApplePay)}]
const apple = checkout.create(
'applepay',
{
}
);
apple.isAvailable()
.then(() => { })
.catch(e => {
[{if $isLog}]
console.error('Apple Pay not available', e);
[{/if}]
const parentElement = document.getElementById('payment_[{$adyenApplePay}]').parentElement;
if (parentElement) {
parentElement.remove(); // remove parent-block
}
});
[{/if}]
[{if $oView->isAvailablePayment($adyenCreditCard)}]
const cardComponent = checkout.create(
'card',
{
onFieldValid : function() {
const paymentIdEl = document.getElementById('payment_[{$adyenCreditCard}]');
paymentIdEl.checked = true;
nextStepEl.disabled = true;
},
}
).mount('#[{$adyenCreditCard}]-container');
cardComponent.paymentIdViewEl = document.getElementById('payment_[{$adyenCreditCard}]').parentElement;
}
).mount('#[{$adyenCreditCard}]-container');
cardComponent.paymentIdViewEl = document.getElementById('payment_[{$adyenCreditCard}]').parentElement;
[{/if}]
[{elseif $isOrderPage}]
[{if $orderPaymentApplePay}]
const applePayComponent = checkout.create('[{$templateCheckoutCreateId}]', configuration);
Expand All @@ -100,8 +108,7 @@
})
.catch(e => {
[{if $isLog}]
console.error('Apple Pay not available');
console.error(e);
console.error('Apple Pay not available', e);
[{/if}]
});
[{else}]
Expand Down Expand Up @@ -178,15 +185,6 @@
// Call adyenAsync
adyenAsync();
function hidePaymentOption() {
var inputElement = document.getElementById('payment_oscadyenapplepay');
if (inputElement) {
var parentElement = inputElement.closest('.well.well-sm');
if (parentElement) {
parentElement.remove(); // remove parent-block
}
}
}
[{/capture}]
[{if $phpStorm}]</script>[{/if}]
[{oxscript add=$adyenJS}]

0 comments on commit 46a30c5

Please sign in to comment.