小编Sta*_*nge的帖子

如何使用curl和Stripe检查客户是否订阅

在Stripe中,要获取使用在线支付系统Stripe提供的curl API订阅的客户列表,只需调用:

curl https://api.stripe.com/v1/customers -u sk_test_key:
Run Code Online (Sandbox Code Playgroud)

这将返回 JSON 格式的客户列表。您可以自己运行代码,因为它使用来自 Stripe 的测试数据。

如果我只想检查给定客户是否订阅了怎么办?例如客户 ID cus_5uR2Kp7ukpBSBc

stripe-payments

6
推荐指数
1
解决办法
9460
查看次数

在PHP中执行Curl以执行Stripe订阅

Stripe API允许进行Curl调用.例如,命令:

curl https://api.stripe.com//v1/customers/cus_5ucsCmNxF3jsSY/subscriptions    -u sk_test_REDACTED:
Run Code Online (Sandbox Code Playgroud)

返回客户cus_5ucsCmNxF3jsSY的订阅.

如何使用PHP来调用此curl命令(我试图避免使用PHP Stripe库).

我正在尝试以下方法:

<?php 
        // create curl resource 
        $ch = curl_init(); 

        // set url 
        curl_setopt($ch, CURLOPT_URL, "https://api.stripe.com//v1/customers/cus_5ucsCmNxF3jsSY/subscriptions    -u sk_test_REDACTED:"); 

        //return the transfer as a string 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

        // $output contains the output string 
        $output = curl_exec($ch); 
        print($output);

        // close curl resource to free up system resources 
        curl_close($ch);      
?>
Run Code Online (Sandbox Code Playgroud)

但是,似乎curl不接受URL的-u参数.我收到以下错误:

{ "error": { "type": "invalid_request_error", "message": "You did not provide an API key. You need to provide your API key in the Authorization …
Run Code Online (Sandbox Code Playgroud)

php curl stripe-payments

5
推荐指数
1
解决办法
5628
查看次数

标签 统计

stripe-payments ×2

curl ×1

php ×1