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
Last revision Both sides next revision
developer:perl [2009/01/29 11:55]
tem
developer:perl [2009/01/29 12:18]
tem
Line 27: Line 27:
 print "​\n";​ print "​\n";​
 </​code>​ </​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 = '​fTU2rg5afrEGazF6ew6PBk6ts0G8gvB0';​
 +$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>​
 +
  
  
developer/perl.txt ยท Last modified: 2011/05/10 09:22 by irina

Page Tools