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 [2009/01/29 11:52]
tem
developer:perl [2011/05/10 09:22]
irina
Line 2: Line 2:
  
  
-===== Simple Example Using NWP =====+===== Simple Example Using LWP Module=====
  
 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 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
Line 11: Line 11:
 $ua = LWP::​UserAgent->​new;​ $ua = LWP::​UserAgent->​new;​
 $res = $ua->​post('​https://​sandbox.usaepay.com/​gate',​ [ $res = $ua->​post('​https://​sandbox.usaepay.com/​gate',​ [
- '​UMkey'​ => "OEyB1Ziz4i4anLLMQAe7OR6Z13mQAkq1",+ '​UMkey'​ => "Your_source_key_here",
  '​UMname'​ => "​Example Tester",​  '​UMname'​ => "​Example Tester",​
  '​UMcard'​ => "​4444555566667779",​  '​UMcard'​ => "​4444555566667779",​
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 = '​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>​
 +
  
  
Line 116: 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