【发布时间】:2022-01-24 05:20:31
【问题描述】:
我是初学者,我正在开发电子商务应用程序。我想做一些事情,如果用户付款成功,将创建一个订单并将其存储在数据库中。
我终于找到了一种集成支付网关的方法,当交易成功时,它会重定向到成功页面。
我这里的问题是付款成功后如何创建订单
这是我的代码
<script>
const API_publicKey = "<ADD YOUR PUBLIC KEY HERE>";
function payWithRave() {
var x = getpaidSetup({
PBFPubKey: API_publicKey,
customer_email: '{{address.email}}',
amount: '{{cart.get_total_price}}',
customer_phone: "234099940409",
currency: "NGN",
txref: "rave-123456",
meta: [{
metaname: "flightID",
metavalue: "AP1234"
}],
onclose: function() {},
callback: function(response) {
var txref = response.data.txRef; // collect txRef returned and pass to a server page to complete status check.
console.log("This is the response returned after a charge", response);
if (
response.data.chargeResponseCode == "00" ||
response.data.chargeResponseCode == "0"
) {
"{% url 'checkout:payment_complete' %}" // redirect to a success page
} else {
// redirect to a failure page.
}
x.close(); // use this to close the modal immediately after payment.
}
});
}
</script>
我该怎么做?将什么值传递给视图?
【问题讨论】:
标签: python html django backend e-commerce