Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. <?php
  2. ini_set('display_errors', 1);
  3. ini_set('display_startup_errors', 1);
  4. error_reporting(E_ALL);
  5.  
  6. session_start();
  7. require './inc/mailer/PHPMailer.php';
  8. require './inc/mailer/Exception.php';
  9. require './inc/mailer/SMTP.php';
  10. require './inc/mailer/OAuth.php';
  11. require './inc/mailer/POP3.php';
  12.  
  13.  
  14. use PHPMailer\PHPMailer\PHPMailer;
  15. use PHPMailer\PHPMailer\Exception;
  16. use PHPMailer\PHPMailer\OAuth;
  17. use PHPMailer\PHPMailer\POP3;
  18. use PHPMailer\PHPMailer\SMTP;
  19.  
  20. require './inc/config.php';
  21. $items = json_decode(file_get_contents('inc/products.json'), true);
  22. if (!isset($items[$_GET['product']])) {
  23. die('Error, product not found.');
  24. }
  25. if (!isset($_SESSION['email'])) {
  26. die('Email session does not exist');
  27. }
  28.  
  29. if (isset($_GET['option'])) {
  30. $option = $_GET['option'];
  31. }
  32.  
  33. $url = $items[$_GET['product']]['downloadurl'];
  34.  
  35. if (isset($_GET['token'])) {
  36. $result = send_curl($api_url, array(
  37. 'user' => $paypal['user'],
  38. 'pwd' => $paypal['pwd'],
  39. 'signature' => $paypal['signature'],
  40. 'version' => $paypal['version'],
  41. 'method' => 'DoExpressCheckoutPayment',
  42. 'paymentrequest_0_paymentaction' => 'sale',
  43. 'paymentrequest_0_amt' => $items[$_GET['product']]['price'],
  44. 'paymentrequest_0_currencycode' => 'USD',
  45. 'token' => $_GET['token'],
  46. 'payerid' => $_GET['PayerID']
  47. ));
  48.  
  49. if ($result['PAYMENTINFO_0_PAYMENTSTATUS'] == 'Completed') {
  50. echo 'success';
  51. $email = new PHPMailer();
  52. $email->SMTPDebug = 0;
  53. $email->isSMTP();
  54. $email->Host = $settings_smtp_host;
  55. $email->SMTPAuth = true;
  56. $email->Username = $settings_email;
  57. $email->Password = $settings_password;
  58. $email->SMTPSecure = "tls";
  59. $email->Port = $settings_smtp_port;
  60.  
  61. $email->SetFrom($settings_email, $email_from_name);
  62. $email->Subject = $email_subject;
  63. $email->Body = $email_text;
  64. $email->AddBCC($user_email, $user_name);
  65. $email->AddAddress( $_GET['email'] );
  66.  
  67.  
  68. $email->AddAttachment( $_GET['url'] , $items[$_GET['product']]['mailfilename'] );
  69.  
  70. echo $email->Send();
  71. if (file_exists($_GET['url'])) {
  72. $url = $_GET['url'];
  73. header('Content-Description: File Transfer');
  74. header('Content-Type: application/octet-stream');
  75. header('Content-Disposition: attachment; filename='.basename($url));
  76. header('Expires: 0');
  77. header('Cache-Control: must-revalidate');
  78. header('Pragma: public');
  79. header('Content-Length: ' . filesize($url));
  80. readfile($url);
  81. }
  82. //header('Location: /?msg=Success');
  83.  
  84. }
  85.  
  86. }
  87.  
  88. if ($option == 'PayPal') {
  89.  
  90. $result = send_curl($api_url, array(
  91. 'method' => 'SetExpressCheckout',
  92. 'paymentrequest_0_paymentaction' => 'sale',
  93. 'paymentre_paymentaction' => 'sale',
  94. 'paymentrequest_ntaction' => 'sale',
  95. 'paymentrequest_0_amt' => $items[$_GET['product']]['price'],
  96. 'paymentrequest_0_currencycode' => 'USD',
  97. 'returnurl' => 'http://'.$_SERVER['HTTP_HOST'].'/purchase.php?email=' . $_SESSION['email'] . '&product=' . $_GET['product'] . '&url=http://' . $_SERVER['HTTP_HOST']. '/' .$items[$_GET['product']]['downloadurl'],
  98. 'cancelurl' => 'http://'.$_SERVER['HTTP_HOST'].'/?msg=Cancelled',
  99. 'user' => $paypal['user'],
  100. 'pwd' => $paypal['pwd'],
  101. 'signature' => $paypal['signature'],
  102. 'version' => $paypal['version']
  103. ));
  104.  
  105. if ($result['ACK'] == 'Success') {
  106. header('Location: ' . $redirect_url . '?cmd=_express-checkout&useraction=commit&token=' . $result['TOKEN']);
  107. } else {
  108. echo 'Error creating payment. Contact TrollC#5916 on discord.';
  109. }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement