Integrate Stripe API using php

If you need to integrate stripe api to your php project then follow this tutorial which can create/edit/update/delete charges, customer, subscription, plan, payment,card and many more. just simply follow this step and you can get your api working.

Step 1)

NOTE*: for this api integration you need to enable below modules in your apache or live server

  • curl, although you can use your own non-cURL client if you prefer
  • json
  • mbstring (Multibyte String)

Upload this stripe demo library to your project. click here for download library

Step 2)

Now make one test.php file for create customer to stripe using api in php and include below code in that file and save the file.

$stripe = new \Stripe\StripeClient(<ENTER STRIPE KEY HERE>);
$customer = $stripe->customers->create('description' => '<CUSTOMER DESCRIPTION>','email' => "<CUSTOMER EMAIL ADDRESS>",'name' => "<CUSTOMER NAME>",
print_r($customer); //get response from stripe when customer created in stripe
    $stripe = new \Stripe\StripeClient(<ENTER STRIPE KEY HERE>);
    $option = array("object" => 'card', "number" => "<CUSTOMER CARD NUMBER>","exp_month" => "CUSTOMER CARD MONTH","exp_year" => "<CUSTOMER CARD YEAR>","cvc" => "<CUSTOMER CARD CVV>");
    $card = $stripe->customers->createSource(
        $id,['source' => $option]);
        print_r($card_id); //get response from stripe when card created in stripe for specific user

    $data = $stripe->charges->create([
               'amount' => "1.00",
               'customer' => $id,
               'currency' => 'usd',
               'description' => 'Total Subscription Charges',

print_r($data); //get response from stripe when charges created in stripe for specific user

Step 3)

Finally, run this test.php file in your system it will sent the data to your stripe. for more api visit this link

One thought on “Integrate Stripe API using php

  1. Ada Markwood

    I actually wanted to write down a small comment to express gratitude to you for those lovely hints you are showing at this site. My rather long internet research has now been rewarded with good insight to talk about with my best friends. I would assert that we site visitors actually are truly blessed to be in a remarkable website with so many marvellous people with very helpful points. I feel truly privileged to have come across your entire web page and look forward to really more exciting minutes reading here. Thanks once again for all the details.


Leave a Reply

Your email address will not be published. Required fields are marked *