#!/usr/bin/perl #Sample PayPal Button Encryption: Copyright 2006,2007 StellarWebSolutions.com #Not for resale - license agreement at #http://www.stellarwebsolutions.com/en/eula.php #Updated: 2007 01 10 use IPC::Open2; #for open2 command # private key file to use $MY_KEY_FILE = "/usr/home/my-prvkey.pem"; # public certificate file to use $MY_CERT_FILE = "/usr/home/my-pubcert.pem"; # Paypal's public certificate $PAYPAL_CERT_FILE = "/usr/home/paypal_cert.pem"; # path to the openssl binary $OPENSSL = "/usr/bin/openssl"; my %hash = ('cmd' => '_xclick', 'business' => 'email@address.here', 'cert_id' => 'KC5YDMCS2DDHL', 'lc' => 'US', 'custom' => 'test', 'invoice' => '', #must be unique 'currency_code' => 'USD', #or USD 'no_shipping' => '1', 'item_name' => 'Donation', 'item_number' => '1', 'amount' => '10' ); my $encrypted = paypal(%hash); # print encrypted button form print < Sample Donation using PayPal Encrypted Buttons

Sample Donation Page

This page uses encrypted PayPal buttons for your security.

HTML_HEADER exit(1); sub paypal ($) { #Sample PayPal Button Encryption: Copyright 2006,2007 StellarWebSolutions.com #Not for resale - license agreement at #http://www.stellarwebsolutions.com/en/eula.php #Updated: 2007 01 10 my (%dat) = @_; $dat{ 'bn' } = 'StellarWebSolutions.PERL_EWP'; my $pid = open2(*READER, *WRITER, "$OPENSSL smime -sign -signer $MY_CERT_FILE -inkey $MY_KEY_FILE " . "-outform der -nodetach -binary | $OPENSSL smime -encrypt " . "-des3 -binary -outform pem $PAYPAL_CERT_FILE") || die "$OPENSSL: failed: $!\n"; for my $key ( keys %dat ) { if ($dat{$key} ne "") { print WRITER "$key=$dat{$key}\n"; } }; close(WRITER); # get encrypted data my @lines = ; close(READER); # get string of encrypted data my $encrypted = join('', @lines); return $encrypted };