Last active
August 29, 2015 14:19
-
-
Save rajasajidmanzoor/59f7a0502fab3913ef0f to your computer and use it in GitHub Desktop.
Stripe Issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$error; | |
include 'dbconfig.php'; | |
include('vendors/stripe/init.php'); | |
require_once('vendors/stripe/config.php'); | |
session_start(); | |
$stripeClassesDir = __DIR__ . '/vendors/stripe/lib/'; | |
// echo $stripeClassesDir; | |
$stripeUtilDir = $stripeClassesDir . 'Util/'; | |
$stripeErrorDir = $stripeClassesDir . 'Error/'; | |
set_include_path($stripeClassesDir . PATH_SEPARATOR . $stripeUtilDir . PATH_SEPARATOR . $stripeErrorDir); | |
function __autoload($class) | |
{ | |
$parts = explode('\\', $class); | |
require end($parts) . '.php'; | |
} | |
?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Armorax</title> | |
<link rel="stylesheet" href="css/normalize.css"> | |
<link rel="stylesheet" href="css/main.css"> | |
<script src="http://code.jquery.com/jquery-2.0.2.min.js"></script> | |
<script src="https://js.stripe.com/v2/"></script> | |
<script> | |
(function() { | |
Stripe.setPublishableKey('<?php echo $stripe['publishable_key'] ?>'); | |
})(); | |
</script> | |
</head> | |
<body> | |
<?php | |
if(isset($_POST['stripeToken'])) | |
{ | |
do_charge(); | |
} | |
function do_charge(){ | |
$token = $_POST['stripeToken']; | |
$email = $_POST['email']; | |
$amount = $_POST['amount']; | |
$amount = round($amount*100); | |
// $amount = 69; | |
try { | |
$customer = \Stripe\Customer::create(array( | |
"description"=>"Customer", | |
"source" => $token, | |
"email" => $email, | |
"plan" => "armorax" | |
) | |
); | |
$payment = \Stripe\Charge::create(array( | |
'amount' => $amount, | |
'currency' => 'usd', | |
//'source' => $_POST['stripeToken'], | |
'description' => $_POST['description'], | |
"customer" => $customer->id | |
) | |
); | |
} catch(\Stripe\Error\Card $e) { | |
$body = $e->getJsonBody(); | |
$err = $body['error']; | |
$error= 'Status is:' . $e->getHttpStatus() . "\n"; | |
$error.='Type is:' . $err['type'] . "\n"; | |
$error.='Code is:' . $err['code'] . "\n"; | |
// param is '' in this case | |
$error.='Param is:' . $err['param'] . "\n"; | |
$error.='Message is:' . $err['message'] . "\n"; | |
} catch (\Stripe\Error\InvalidRequest $e) { | |
// Invalid parameters were supplied to Stripe's API | |
} catch (\Stripe\Error\Authentication $e) { | |
// Authentication with Stripe's API failed | |
// (maybe you changed API keys recently) | |
} catch (\Stripe\Error\ApiConnection $e) { | |
// Network communication with Stripe failed | |
} catch (\Stripe\Error\Base $e) { | |
// Display a very generic error to the user, and maybe send | |
// yourself an email | |
} catch (Exception $e) { | |
// Something else happened, completely unrelated to Stripe | |
} | |
} | |
?> | |
<div id="wrapper"> | |
<form method="POST" id="payment-form"> | |
<div id="content-wrapper"> | |
<!-- Navigation Bar Begin --> | |
<nav id="no-border"> | |
<div class="content"> | |
<a href="index.html"><img src="img/armorax-logo.svg"></a> | |
<div class="nav-icons-holder"> | |
<p>Step 3 of 3</p><span class="vert-divider"></span> | |
<ul class="nav-icons"> | |
<li><img src="img/step-1-cart.svg"></li> | |
<li><img src="img/step-2-notes.svg"></li> | |
<li><img src="img/step-3-card-active.svg"></li> | |
</ul> | |
</div> | |
</div> | |
</nav> | |
<!-- Navigation Bar End --> | |
<!-- Tilte Begin --> | |
<div class="titleBlock"> | |
<h1>Payment</h1> | |
</div> | |
<!-- Title End --> | |
<!-- Second Section Columns Begin --> | |
<div class="content"> | |
<?php //if(isset($error)) | |
?> | |
<div class="alert"> <?php //echo "oh no I don't have a PHP error"; | |
echo $error; ?> </div> | |
<?php ?> | |
<div class="collumn1-small" id="fields"> | |
<div id="contacts-block"> | |
<div class="title-icon" id="contact"> | |
<h3>Contact</h3> | |
</div> | |
<!-- <a class="edit-link" href="#">Edit</a>--> | |
<div class="text-from-inputs"> | |
<ul> | |
<li><?php echo $row[0]['firstName'] ?> <?php echo $row[0]['LastName'] ?></li> | |
<li><?php echo $row[0]['email'] ?></li> | |
<input type="hidden" name="email" value="<?php echo $row[0]['email'] ?>" /> | |
</ul> | |
</div> | |
</div> | |
<div class="divider"></div> | |
<div id="installation-block"> | |
<div class="title-icon" id="installation"> | |
<h3>Installation</h3> | |
</div> | |
<!-- <a class="edit-link" href="#">Edit</a>--> | |
<div class="text-from-inputs"> | |
<ul> | |
<li><?php echo $row[0]['firstName'] ?> <?php echo $row[0]['LastName'] ?></li> | |
<li><?php echo $row[0]['address1'] ?></li> | |
<?php if(!empty($row[0]['address2'])) { ?><?php echo $row[0]['address2'] ?> <?php } ?> | |
<li><?php echo $row[0]['city'] ?> <?php echo $row[0]['state']; ?> <?php echo $row[0]['zip'] ?></li> | |
<li>United States</li> | |
</ul> | |
</div> | |
</div> | |
<div class="divider"></div> | |
<div id="payment-block"> | |
<div class="title-icon" id="payment"> | |
<h3>Payment</h3> | |
</div> | |
<div class="cl-inputs"> | |
<input type="text" name="cardHolderName" placeholder="Card Holder Name"><br> | |
<input type="text" data-stripe="number" placeholder="Card Number" size="20" autocomplete="off" class="card-number input-medium"><br> | |
<div class="styled-select" id="expiryMonth" > | |
<select data-stripe="exp-month" form="expiryMonth" class="card-expiry-month"> | |
<option value='' disabled selected style='display:none;'>MM</option> | |
<option value="01">01</option> | |
<option value="02">02</option> | |
<option value="03">03</option> | |
<option value="04">04</option> | |
<option value="05">05</option> | |
<option value="06">06</option> | |
<option value="07">07</option> | |
<option value="08">08</option> | |
<option value="09">09</option> | |
<option value="10">10</option> | |
<option value="11">11</option> | |
<option value="12">12</option> | |
</select> | |
<input type="hidden" name="expMonth" id="expMonth"> | |
</div> | |
<div class="styled-select"> | |
<select data-stripe="exp-year" form="expiryYear" class="card-expiry-year"> | |
<option value='' disabled selected style='display:none;'>YY</option> | |
<option value="2015">15</option> | |
<option value="2016">16</option> | |
<option value="2017">17</option> | |
<option value="2018">18</option> | |
<option value="2019">19</option> | |
<option value="2020">20</option> | |
</select><br> | |
<input type="hidden" name="expYear" id="expYear"> | |
</div> | |
<input type="text" id="CVC" data-stripe="cvc" size="4" autocomplete="off" class="card-cvc input-mini" placeholder="Security Code"><br> | |
<div class="payment-errors alert alert-warning" style="display:none;"></div> | |
</div> | |
</div> | |
</div> | |
<div class="collumn2-small" id="summary"> | |
<div class="title-icon" id="order"> | |
<h3>Order Summary</h3> | |
</div> | |
<p class="order-summary-list"> | |
<?php for($i=0; $i<$result->num_rows; $i++){ ?> | |
<span class="title"><?php echo $row[$i]['Description']; ?></span><span class="data">USD <?php echo $row[$i]['Fees']; ?></span><br> | |
<!-- <span class="title">Pro Monitoring</span><span class="data">USD 89.00/mo</span><br>--> | |
<?php } ?> | |
<span class="color"><span class="title">Today you pay</span><span class="data">USD <?php echo $row[0]['total_amount'] ?></span></span> | |
<input type="hidden" name="amount" value="<?php echo $row[0]['total_amount'] ?>"/> | |
<input type="hidden" name="description" value="Total"/> | |
</p> | |
<div class="clear"></div> | |
<div class="divider"></div> | |
<div class="title-icon" id="agreement"> | |
<h3>Your Agreement</h3> | |
</div> | |
<textarea disabled rows="4" cols="57" name="name" placeholder='This web page represents a legal document that serves as our Terms of Use and it governs the legal terms of our website, http://www.armorax.com, sub-domains, and any associated web-based and mobile applications (collectively, "Website"), as owned and operated by Armorax. | |
Capitalized terms, unless otherwise defined, have the meaning specified within the Definitions section below. This Terms of Use, along with our Privacy Policy, any mobile license agreement, and other posted guidelines within our Website, collectively "Legal Terms", constitute the entire and only agreement between you and Armorax, and supersede all other agreements, representations, warranties and | |
understandings with respect to our Website and the subject matter contained herein. We may amend our Legal Terms at any time without specific notice to you. The latest copies of our Legal Terms will be posted on our Website, and you should review all Legal Terms prior to using our Website. After any revisions to our Legal Terms are posted, you agree to be bound to any such changes to them. Therefore, it is important for you to periodically review our Legal Terms to make sure you still agree to them. | |
By accessing this web site, you are agreeing to be bound by these web site Terms and Conditions of Use, all applicable laws and regulations, and agree that you are responsible for compliance with any applicable local laws. If you do not agree with any of these terms, you are prohibited from using or accessing this site. The materials contained in this web site are protected by applicable copyright and trademark law. | |
The last update to our Terms of Use was posted on 2 February 2015. | |
Definitions | |
The terms "us" or "we" or "our" refers to Armorax, the owner of the Website. | |
A "Visitor" is someone who merely browses our Website, but has not registered as Member. | |
A "Member" is an individual that has registered with us to use our Service. | |
Our "Service" represents the collective functionality and features as offered through our Website to our Members. | |
A "User" is a collective identifier that refers to either a Visitor or a Member. | |
All text, information, graphics, audio, video, and data offered through our Website are collectively known as our "Content". | |
Use License | |
Permission is granted to temporarily download one copy of the materials (information or software) on Armorax’s web site for personal, non-commercial transitory viewing only. This is the grant of a license, not a transfer of title, and under this license you may not: | |
• modify or copy the materials; | |
• use the materials for any commercial purpose, or for any public display (commercial or non-commercial); | |
• attempt to decompile or reverse engineer any software contained on Armorax’s web site; | |
• remove any copyright or other proprietary notations from the materials; | |
or | |
• transfer the materials to another person or “mirror” the materials on any vother server. | |
This license shall automatically terminate if you violate any of these restrictions and may be terminated by Armorax at any time. Upon terminating your viewing of these materials or upon the termination of this license, you must destroy any downloaded materials in your possession whether in electronic or printed format.' id="agreement-box"></textarea><br> | |
<p class="agreement-text-name">By typing name in the space below you specifically indicate your acceptance of and consent to all provisions of the monitoring agreement. Please enter your name exactly as you typed it in your billing address.</p> | |
<input type="text" name="confirmName" placeholder="" id="confirm-name"> | |
<div class="divider"></div> | |
<input type="submit" name="submit2" value="Place Order" class="lineButton" id="agreement-place-order"> | |
<img class="secure-logo" src="img/geotrust-logo.png"> | |
<p class="button-text-desk">Any last questions? <a>Let’s have a quick chat!</a></p> | |
</div> | |
</div> | |
<div class="clear"></div> | |
<!-- <input type="hidden" name="stripeToken" class="stripeToken" />--> | |
<!-- Second Section Columns End--> | |
</div><!--Wrapper closed--> | |
</form> | |
<!-- Footer Begin--> | |
<div class="section" id="footer-small"> | |
<div class="content"> | |
<div class="footer-small"> | |
<img src="img/armorax-logo-small-footer.svg"> | |
<p>© 2015 Armorax - Control Your Safety</p> | |
<ul> | |
<li><a href="#">Privacy Policy</a></li> | |
<li><a href="#">Terms of service</a></li> | |
</ul> | |
</div> | |
</div> | |
</div> | |
<!-- Footer End--> | |
</div> | |
<!-- <script type="text/javascript" src="css/process.js"></script>--> | |
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script> | |
<script> | |
$(document).ready(function() { | |
// Event Listeners | |
//$('#agreement-place-order').on('click', generateToken); | |
$('#agreement-place-order').click( function(ev){ | |
Stripe.card.createToken({ | |
number: $('.card-number').val(), | |
cvc: $('.card-cvc').val(), | |
exp_month: $('.card-expiry-month').val(), | |
exp_year: $('.card-expiry-year').val() | |
}, stripeResponseHandler); | |
// | |
//ev.preventDefault(); | |
return false; | |
// | |
}); | |
function stripeResponseHandler(status, response) { | |
var $form = $('#payment-form'); | |
if (response.error) { | |
// Show the errors on the form | |
$form.find('.payment-errors').text(response.error.message); | |
$form.find('.payment-errors').show(); | |
$form.find('button').prop('disabled', false); | |
} else { | |
// response contains id and card, which contains additional card details | |
var token = response.id; | |
// Insert the token into the form so it gets submitted to the server | |
// $form.append($('<input type="hidden" name="stripeToken" />').val(token)); | |
$form.append($('<input type="hidden" name="stripeToken" />').val(token)); | |
//$(".stripeToken").val(token); | |
// | |
// and submit | |
//alert('Hello'); | |
$form.get(0).submit(); | |
} | |
} | |
$(".card-expiry-month").change(function(){ | |
$("#expMonth").val($(this).val()) | |
}); | |
$(".card-expiry-year").change(function(){ | |
$("#expYear").val($(this).val()) | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Define useful constants: | |
$stripe = array( | |
"secret_key" => "sk_test_KyqCXJcsXJaoaZwVazDzRUiQ", | |
"publishable_key" => "pk_test_UkGl1uq1UenzAd7ORa9aInhM" | |
); | |
\Stripe\Stripe::setApiKey($stripe['secret_key']); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $error1; | |
global $myError; | |
$error1="hello"; | |
include 'dbconfig.php'; | |
include('vendors/stripe/init.php'); | |
require_once('vendors/stripe/config.php'); | |
session_start(); | |
$stripeClassesDir = __DIR__ . '/vendors/stripe/lib/'; | |
// echo $stripeClassesDir; | |
$stripeUtilDir = $stripeClassesDir . 'Util/'; | |
$stripeErrorDir = $stripeClassesDir . 'Error/'; | |
set_include_path($stripeClassesDir . PATH_SEPARATOR . $stripeUtilDir . PATH_SEPARATOR . $stripeErrorDir); | |
function __autoload($class) | |
{ | |
$parts = explode('\\', $class); | |
require end($parts) . '.php'; | |
} | |
?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Armorax</title> | |
<link rel="stylesheet" href="css/normalize.css"> | |
<link rel="stylesheet" href="css/main.css"> | |
<script src="http://code.jquery.com/jquery-2.0.2.min.js"></script> | |
<script src="https://js.stripe.com/v2/"></script> | |
<script> | |
(function() { | |
Stripe.setPublishableKey('<?php echo $stripe['publishable_key'] ?>'); | |
})(); | |
</script> | |
</head> | |
<body> | |
<?php | |
if(isset($_POST['stripeToken'])) | |
{ | |
do_charge(); | |
} | |
function do_charge(){ | |
$token = $_POST['stripeToken']; | |
$email = $_POST['email']; | |
$amount = $_POST['amount']; | |
$amount = round($amount*100); | |
// $amount = 69; | |
try { | |
$customer = \Stripe\Customer::create(array( | |
"description"=>"Customer", | |
"source" => $token, | |
"email" => $email, | |
"plan" => "armorax" | |
) | |
); | |
$payment = \Stripe\Charge::create(array( | |
'amount' => $amount, | |
'currency' => 'usd', | |
//'source' => $_POST['stripeToken'], | |
'description' => $_POST['description'], | |
"customer" => $customer->id | |
) | |
); | |
/*echo '<pre>'; | |
print_r($payment); | |
echo '</pre>'; | |
* */ | |
// Use Stripe's bindings... | |
} catch(\Stripe\Error\Card $e) { | |
// Since it's a decline, \Stripe\Error\Card will be caught | |
$body = $e->getJsonBody(); | |
$err = $body['error']; | |
//print('Status is:' . $e->getHttpStatus() . "\n"); | |
$GLOBALS['myError']= 'Status is:' . $e->getHttpStatus(); | |
//$error1= 'Status is:' . $e->getHttpStatus(); | |
$error1.='Type is:' . $err['type']; | |
$error1.='Code is:' . $err['code']; | |
// param is '' in this case | |
$error1.='Param is:' . $err['param']; | |
$error1.='Message is:' . $err['message']; | |
echo $error1; | |
//return $error; | |
} catch (\Stripe\Error\InvalidRequest $e) { | |
// Invalid parameters were supplied to Stripe's API | |
} catch (\Stripe\Error\Authentication $e) { | |
// Authentication with Stripe's API failed | |
// (maybe you changed API keys recently) | |
} catch (\Stripe\Error\ApiConnection $e) { | |
// Network communication with Stripe failed | |
} catch (\Stripe\Error\Base $e) { | |
// Display a very generic error to the user, and maybe send | |
// yourself an email | |
} catch (Exception $e) { | |
// Something else happened, completely unrelated to Stripe | |
} | |
} | |
?> | |
<div id="wrapper"> | |
<form method="POST" id="payment-form"> | |
<div id="content-wrapper"> | |
<!-- Navigation Bar Begin --> | |
<nav id="no-border"> | |
<div class="content"> | |
<a href="index.html"><img src="img/armorax-logo.svg"></a> | |
<div class="nav-icons-holder"> | |
<p>Step 3 of 3</p><span class="vert-divider"></span> | |
<ul class="nav-icons"> | |
<li><img src="img/step-1-cart.svg"></li> | |
<li><img src="img/step-2-notes.svg"></li> | |
<li><img src="img/step-3-card-active.svg"></li> | |
</ul> | |
</div> | |
</div> | |
</nav> | |
<!-- Navigation Bar End --> | |
<!-- Tilte Begin --> | |
<div class="titleBlock"> | |
<h1>Payment</h1> | |
</div> | |
<!-- Title End --> | |
<!-- Second Section Columns Begin --> | |
<div class="content"> | |
<?php //if(isset($error)) | |
?> | |
<div class="alert"> <?php //echo "oh no I don't have a PHP error"; | |
// print_r($error1); | |
$GLOBALS['myError'] | |
//echo do_charge(); | |
?> </div> | |
<?php ?> | |
<div class="collumn1-small" id="fields"> | |
<div id="contacts-block"> | |
<div class="title-icon" id="contact"> | |
<h3>Contact</h3> | |
</div> | |
<!-- <a class="edit-link" href="#">Edit</a>--> | |
<div class="text-from-inputs"> | |
<ul> | |
<li><?php echo $row[0]['firstName'] ?> <?php echo $row[0]['LastName'] ?></li> | |
<li><?php echo $row[0]['email'] ?></li> | |
<input type="hidden" name="email" value="<?php echo $row[0]['email'] ?>" /> | |
</ul> | |
</div> | |
</div> | |
<div class="divider"></div> | |
<div id="installation-block"> | |
<div class="title-icon" id="installation"> | |
<h3>Installation</h3> | |
</div> | |
<!-- <a class="edit-link" href="#">Edit</a>--> | |
<div class="text-from-inputs"> | |
<ul> | |
<li><?php echo $row[0]['firstName'] ?> <?php echo $row[0]['LastName'] ?></li> | |
<li><?php echo $row[0]['address1'] ?></li> | |
<?php if(!empty($row[0]['address2'])) { ?><?php echo $row[0]['address2'] ?> <?php } ?> | |
<li><?php echo $row[0]['city'] ?> <?php echo $row[0]['state']; ?> <?php echo $row[0]['zip'] ?></li> | |
<li>United States</li> | |
</ul> | |
</div> | |
</div> | |
<div class="divider"></div> | |
<div id="payment-block"> | |
<div class="title-icon" id="payment"> | |
<h3>Payment</h3> | |
</div> | |
<div class="cl-inputs"> | |
<input type="text" name="cardHolderName" placeholder="Card Holder Name"><br> | |
<input type="text" data-stripe="number" placeholder="Card Number" size="20" autocomplete="off" class="card-number input-medium"><br> | |
<div class="styled-select" id="expiryMonth" > | |
<select data-stripe="exp-month" form="expiryMonth" class="card-expiry-month"> | |
<option value='' disabled selected style='display:none;'>MM</option> | |
<option value="01">01</option> | |
<option value="02">02</option> | |
<option value="03">03</option> | |
<option value="04">04</option> | |
<option value="05">05</option> | |
<option value="06">06</option> | |
<option value="07">07</option> | |
<option value="08">08</option> | |
<option value="09">09</option> | |
<option value="10">10</option> | |
<option value="11">11</option> | |
<option value="12">12</option> | |
</select> | |
<input type="hidden" name="expMonth" id="expMonth"> | |
</div> | |
<div class="styled-select"> | |
<select data-stripe="exp-year" form="expiryYear" class="card-expiry-year"> | |
<option value='' disabled selected style='display:none;'>YY</option> | |
<option value="2015">15</option> | |
<option value="2016">16</option> | |
<option value="2017">17</option> | |
<option value="2018">18</option> | |
<option value="2019">19</option> | |
<option value="2020">20</option> | |
</select><br> | |
<input type="hidden" name="expYear" id="expYear"> | |
</div> | |
<input type="text" id="CVC" data-stripe="cvc" size="4" autocomplete="off" class="card-cvc input-mini" placeholder="Security Code"><br> | |
<div class="payment-errors alert alert-warning" style="display:none;"></div> | |
</div> | |
</div> | |
</div> | |
<div class="collumn2-small" id="summary"> | |
<div class="title-icon" id="order"> | |
<h3>Order Summary</h3> | |
</div> | |
<p class="order-summary-list"> | |
<?php for($i=0; $i<$result->num_rows; $i++){ ?> | |
<span class="title"><?php echo $row[$i]['Description']; ?></span><span class="data">USD <?php echo $row[$i]['Fees']; ?></span><br> | |
<!-- <span class="title">Pro Monitoring</span><span class="data">USD 89.00/mo</span><br>--> | |
<?php } ?> | |
<span class="color"><span class="title">Today you pay</span><span class="data">USD <?php echo $row[0]['total_amount'] ?></span></span> | |
<input type="hidden" name="amount" value="<?php echo $row[0]['total_amount'] ?>"/> | |
<input type="hidden" name="description" value="Total"/> | |
</p> | |
<div class="clear"></div> | |
<div class="divider"></div> | |
<div class="title-icon" id="agreement"> | |
<h3>Your Agreement</h3> | |
</div> | |
<div class="divider"></div> | |
<input type="submit" name="submit2" value="Place Order" class="lineButton" id="agreement-place-order"> | |
<img class="secure-logo" src="img/geotrust-logo.png"> | |
<p class="button-text-desk">Any last questions? <a>Let’s have a quick chat!</a></p> | |
</div> | |
</div> | |
<div class="clear"></div> | |
<!-- <input type="hidden" name="stripeToken" class="stripeToken" />--> | |
<!-- Second Section Columns End--> | |
</div><!--Wrapper closed--> | |
</form> | |
<!-- Footer Begin--> | |
<div class="section" id="footer-small"> | |
<div class="content"> | |
<div class="footer-small"> | |
<img src="img/armorax-logo-small-footer.svg"> | |
<p>© 2015 Armorax - Control Your Safety</p> | |
<ul> | |
<li><a href="#">Privacy Policy</a></li> | |
<li><a href="#">Terms of service</a></li> | |
</ul> | |
</div> | |
</div> | |
</div> | |
<!-- Footer End--> | |
</div> | |
<!-- <script type="text/javascript" src="css/process.js"></script>--> | |
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script> | |
<script> | |
$(document).ready(function() { | |
// Event Listeners | |
//$('#agreement-place-order').on('click', generateToken); | |
$('#agreement-place-order').click( function(ev){ | |
Stripe.card.createToken({ | |
number: $('.card-number').val(), | |
cvc: $('.card-cvc').val(), | |
exp_month: $('.card-expiry-month').val(), | |
exp_year: $('.card-expiry-year').val() | |
}, stripeResponseHandler); | |
// | |
//ev.preventDefault(); | |
return false; | |
// | |
}); | |
function stripeResponseHandler(status, response) { | |
var $form = $('#payment-form'); | |
if (response.error) { | |
// Show the errors on the form | |
$form.find('.payment-errors').text(response.error.message); | |
$form.find('.payment-errors').show(); | |
$form.find('button').prop('disabled', false); | |
} else { | |
// response contains id and card, which contains additional card details | |
var token = response.id; | |
// Insert the token into the form so it gets submitted to the server | |
// $form.append($('<input type="hidden" name="stripeToken" />').val(token)); | |
$form.append($('<input type="hidden" name="stripeToken" />').val(token)); | |
//$(".stripeToken").val(token); | |
// | |
// and submit | |
//alert('Hello'); | |
$form.get(0).submit(); | |
} | |
} | |
$(".card-expiry-month").change(function(){ | |
$("#expMonth").val($(this).val()) | |
}); | |
$(".card-expiry-year").change(function(){ | |
$("#expYear").val($(this).val()) | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Working Code | |
try { | |
$customer = \Stripe\Customer::create(array( | |
"description"=>"Customer", | |
"source" => $token, | |
"email" => $email, | |
"plan" => "armorax" | |
) | |
); | |
$payment = \Stripe\Charge::create(array( | |
'amount' => $amount, | |
'currency' => 'usd', | |
//'source' => $_POST['stripeToken'], | |
'description' => $_POST['description'], | |
"customer" => $customer->id | |
) | |
); | |
} catch(\Stripe\Error\Card $e) { | |
// Since it's a decline, \Stripe\Error\Card will be caught | |
$body = $e->getJsonBody(); | |
$err = $body['error']; | |
print('Status is:' . $e->getHttpStatus() . "\n"); | |
print('Type is:' . $err['type'] . "\n"); | |
print('Code is:' . $err['code'] . "\n"); | |
// param is '' in this case | |
print('Param is:' . $err['param'] . "\n"); | |
print('Message is:' . $err['message'] . "\n"); | |
} | |
/// If I customize my code to match my theme | |
// Code customized in following way | |
try { | |
$customer = \Stripe\Customer::create(array( | |
"description"=>"Customer", | |
"source" => $token, | |
"email" => $email, | |
"plan" => "armorax" | |
) | |
); | |
$payment = \Stripe\Charge::create(array( | |
'amount' => $amount, | |
'currency' => 'usd', | |
//'source' => $_POST['stripeToken'], | |
'description' => $_POST['description'], | |
"customer" => $customer->id | |
) | |
); | |
} catch(\Stripe\Error\Card $e) { | |
$body = $e->getJsonBody(); | |
$err = $body['error']; | |
$error= 'Status is:' . $e->getHttpStatus() . "\n"; | |
$error+='Type is:' . $err['type'] . "\n"; | |
$error+='Code is:' . $err['code'] . "\n"; | |
// param is '' in this case | |
$error+='Param is:' . $err['param'] . "\n"; | |
$error+='Message is:' . $err['message'] . "\n"; | |
} | |
catch (\Stripe\Error\InvalidRequest $e) { | |
} | |
// Now i tried following | |
echo $error; | |
print_r($error); | |
//Nothing is prinited. Also i want to show a success message when payment is completed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment