Advertisement
Guest User

Example

a guest
Nov 3rd, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.39 KB | None | 0 0
  1. <?php
  2. $url       = 'https://www.paypal.com/cgi-bin/webscr';
  3. $tier      = $_GET["tier"];
  4. $form_data = array(
  5.     'business' => 'business@jerr0w.xyz',
  6.     'notify_url' => 'https://donate.trinia.pro/classes/paypal-listener.php',
  7.     'cancel_return' => 'https://donate.trinia.pro/verify_error.php',
  8.     'return' => 'https://donate.trinia.pro/verify_success.php',
  9.     'rm' => '2',
  10.     'no_shipping' => '1',
  11.     'no_note' => '1',
  12.     'currency_code' => 'EUR',
  13.     'page_style' => 'paypal',
  14.     'charset' => 'utf-8',
  15.     'cmd' => '_xclick'
  16. );
  17.  
  18. // This would be the user's steamid, could just use https://github.com/SmItH197/SteamAuthentication
  19. // since he's already using it, and wouldn't have to trust the clients steamid
  20. $form_data["custom"] = "";
  21.  
  22. switch ($tier) {
  23.     case 1:
  24.         $form_data["item_name"] = "Donation: Tier I";
  25.         $form_data["amount"]    = 0.01;
  26.         break;
  27.     case 2:
  28.         $form_data["item_name"] = "Donation: Tier II";
  29.         $form_data["amount"]    = 10.00;
  30.         break;
  31.     case 3:
  32.         $form_data["item_name"] = "Donation: Tier III";
  33.         $form_data["amount"]    = 15.00;
  34.         break;
  35.     case 4:
  36.         $form_data["item_name"] = "Donation: Tier IV";
  37.         $form_data["amount"]    = 25.00;
  38.         break;
  39.     case 5:
  40.         $form_data["item_name"] = "Donation: Tier V";
  41.         $form_data["amount"]    = 50.00;
  42.         break;
  43.     default:
  44.         die("Invalid tier");
  45. }
  46.  
  47. $options = array(
  48.     'http' => array(
  49.         'header' => "Content-type: application/x-www-form-urlencoded\r\n",
  50.         'method' => 'POST',
  51.         'content' => http_build_query($form_data)
  52.     )
  53. );
  54. $context = stream_context_create($options);
  55. $result  = file_get_contents($url, false, $context);
  56. $headers = parseHeaders($http_response_header);
  57.  
  58. if (strpos($headers[0], '302') !== false) {
  59.     header("Location: " . $headers["Location"]);
  60. }
  61.  
  62. //Taken from http://php.net/manual/en/reserved.variables.httpresponseheader.php#117203
  63. function parseHeaders( $headers )
  64. {
  65.     $head = array();
  66.     foreach( $headers as $k=>$v )
  67.     {
  68.         $t = explode( ':', $v, 2 );
  69.         if( isset( $t[1] ) )
  70.             $head[ trim($t[0]) ] = trim( $t[1] );
  71.         else
  72.         {
  73.             $head[] = $v;
  74.             if( preg_match( "#HTTP/[0-9\.]+\s+([0-9]+)#",$v, $out ) )
  75.                 $head['reponse_code'] = intval($out[1]);
  76.         }
  77.     }
  78.     return $head;
  79. }
  80. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement