developer:perl

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
developer:perl [2008/06/17 15:11]
vladg edit out UMexpire, which is deprecated
developer:perl [2011/05/10 09:22]
irina
Line 1: Line 1:
-====== Perl Script v1.2 ======+====== ​Using Perl with USAePay ​======
  
  
 +===== Simple Example Using LWP Module=====
  
-===== Example ​Perl Code=====+Make sure to replace the UMkey parameter with your source key.  Also,  the example below uses our [[developer:​sandbox|sandbox]] test server. ​ Make sure to change the url to https://​secure.usaepay.com/​gate when ready to process production transactions 
 + 
 +<code perl> 
 +use LWP::​UserAgent;​ 
 + 
 +$ua = LWP::​UserAgent->​new;​ 
 +$res = $ua->​post('​https://​sandbox.usaepay.com/​gate',​ [ 
 + '​UMkey'​ => "​Your_source_key_here",​ 
 + '​UMname'​ => "​Example Tester",​ 
 + '​UMcard'​ => "​4444555566667779",​ 
 + '​UMexpir'​ => "​0113",​ 
 + '​UMcvv2'​ => "​999",​ 
 + '​UMamount'​ => "​5.50",​ 
 + '​UMinvoice'​ => "​123456",​ 
 + '​UMstreet'​ => "1234 Main Street",​ 
 + '​UMzip'​ => "​12345",​ 
 + '​UMcommand'​ => '​cc:​sale'​ 
 +]); 
 + 
 + 
 +print "​\n\nresult:​ "​.$res->​content;​ 
 +print "​\n";​ 
 +</​code>​ 
 + 
 + 
 +===== Source Key with Pin Example Using LWP Module===== 
 + 
 +If your source key has been secured with a pin,  you must generate and pass a hash authentication token to the server. ​ The following example demonstrates this using the Digest::​SHA1 module. 
 + 
 +<code perl> 
 +use LWP::​UserAgent;​ 
 +use Digest::​SHA1 ​ qw(sha1 sha1_hex sha1_base64);​ 
 + 
 +$sourcekey = '​Your_source_key_here';​ 
 +$pin = '​1234';​ 
 +$command = '​cc:​sale';​ 
 +$amount = '​5.50';​ 
 +$invoice = '​123123';​ 
 + 
 +# Generate Hash 
 +$seed = rand(); 
 +$prehash = $command . ":"​ . $pin . ":"​ . $amount . ":"​ . $invoice . ":"​ . $seed; 
 +$hash = '​s/'​ . $seed . '/'​ . sha1_hex($prehash) . '/​n';​ 
 + 
 + 
 +$ua = LWP::​UserAgent->​new;​ 
 +$res = $ua->​post('​https://​sandbox.usaepay.com/​gate.php',​ [ 
 + '​UMkey'​ => $sourcekey,​ 
 + '​UMhash'​ => $hash, 
 + '​UMname'​ => "​Example Tester",​ 
 + '​UMcard'​ => "​4444555566667779",​ 
 + '​UMexpir'​ => "​0113",​ 
 + '​UMcvv2'​ => "​999",​ 
 + '​UMamount'​ => $amount, 
 + '​UMinvoice'​ => $invoice, 
 + '​UMstreet'​ => "1234 Main Street",​ 
 + '​UMzip'​ => "​12345",​ 
 + '​UMcommand'​ => $command 
 +]); 
 + 
 + 
 +print "​\n\nresult:​ "​.$res->​content;​ 
 +print "​\n";​ 
 +</​code>​ 
 + 
 + 
 + 
 +===== Example ​Net::​SSLeay ​Code =====
  
 <code perl> <code perl>
Line 90: Line 158:
  
 #Your Source Key that is provided by usaepay #Your Source Key that is provided by usaepay
-$sourceKey = 'PUT_YOUR_SOUCE_KEY_HERE';+$sourceKey = 'Your_source_key_here';
  
  
developer/perl.txt · Last modified: 2011/05/10 09:22 by irina

Page Tools