developer:formtokenization
<?php 
include '/usr/share/php/usaepay.php';
 
if($_REQUEST['submitted']) {
 
	$client = new umTransaction();
	$client->usesandbox=true;
	$client->key='_82lz9VsLm87MA54Sv8E582h8OZMArL6';
	$client->pin=1234;
	$client->card = $_REQUEST['ccnum'];
	$client->exp = $_REQUEST['expdate'];
	$client->amount = $_REQUEST['amount'];
	$client->street = $_REQUEST['address'];
	$client->zip = $_REQUEST['zip'];
	$client->invoice = '12354';
	$client->description = 'Example tokenized transaction';
 
	echo "<h1>Please wait one moment while we process your card...<br>\n";
	flush();
 
	if($client->Process())
	{
		echo "<b>Card Approved</b><br>";
		echo "<b>Authcode:</b> " . $client->authcode . "<br>";
		echo "<b>AVS Result:</b> " . $client->avs . "<br>";
		echo "<b>Cvv2 Result:</b> " . $client->cvv2 . "<br>";
	} else {
		echo "<b>Card Declined</b> (" . $client->result . ")<br>";
		echo "<b>Reason:</b> " . $client->error . "<br>";	
		if(@$client->curlerror) echo "<b>Curl Error:</b> " . $client->curlerror . "<br>";	
	}	
	exit;
}
 
?>
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
</head>
<body>
<div class="container">
	<form action="" method="post" class="form-horizontal" role="form">
	<input type="hidden" name="submitted" value="1">
		<div class="form-group">
			<label for="fldAmount">Amount</label> <input type="text" id="fldAmount" name="amount" />
		</div>
		<div class="form-group">
			<label for="fldAddress">Address</label> <input type="text" id="fldAddress" name="address" />
		</div>
		<div class="form-group">
			<label for="fldZip">Zip</label> <input type="text" id="fldZip" name="zip" />
		</div>
		<div class="form-group">
			<label for="fldCcnum">Credit Card Number</label> <input type="text" id="fldCcnum" name="ccnum" />
		</div>
		<div class="form-group">
			<label for="fldExpdate">Exp Date</label> <input type="text" id="fldExpdate" name="expdate" />
		</div>
		<div class="form-group">
			<label for="fldCvv">CVV2</label> <input type="text" id="fldCvv" name="cvv2" />
		</div>
	  <input type="submit" name="gotime" value="Submit" class="btn btn-default"/>
	</form>
</div>
 
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://sandbox.usaepay.com/tokenize/jquery.ueform.js"></script>
<script>
  $('form')
    .ueForm({
      form_error  : function ( errors ) {
        $.each( errors, function( field, isError ){
          if ( isError )
            console.log('error on field ' + field);
        })
 
      },
      error       : function ( code, text ) {
        console.log('Error (' + code + '): ' + text);
      }
    });
</script>
</body>
</html>
developer/formtokenization.txt · Last modified: 2014/08/14 09:40 by tem

Page Tools