I created a customer and charge that customer by using amount instead of plan. I checked their documentation but have no idea how to do that. Can anyone help me with my below code,
// create customer
$customer = Stripe_Customer::create(array(
"card" => $_POST['stripeToken'],
"description" => "This is testing mode",
"email" => "test#mail.com",
));
// Charge the Customer
Stripe_Charge::create(array(
"amount" => 3000,
"currency" => "usd",
"customer" => $customer->id)
);
Your code looks fine, and follows that outlined here:
https://stripe.com/docs/tutorials/charges
Is there a specific question or problem you're having?
Best,
Larry
PS I work on Support at Stripe.
Related
Hello got this code how can i return stripe payment description to a php variable so that i can later on can use it in sql query.
\Stripe\Stripe::setApiKey("STRIPE API");
try {
//Charge the Card
$newcard = \Stripe\Charge::create(array(
"customer" => $userstrip,
"amount" => 400,
"currency" => "USD",
'capture' => false),
);
$newcards = $newcard->description; // Tried like this
Okay if you just use id instead of description it also gets the payment id! :)
As per the stripe documentation here we read all the information and know the ideas about the SCA. But I am not getting any related API documentation. So, I am confusing how to implement in our existing PHP code and what are the parameters we will add. Please find below my example of code:
\Stripe\Stripe::setApiKey(API_KEY_HERE);
$customer = \Stripe\Token::create(
array("card" => array(
"name" => $arg['name'],
"number" => $arg['number'],
"exp_month" => $arg['exp_month'],
"exp_year" => $arg['exp_year'],
"cvc" => $arg['cvc']
))
);
/* some other code here */
$charge = \Stripe\Charge::create(
array(
"amount" => $arg['amount'],
"currency" => "usd",
"description" => "Subscription Charge",
"customer" => $customer->id
)
);
/* some other db related code here */
I have shared the code. Could you please let us know what we need to change for SCA?
I just answered this question where OP did a great job on the question.
Perhaps her code can help you see how you need to implement this using JS in the
front-end and PHP in the backend.
Stripe - Payment Intents (3d secure issue)
I'm building stripe payment gateway in PHP, all things working. but I need to create first subscription for future dates(that user select). its always starts with current date when I submit details. Please help...
I'm not able to find there is date parameter for start subscription from specific date. Please help so I can complete payment gateway.
https://stripe.com/docs/api#subscriptions
$charge = \Stripe\Charge::create(array(
"amount" => 1,
"currency" => "usd",
"customer" => $stripe_custmerid,
"description" => $_SESSION['user_name']
));
$subscription = \Stripe\Subscription::create(array(
"customer" => $stripe_custmerid,
"plan" => $plan_id,
));
First of all, I am aware that this question has been asked but they didn't explain how to get the information using
charge.succeeded
I am creating an auth and capture charge using Stripe. I need the charge ID to confirm/capture the charge.
The following code creates the charge but doesn't charge until it's been approved.
\Stripe\Charge::create(array(
"amount" => $price,
"currency" => "usd",
"customer" => $custID, // obtained with Stripe.js
"description" => "Charge for test#example.com",
"capture" => false
));
I assumed that I could get the charge ID by doing:
$chargeID = $charge->id;
because that's how I get the customer ID when I create a customer. But I get nothing when I echo out the variable, which doesn't help since I want to save it in a database. I've looked everywhere but can't find anything concrete or recent.
Then to complete the charge. I have to capture it this way:
$ch = \Stripe\Charge::retrieve("$chargeID");
$ch->capture();
This is all from the Stripe API Reference but it doesn't explain how to get the charge ID. It doesn't even tell you how to get the customer ID, luckily Stack Overflow came through with that one.
This is all done using PHP.
According to Stripe's Documentation, when creating a new charge you get Stripe\Charge JSON object in return (or an exception if something went wrong).
You can var_dump the object you just created to see what your object looks like, but according the the API you can use the id of the returned object:
$charge = \Stripe\Charge::create(array(
"amount" => $price,
"currency" => "usd",
"customer" => $custID, // obtained with Stripe.js
"description" => "Charge for test#example.com",
"capture" => false
));
// you can use the var_dump function to see what's inside the $charge object
// var_dump($charge);
$chargeID = $charge->id;
(And you don't need to call the Charge::retrieve again, you can use the current $charge object).
I am trying to integrate Stripe payment onto my site. I have a php variable '$val' set with a price amount sent from a form
$val = $_POST['myFieldName'];
I'm trying to use this variable to charge the amount it holds with stripe
Stripe_Charge::create(array(
"amount" => $val ,
"currency" => "gbp",
"card" => $_POST['stripeToken']));
But it seems Stripe wont except this variable. it puts a 'Missing required param: amount' error on the page It only wants to accept a actuale integer such as '1234' I tried cast to int using => intval($var) nut with no joy. Could someone tell me where Im going wrong
Thnks
you should try this
Stripe_Charge::create(array(
"amount" => 400,
"currency" => "usd",
"card" => "tok_14igbg2eZvKYlo2Cm0Akcrhg", // obtained with Stripe.js
"description" => "Charge for test#example.com"
));
description field is missing as per the documentation
I face same issue but its my coding fault
when you land on payment page
in the end just add this line before form submit button
" name="myFieldName">