1

I am trying to pass a few variables to the shell_exec command, but for some reason it's not picking up the data in the php variables. Please help me, and the below is what I got:

$out = exec('curl -silent https://api.stripe.com/v1/charges -u sk_live_sdfsdfdsfsdfdf: -d "amount=$aaamount" -d currency=usd -d "description=BBB $aaamount" -d "card[number]=$ccnumber" -d "card[exp_month]=$expm" -d "card[exp_year]=$expy" -d "card[cvc]=611"');

Any kind of help I can get on this is greatly appreciated.

4
  • 1
    Single quoted strings won't parse variables; use double quotes php.net/manual/en/language.types.string.php Commented Jun 1, 2013 at 19:41
  • 1
    You're aware that PHP has bindings to cURL, right? Commented Jun 1, 2013 at 19:41
  • @JonathonReinhart what does that mean :) ? Commented Jun 2, 2013 at 3:27
  • 1
    @thevoipman Click the link :-) Commented Jun 2, 2013 at 11:44

1 Answer 1

2

You're aware that PHP has bindings to cURL, right?

Besides, on the very front page of Stripe, right where you probably copied that curl command line, is a drop-down to change to other languages, namely PHP. They have an API for you to use:

require_once('./lib/Stripe.php');
Stripe::setApiKey("sk_test_mkGsLqEW6SLnZa487HYfJVLf");

Stripe_Charge::create(array(
  "amount" => 400,
  "currency" => "usd",
  "card" => array(
    "number" => "4242424242424242",
    "exp_month" => 6,
    "exp_year" => 2014,
    "cvc" => 314
  ),
  "description" => "Charge for [email protected]")
);
Sign up to request clarification or add additional context in comments.

7 Comments

Well your current code structure obviously isn't working, right? Why not do it the right way then and use their API?
i substitute single quotes with double quotes, now it's working, thanks anyways.
Sigh, some people never get it.
Stripe::setApiKey($stripe['secret_key']); try{ $customer = Stripe_Customer::create(array( 'email' => $email, 'card' => $stripCode ));} catch(Exception $e){ echo $e->getMessage(); } try{ $charge = Stripe_Charge::create(array( "amount" => $order_amount, // amount in cents "customer"=>$customer->id, "currency" => "usd", "source" => $token, "description" => "[email protected]", "application_fee" => 123 // amount in cents )); } catch(Exception $e){ echo $e->getMessage(); } It gives an error and charge is not created!!
@Prince If you have a problem, ask a new question. Don't post a blob of unreadable code in the comments. If you feel so inclined, you could post a comment here linking to your new question.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.