我在 Stripe 中有两种类型的用户:
最终客户(支付和接收产品/服务);
连接用户(将拥有连接帐户并将提供产品/服务);
让我们假设在下面的例子中用户是一个模型实例(Django):
# Connect Account
instance = stripe.Account.create(
type="custom",
country="PL",
email=user.email,
default_currency="pln",
business_type="individual",
requested_capabilities=["card_payments", "transfers",],
individual={
"first_name": user.first_name.strip(),
"last_name": user.last_name.strip(),
"email": user.email,
"dob": {
"day": user.profile.date_of_birth.day,
"month": user.profile.date_of_birth.month,
"year": user.profile.date_of_birth.year,
},
"phone": user.profile.phone_number,
"address": {
"city": user.city.strip(),
"postal_code": user.profile.postal_code.strip(),
"country": "PL",
"line1": user.profile.address.strip(),
},
},
)
# Customer Account
instance = stripe.Customer.create(
email=user.email,
description="desc",
name=user.get_full_name.strip(),
phone=user.profile.phone_number.strip(),
)
这两个 API 调用正常工作。然后我能够为新用户检索唯一的Stripe ID :
stripe_customer_id = instance.get("id")
对于stripe.Account类型,我需要提供身份验证:身份证正反面(作为示例):
document_images_data = [
"data:image/png;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
"data:image/png;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
]
_front = stripe.File.create(
purpose="identity_document",
file=Base64ImageField().to_internal_value(base64_data=document_images_data[0]),
stripe_account=stripe_customer_id,
)
_back = stripe.File.create(
purpose="identity_document",
file=Base64ImageField().to_internal_value(base64_data=document_images_data[1]),
stripe_account=stripe_customer_id,
)
慕少森
相关分类