Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 条带支付订阅无法正常工作_Php_Codeigniter_Stripe Payments - Fatal编程技术网

Php 条带支付订阅无法正常工作

Php 条带支付订阅无法正常工作,php,codeigniter,stripe-payments,Php,Codeigniter,Stripe Payments,我正在我的一个codeigniter项目中使用stripe 我正在使用subscription方法将用户添加到订阅 $customer = Stripe_Customer::create(array( "card" => $token, "plan" => "monthly", "email" => "user@domain.com", "description" => "user@domain.com", )); 这是我的订阅代码 $customer

我正在我的一个codeigniter项目中使用stripe

我正在使用subscription方法将用户添加到订阅

$customer = Stripe_Customer::create(array(
  "card" => $token,
  "plan" => "monthly",
  "email" => "user@domain.com",
  "description" => "user@domain.com",
));
这是我的订阅代码

$customer = Stripe_Customer::create(array(
  "card" => $token,
  "plan" => "monthly",
  "email" => "user@domain.com",
  "description" => "user@domain.com",
));
使用此代码,我正在创建新客户并将其添加到订阅计划中。 此代码创建新用户并将该用户添加到订阅计划中,但该用户不收取该金额


我做错了什么或遗漏了什么吗?

您最好创建客户、卡对象,然后分别订阅客户。Stripe应在添加到订阅时自动向客户收费,但可能试图在一次完成所有操作时按错误顺序收费?你试过把它们分开吗?我编写了以下库,用于CI和Stripe:

/application/libaries/Stripe.php 创建我的客户

// Create Stripe Customer
$request = array(
  "description" => {CUSTOMER-NAME},
  "metadata" => array(
    'First Name' => {CONTACT-FIRST-NAME},
    'Last Name' => {CONTACT-LAST-NAME},
    'Company Name' => {COMPANY-NAME}
  ),
  "shipping" => array(
    "name" => {CUSTOMER-NAME},
    "address" => array (
        "city" => {CITY},
        "state" => {STATE},
        "postal_code" => {ZIP},
        "line1" => {STREET-1},
        "line2" => {STREET-2},
    )
  ),
  "email" => $this->input->post('vendor_contact_email')
);

// Create the Customer
$stipe_response = $this->stripe->create_customer($request);
$response_arr = $this->stripe->decode_response($stipe_response);
$stripe_customer_id = $response_arr->id;
加一张卡片

$data = array(
    "object" => 'card',
    "number" => {CARD-NUMBER},

    "address_city" => {BILLING-CITY},
    "address_state" => {BILLING-STATE},
    "address_zip" => {BILLING-ZIP},
    "address_line1" => {BILLING-ADDRESS},
    "address_line2" => {BILLING-ADDRESS-2},

    "name" => {BILLING-NAME},
    "exp_month" => {EXPIRATION-MONTH},
    "exp_year" => {EXPIRATION-YEAR},
);

// Add the Card
$stripe_response = $this->stripe->add_card($stripe_customer_id,$data);
$response_arr = $this->stripe->decode_response($stipe_response);
订阅客户

$stripe_response = $this->stripe->subscribe_customer($stripe_customer_id,{PLAN-ID},{SOURCE-ID});
$response_arr = $this->stripe->decode_response($stipe_response);
如果遇到问题,可以使用$response\u arr调试从Stripe获得的任何响应。希望这能有所帮助。我发现libarary比stripesdk更容易使用。

展示了如何创建订阅。如果它不起作用,我建议分享更多的代码和您在这里遇到的任何错误,或者联系支持,提供客户和订阅令牌等详细信息,以便他们可以查看详细信息。
$stripe_response = $this->stripe->subscribe_customer($stripe_customer_id,{PLAN-ID},{SOURCE-ID});
$response_arr = $this->stripe->decode_response($stipe_response);