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.

Leave a Comment