我想在条带中创建订阅并收到错误

问题描述 投票:0回答:1

当我使用下面的代码时出现此错误:此客户没有附加的付款来源或默认付款方式。

我必须在哪里设置付款方式?

如何给我一个代码示例?

                'email' => $email,
                'description' => 'printloop stripe customer',
            ]);

            $plan = $this->API->plans->create([
                'amount' => $price * 100,
                'currency' => 'usd',
                'interval' => 'month',
                'product' => 'prod_HOeoRj9boHP28C',
            ]);

            $this->API->subscriptions->create([
                'customer' => $customer->id,
                'items' => [
                    [
                        "price" => $plan->id,
                    ]
                ],
            ]);
php api methods payment
1个回答
0
投票

我已使用此代码。

 $customer = $this->API->customers->create([
                'email' => $email,
                'description' => 'printloop stripe customer',
            ]);

            $plan = $this->API->plans->create([
                'amount' => $price * 100,
                'currency' => 'usd',
                'interval' => 'month',
                'product' => 'prod_HOeoRj9boHP28C',
            ]);

            $this->API->subscriptions->create([
                'customer' => $customer->id,
                'items' => [
                    [
                        "price" => $plan->id,
                    ]
                ],
            ]);
© www.soinside.com 2019 - 2024. All rights reserved.