3

This is a curl request from Stripe API curl method:

curl https://api.stripe.com/v1/accounts \
   -u sk_test_**********: \
   -d managed=false \
   -d country=US \
   -d email="bob@example.com"

Right now I have this unirest code:

<?php Unirest\Request::auth(Config::get("stripe.secret.api_key"), '');

        $headers = array(
            "Content-Type" => "application/json"
        );
        $body    = array(  
           "managed" => $_managed,
           "country" => $_country,
           "email"   => $_email,
        );
        $response = Unirest\Request::post("https://api.stripe.com/v1/accounts", $headers, $body);
        return array(
            'status'  => 'success',
            'message' => $response
        ); ?>

Stripe returns method is wrong. I think its the -u param in curl.

Emily
  • 71
  • 1
  • 7

1 Answers1

0

I don't have much idea about Unirest. As you are facing issue with -u header, you can use the authorization parameter inside the url as below.

https://sk_test_RxRTXF1CDHuRw3ZUdynxnG6P:@api.stripe.com/v1/accounts
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sabuj Hassan
  • 38,281
  • 14
  • 75
  • 85
  • Remove header `"Content-Type" => "application/json"` from your code. You are not passing json there. – Sabuj Hassan Feb 11 '16 at 07:27
  • But what parameter is -u sk_test_ASX21312FCA? – Emily Feb 16 '16 at 03:16
  • tried this `https://sk_test_RxRTXF1CDHuRw3ZUdynxnG6P:@api.stripe.com/v1/accounts` didnt work – Emily Feb 16 '16 at 03:17
  • It can happen that your Unirest (or curl) is not configured for ssl. I didn't see any document regarding ssl on Unirest., except this: https://github.com/Mashape/unirest-php#ssl-validation and it is not a good idea to disable validation. – Sabuj Hassan Feb 16 '16 at 08:19