* You are free to use, distribute, and modify this software * ============================================================================== * */ //error_reporting(0); // Stripe library require 'stripe/Stripe.php'; $params = array( "testmode" => "on", "private_live_key" => "sk_live_6Y2Rr4wlyJOrMRXmEZ3jRzyG", "public_live_key" => "pk_live_5Zr4DtVUfh0CGXZ2ajOBVax0", "private_test_key" => "sk_test_1RdmpoZDkCFUogt23YoOHWnd", "public_test_key" => "pk_test_kBASW4YbJKHXzwccAIrtWyhd" ); if ($params['testmode'] == "on") { Stripe::setApiKey($params['private_test_key']); $pubkey = $params['public_test_key']; } else { Stripe::setApiKey($params['private_live_key']); $pubkey = $params['public_live_key']; } if(isset($_POST['stripeToken'])) { //$amount_cents = str_replace(".","","10.52"); // Chargeble amount $amount_cents = str_replace(".","",$_POST['invoice_amount']); // Chargeble amount $invoiceid = trim($_POST['invoice_number']); // Invoice ID $description = "Invoice #" . $invoiceid . " - Amt " . $_POST['invoice_amount']; /* $charge = Stripe_Charge::create(array( "amount" => "030", "currency" => "GBP", "source" => $_POST['stripeToken'], "description" => $description) ); echo '
'; print_r($charge);  */

	try {
		$charge = Stripe_Charge::create(array(		 
			  "amount" => $amount_cents,
			  "currency" => "GBP",
			  "source" => $_POST['stripeToken'],
			  "description" => $description)			  
		);

		if ($charge->card->address_zip_check == "fail") {
			throw new Exception("zip_check_invalid");
		} else if ($charge->card->address_line1_check == "fail") {
			throw new Exception("address_check_invalid");
		} else if ($charge->card->cvc_check == "fail") {
			throw new Exception("cvc_check_invalid");
		}
		// Payment has succeeded, no exceptions were thrown or otherwise caught				

		$result = "success";
		$mymessage = "";
	} catch(Stripe_CardError $e) {
		$error = $e->getMessage();
		$result = "declined";
		$mymessage = "Error 1".$e->getMessage();
	} catch (Stripe_InvalidRequestError $e) {
		$result = "declined";
		$mymessage = "Error 2".$e->getMessage();
	} catch (Stripe_AuthenticationError $e) {
		$result = "declined";
		$mymessage = "Error 3".$e->getMessage();
	} catch (Stripe_ApiConnectionError $e) {
		$result = "declined"; 
		$mymessage = "Error 4".$e->getMessage();
	} catch (Stripe_Error $e) {
		$result = "declined";
		$mymessage = "Error 5".$e->getMessage();
	} catch (Exception $e) {
		if ($e->getMessage() == "zip_check_invalid") {
			$result = "declined";
			$mymessage = "zip_check_invalid";
		} else if ($e->getMessage() == "address_check_invalid") {
			$result = "declined";
			$mymessage = "address_check_invalid";
		} else if ($e->getMessage() == "cvc_check_invalid") {
			$result = "declined";
			$mymessage = "cvc_check_invalid";
		} else {
			$result = "declined";
			$mymessage = "Error 6";
		}		  
	}
	$msg = '';
	if($result == 'success'){
		$to = 'tom@tsgas.co.uk';
		$subject = "Payment for invoice - ".$invoiceid;
		$headers[] = 'MIME-Version: 1.0';
		$headers[] = 'Content-type: text/html; charset=iso-8859-1';
		$headers[] = 'From: TSGas ';
		$message = "Hello Admin
A new payment has been received. Below are the details:

Invoice Number: ".$invoiceid."
Invoice Amount: £".$_POST['invoice_amount']."

Thanks."; mail($to, $subject, $message, implode("\r\n", $headers)); header("location:payment-thankyou.html"); } else { $msg = "There is some issue in your payment. Please try again or contact us."; $file = fopen("error.txt","a+"); echo fwrite($file,$mymessage); fclose($file); } } ?> RS Heating

MAKE A PAYMENT

We accept cash, cheques and all major credit & debit cards

We offer easy credit and debit card payments over the phone, call us today and one of our friendly and helpful staff will be happy to help.

Need to pay an invoice? You can do so using our online gateway in a few simple steps.

We cover a large area of approx 25 miles including Hertfordshire and North London

We provide Gas & Central Heating Services to homes and businesses across Hertfordshire and North London

  • Ware
  • Welwyn
  • Broxbourne
  • Thundridge
  • Hertfordshire
  • North London

Looking for trustworthy and reliable heating & plumbing engineers?