Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. <input type="hidden" name="encrypted" value="ERROR: encryption failed">
  2.  
  3. <HTML>
  4. <?php
  5. //Sample PayPal Button Encryption: Copyright 2006-2010 StellarWebSolutions.com
  6. //Not for resale - license agreement at
  7. //http://www.stellarwebsolutions.com/en/eula.php
  8. //Updated: 2010 02 01
  9.  
  10. # private key file to use
  11. $MY_KEY_FILE = "inc/paypal/xxx-prvkey.pem";
  12.  
  13. # public certificate file to use
  14. $MY_CERT_FILE = "inc/paypal/xxx-pubcert.pem";
  15.  
  16. # Paypal's public certificate
  17. $PAYPAL_CERT_FILE = "inc/paypal/paypal_cert_pem.txt";
  18.  
  19. # path to the openssl binary
  20. $OPENSSL = "/etc/pki/tls/openssl.cnf";
  21.  
  22.  
  23. $form = array('cmd' => '_xclick',
  24. 'business' => 'xxx@gmail.com',
  25. 'cert_id' => 'xxx',
  26. 'lc' => 'US',
  27. 'custom' => 'test',
  28. 'currency_code' => 'USD',
  29. 'no_shipping' => '1',
  30. 'item_name' => 'Donation',
  31. 'item_number' => '1',
  32. 'amount' => '10',
  33. 'tax'=>'41.25',
  34. 'shipping'=>'20.00',
  35. 'cancel_return'=>'http://www.company.com/cancel.htm'
  36. );
  37.  
  38.  
  39. $encrypted = paypal_encrypt($form);
  40.  
  41.  
  42. function paypal_encrypt($hash)
  43. {
  44. //Sample PayPal Button Encryption: Copyright 2006-2010 StellarWebSolutions.com
  45. //Not for resale - license agreement at
  46. //http://www.stellarwebsolutions.com/en/eula.php
  47. global $MY_KEY_FILE;
  48. global $MY_CERT_FILE;
  49. global $PAYPAL_CERT_FILE;
  50. global $OPENSSL;
  51.  
  52.  
  53. if (!file_exists($MY_KEY_FILE)) {
  54. echo "ERROR: MY_KEY_FILE $MY_KEY_FILE not foundn";
  55. }
  56. if (!file_exists($MY_CERT_FILE)) {
  57. echo "ERROR: MY_CERT_FILE $MY_CERT_FILE not foundn";
  58. }
  59. if (!file_exists($PAYPAL_CERT_FILE)) {
  60. echo "ERROR: PAYPAL_CERT_FILE $PAYPAL_CERT_FILE not foundn";
  61. }
  62. if (!file_exists($OPENSSL)) {
  63. echo "ERROR: OPENSSL $OPENSSL not found<br/>";
  64. }
  65.  
  66.  
  67.  
  68. //Assign Build Notation for PayPal Support
  69. //$hash['bn']= 'StellarWebSolutions.PHP_EWP';
  70.  
  71. $data = "";
  72. foreach ($hash as $key => $value) {
  73. if ($value != "") {
  74. //echo "Adding to blob: $key=$valuen";
  75. $data .= "$key=$valuen";
  76. }
  77. }
  78.  
  79. $openssl_cmd = "($OPENSSL smime -sign -signer $MY_CERT_FILE -inkey $MY_KEY_FILE " .
  80. "-outform der -nodetach -binary <<_EOF_n$datan_EOF_n) | " .
  81. "$OPENSSL smime -encrypt -des3 -binary -outform pem $PAYPAL_CERT_FILE";
  82.  
  83. exec($openssl_cmd, $output, $error);
  84.  
  85. if (!$error) {
  86. return implode("n",$output);
  87. } else {
  88. return "ERROR: encryption failed";
  89. }
  90. }
  91. ?>
  92. <HEAD>
  93. <TITLE>PHP Sample Donation using PayPal Encrypted Buttons</TITLE>
  94. </HEAD>
  95. <BODY bgcolor=white>
  96. <TABLE border=0>
  97. <TR><TD align=center>
  98. <h1>Sample Donation Page</h1>
  99. <P>This page uses encrypted PayPal buttons for your security.</P>
  100. <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target=_blank>
  101. <input type="hidden" name="cmd" value="_s-xclick">
  102. <input type="hidden" name="encrypted" value="<?PHP echo $encrypted; ?>">
  103. <input type="submit" value="Donate $10">
  104. </form>
  105. <P><SMALL>(PayPal will open in a new window for demonstration purposes.)</SMALL></P>
  106. </TD></TR></TABLE>
  107. </BODY>
  108.  
  109. </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement