Tagged: laravel stripe php

Stripe API Master – Download Stripe API using PHP 0

Stripe API Master - Download Stripe API using PHP

Stripe API Master – Download Stripe API using PHP

In this Post We Will Explain About is Stripe API Master – Download Stripe API using PHP With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Stripe API Master – Download Stripe API using PHPExample

In this post we will show you Best way to implement Stripe API Master – Download Stripe API using PHP, hear for Stripe API Master – Download Stripe API using PHPwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

In this Post to Learn, Balance,The balance object,The balance transaction object,Retrieve balance,Retrieve a balance transaction,List all balance history,Charges,The charge object,Create a charge,Retrieve a charge,Update a charge,Capture a charge,List all charges,Customers,The customer object,Create a customer,Retrieve a customer,Update a customer,Delete a customer,List all customers,Disputes,The dispute object,The dispute evidence object,Retrieve a dispute,Update a dispute,Close a dispute,List all disputes,Events,The event object,Retrieve an event,List all events,Types of events,File Uploads,The file upload object.

Config.php

Create.php

require_once('config.php');
$required = array('email','country','currency','ssn_last_4','personal_id_number','account_holder_name','account_holder_type','routing_number','account_number');

	// Devloped By : Pakainfo.com - Loop over field names, make sure each one exists and is not empty
	$error = false;
	foreach($required as $field) {
	  if (empty($_POST[$field])) {
		$error = true;
	  }
	}

	if ($error) {
	  echo "Some fields are required.";
	  
	} 
	else 
	{
		
				$account =\Stripe\Token::create(array(
				"bank_account" => array(
				"country" => $_POST['country'],
				"currency" => $_POST['currency'],
				"account_holder_name" => $_POST['account_holder_name'],
				"account_holder_type" => $_POST['account_holder_type'],
				"routing_number" => $_POST['routing_number'],
				"account_number" => $_POST['account_number']
			  )
			)); 
			$get_customer_information = $account->__toJSON();
			$obj = json_decode($get_customer_information, TRUE);

						if($get_customer_information)
						{
							$optional = array('business_name','line1','line2','city','postal_code','country','state','email','business_tax_id','first_name','last_name','personal_id_number','ssn_last_4','type','dob');
							$data=array();
							foreach($optional as $field) {
								if(array_key_exists($field,$_POST))
								{
									$data[$field]=$_POST[$field];
								}
								else
								{
									$data[$field]="";
								}
							}
							if($data['dob']!="")
							{
								$thedate = explode("/", $data['dob']);
							}
							else
							{
								
								 $date=date_create("00-00-1971");
								$thedate = explode("/",date_format($date,'d/m/Y'));
							}
							//print_r($data);
							//die();
							$account_data = \Stripe\Account::create(
								array(
									"country" => $data['country'],
									"email" => $data['email'],
									"managed" => true,
									"legal_entity" => array(
										'address' => array(
											'city' => $data['city'],
											'country' => $data['country'],
											"line1" => $data['line1'],
											"line2" => $data['line2'],
											"postal_code" =>$data['postal_code'],
											"state" => $data['state']
										),
										'business_name' => $data['business_name'],
										'business_tax_id' => $data['business_tax_id'],
										'dob' => array(
											'day' => $thedate[0],
											'month' => $thedate[1],
											'year' => $thedate[2]
											),
									'first_name' => $data['first_name'],
									'last_name' => $data['last_name'],
									'personal_id_number' => $data['personal_id_number'],
									'ssn_last_4' => $data['ssn_last_4'],
									'type' => $data['type']
									),
									'tos_acceptance' => array(
										'date' => time(),
										'ip' => $_SERVER['REMOTE_ADDR']
									),
									
									'external_account' =>$obj['id']
								));
								
								$customer_json_data = $account_data->__toJSON();
								$obj_data = json_decode($customer_json_data, TRUE);
								print_r($customer_json_data);
						}


	}
	if($customer_json_data)
	{
		$stripe_type="RESPONSE for create account";
		$accid=$obj_data['id'];
		$object=$obj_data['object'];
		$country=$obj_data['country'];
		$currency=$obj_data['default_currency'];
		$email=$obj_data['email'];
		$s_json=$customer_json_data;

		$sql_add_supplay=mysql_query("INSERT INTO `strip_master` (`s_id`, `stripe_type`, `accid`, `object`, `country`, `currency`, `email`,`s_json`, `s_date`)
		VALUES(NULL,'$stripe_type', '$accid', '$object', '$country', '$currency', '$email','$s_json',Now())");
	}

In this Post to Learn, Create a file upload,Retrieve a file upload,List all file uploads,Payouts,The payout object,Create a payout,Retrieve a payout,Update a payout,List all payouts,Cancel a payout,Types of payout failures,Refunds,The refund object,Create a refund,Retrieve a refund,Update a refund,List all refunds,Tokens,The token object,Bank Accounts,The bank account object,Create a bank account,Retrieve a bank account,Update a bank account,Verify a bank account,Delete a bank account,List all bank accounts,Cards,The card object,Create a card,Retrieve a card,Update a card,Delete a card,List all cards,Sources

charge.php

require_once('config.php');
$required = array('currency','amount','application_fee','number','exp_month','exp_year','cvc');
// Devloped By : Pakainfo.com - Loop over field names, make sure each one exists and is not empty
$error = false;
foreach($required as $field) {
  if (empty($_POST[$field])) {
	$error = true;
  }
}
if ($error) {
  echo "Some fields are required.";
  
}
else
{
	
	$optional = array('receipt_email','description','currency','amount','application_fee','number','exp_month','exp_year','cvc');
	$data=array();
	foreach($optional as $field) 
	{
		if(array_key_exists($field,$_POST))
		{
			$data[$field]=$_POST[$field];
		}
		else
		{
			$data[$field]="";
		}
	}


 $account = \Stripe\Token::create(array(
				  "card" => array(
					"number" => $data['number'],
					"exp_month" => $data['exp_month'],
					"exp_year" => $data['exp_year'],
					"cvc" => $data['cvc']
				  )
				));
	$get_customer_information = $account->__toJSON();
	$obj = json_decode($get_customer_information, TRUE);
	if($obj)
	{
	
		$account_data =\Stripe\Charge::create(array(
		  "amount" => $data['amount'],
		  "currency" => $data['currency'],
		  "source" => $obj['id'], 
		  "description" =>$data['description'],
		  "receipt_email" =>$data['receipt_email']
		  
		  
		 // "application_fee"=>123
		));
		$customer_json_data = $account_data->__toJSON();
		$obj_redata = json_decode($customer_json_data, TRUE);
		print_r($obj_redata);

				if($customer_json_data)
				{
					$c_type="RESPONSE for charge data";
					$chargeid=$obj_redata['id'];
					$object=$obj_redata['object'];
					$amount=$obj_redata['amount'];
					$balance_transaction=$obj_redata['balance_transaction'];
					$amount_refunded=$obj_redata['amount_refunded'];
					$currency=$obj_redata['currency'];
					$application_fee=$obj_redata['application_fee'];
					$description=$obj_redata['description'];
					$status=$obj_redata['status'];
					$s_json=$customer_json_data;

					$sql_add_refund=mysql_query("INSERT INTO `charge_mst` (`cid`,`chargeid`,`type`,`object`,`amount`,`balance_transaction`,`amount_refunded`,`currency`,`application_fee`,`description`,`json`,`status`,`c_date`)
					VALUES(NULL,'$chargeid', '$c_type','$object','$amount','$balance_transaction', '$amount_refunded','$currency','$application_fee','$description','$s_json','$status',Now())");
				}
			
		}
	}

In this Post to Learn, Update a card,Delete a card,List all cards,Recipients,The recipient object,Create a recipient,Retrieve a recipient,Update a recipient,Delete a recipient,List all recipients,Transfers,The transfer object,Create a transfer,Retrieve a transfer,Update a transfer,List all transfers,Transfer Reversals,The transfer reversal object,Create a transfer reversal,Retrieve a reversal,Update a reversal,List all reversals.

createorder.php

require_once('config.php');
$required = array('currency');

// Devloped By : Pakainfo.com - Loop over field names, make sure each one exists and is not empty
$error = false;
foreach($required as $field) {
  if (empty($_POST[$field])) {
	$error = true;
  }
}

if ($error) {
  echo "Some fields are required.";
  
}
else
{
	
	$optional = array('line1','name','type','parent','currency','city','postal_code','country','state','email');
						$data=array();
						foreach($optional as $field) {
							if(array_key_exists($field,$_POST))
							{
								$data[$field]=$_POST[$field];
							}
							else
							{
								$data[$field]="";
							}
						}
						
	$account =\Stripe\Order::create(array(
	  "items" => array(
		array(
		  "type" => "sku",
		  "parent" => $data['parent']
		)
	  ),
	  "currency" => $data['currency'],
	  "shipping" => array(
		"name" => $data['name'],
		"address" => array(
		  "line1" => $data['line1'],
		  "city" => $data['city'],
		  "country" => $data['country'],
		  "postal_code" => $data['postal_code']
		)
	  ),
	  "email" => $data['email']
	));
	$get_customer_information = $account->__toJSON();
			$obj = json_decode($get_customer_information, TRUE);
			print_r($get_customer_information);
			
		if($get_customer_information)
		{
			$stripe_type="RESPONSE for create New Order";
			$oid=$obj['id'];
			$object=$obj['object'];
			$email=$obj['email'];
			$amount=$obj['amount'];
			$currency=$obj['currency'];
			$smethod=$obj['selected_shipping_method'];
			$s_json=$get_customer_information;
			$sql_add_supplay=mysql_query("INSERT INTO `order_mst` (`oid`, `order_id`, `type`, `object`,`email`, `amount`,`currency`,`shipping_method`,`json`, `cr_date`) 
			VALUES(NULL,'$oid', '$stripe_type','$object','$email', '$amount','$currency','$smethod','$s_json',Now())");
		}
}	

createproduct.php

require_once('config.php');
$account =\Stripe\Product::create(array(
	  "name" => $_POST['name'],
	  "description" => $_POST['description'],
	  "attributes" => ["size", "gender"]
	));

	$get_customer_information = $account->__toJSON();
	$obj = json_decode($get_customer_information, TRUE);
	print_r($get_customer_information);
	if($get_customer_information)
	{
		$stripe_type="RESPONSE for create New Product";
		$proid=$obj['id'];
		$object=$obj['object'];
		$active=$obj['active'];
		$name=$obj['name'];
		$description=$obj['description'];
		$s_json=$get_customer_information;

		$sql_add_supplay=mysql_query("INSERT INTO `product_mst` (`pid`, `prod_id`, `type`, `object`, `active`, `prod_name`, `prod_desc`,`json`, `cr_date`) VALUES(NULL,'$proid', '$stripe_type','$object','$active','$name', '$description','$s_json',Now())");
	}

In this Post to Learn, The source object,Coupons,The coupon object,Create a coupon,Retrieve a coupon,Update a coupon,Delete a coupon,List all coupons,Discounts,The discount object,Delete a customer discount,Delete a subscription discount,Invoices,The invoice object,The (invoice) line item object,Create an invoice,Retrieve an invoice,Retrieve an invoice’s line items,Retrieve an upcoming invoice,Update an invoice,Pay an invoice,List all invoices,Invoice Items,The invoiceitem object,Create an invoice item,Retrieve an invoice item,Update an invoice item,Delete an invoice item,List all invoice items,Plans.

createsku.php

require_once('config.php');

$account =\Stripe\SKU::create(array(
  "product" => $_POST['productid'],
  "attributes" => array(
	"size" => "Medium",
	"gender" => "Unisex"
  ),
  "price" => $_POST['price'],
  "currency" => $_POST['currency'],
  "inventory" => array(
	"type" => "finite",
	"quantity" => $_POST['quantity']
  )
));    
$get_customer_information = $account->__toJSON();
		$obj = json_decode($get_customer_information, TRUE);
		print_r($get_customer_information);
	if($get_customer_information)
	{
		$stripe_type="RESPONSE for create New SKU";
		$proid=$obj['product'];
		$object=$obj['object'];
		$active=$obj['active'];
		$price=$obj['price'];
		$sku=$obj['id'];
		$s_json=$get_customer_information;

		$sql_add_supplay=mysql_query("INSERT INTO `product_mst` (`pid`, `prod_id`,`sku`, `type`, `object`, `active`,`price`,`json`, `cr_date`) VALUES(NULL,'$proid','$sku','$stripe_type','$object','$active','$price','$s_json',Now())");
	}

delete.php

require_once('config.php');

$account = \Stripe\Account::retrieve($_POST['account_id']);
$account->delete();

$get_customer_information = $account->__toJSON();
$obj = json_decode($get_customer_information, TRUE);

print_r($get_customer_information);

if($get_customer_information)
{
	$stripe_type="RESPONSE - for delete account";
	$accid=$obj['id'];
	$object=$obj['deleted'];
	if($object=="true")
	{
		$object_data="Account - deleted";
	}
	$s_json=$get_customer_information;
	$s_date= date('d-m-Y H:i:s');
	$sql_add_supplay=mysql_query("INSERT INTO `strip_master` (`s_id`, `stripe_type`, `accid`, `object`, `s_json`, `s_date`)
	VALUES(NULL,'$stripe_type', '$accid', '$object_data','$s_json',Now())");
} 

In this Post to Learn, The plan object,Create a plan,Retrieve a plan,Update a plan,Delete a plan,List all plans,Subscriptions,The subscription object,Create a subscription,Retrieve a subscription,Update a subscription,Cancel a subscription,List subscriptions,Subscription Items,The subscription item object,Create a subscription item,Retrieve a subscription item,Update a subscription item,Delete a subscription item,List all subscription items,Account,The account object,Create an account,Retrieve account details,Update an account,Delete an account,Reject an account,List all connected accounts,The login link object

refund.php

require_once('config.php');

$required = array('charge');

	// Devloped By : Pakainfo.com - Loop over field names, make sure each one exists and is not empty
	$error = false;
	foreach($required as $field) {
	  if (empty($_POST[$field])) {
		$error = true;
	  }
	}

	if ($error) {
	  echo "Some fields are required.";
	  
	}
	else
	{
		
		$optional = array('charge','amount','receipt_number','reason');
							$data=array();
							foreach($optional as $field) {
								if(array_key_exists($field,$_POST))
								{
									$data[$field]=$_POST[$field];
								}
								else
								{
									$data[$field]="";
								}
							}
						
		$re_data = \Stripe\Refund::create(array(
		  "charge" => $data['charge']
		  //"amount" => $data['amount']
		));

$customer_refund = $re_data->__toJSON();
$obj_redata = json_decode($customer_refund, TRUE);
print_r($obj_redata);

			if($customer_refund)
			{
				$r_type="RESPONSE for Refund data";
				$refundid=$obj_redata['id'];
				$object=$obj_redata['object'];
				$amount=$obj_redata['amount'];
				$balance_transaction=$obj_redata['balance_transaction'];
				$charge=$obj_redata['charge'];
				$currency=$obj_redata['currency'];
				$reason=$obj_redata['reason'];
				$receipt_number=$obj_redata['receipt_number'];
				$status=$obj_redata['status'];
				$s_json=$customer_refund;

				$sql_add_refund=mysql_query("INSERT INTO `refund_mst` (`rid`,`refundid`,`type`,`object`,`amount`,`balance_transaction`,`charge`,`currency`,`reason`,`receipt_number`,`json`,`status`,`r_date`)
				VALUES(NULL,'$refundid', '$r_type','$object','$amount','$balance_transaction', '$charge','$currency','$reason','$receipt_number','$s_json','$status',Now())");
			}
	}	

update.php

require_once('config.php');

 $required = array('account_id');

			// Devloped By : Pakainfo.com - Loop over field names, make sure each one exists and is not empty
			$error = false;
			foreach($required as $field) {
			  if (empty($_POST[$field])) {
				$error = true;
			  }
			}

			if ($error) {
			  echo "Account id fields are required.";
			  
			}
		
	foreach($_POST as $key=>$value)
	{
		if($key!='account_id')
		{
				$account = \Stripe\Account::retrieve($_POST['account_id']);
				$account->$key = $value;
				$account->save();	
		}
	
	}
	
$get_customer_information = $account->__toJSON();
$obj = json_decode($get_customer_information, TRUE);
print_r($get_customer_information);
if($get_customer_information)
{
	$stripe_type="RESPONSE for Update account";
	$accid=$obj['id'];
	$object=$obj['object'];
	$country=$obj['country'];
	$currency=$obj['default_currency'];
	$email=$obj['email'];
	$s_json=$get_customer_information;
	$sql_update=mysql_query("update `strip_master` SET `stripe_type`='$stripe_type', `object`='$object', `country`='$country', `currency`='$currency', `email`='$email',`s_json`='$s_json', `s_date`=Now() where `accid`='$accid'");

}

In this Post to Learn,Create a login link,Application Fee Refunds,The application fee refund object,Create an application fee refund,Retrieve an application fee refund,Update an application fee refund,List all application fee refunds,Application Fees,The application fee object,Retrieve an application fee,List all application fees,Country Specs,The country spec object,List Country Specs,Retrieve a Country Spec,External Accounts,The (account) bank account object,Create a bank account,Retrieve a bank account,Update a bank account,Delete a bank account,List all bank accounts,The (account) card object,Create a card,Retrieve a card.

Example

I hope you have Got What is Stripe API Master – Download Stripe API using PHP And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Laravel 5.7 Stripe Payment Gateway Example From Scratch 0

Laravel 5.7 Stripe Payment Gateway Example From Scratch

Today, We want to share with you Laravel 5.7 Stripe Payment Gateway Example From Scratch.In this post we will show you Stripe Payment Gateway Integration using Laravel 5.7, hear for Laravel 5.7 – Stripe Payment Gateway Integration Example we will give you demo and example for implement.In this post, we will learn about Laravel Stripe Payment Gateway Integration Tutorial with an example.

Laravel 5.7 Stripe Payment Gateway Example From Scratch

There are the Following The simple About Laravel 5.7 Stripe Payment Gateway Example From Scratch Full Information With Example and source code.

As I will cover this Post with live Working example to develop How to integrate Stripe payment gateway in laravel 5.7, so the Integrate Laravel Stripe Gateway for Online Payments for this example is following below.

Phase 1: Install Laravel 5.7

composer create-project --prefer-dist laravel/laravel atmiya25

Phase 2: Install stripe-php Package

install stripe-php via the Composer package manager

composer require stripe/stripe-php

Phase 3: Set Stripe API Key and SECRET

.env files

STRIPE_KEY=pk_test_reFxwb98Js58diDf25TfxAR
STRIPE_SECRET=sk_test_oJSkdui85dJiPd4wDJsui5pY

Phase 4: Define a Laravel Routes

routes/api.php

name('stripe.post');

Phase 5: Create Controller File

app/Http/Controllers/CkPaymentStripeController.php

 100 * 100,
                "currency" => "usd",
                "source" => $request->liveTokenStripe,
                "description" => "Test payment from pakainfo.com." 
        ]);
  
        Session::flash('success', 'Your Payment successful!');
          
        return back();
    }
}

Phase 6: Make a Laravel Blade File

resources/views/stripe.blade.php



	<title>Laravel 5.7 Stripe Payment Gateway Example From Scratch - pakainfo.com</title>
	
    
    
        .panel-title {
        display: inline;
        font-weight: bold;
        }
        .display-table {
            display: table;
        }
        .display-tr {
            display: table-row;
        }
        .display-td {
            display: table-cell;
            vertical-align: middle;
            width: 61%;
        }
    


  
<div class="container">
  
    <h1>Laravel 5 - Stripe Payment Gateway Integration Example <br /> pakainfo.com</h1>
  <b>Laravel 5.7 Stripe Payment Gateway Example From Scratch</b>
    <div class="pakainfo row">
        <div class="col-md-6 col-md-offset-3">
            <div class="pakainfo panel panel-default credit-card-box">
                <div class="pakainfo panel-heading display-table">
                    <div class="row display-tr pakainfo">
                        <h3 class="panel-title display-td">Your Payment Details</h3>
                        <div class="display-td">                            
                            <img class="pakainfo img-responsive pull-right" src="http://i76.imgup.net/accepted_c22e0.png">
                        </div>
                    </div>                    
                </div>
                <div class="panel-body">
  
                    @if (Session::has('success'))
                        <div class="alert alert-success text-center">
                            <a href="#" class="pakainfo close">×</a>
                            <p>{{ Session::get('success') }}</p>
                        </div>
                    @endif
  
                    <form role="form" action="{{ route('stripe.post') }}" method="post" class="pakainfo require-validation" id="payment-form">
                        @csrf
  
                        <div class='pakainfo form-row pakainfo row'>
                            <div class='gst col-xs-12 live form-group required'>
                                <label class='control-label'>Name on Card</label> 
                            </div>
                        </div>
  
                        <div class='form-row pakainfo row'>
                            <div class='gst col-xs-12 live form-group card required'>
                                <label class='control-label'>Card Number</label> 
                            </div>
                        </div>
  
                        <div class='form-row pakainfo row'>
                            <div class='gst col-xs-12 live col-md-4 form-group cvc required'>
                                <label class='control-label'>CVC</label> 
                            </div>
                            <div class='gst col-xs-12 live col-md-4 form-group expiration required'>
                                <label class='control-label'>Expiration Month</label> 
                            </div>
                            <div class='gst col-xs-12 live col-md-4 form-group expiration required'>
                                <label class='control-label'>Expiration Year</label> 
                            </div>
                        </div>
  
                        <div class='form-row pakainfo row'>
                            <div class='col-md-12 error form-group hide'>
                                <div class='alert-danger alert'>Please Your correct the errors and try
                                    again.</div>
                            </div>
                        </div>
  
                        <div class="gst row">
                            <div class="gst col-xs-12 live">
                                <button class="btn btn-success btn-lg btn-block" type="submit">Pay Now ($100)</button>
                            </div>
                        </div>
                          
                    </form>
                </div>
            </div>        
        </div>
    </div>
      
</div>
  

  

  

$(function() {
    var $liveFrm         = $(".require-validation");
  $('form.require-validation').bind('submit', function(e) {
    var $liveFrm         = $(".require-validation"),
        inputSelector = ['input[type=email]', 'input[type=password]',
                         'input[type=text]', 'input[type=file]',
                         'textarea'].join(', '),
        $inputs       = $liveFrm.find('.required').find(inputSelector),
        $errorMessage = $liveFrm.find('div.error'),
        valid         = true;
        $errorMessage.addClass('hide');
 
        $('.has-error').removeClass('has-error');
    $inputs.each(function(i, el) {
      var $input = $(el);
      if ($input.val() === '') {
        $input.parent().addClass('has-error');
        $errorMessage.removeClass('hide');
        e.preventDefault();
      }
    });
  
    if (!$liveFrm.data('cc-on-file')) {
      e.preventDefault();
      Stripe.setPublishableKey($liveFrm.data('stripe-publishable-key'));
      Stripe.createToken({
        number: $('.card-number').val(),
        cvc: $('.card-cvc').val(),
        exp_month: $('.card-expiry-month').val(),
        exp_year: $('.card-expiry-year').val()
      }, stripeResponseHandler);
    }
  
  });
  
  function stripeResponseHandler(status, response) {
        if (response.error) {
            $('.error')
                .removeClass('hide')
                .find('.alert')
                .text(response.error.message);
        } else {
            var token = response['id'];
            $liveFrm.find('input[type=text]').empty();
            $liveFrm.append("");
            $liveFrm.get(0).submit();
        }
    }
  
});


Now We can check or testing purpose with following card Info:

//Testing Details
Your Name: Jaydeep Gondaliya
Number: 4242 4242 4242 4242
CSV: 715
Expiration Month: 12
Expiration Year: 2029

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel 5.7 Stripe Payment Gateway Example From Scratch.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.