我们正在使用带有一些扩展的 Magento,其中之一是 Paypalplus,它是必不可少的。
现在我们要销售礼券,这是 Paypal 明确禁止的。所以我们需要停用 Paypayplus,或者至少停用它的一些付款方式。
我们首先尝试完全停用它,这导致 Javascript 损坏,并且 Magento 拒绝了订单。似乎如果 PPP 被激活,其他内置方法不会加载他们的 Js,而是尝试使用未加载的 PPP-Js,当购物车中存在礼券时。
然后我尝试使用它自己的 Js 停用被禁止的付款方式,它自己呈现所有方法。
window.ppp = PAYPAL.apps.PPP({ ... })
这应该设置 PPP Js。但我不知道是否有可能或在对象中传递哪个参数来部分或完全停用其自己的支付方式。谁能告诉我。我现在搜索了一段时间,但我找不到有关此 API 的文档。
这是应该呈现 PPP 的完整代码,包含在 Magento PPP-Extension 中:
<div id="ppplus"></div>
<script type="text/javascript">
if(typeof payment == 'undefined') {
var payment = {};
}
function selectMethod(code) {
try {
if(typeof awOSCPayment != "undefined") {
awOSCPayment.currentMethod = code;
}
} catch (e) {
}
document.getElementById('p_method_' + code).click();
}
window.externMethodEnabled = false;
window.startPPP = function () {
if(typeof window.thirdPartyObject == 'undefined') {
window.thirdPartyObject = <?php echo $this->getThirdPartyJsonObject(); ?>;
window.thirdPartyMethodObject = <?php echo $this->getThirdPartyMethodJsonObject(); ?>;
}
document.cookie = 'paypalplus_session=; Path=/checkout/onepage; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
document.cookie = 'paypalplus_session=; Path=/checkout; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
document.cookie = 'paypalplus_session=; Path=/firecheckout; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
document.cookie = 'paypalplus_session=; Path=/onestepcheckout; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
window.pppId = '<?php echo $this->getPayPalPaymentId(); ?>';
selectMethod('<?php echo Iways_PayPalPlus_Model_Payment::METHOD_CODE; ?>');
window.ppp = PAYPAL.apps.PPP(
{
approvalUrl: "<?php echo $paymentExperience; ?>",
placeholder: "ppplus",
mode: "<?php echo Mage::getStoreConfig('iways_paypalplus/api/mode'); ?>",
useraction:"commit",
buttonLocation:"outside",
<?php if($this->isPuiSandboxMode()) : ?>
showPuiOnSandbox: true,
<?php endif; ?>
<?php if($this->showLoadingIndicator()) : ?>
showLoadingIndicator: true,
<?php endif; ?>
country:"<?php echo $this->getCountryId(); ?>",
language:"<?php echo $this->getLanguage(); ?>",
onContinue: function () {
payment.save()
},
onThirdPartyPaymentMethodSelected:function (data) {
this.lastCall = 'onThirdPartyPaymentMethodSelected';
selectMethod(window.thirdPartyObject[data.thirdPartyPaymentMethod]);
},
enableContinue: function (data) {
if(this.lastCall != 'onThirdPartyPaymentMethodSelected') {
selectMethod('<?php echo Iways_PayPalPlus_Model_Payment::METHOD_CODE; ?>');
}
this.lastCall = 'enableContinue';
try {
if($$('#payment-buttons-container > button').length > 0) {
$$('#payment-buttons-container > button')[0].enable();
}
if($('onestepcheckout-place-order') != null) {
$('onestepcheckout-place-order').enable();
}
if($$('#review-buttons-container > button').length > 0) {
$$('#review-buttons-container > button')[0].enable();
}
if($('onestepcheckout-button-place-order') != null) {
$('onestepcheckout-button-place-order').enable();
}
if($$('#checkout-review-submit > button.opc-btn-checkout').length > 0) {
$$('#checkout-review-submit > button.opc-btn-checkout')[0].enable();
}
if($$('#aw-onestepcheckout-place-order-button').length > 0) {
$$('#aw-onestepcheckout-place-order-button')[0].enable();
}
}catch (e) {
console.log(e);
}
},
disableContinue: function (data) {
if(!window.externMethodEnabled) {
try {
if($$('#payment-buttons-container > button').length > 0) {
$$('#payment-buttons-container > button')[0].disable();
}
if($('onestepcheckout-place-order') != null) {
$('onestepcheckout-place-order').disable();
}
if($$('#review-buttons-container > button').length > 0) {
$$('#review-buttons-container > button')[0].disable();
}
if($('onestepcheckout-button-place-order') != null) {
$('onestepcheckout-button-place-order').disable();
}
if($$('#checkout-review-submit > button.opc-btn-checkout').length > 0) {
$$('#checkout-review-submit > button.opc-btn-checkout')[0].disable();
}
if($$('#aw-onestepcheckout-place-order-button').length > 0) {
$$('#aw-onestepcheckout-place-order-button')[0].disable();
}
}catch (e) {
console.log(e);
}
}
},
<?php echo $this->getThirdPartyMethods(); ?>
});
}
window.startPPP();
function checkStep() {
try {
if(typeof window.checkout != 'undefined' && typeof window.lastStep == 'undefined') {
window.lastStep = window.checkout.accordion.currentSection;
}
if (typeof window.lastStep != 'undefined' && window.lastStep != window.checkout.accordion.currentSection) {
window.lastStep = checkout.accordion.currentSection;
if (checkout.accordion.currentSection == "opc-payment") {
window.startPPP();
}
}
} catch(e) {
}
}
window.setInterval(checkStep, 1000);
</script>
感谢您的关注。