Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for ionCube Encoder)
- *
- * @ Version : 5.0.1.0
- * @ Author : DeZender
- * @ Release on : 22.04.2022
- * @ Official site : http://DeZender.Net
- *
- */
- function VnpayGateway_MetaData()
- {
- return ['DisplayName' => 'VnpayGateway [CodeTay.com]', 'APIVersion' => '1.1', 'DisableLocalCredtCardInput' => true, 'TokenisedStorage' => false];
- }
- function VnpayGateway_config()
- {
- return [
- 'FriendlyName' => ['Type' => 'System', 'Value' => 'VnpayGateway [CodeTay.com]'],
- 'partnerCode' => ['FriendlyName' => 'Parter Code', 'Type' => 'text', 'Default' => ''],
- 'secretKey' => ['FriendlyName' => 'Secret Key', 'Type' => 'password', 'Default' => ''],
- 'rate' => ['FriendlyName' => 'Tỷ giá USD', 'Type' => 'text', 'Default' => '24000', 'Description' => 'Tỷ giá quy đổi từ USD->VND'],
- '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.'],
- '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'],
- 'payNow' => ['FriendlyName' => 'Nút thanh toán', 'Type' => 'text', 'Default' => 'THANH TOÁN NGAY !'],
- 'licenseKey' => ['FriendlyName' => 'License Key', 'Type' => 'text', 'Default' => ''],
- 'sandbox' => ['FriendlyName' => 'Môi trường sandbox', 'Type' => 'yesno', 'Description' => 'Bật chế độ chạy thử trên môi trường sandbox']
- ];
- }
- function VnpayGateway_link($params)
- {
- global $CONFIG;
- $licenseKey = $params['licenseKey'];
- if (empty($licenseKey)) {
- return false;
- }
- $rate = trim($params['rate']);
- $guide = trim($params['guide']);
- $sandbox = strtolower($params['sandbox']) == 'on';
- $invoiceId = $params['invoiceid'];
- $description = $params['description'];
- $amount = $params['amount'];
- $currencyCode = strtolower($params['currency']);
- if ($currencyCode == 'usd') {
- $amount *= $rate;
- $amount = ceil($amount);
- }
- else if ($currencyCode == 'vnd') {
- $amount = (int) $amount;
- }
- $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();
- if (isset($_GET['vnp_ResponseCode']) && ($_GET['vnp_ResponseCode'] == '00')) {
- $vnp_SecureHash = $_GET['vnp_SecureHash'];
- $inputData = [];
- foreach ($_GET as $key => $value) {
- if (substr($key, 0, 4) == 'vnp_') {
- $inputData[$key] = $value;
- }
- }
- unset($inputData['vnp_SecureHashType']);
- unset($inputData['vnp_SecureHash']);
- ksort($inputData);
- $i = 0;
- $hashData = '';
- foreach ($inputData as $key => $value) {
- if ($i == 1) {
- $hashData = $hashData . '&' . $key . '=' . $value;
- }
- else {
- $hashData = $hashData . $key . '=' . $value;
- $i = 1;
- }
- }
- $secureHash = hash('sha256', $params['secretKey'] . $hashData);
- if ($secureHash == $vnp_SecureHash) {
- $invoice = WHMCS\Billing\Invoice::find($inputData['vnp_TxnRef']);
- if (!$invoice) {
- 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>';
- }
- $currency = strtolower(getCurrency($invoice->id)['code']);
- $total = $invoice->total;
- if ($currency == 'usd') {
- $total = $params['rate'] * $invoice->total;
- .................................................................
- ..........................................
- ...............
Add Comment
Please, Sign In to add comment