Guest User

Untitled

a guest
Jul 30th, 2022
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 5.0.1.0
  8. * @ Author : DeZender
  9. * @ Release on : 22.04.2022
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. function VnpayGateway_MetaData()
  15. {
  16. return ['DisplayName' => 'VnpayGateway [CodeTay.com]', 'APIVersion' => '1.1', 'DisableLocalCredtCardInput' => true, 'TokenisedStorage' => false];
  17. }
  18.  
  19. function VnpayGateway_config()
  20. {
  21. return [
  22. 'FriendlyName' => ['Type' => 'System', 'Value' => 'VnpayGateway [CodeTay.com]'],
  23. 'partnerCode' => ['FriendlyName' => 'Parter Code', 'Type' => 'text', 'Default' => ''],
  24. 'secretKey' => ['FriendlyName' => 'Secret Key', 'Type' => 'password', 'Default' => ''],
  25. 'rate' => ['FriendlyName' => 'Tỷ giá USD', 'Type' => 'text', 'Default' => '24000', 'Description' => 'Tỷ giá quy đổi từ USD->VND'],
  26. 'congrats' => ['FriendlyName' => 'Thông báo sau khi thanh toán thành công ở cổng thanh toán redirect về', 'Type' => 'text', 'Default' => 'Chúc mừng bạn đã Thanh toán thành công ! Xin vui lòng chờ một lát để hệ thống cập nhật thông tin.'],
  27. 'guide' => ['FriendlyName' => 'Hướng dẫn thanh toán', 'Type' => 'text', 'Default' => 'Nhấn vào nút bên dưới để chuyển qua trang thanh toán với VNPAY'],
  28. 'payNow' => ['FriendlyName' => 'Nút thanh toán', 'Type' => 'text', 'Default' => 'THANH TOÁN NGAY !'],
  29. 'licenseKey' => ['FriendlyName' => 'License Key', 'Type' => 'text', 'Default' => ''],
  30. 'sandbox' => ['FriendlyName' => 'Môi trường sandbox', 'Type' => 'yesno', 'Description' => 'Bật chế độ chạy thử trên môi trường sandbox']
  31. ];
  32. }
  33.  
  34. function VnpayGateway_link($params)
  35. {
  36. global $CONFIG;
  37. $licenseKey = $params['licenseKey'];
  38.  
  39. if (empty($licenseKey)) {
  40. return false;
  41. }
  42.  
  43. $rate = trim($params['rate']);
  44. $guide = trim($params['guide']);
  45. $sandbox = strtolower($params['sandbox']) == 'on';
  46. $invoiceId = $params['invoiceid'];
  47. $description = $params['description'];
  48. $amount = $params['amount'];
  49. $currencyCode = strtolower($params['currency']);
  50.  
  51. if ($currencyCode == 'usd') {
  52. $amount *= $rate;
  53. $amount = ceil($amount);
  54. }
  55. else if ($currencyCode == 'vnd') {
  56. $amount = (int) $amount;
  57. }
  58.  
  59. $paymentUrl = (new CODETAY\WHMCS\Package\VnpayPackage())->setMode($sandbox)->setParams($params['partnerCode'], $params['secretKey'])->setOrderID($invoiceId)->setAmount($amount)->setLocale(strtolower($params['clientdetails']['countrycode']) == 'vn' ? 'vn' : 'en')->setOrderInfo(base64_encode(json_encode(['order_id' => $invoiceId, 'currency_code' => $currencyCode, 'time' => time()])))->setReturnUrl($params['returnurl'])->getPaymentRequestUrl();
  60. if (isset($_GET['vnp_ResponseCode']) && ($_GET['vnp_ResponseCode'] == '00')) {
  61. $vnp_SecureHash = $_GET['vnp_SecureHash'];
  62. $inputData = [];
  63.  
  64. foreach ($_GET as $key => $value) {
  65. if (substr($key, 0, 4) == 'vnp_') {
  66. $inputData[$key] = $value;
  67. }
  68. }
  69.  
  70. unset($inputData['vnp_SecureHashType']);
  71. unset($inputData['vnp_SecureHash']);
  72. ksort($inputData);
  73. $i = 0;
  74. $hashData = '';
  75.  
  76. foreach ($inputData as $key => $value) {
  77. if ($i == 1) {
  78. $hashData = $hashData . '&' . $key . '=' . $value;
  79. }
  80. else {
  81. $hashData = $hashData . $key . '=' . $value;
  82. $i = 1;
  83. }
  84. }
  85.  
  86. $secureHash = hash('sha256', $params['secretKey'] . $hashData);
  87.  
  88. if ($secureHash == $vnp_SecureHash) {
  89. $invoice = WHMCS\Billing\Invoice::find($inputData['vnp_TxnRef']);
  90.  
  91. if (!$invoice) {
  92. return "\n" . ' <style>' . "\n" . ' .payment-box {' . "\n" . ' ' . "\n" . ' }' . "\n" . ' .payment-legend-error {' . "\n" . ' border: 5px solid red;' . "\n" . ' border-radius: 10px;' . "\n" . ' padding: 10px;' . "\n" . ' }' . "\n" . ' </style>' . "\n" . ' <fieldset class="payment-box">' . "\n" . ' <legend class="payment-legend-error">Không tìm thấy hóa đơn</legend> ' . "\n" . ' </fieldset>';
  93. }
  94.  
  95. $currency = strtolower(getCurrency($invoice->id)['code']);
  96. $total = $invoice->total;
  97.  
  98. if ($currency == 'usd') {
  99. $total = $params['rate'] * $invoice->total;
  100. .................................................................
  101. ..........................................
  102. ...............
Add Comment
Please, Sign In to add comment