接受来自印度的烧瓶中的国际条纹付款

Accept international stripe payments in flask from India

我试过 stripe,但问题是在文档中他们列出了接受来自印度的国际付款,我必须注册并且我还需要添加账单地址、客户姓名和付款意向.他们提供了有关如何添加名称和付款意向的文档,但我不知道如何在我的应用程序中实现提供的代码。

所以,请告诉我怎么做...

以防万一,这是我的结帐代码

@app.route('/create-checkout-session', methods=['POST'])
def create_checkout_session():
   session = stripe.checkout.Session.create(
        payment_method_types=['card'],
        line_items=[{
            'price_data': {
               'currency': 'usd',
               'product_data': {
                   'name': 'T-shirt',
                },
                'unit_amount': 2000,
            },
            'quantity': 1,
       }],
       mode='payment',
       success_url=redirect("success.html"),
       cancel_url=redirect("cancel.html"),
    )

已编辑回复

这是您可以添加其他可选参数的方法:

@bp.route('/create-checkout-session')
def create_checkout_session():
    domain_url = 'http://localhost:5000/'
    stripe.api_key = current_app.config['STRIPE_SECRET_KEY']
    try:
        checkout_session = stripe.checkout.Session.create(
            success_url=domain_url + 'success',
            cancel_url=domain_url + 'cancelled',
            payment_method_types=['card'],
            billing_address_collection='required',
            mode='payment',
            customer='customer_id',
            line_items=[
                {
                  # using the price api takes care of the product well
                  # rather than having to specify name, currency etc
                  'quantity': 1,
                  'price': 'price_1IYgbtFWpU2KHaPLODAVgoKU'
                }
            ],
            payment_intent_data=[
                {
                  # Place your data here
                  'param-key': 'value',
                  # ...
                }
            ]
        )
        # your return statement
    except Exception as e:
        # your return statement

您可以对其他参数执行此操作

如果您使用的是 Stripe Checkout,则无需更改代码;结帐将在结帐页面上从您的客户那里收集所需信息(姓名和账单地址)。