Hi i have seen the code for stripe payment as below. First create a customer object
$customer = \Stripe\Customer::create(array(
"card" => $token,
"description" => "Product Purchase for Book",
"email" => "[email protected]"
));
Then charge by using that customer object
\Stripe\Charge::create(array(
"amount" => $amount, # amount in cents, again
"currency" => 'usd',
"customer" => $customer->id)
);
But below is the code which can be used to charge the user directly without creating any customer object.
\Stripe\Charge::create(array(
"amount" => 3000,
"currency" => "eur",
"card" => $_POST['stripeToken'],
"description" => $_POST['email'],
"metadata" => array("order_id" => "6735", "userid" => '1111')
));
So can you please explain me below things
Thanks in advance
You can charge your customers at any time and for any amount once you have saved the customer's card in Stripe. If you have certain action-based criteria which you want to trigger a charge, you can set that logic up on your back end and directing it to charge the card associated with the customer ID.
If a payment fails for a subscription invoice, your customers can use the Stripe-hosted page to: View the details and amounts for the failed invoice and the associated subscription. Add a new card payment method for their subscription for the payment that's due and for future subscription payments.
The PaymentIntent encapsulates details about the transaction, such as the supported payment methods, the amount to collect, and the desired currency.
There are several benefits to creating the customer object first:
You can charge multiple items to the same user, thus providing both you and the customer a billing history. This is valuable to you as a store owner (e.g. offering deals to repeat customers) and valuable to the customer to quickly pull up their purchase history.
Fraud prevention
Trends and analytics
As you've already stated, subscriptions
A footnote: I personally maintain my own user-base and update both the Stripe customer object and my user data when a transaction occurs. This allows me to extend the Stripe customer with my own custom data and run complex analytics to discover trends.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With