是否可以在不使用paypal_dict形式的情况下集成Django Paypal IPN?

问题描述

我正在尝试使用paypal提供的javascript按钮代码,而不是使用从视图传递到模板的paypal_dict表单。

由于它的现代设计和简单性,我想使用贝宝代码。

我的Paypal代码在沙盒上运行良好。具体来说,我使用的是订阅付款方式。

我已在settings.py中集成了贝宝IPN:

INSTALLED_APPS = [
   ...
    'paypal.standard.ipn',...

urls.py:

urlpatterns += [

...
    path('',include(apps.get_app_config('oscar').urls[0])),...

我已将以下内容添加到apps.py

from django.apps import AppConfig


class MypaypalConfig(AppConfig):
    name = 'myPaypal'

    def ready(self):
            import myPaypal.signals.handlers

这是我的handlers.py文件:

from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received
from django.utils import timezone


from Store.colors import *

def show_me_the_money(sender,**kwargs):
    ipn_obj = sender
    print(sender)
    if ipn_obj.payment_status == ST_PP_COMPLETED:
        print("ST_PP_COMPLETED")




valid_ipn_received.connect(show_me_the_money)

,在我的模板中,我有paypal提供的代码:

<div id="paypal-button-container"></div>
<script src="https://www.paypal.com/sdk/js?client-id= ***" data-sdk-integration-source="button-factory"></script>
<script>
  paypal.Buttons({
      style: {
          shape: 'pill',color: 'gold',layout: 'vertical',label: 'subscribe'
      },createSubscription: function(data,actions) {
        return actions.subscription.create({
          'plan_id': '***'
        });
      },onApprove: function(data,actions) {
        // $("#confirm_form").submit()
        console.log(data)
        console.log(actions)
      }
  }).render('#paypal-button-container');
</script>

成功处理付款(沙盒)后,我没有收到任何IPN。

是否可以通过这种方式集成贝宝IPN?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...