Javascript 如何取消/阻止PayPal';在满足条件之前是否会弹出检查模式?

Javascript 如何取消/阻止PayPal';在满足条件之前是否会弹出检查模式?,javascript,paypal,paypal-rest-sdk,paypal-buttons,Javascript,Paypal,Paypal Rest Sdk,Paypal Buttons,我正在尝试让PayPal的服务器端REST正常工作 这是我正在使用的表单: 如果金额或电子邮件字段为空,我想做的是阻止/取消付款 根据,单击按钮后将调用payment()。文档介绍了如何处理“乐观”用例,但没有提到如何取消支付流程: // payment() is called when the button is clicked payment: function() { // Set up a url on your server to create the payment

我正在尝试让PayPal的服务器端REST正常工作

这是我正在使用的表单:

如果
金额
电子邮件
字段为空,我想做的是阻止/取消付款

根据,单击按钮后将调用
payment()
。文档介绍了如何处理“乐观”用例,但没有提到如何取消支付流程:

// payment() is called when the button is clicked
payment: function() {

    // Set up a url on your server to create the payment
    var CREATE_URL = '/demo/checkout/api/paypal/payment/create/';

    // Make a call to your server to set up the payment
    return paypal.request.post(CREATE_URL)
        .then(function(res) {
            return res.paymentID;
        });
},

简单地返回
null
似乎也不起作用。如何处理此问题?

您不能直接在
payment()
函数中执行此操作,但可以添加一个
validate()
函数,根据表单状态启用/禁用按钮:


真不敢相信我错过了!谢谢