如何创建付款来源以用于带发票的条带订阅
how to create payment source to be used with stripe subscription with invoice
我需要在 stripe 中创建一个订阅,客户使用收到的发票付款并转到付款页面
所以我没有客户卡的详细信息,当我尝试为客户创建付款来源时,这是必需的
这就是我所做的
def createStripeCustomer(profile,request):
host=request.build_absolute_uri()
parts=host.split('/')
host=parts[0]+'//'+parts[2]
source=stripe.Source.create(
type='card',
currency='gbp',
redirect={'return_url':host + '/payments/success/'},
owner={
'email': profile.user.email
}
)
customer=stripe.Customer.create(
description="My First Test Customer ",
email=profile.user.email,
name=profile.full_name,
phone=profile.phone_no,
address={'line1':profile.address},
)
source = stripe.Customer.create_source(
customer.id,
source=source.id
)
profile.stripe_customer=customer.id
profile.stripe_source=source.id
profile.save()
并用于订阅
def createStripeSubscription(subscription):
price=subscription.course.get_pay_price()
stripe_price=stripe.Price.create(
unit_amount=price,
currency=subscription.course.currency,
recurring={"interval": "week"},
product=subscription.course.stripe_product,
)
stripe_subscription=stripe.Subscription.create(
customer=subscription.student.stripe_customer,
items=[
{"price": stripe_price.id,
'quantity': 1,
},
],
metadata={
"subscription_pk": subscription.pk
},
)
subscription.stripe_price=stripe_price.id
subscription.stripe_subscription=stripe_subscription.id
subscription.save()
谁能帮忙让人们通过发票输入他们的卡
您的代码正在创建源代码,那些被认为是遗留的,不要使用它们。
您需要创建一个 PaymentMethod。这样做的方法是使用 Stripe.js 和 Stripe 托管的 UI “元素”,允许客户输入他们的银行卡详细信息(在符合 PCI 的 Stripe 托管的 iframe 输入字段中)(by following Step 3 here) and you can create a PaymentMethod out of that.
然后,您将该 PaymentMethod 发送到您的服务器,将其附加到客户,并在创建订阅时将其作为 default_payment_method
传递。
我需要在 stripe 中创建一个订阅,客户使用收到的发票付款并转到付款页面 所以我没有客户卡的详细信息,当我尝试为客户创建付款来源时,这是必需的 这就是我所做的
def createStripeCustomer(profile,request):
host=request.build_absolute_uri()
parts=host.split('/')
host=parts[0]+'//'+parts[2]
source=stripe.Source.create(
type='card',
currency='gbp',
redirect={'return_url':host + '/payments/success/'},
owner={
'email': profile.user.email
}
)
customer=stripe.Customer.create(
description="My First Test Customer ",
email=profile.user.email,
name=profile.full_name,
phone=profile.phone_no,
address={'line1':profile.address},
)
source = stripe.Customer.create_source(
customer.id,
source=source.id
)
profile.stripe_customer=customer.id
profile.stripe_source=source.id
profile.save()
并用于订阅
def createStripeSubscription(subscription):
price=subscription.course.get_pay_price()
stripe_price=stripe.Price.create(
unit_amount=price,
currency=subscription.course.currency,
recurring={"interval": "week"},
product=subscription.course.stripe_product,
)
stripe_subscription=stripe.Subscription.create(
customer=subscription.student.stripe_customer,
items=[
{"price": stripe_price.id,
'quantity': 1,
},
],
metadata={
"subscription_pk": subscription.pk
},
)
subscription.stripe_price=stripe_price.id
subscription.stripe_subscription=stripe_subscription.id
subscription.save()
谁能帮忙让人们通过发票输入他们的卡
您的代码正在创建源代码,那些被认为是遗留的,不要使用它们。
您需要创建一个 PaymentMethod。这样做的方法是使用 Stripe.js 和 Stripe 托管的 UI “元素”,允许客户输入他们的银行卡详细信息(在符合 PCI 的 Stripe 托管的 iframe 输入字段中)(by following Step 3 here) and you can create a PaymentMethod out of that.
然后,您将该 PaymentMethod 发送到您的服务器,将其附加到客户,并在创建订阅时将其作为 default_payment_method
传递。