缺少必需的参数:interval - stripe / PHP

时间:2018-03-21 20:01:57

标签: php stripe-payments

我不明白PHP上的条带代码是什么。我当然定义间隔,但他们告诉我"缺少必需的参数:interval"

我只想制作一个计划对象。我想在从ajax收到的令牌中创建一个Customer对象之后创建一个计划对象。

是否有必要从Composer等获取另一个php外部资源来制定计划?

我制定了如下计划

  \Stripe\Plan::create();
  // \Stripe\Stripe::setApiKey("sk_test_");
  $plan =  \Stripe\Plan::create(array(
    "amount" => 5000,
    "interval" => "month",
    "product" => array(
      "name" => "Emerald classic"
    ),
    "currency" => "jpy",
    "id" => "emerald-classic"
  ));

所有来源都是

<?php

  header("Content-type: text/plain; charset=UTF-8");

  if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])
     && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
  {
    if (isset($_POST['request']))
    {

      $name = $_POST['request'];
        require_once 'vendor/autoload.php';
        \Stripe\Stripe::setApiKey("sk_test_");

      \Stripe\Customer::create();
      $customer =  \Stripe\Customer::create(array(
        "description" => "taylor@example.com",
        "source" => "$name",
      ));

      //echo $customer;
      $customer_array = $customer->__toArray(true);
       foreach ($customer_array as $key => $value) {
        if ($key === "id") {
          $value_cus = $value;
        }
       }
       echo $value_cus;

      \Stripe\Plan::create();
      // \Stripe\Stripe::setApiKey("sk_test_");
      $plan =  \Stripe\Plan::create(array(
        "amount" => 5000,
        "interval" => "month",
        "product" => array(
          "name" => "Emerald classic"
        ),
        "currency" => "jpy",
        "id" => "emerald-classic"
      ));

    };
  };

  ?>

0 个答案:

没有答案