button'paynow!'在payment-braintree和django中无法工作,无法重定向到支付完成视图
创始人
2025-01-10 03:00:29
0
  1. 确保在表单中正确的引入了相应的js文件和braintree客户端token。
  2. 确认表单的提交按钮id属性与js代码中的按钮id属性相同。
  3. 检查重定向到支付完成视图的路由和视图是否正确设置。
  4. 在视图中确认是否有正确的重定向逻辑。
  5. 确保开发环境的调试器没有显示任何错误信息。 下面是一个示例代码,可以用来参考:

HTML表单:

JS代码: var button = document.querySelector('#submit-button');

braintree.dropin.create({ authorization: 'your_client_token', container: '#payment-form' }, function(createErr, instance) { button.addEventListener('click', function(e) {
e.preventDefault();
instance.requestPaymentMethod(function (err, payload) {
if (err) {
console.log('Error', err);
} else {
$.post('/checkout', {
'payment_method_nonce': payload.nonce
}, function(res) { if (res.success) { window.location.href = "/payment-done/"; } else { console.log(res.message); } });
}
});
});
});

Django视图: def payment(request): if request.method == 'POST': nonce = request.POST.get("payment_method_nonce", None) result = gateway.transaction.sale({ "amount": "10.00", "payment_method_nonce": nonce, "options": { "submit_for_settlement": True } }) if result.is_success: return JsonResponse({'success': True}) else: return JsonResponse({'success': False, 'message': result.message}) else: return render(request, 'payment.html')

Django路由: from django.urls import path

相关内容

热门资讯

透视好友房"wepo... 透视好友房"wepoker辅助软件视频"详细辅助微扑克教程(软件透视);玩家必备必赢加哟《13670...
透视了解"hhpok... 透视了解"hhpoker免费辅助器"详细辅助技巧教程(作弊辅助方法);科技安装教程;13670430...
透视攻略"wepok... 此外,数据分析德州(wepoker免费脚本咨询)辅助神器app还具备辅助透视行为开挂功能,通过对客户...
透视辅助"wpk作弊... 透视辅助"wpk作弊"详细辅助新2025版(黑侠辅助器正版下载神器)是一款可以让一直输的玩家,快速成...
透视规律"wepok... 透视规律"wepoker买钻石有用吗"详细辅助德州论坛(免费透视脚本攻略);1分钟了解详细教程(微信...
透视脚本"wepok... 透视脚本"wepoker透视破解版"详细辅助玩家教你(辅助软件视频神器);实战中需综合运用上述技巧,...
透视真的"wepok... 透视真的"wepoker轻量版有透视吗"详细辅助AI教程(插件攻略)1、不需要AI权限,帮助你快速的...
透视攻略"wepok... 透视攻略"wepoker有脚本吗"详细辅助扑克教程(透视器免费技巧);玩家必备必赢加哟《136704...
透视私人局"wepo... 透视私人局"wepoker开辅助能查到吗"详细辅助AI教程(透视脚本网页辅助),支持语音通讯、好友开...
透视ai"wepok... 透视ai"wepoker有什么规律"详细辅助必备教程(数据分析工具攻略)是一款可以让一直输的玩家,快...