request()获得了意外的关键字参数'customer' [英] request() got an unexpected keyword argument 'customer'

查看:53
本文介绍了request()获得了意外的关键字参数'customer'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实施razorpay时遇到了以上错误.我需要在razorpay api中创建一个新客户.无法获得客户,因为它说错误无法获得客户.

Was implementing the razorpay,got the above error. I need to create a new customer in the razorpay api. unable to get the customer as it is saying the error is unable to get customer.

from django.db import models
from customers.models import Customer
from django.db.models.signals import post_save,pre_save
import razorpay

client = razorpay.Client(auth=("", ""))

class BillingProfile(models.Model):
customer      = models.OneToOneField(Customer,null=True,blank=True)
inserted      = models.DateTimeField(auto_now_add=True)
updated       = models.DateTimeField(auto_now=True)
b_customer_id = models.CharField(max_length=120,null=True,blank=True)

def __str__(self):
    return self.customer.name

def billing_profile_recieved(sender,instance,*args,**kwargs):
if not instance.b_customer_id and instance.customer:
    print(instance.id,"OOOOOOOOOOOOOOOOOOOoo")
    print(client,"------------------------------")
    customer = client.customer.create(customer=instance.id)  //_______ ERROR
    print(customer)
pre_save.connect(billing_profile_recieved,sender=BillingProfile)


def user_created_reciever(sender,instance,created,*args,**kwargs):
if created:
    BillingProfile.objects.get_or_create(customer=instance)
print(instance.user_customer,client)

post_save.connect(user_created_reciever, sender=Customer)

推荐答案

可能是因为已有使用电子邮件的用户.您可以传递一个名为"fail_existing":"0"的附加参数.然后将返回customer_id.如果没有现有客户,它将创建一个新客户并返回customer_id.

May be because user with Email already existing. You can pass an additional parameter called "fail_existing":"0" . Then the customer_id will be returned. If there is no existing customer, it will create a new customer and return customer_id.

身体应该是这样的:

{
  "name" : "Cornelius123",
  "email" : "cornelius19901@gmail.com",
  "contact" : "+919000000000",
  "fail_existing":"0",
  "notes": {}
}

这篇关于request()获得了意外的关键字参数'customer'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆