亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Stripe 在 PHP 中創建多個階段

Stripe 在 PHP 中創建多個階段

PHP
慕桂英546537 2023-04-21 15:31:00
我正在嘗試使用 Stripe 為一個非常具體的用例創建多個階段。使用 Stripe Billings API 運行以下代碼實際上不會創建多個階段。它只創建一個階段(最后一個)。$schedule = \Stripe\SubscriptionSchedule::create([  'customer' => 'cus_HMDwmb8iAV0X7k',  'start_date' => 'now',  'end_behavior' => 'cancel',    'phases' => [      [        'end_date' => 1592910720,        'proration_behavior' => 'none',        'plans' => [          [            'price_data' => [              'unit_amount' => 5000,              'currency' => 'usd',              'product' => 'prod_HMrCxIwor5bbjO',              'recurring' => [                  'interval' => 'year',              ],            ],          ],        ],      ],    ],    'phases' => [      [        'end_date' => 1594850400,        'proration_behavior' => 'none',        'plans' => [          [            'price_data' => [              'unit_amount' => 6000,              'currency' => 'usd',              'product' => 'prod_HMrCxIwor5bbjO',              'recurring' => [                  'interval' => 'year',              ],            ],          ],        ],      ],    ],]);
查看完整描述

1 回答

?
尚方寶劍之說

TA貢獻1788條經驗 獲得超4個贊

在您的 php 調用中,您指定了phases參數兩次。因此只有第二個phases定義被用于創建訂閱計劃。此處的解決方法是將所有階段移動到單個數組和參數下,如下所示:


$schedule = \Stripe\SubscriptionSchedule::create([

  'customer' => $customer->id,

  'start_date' => 'now',

  'end_behavior' => 'cancel',

    'phases' => [

      [

        'end_date' => 1592910720,

        'proration_behavior' => 'none',

        'plans' => [

          [

            'price_data' => [

              'unit_amount' => 5000,

              'currency' => 'usd',

              'product' => $product->id,

              'recurring' => [

                  'interval' => 'year',

              ],

            ],

          ],

        ],

      ],

      [

        'end_date' => 1594850400,

        'proration_behavior' => 'none',

        'plans' => [

          [

            'price_data' => [

              'unit_amount' => 6000,

              'currency' => 'usd',

              'product' => $product->id,

              'recurring' => [

                  'interval' => 'year',

              ],

            ],

          ],

        ],

      ],

    ],

]);

我看到的唯一區別是,在 Curl 請求中,我明確傳遞了階段編號。


更多的是你在 phases 數組中傳遞相位索引。您必須在 cURL 中明確說明這一點,但在 php 中,您只需將每個元素添加到一個數組中,并且索引是隱含的。


查看完整回答
反對 回復 2023-04-21
  • 1 回答
  • 0 關注
  • 234 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號