dongzou3751 2018-07-20 11:27
浏览 25
已采纳

条带身份文档上传错误

The following error is appearing while trying to upload identity document using stripe API.The code is used is also given below.Please help.! Thanks in advance.

The php code that I used is

require '.././libs/stripe-php/init.php';

\Stripe\Stripe::setApiKey('sk_test_abc123'); 

$fileName = "success.png";

$fp = fopen($fileName, "r");

$file_obj = \Stripe\FileUpload::create(
    array(
        "purpose" => "identity_document",
        "file" => $fp
    ),
    array(
        "stripe_account" => 'acct_1AbC123'
    )
);

$file = $file_obj->id;

$response['status'] = $file;

Response is given below.

Stripe\Error\ApiConnection: Unexpected error communicating with Stripe. If this problem persists, let us know at support@stripe.com.

(Network error [errno 26]: couldn't open file "success.png") in C:\xampp\htdocs\stripe\libs\stripe-php\lib\HttpClient\CurlClient.php:277
Stack trace:
#0 C:\xampp\htdocs\stripe\libs\stripe-php\lib\HttpClient\CurlClient.php(234): Stripe\HttpClient\CurlClient->handleCurlError('https://uploads...', 26, 'couldn't open f...', 0)
#1 C:\xampp\htdocs\stripe\libs\stripe-php\lib\HttpClient\CurlClient.php(196): Stripe\HttpClient\CurlClient->executeRequestWithRetries(Array, 'https://uploads...')
#2 C:\xampp\htdocs\stripe\libs\stripe-php\lib\ApiRequestor.php(271): Stripe\HttpClient\CurlClient->request('post', 'https://uploads...', Array, Array, true)
#3 C:\xampp\htdocs\stripe\libs\stripe-php\lib\ApiRequestor.php(60): Stripe\ApiRequestor->_requestRaw('post', '/v1/files', Array, Array)
#4 C:\xampp\htdocs\stripe\libs\stripe-php\lib\ApiOperations\Request.php(56): Stripe\ApiRequestor->request('post', '/v1/files', Array, Array)
#5 C:\xampp\htdocs\stripe\libs\stripe-php\lib\ApiOperations\Create.php(23): Stripe\ApiResource::_staticRequest('post', '/v1/files', Array, Array)
#6 C:\xampp\htdocs\stripe\v1\index.php(318): Stripe\FileUpload::create(Array, Array)
#7 [internal function]: {closure}()
#8 C:\xampp\htdocs\stripe\libs\Slim\Route.php(468): call_user_func_array(Object(Closure), Array)
#9 C:\xampp\htdocs\stripe\libs\Slim\Slim.php(1355): Slim\Route->dispatch()
#10 C:\xampp\htdocs\stripe\libs\Slim\Middleware\Flash.php(85): Slim\Slim->call()
#11 C:\xampp\htdocs\stripe\libs\Slim\Middleware\MethodOverride.php(92): Slim\Middleware\Flash->call()
#12 C:\xampp\htdocs\stripe\libs\Slim\Middleware\PrettyExceptions.php(67): Slim\Middleware\MethodOverride->call()
#13 C:\xampp\htdocs\stripe\libs\Slim\Slim.php(1300): Slim\Middleware\PrettyExceptions->call()
#14 C:\xampp\htdocs\stripe\v1\index.php(745): Slim\Slim->run()
#15 {main}{"status":"3"}

In order to confirm that the file was there.I used the following code

$fileName = "success.png";

if (!file_exists($fileName))
  {
      echo "Cannot find file.";
  } else {  
      $fp = fopen($fileName, "rt")or die("Unable to open");
      echo "b".var_dump($fp);
  }

And the response was " bresource(108) of type (stream) " which means file is there .Correct me if I am wrong.

Thanks

  • 写回答

1条回答 默认 最新

  • duanguzhong5776 2018-07-24 10:40
    关注

    I have found the solution myself.The issue was with the TLS version 1.1 on local server.On Windows 10 OS you have option to choose the TLS version to use by following the below given steps. 1.Open Internet options from control panal 2.Select advanced tab 3.Scroll to bottom and there you can find check boxes of TLS versions.

    Please note that this solution is what I found for my windows localhost. Thanks.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同