我正在尝试建立一个基本的电子商务网站使用Django奥斯卡和我有困难。大多数问题都与缺乏如何挂钩有意义的(想想贝宝,条纹,Braintree)支付方法的例子有关,以及存在我以前从未听说过的晦涩的方法。
无论哪种方式,我都会尝试使用django-oscar-paypal并遵循它的文档。Paypal Express部分似乎工作正常,按钮显示出来,类似于结帐和处理发生的事情。
但是,如果我选择以常规方式结账(希望使用信用卡付款),我将进入以下页面(括号中的消息是我的)

它是以下模板的产品:
{% extends "checkout/checkout.html" %}
{% load i18n %}
{% block title %}
{% trans "Payment details" %} | {{ block.super }}
{% endblock %}
{% block checkout_nav %}
{% include 'checkout/nav.html' with step=3 %}
{% endblock %}
{% block checkout_title %}{% trans "Enter payment details" %}{% endblock %}
{% block order_contents %}{% endblock %}
{% block shipping_address %}{% endblock %}
{% block shipping_method %}{% endblock %}
{% block payment_method %}{% endblock %}
{% block payment_details %}
{% block payment_details_content %}
<p>{% trans "(*** Message from ./templates/tshirt-theme/ ***) This page needs implementing within your project. You may want to use one of Oscar's payment gateway libraries:" %}</p>
<ul>
<li><a href="https://github.com/django-oscar/django-oscar-paypal">django-oscar-paypal</a></li>
<li><a href="https://github.com/django-oscar/django-oscar-datacash">django-oscar-datacash</a></li>
<li><a href="https://github.com/django-oscar/django-oscar-gocardless">django-oscar-gocardless</a></li>
<li><a href="https://github.com/django-oscar/django-oscar-paymentexpress">django-oscar-paymentexpress</a></li>
<li><a href="https://github.com/django-oscar/django-oscar-accounts">django-oscar-accounts</a></li>
</ul>
<a id="view_preview" href="{% url 'checkout:preview' %}" class="btn btn-primary btn-lg">{% trans "Continue" %}</a>
{% endblock payment_details_content %}
{% endblock payment_details %}当我点击“继续”时,我被带到一个类似于预购页面的东西,在这个页面上付款方式是空的。当我点击“更改”时,它会带我回到屏幕截图上的页面。
我的问题是,我如何让信用卡与此设置一起工作?有没有更好的方法来做这件事呢?我对Django有点熟悉,但这项看似简单的任务似乎需要大量的知识和/或大量的重新发明轮子。后者肯定是这样的,因为没有任何关于这方面的文档或教程,但据说许多网站都使用Django-Oscar。
任何帮助或建议都是非常感谢的。
发布于 2018-07-12 20:40:10
从django-paypal repo中查看sandbox代码,特别是模板文件夹settings.py和urls.py。我按照说明,并添加必要的贝宝密钥到settings.py以及urls.py,但未能复制模板,因为这是不太仔细的文档。
对我来说,简单地添加至少与沙箱相同的模板,使您正在查看的屏幕被工作的贝宝按钮取代。特别是,sandbox/templates/checkout/payment_details.html似乎是用来代替您看到的提醒消息的内容-请注意,模板同时具有Express和Flow选项,因此只使用您的站点设置要使用的内容。
发布于 2019-11-21 21:58:01
将以下代码添加到oscar/checkout/preview.html,并更改客户端ID #
<body>
<div class="col-sm-5 col-sm-offset-7">
<!-- Set up a container element for the button -->
<div id="paypal-button-container" ></div>
<!-- Include the PayPal JavaScript SDK -->
<script src="https://www.paypal.com/sdk/js?client-id={{'Askdlsfhslfkdlfkdsflskd-wkJzFrkfldfkjhdlkfrW3-5U-RW0-ZsZskflsfu_YT-85r'}}¤cy=PLN&locale=pl_PL"></script>
<script>
// Render the PayPal button into #paypal-button-container
paypal.Buttons({
style: {
layout: 'horizontal',
size: 'small',
color: 'blue',
shape: 'rect',
label: 'pay',
height: 44,
tagline: 'true'
},
enableStandardCardFields: false,
// Set up the transaction
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: JSON.parse({{ order_total.incl_tax }}) // pass variable with amount to script
// <!-- value: '0.01', -->
}
}]
});
},
// Finalize the transaction
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
// Show a success message to the buyer
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
}
}).render('#paypal-button-container');
</script>
</div>
</body>https://stackoverflow.com/questions/50576247
复制相似问题