Javascript Magento Paypalplus-通过PHP停用付款方式
我们正在使用带有一些扩展的Magento,其中一个是Paypalplus,它是必不可少的 现在我们想销售礼券,这是贝宝明确禁止的。所以我们需要停用PayPlus,或者至少是它的一些支付方式 我们首先尝试完全停用它,结果导致Javascript崩溃,Magento拒绝了订单。似乎如果激活了PPP,其他内置方法不会加载其Js,而是在购物车中存在礼品券时尝试使用未加载的PPP Js 然后,我尝试使用它自己的Js停用禁止的支付方法,它自己呈现所有方法Javascript Magento Paypalplus-通过PHP停用付款方式,javascript,php,magento,paypal,paypal-plus,Javascript,Php,Magento,Paypal,Paypal Plus,我们正在使用带有一些扩展的Magento,其中一个是Paypalplus,它是必不可少的 现在我们想销售礼券,这是贝宝明确禁止的。所以我们需要停用PayPlus,或者至少是它的一些支付方式 我们首先尝试完全停用它,结果导致Javascript崩溃,Magento拒绝了订单。似乎如果激活了PPP,其他内置方法不会加载其Js,而是在购物车中存在礼品券时尝试使用未加载的PPP Js 然后,我尝试使用它自己的Js停用禁止的支付方法,它自己呈现所有方法 window.ppp = PAYPAL.apps.P
window.ppp = PAYPAL.apps.PPP({ ... })
这将设置PPP Js。但我不知道是否有可能,也不知道在对象中传递哪个参数,是部分停用还是完全停用
它自己的支付方式。有人能告诉我吗。我现在搜索了一段时间,但是我找不到关于这个API的文档
以下是应呈现PPP的完整代码,包含在Magento PPP扩展中:
<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>
如果(付款类型=‘未定义’){
var支付={};
}
函数选择方法(代码){
试一试{
if(付款类型!=“未定义”){
awOSCPayment.currentMethod=代码;
}
}捕获(e){
}
document.getElementById('p_method_'+code.)。单击();
}
window.externMethodEnabled=false;
window.startPPP=函数(){
if(typeof window.thirdPartyObject==“未定义”){
window.thirdPartyObject=;
window.thirdPartyMethodObject=;
}
document.cookie='paypaplllus_session=;Path=/checkout/onepage;Expires=Thu,1970年1月1日00:00:01 GMT;';
document.cookie='paypapllus_session=;Path=/checkout;Expires=Thu,1970年1月1日00:00:01 GMT;';
document.cookie='paypapllus_session=;Path=/firecheckout;Expires=Thu,1970年1月1日00:00:01 GMT;';
document.cookie='paypapllus_session=;Path=/onestepcheckout;Expires=Thu,1970年1月1日00:00:01 GMT;';
window.pppId='';
选择方法(“”);
window.ppp=PAYPAL.apps.ppp(
{
批准:“,
占位符:“ppplus”,
模式:“,
用户操作:“提交”,
按钮位置:“外部”,
showPuiOnSandbox:正确,
showLoadingIndicator:真,
国家:“,
语文:“,
onContinue:函数(){
payment.save()
},
第三方支付方式选择:函数(数据){
this.lastCall='onThirdPartyPaymentMethodSelected';
selectMethod(window.thirdPartyObject[data.thirdPartyPaymentMethod]);
},
enableContinue:功能(数据){
如果(this.lastCall!=“onThirdPartyPaymentMethodSelected”){
选择方法(“”);
}
this.lastCall='enableContinue';
试一试{
如果($$(“#付款按钮容器>按钮”)。长度>0){
$$(“#付款按钮容器>按钮”)[0]。启用();
}
if($('onestepcheckout-place-order')!=null){
$('onestepcheckout-place-order').enable();
}
如果($$(“#查看按钮容器>按钮”)。长度>0){
$$(“#查看按钮容器>按钮”)[0]。启用();
}
if($('onestepcheckout-button-place-order')!=null){
$('onestepcheckout-button-place-order').enable();
}
如果($$('#签出审核提交>按钮.opc btn checkout')。长度>0){
$$('#checkout review submit>按钮.opc btn checkout')[0]。启用();
}
如果($$('#aw onestepcheckout下订单按钮')。长度>0){
$$('#aw onestepcheckout下订单按钮')[0]。启用();
}
}捕获(e){
控制台日志(e);
}
},
disableContinue:函数(数据){
如果(!window.externMethodEnabled){
试一试{
如果($$(“#付款按钮容器>按钮”)。长度>0){
$$(“#付款按钮容器>按钮”)[0]。禁用();
}
if($('onestepcheckout-place-order')!=null){
$('onestepcheckout-place-order')。禁用();
}
如果($$(“#查看按钮容器>按钮”)。长度>0){
$$(“#查看按钮容器>按钮”)[0]。禁用();
}
if($('onestepcheckout-button-place-order')!=null){
$('onestepcheckout-button-place-order')。禁用();
}
如果($$('#签出审核提交>按钮.opc btn checkout')。长度>0){
$$('#checkout review submit>按钮.opc btn checkout')[0]。禁用();
}
如果($$('#aw onestepcheckout下订单按钮')。长度>0){
$$('#aw onestepcheckout下订单按钮')[0]。禁用();
}
}捕获(e){
控制台日志(e);
}