From bed435640487715148543a956d6903fb5a8f63a6 Mon Sep 17 00:00:00 2001 From: Thuan Bui Date: Sat, 1 Oct 2022 12:51:02 +0700 Subject: [PATCH] Initial version from VNPay --- LICENSE | 4 + README.md | 1 + composer.json | 10 + images/logo.png | Bin 0 -> 16046 bytes src/FacadeResponse.php | 20 ++ src/Page.php | 27 ++ src/gateways/international/vnpayGateway.php | 226 +++++++++++++ .../vnpayInternationalResponse.php | 39 +++ src/shortcodes/Thankyou.php | 31 ++ src/traits/Pages.php | 20 ++ src/vnpayResponse.php | 137 ++++++++ uninstall.php | 0 vendor/autoload.php | 6 + vendor/composer/ClassLoader.php | 309 ++++++++++++++++++ vendor/composer/LICENSE | 21 ++ vendor/composer/autoload_classmap.php | 16 + vendor/composer/autoload_namespaces.php | 8 + vendor/composer/autoload_psr4.php | 12 + vendor/composer/autoload_real.php | 51 +++ vendor/composer/autoload_static.php | 56 ++++ vendor/composer/installed.json | 1 + vnpay.php | 124 +++++++ 22 files changed, 1119 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 composer.json create mode 100644 images/logo.png create mode 100644 src/FacadeResponse.php create mode 100644 src/Page.php create mode 100644 src/gateways/international/vnpayGateway.php create mode 100644 src/gateways/international/vnpayInternationalResponse.php create mode 100644 src/shortcodes/Thankyou.php create mode 100644 src/traits/Pages.php create mode 100644 src/vnpayResponse.php create mode 100644 uninstall.php create mode 100644 vendor/autoload.php create mode 100644 vendor/composer/ClassLoader.php create mode 100644 vendor/composer/LICENSE create mode 100644 vendor/composer/autoload_classmap.php create mode 100644 vendor/composer/autoload_namespaces.php create mode 100644 vendor/composer/autoload_psr4.php create mode 100644 vendor/composer/autoload_real.php create mode 100644 vendor/composer/autoload_static.php create mode 100644 vendor/composer/installed.json create mode 100644 vnpay.php diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..cdb1fe8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,4 @@ +MIT License + +Copyright (c) 2016 Thang Nguyen + diff --git a/README.md b/README.md new file mode 100644 index 0000000..1095582 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# vnpay \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..d81b4c4 --- /dev/null +++ b/composer.json @@ -0,0 +1,10 @@ +{ + "autoload": { + "psr-4": { + "vnpay\\": "src", + "vnpay\\Gateways\\": "src/gateways", + "vnpay\\Shortcodes\\": "src/shortcodes", + "vnpay\\Traits\\": "src/traits" + } + } +} \ No newline at end of file diff --git a/images/logo.png b/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..cc9ac45a0154523722d75472efab342d05b111bc GIT binary patch literal 16046 zcmV;fK2gDmP)KLZ*U+5Lu!Sk^o_Z5E4Meg@_7P6crJiNL9pw)e1;Xm069{HJUZAPk55R%$-RIA z6-eL&AQ0xu!e<4=008gy@A0LT~suv4>S3ILP<0Bm`DLLvaF4FK%)Nj?Pt*r}7;7Xa9z9H|HZjR63e zC`Tj$K)V27Re@400>HumpsYY5E(E}?0f1SyGDiY{y#)Yvj#!WnKwtoXnL;eg03bL5 z07D)V%>y7z1E4U{zu>7~aD})?0RX_umCct+(lZpemCzb@^6=o|A>zVpu|i=NDG+7} zl4`aK{0#b-!z=TL9Wt0BGO&T{GJWpjryhdijfaIQ&2!o}p04JRKYg3k&Tf zVxhe-O!X z{f;To;xw^bEES6JSc$k$B2CA6xl)ltA<32E66t?3@gJ7`36pmX0IY^jz)rRYwaaY4 ze(nJRiw;=Qb^t(r^DT@T3y}a2XEZW-_W%Hszxj_qD**t_m!#tW0KDiJT&R>6OvVTR z07RgHDzHHZ48atvzz&?j9lXF70$~P3Knx_nJP<+#`N z#-MZ2bTkiLfR>_b(HgWKJ%F~Nr_oF3b#wrIijHG|(J>BYjM-sajE6;FiC7vY#};Gd zST$CUHDeuEH+B^pz@B062qXfFfD`NpUW5?BY=V%GM_5c)L#QR}BeW8_2v-S%gfYS= zB9o|3v?Y2H`NVi)In3rTB8+ej^> zQ=~r95NVuDChL%G$=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z@Y)}5jko{Yd3R!psgxu5np7w0OmBRSs}J6+GugRfmYQ=xm(OvjC{B6A*`Yo0a;y4r zxj;(!w>vuxCb>GYPWUD#&^WsOG}pQg62q(yTCY>pD{W>?VEyq zZ(jAhq1gjAn}4D=yUsh=vwEH#uq47*XssN=IRe_W#m!mL7bnvLvTOk?x&pPFuW z7Lw`_Xk|!sx%T}>jYqZFr)sl{+9}=*k^6d)hahqf!}ew6kSn+BV*cnYbo;m9vhc1L z(_76L9#PC-V%DGUhOr5;_9+1@;Q~_knuAhe?cKK1evH!5G`Y^HnpxPSZ9ix5epe+0Vqgo#K5mGX#e>=dyA49l@TO>NIzo;9ywe oim)v^c4Du27qHv!*8blE0P=G1$S(^uasU7T07*qoM6N<$g45C0Bme*a literal 0 HcmV?d00001 diff --git a/src/FacadeResponse.php b/src/FacadeResponse.php new file mode 100644 index 0000000..84a4cd0 --- /dev/null +++ b/src/FacadeResponse.php @@ -0,0 +1,20 @@ +args = $args; + $this->createPage(); + } + + public function createPage() + { + return wp_insert_post($this->args); + } +} \ No newline at end of file diff --git a/src/gateways/international/vnpayGateway.php b/src/gateways/international/vnpayGateway.php new file mode 100644 index 0000000..70ecc43 --- /dev/null +++ b/src/gateways/international/vnpayGateway.php @@ -0,0 +1,226 @@ +id = 'vnpay'; + $this->icon = $this->get_option('logo'); + $this->has_fields = false; + $this->method_title = __('vnpay', 'woocommerce'); + + $this->supports = array( + 'products', + 'refunds' + ); + + // Load the settings. + $this->init_form_fields(); + $this->init_settings(); + + // Define user set variables + $this->title = $this->get_option('title'); + $this->description = $this->get_option('description'); + $this->Url = $this->get_option('Url'); + $this->terminal = $this->get_option('terminal'); + $this->secretkey = $this->get_option('secretkey'); + $this->locale = $this->get_option('locale'); + + if (!$this->isValidCurrency()) { + $this->enabled = 'no'; + } + + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array(&$this, 'process_admin_options')); + } + + public function getPagesList() { + $pagesList = array(); + $pages = get_pages(); + if (!empty($pages)) { + foreach ($pages as $page) { + $pagesList[$page->ID] = $page->post_title; + } + } + return $pagesList; + } + + public function init_form_fields() { + + $this->form_fields = array( + 'enabled' => array( + 'title' => __('Enable/Disable', 'woocommerce'), + 'type' => 'checkbox', + 'label' => __('Enable vnpay Paygate', 'woocommerce'), + 'default' => 'yes', + ), + 'title' => array( + 'title' => __('Tiêu đề', 'woocommerce'), + 'type' => 'text', + 'description' => 'Tiêu đề thanh toán', + 'default' => 'Thanh toán qua VNPAY', + 'desc_tip' => true + ), + 'description' => array( + 'title' => __('Mô tả', 'woocommerce'), + 'type' => 'textarea', + 'description' => __('Mô tả phương thức thanh toán', 'woocommerce'), + 'default' => __('Thanh toán trực tuyến qua VNPAY', 'woocommerce'), + 'desc_tip' => true + ), + 'Url' => array( + 'title' => __('VNPAY URL', 'woocommerce'), + 'type' => 'text', + 'description' => 'Url khởi tạo giao dịch sang VNPAY(VNPAY Cung cấp)', + 'default' => '', + 'desc_tip' => true + ), + 'terminal' => array( + 'title' => __('Terminal ID', 'woocommerce'), + 'type' => 'text', + 'description' => 'Mã terminal VNPAY cung cấp', + 'default' => '', + 'desc_tip' => true + ), + 'secretkey' => array( + 'title' => __('Secret Key', 'woocommerce'), + 'type' => 'password', + 'description' => 'Key cấu hình VNPAY cung cấp', + 'default' => '', + 'desc_tip' => true + ), + 'locale' => array( + 'title' => __('Locale', 'woocommerce'), + 'type' => 'select', + 'class' => 'wc-enhanced-select', + 'description' => __('Choose your locale', 'woocommerce'), + 'desc_tip' => true, + 'default' => 'vn', + 'options' => array( + 'vn' => 'vn', + 'en' => 'en' + ) + ), + ); + } + + public function process_payment($order_id) { + $order = new \WC_Order($order_id); + return array( + 'result' => 'success', + 'redirect' => $this->redirect($order_id) + ); + } + + public function redirect($order_id) { + date_default_timezone_set('Asia/Ho_Chi_Minh'); + $order = new \WC_Order($order_id); + $order->update_status('on-hold'); + $order->add_order_note(__('Giao dịch chờ thanh toán hoặc chưa hoàn tất', 'woocommerce')); + + // + $forenamefw = $order->get_billing_first_name(); + $forename = $this->convert_vi_to_en($forenamefw); + $surnamefw = $order->get_billing_last_name(); + $surname = $this->convert_vi_to_en($surnamefw); + $mobile = $order->get_billing_phone(); + $emailfw = $order->get_billing_email(); + $email = $this->convert_vi_to_en($emailfw); + + $amount = number_format($order->order_total, 2, '.', '') * 100; + $vnp_TxnRef = $order_id; + $date = date('Y-m-d H:i:s'); + $vnp_Url = $this->Url; + $vnp_Returnurl = admin_url('admin-ajax.php') . '?action=payment_response&type=international'; + $vnp_TmnCode = $this->terminal; + $hashSecret = $this->secretkey; + $vnp_OrderInfo = 'Ma giao dich thanh toan:'.$order_id .'-'.'Ho va ten KH:'.$surname. ' ' .$forename. '-'.'SDT:'.$mobile.'-'.'Email:'.$email; + $vnp_OrderType = 'orther'; + $vnp_Amount = $amount; + $vnp_Locale = $this->locale; + $vnp_IpAddr = $_SERVER['REMOTE_ADDR']; + $inputData = array( + "vnp_TmnCode" => $vnp_TmnCode, + "vnp_Amount" => $vnp_Amount, + "vnp_Command" => "pay", + "vnp_CreateDate" => date('YmdHis'), + "vnp_CurrCode" => "VND", + "vnp_IpAddr" => $vnp_IpAddr, + "vnp_Locale" => $vnp_Locale, + "vnp_OrderInfo" => $vnp_OrderInfo, + "vnp_OrderType" => $vnp_OrderType, + "vnp_ReturnUrl" => $vnp_Returnurl, + "vnp_TxnRef" => $vnp_TxnRef, + "vnp_Version" => "2.1.0", + ); + ksort($inputData); + $query = ""; + $i = 0; + $hashdata = ""; + foreach ($inputData as $key => $value) { + if ($i == 1) { + $hashdata .= '&' . urlencode($key) . "=" . urlencode($value); + } else { + $hashdata .= urlencode($key) . "=" . urlencode($value); + $i = 1; + } + $query .= urlencode($key) . "=" . urlencode($value) . '&'; + } + $vnp_Url = $vnp_Url . "?" . $query; + if (isset($hashSecret)) { + $vnpSecureHash = hash_hmac('sha512', $hashdata, $hashSecret); + $vnp_Url .= 'vnp_SecureHash=' . $vnpSecureHash; + } + + return $vnp_Url; + } + + public function isValidCurrency() { + return in_array(get_woocommerce_currency(), array('VND')); + } + + function convert_vi_to_en($str) { + $str = preg_replace("/(à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/", 'a', $str); + $str = preg_replace("/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/", 'e', $str); + $str = preg_replace("/(ì|í|ị|ỉ|ĩ)/", 'i', $str); + $str = preg_replace("/(ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/", 'o', $str); + $str = preg_replace("/(ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/", 'u', $str); + $str = preg_replace("/(ỳ|ý|ỵ|ỷ|ỹ)/", 'y', $str); + $str = preg_replace("/(đ)/", 'd', $str); + $str = preg_replace("/(À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ)/", 'A', $str); + $str = preg_replace("/(È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ)/", 'E', $str); + $str = preg_replace("/(Ì|Í|Ị|Ỉ|Ĩ)/", 'I', $str); + $str = preg_replace("/(Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ)/", 'O', $str); + $str = preg_replace("/(Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ)/", 'U', $str); + $str = preg_replace("/(Ỳ|Ý|Ỵ|Ỷ|Ỹ)/", 'Y', $str); + $str = preg_replace("/(Đ)/", 'D', $str); + return $str; + } + + public function admin_options() { + if ($this->isValidCurrency()) { + parent::admin_options(); + } else { + ?> +

+

+ + + : + +

+
+ get_option('receipt_return_url'); + } + + + +} diff --git a/src/shortcodes/Thankyou.php b/src/shortcodes/Thankyou.php new file mode 100644 index 0000000..d02f3eb --- /dev/null +++ b/src/shortcodes/Thankyou.php @@ -0,0 +1,31 @@ +"; + $content.= "
".$_GET["message"]."
"; + $content.= "
Mã giao dich: " . $_GET["vnp_TxnRef"] . "
"; + $content.= "
Số tiền:  " . $_GET["amount"] . "
"; + $content.= "
Ngân hàng:  " . $_GET["vnp_BankCode"] . "
"; + $content.= ""; + $content.= ""; + echo $content; + } + +} \ No newline at end of file diff --git a/src/traits/Pages.php b/src/traits/Pages.php new file mode 100644 index 0000000..fe48cf0 --- /dev/null +++ b/src/traits/Pages.php @@ -0,0 +1,20 @@ + array( + 'post_type' => 'page', + 'post_status' => 'publish', + 'post_title' => 'Payment Success', + 'post_content' => '' + ) + ); +} \ No newline at end of file diff --git a/src/vnpayResponse.php b/src/vnpayResponse.php new file mode 100644 index 0000000..e2b5832 --- /dev/null +++ b/src/vnpayResponse.php @@ -0,0 +1,137 @@ +action(); + } + + public function action() { + add_action('wp_ajax_payment_response', array($this, 'checkResponse')); + add_action('wp_ajax_nopriv_payment_response', array($this, 'checkResponse')); + add_action('wp_ajax_payment_response_vnpay', array($this, 'ipn_url_vnpay')); + add_action('wp_ajax_nopriv_payment_response_vnpay', array($this, 'ipn_url_vnpay')); + } + + public function checkResponse($txnResponseCode) { + global $woocommerce; + $woocommerce->cart->get_checkout_url(); + $order = $this->getOrder($_GET["vnp_TxnRef"]); + $url = wc_get_checkout_url() . 'order-received/' . $order->id . '/?key=' . $order->order_key; + wp_redirect($url); + WC()->cart->empty_cart(); + exit(); + } + + public function ipn_url_vnpay($txnResponseCode) { + global $woocommerce; + $transStatus = ''; + $checkoutUrl = $woocommerce->cart->get_checkout_url(); + + $order = $this->getOrder($_GET["vnp_TxnRef"]); + $gateway = new vnpayGateway; + $hashSecret = $gateway->get_option('secretkey'); + + // ($hashSecret); + $params = array(); + $returnData = array(); + $data = $_GET; + + foreach ($data as $key => $value) { + if (substr($key, 0, 4) == "vnp_") { + $params[$key] = $value; + } + } + $vnp_SecureHash = $params['vnp_SecureHash']; + unset($params['vnp_SecureHashType']); + unset($params['action']); + unset($params['type']); + unset($params['vnp_SecureHash']); + ksort($params); + $i = 0; + $hashData = ""; + foreach ($params as $key => $value) { + if ($i == 1) { + $hashData = $hashData . '&' . urlencode($key). "=" . urlencode($value); + } else { + $hashData = $hashData . urlencode($key) . "=" . urlencode($value); + $i = 1; + } + } + $secureHash = hash_hmac('sha512', $hashData, $hashSecret); +//Check Orderid + if ($order->post_status != \NULL && $order->post_status != '') { + //Check chữ ký + if ($secureHash == $vnp_SecureHash) { + //Check Status của đơn hàng + if ($order->post_status != \NULL && $order->post_status == 'wc-on-hold'){ + if ($params['vnp_ResponseCode'] == '00') { + $returnData['RspCode'] = '00'; + $returnData['Message'] = 'Confirm Success'; + $returnData['Signature'] = $secureHash; + $transStatus = $this->getResponseDescription($txnResponseCode); + $order->update_status('processing'); + $order->add_order_note(__($transStatus, 'woocommerce')); + WC()->cart->empty_cart(); + } + elseif ($params['vnp_ResponseCode'] == '24') { + $returnData['RspCode'] = '00'; + $returnData['Message'] = 'Confirm Success'; + $returnData['Signature'] = $secureHash; + $order->update_status('cancelled'); + $order->add_order_note(__('Khách hàng hủy giao dịch', 'woocommerce')); + WC()->cart->empty_cart(); + } + else + { + $returnData['RspCode'] = '00'; + $returnData['Message'] = 'Confirm Success'; + $returnData['Signature'] = $secureHash; + $transStatus = $this->getResponseDescription($txnResponseCode); + $order->add_order_note(__($transStatus, 'woocommerce')); + $order->update_status('failed'); + WC()->cart->empty_cart(); + } + } else { + $returnData['RspCode'] = '02'; + $returnData['Message'] = 'Order already confirmed'; + WC()->cart->empty_cart(); + } + } else { + $returnData['RspCode'] = '97'; + $returnData['Message'] = 'Chu ky khong hop le'; + $returnData['Signature'] = $secureHash; + WC()->cart->empty_cart(); + } + } else { + $returnData['RspCode'] = '01'; + $returnData['Message'] = 'Order not found'; + WC()->cart->empty_cart(); + } + echo json_encode($returnData); + exit(); + } + + abstract public function thankyou(); + + abstract public function getResponseDescription($responseCode); + + public function getOrder($orderId) { + preg_match_all('!\d+!', $orderId, $matches); + $order = new \WC_Order($matches[0][0]); + return $order; + } + +} diff --git a/uninstall.php b/uninstall.php new file mode 100644 index 0000000..e69de29 diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 0000000..2b08e65 --- /dev/null +++ b/vendor/autoload.php @@ -0,0 +1,6 @@ +prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + + public function findFile($class) + { + // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 + if ('\\' == $class[0]) { + $class = substr($class, 1); + } + + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative) { + return false; + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if ($file === null && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if ($file === null) { + // Remember that this class does not exist. + return $this->classMap[$class] = false; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 0000000..1a28124 --- /dev/null +++ b/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) 2016 Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..d1ae869 --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,16 @@ + $baseDir . '/src/FacadeResponse.php', + 'vnpay\\Gateways\\vnpayGateway' => $baseDir . '/src/gateways/international/vnpayGateway.php', + 'vnpay\\Gateways\\vnpayInternationalResponse' => $baseDir . '/src/gateways/international/vnpayInternationalResponse.php', + 'vnpay\\Page' => $baseDir . '/src/Page.php', + 'vnpay\\Responses\\vnpayResponse' => $baseDir . '/src/vnpayResponse.php', + 'vnpay\\Shortcodes\\Thankyou' => $baseDir . '/src/shortcodes/Thankyou.php', + 'vnpay\\Traits\\Pages' => $baseDir . '/src/traits/Pages.php', +); + diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..2b2735d --- /dev/null +++ b/vendor/composer/autoload_namespaces.php @@ -0,0 +1,8 @@ + array($baseDir . '/src/traits'), + 'vnpay\\Shortcodes\\' => array($baseDir . '/src/shortcodes'), + 'vnpay\\Gateways\\' => array($baseDir . '/src/gateways'), + 'vnpay\\' => array($baseDir . '/src'), +); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php new file mode 100644 index 0000000..b1b4f15 --- /dev/null +++ b/vendor/composer/autoload_real.php @@ -0,0 +1,51 @@ += 50600 && !defined('HHVM_VERSION'); + if ($useStaticLoader) { + require_once __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInit8f72f3bb7c6ee32c2a5028b2e2d64d68::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + return $loader; + } +} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php new file mode 100644 index 0000000..7ced056 --- /dev/null +++ b/vendor/composer/autoload_static.php @@ -0,0 +1,56 @@ + + array ( + 'vnpay\\Traits\\' => 17, + 'vnpay\\Shortcodes\\' => 21, + 'vnpay\\Gateways\\' => 19, + 'vnpay\\' => 10, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'vnpay\\Traits\\' => + array ( + 0 => __DIR__ . '/../..' . '/src/traits', + ), + 'vnpay\\Shortcodes\\' => + array ( + 0 => __DIR__ . '/../..' . '/src/shortcodes', + ), + 'vnpay\\Gateways\\' => + array ( + 0 => __DIR__ . '/../..' . '/src/gateways', + ), + 'vnpay\\' => + array ( + 0 => __DIR__ . '/../..' . '/src', + ), + ); + + public static $classMap = array ( + 'vnpay\\Facades\\FacadeResponse' => __DIR__ . '/../..' . '/src/FacadeResponse.php', + 'vnpay\\Gateways\\vnpayGateway' => __DIR__ . '/../..' . '/src/gateways/international/vnpayGateway.php', + 'vnpay\\Gateways\\vnpayInternationalResponse' => __DIR__ . '/../..' . '/src/gateways/international/vnpayInternationalResponse.php', + 'vnpay\\Page' => __DIR__ . '/../..' . '/src/Page.php', + 'vnpay\\Responses\\vnpayResponse' => __DIR__ . '/../..' . '/src/vnpayResponse.php', + 'vnpay\\Shortcodes\\Thankyou' => __DIR__ . '/../..' . '/src/shortcodes/Thankyou.php', + 'vnpay\\Traits\\Pages' => __DIR__ . '/../..' . '/src/traits/Pages.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInit8f72f3bb7c6ee32c2a5028b2e2d64d68::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit8f72f3bb7c6ee32c2a5028b2e2d64d68::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit8f72f3bb7c6ee32c2a5028b2e2d64d68::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/vendor/composer/installed.json @@ -0,0 +1 @@ +[] diff --git a/vnpay.php b/vnpay.php new file mode 100644 index 0000000..4db0b20 --- /dev/null +++ b/vnpay.php @@ -0,0 +1,124 @@ +constants(); + add_action('init', array($this, 'renderPages')); + add_action('plugins_loaded', array($this, 'vnpayInit')); + add_filter('woocommerce_locate_template', array($this, 'vnpayWoocommerceTemplates'), 10, 3); + $this->loadModule(); + $this->responseListener(); + } + + + public function constants() + { + $consts = array( + 'URL' => plugins_url('', __FILE__), + 'IMAGE' => plugins_url('/images', __FILE__) + ); + + foreach ($consts as $key => $value) { + define($key, $value); + } + } + + + public function vnpayInit() + { + add_filter('woocommerce_payment_gateways', array($this, 'addPaymentMethod')); + } + + + public function addPaymentMethod($methods) + { + $methods[] = 'vnpay\Gateways\vnpayGateway'; + return $methods; + } + + + public function loadModule() + { + $this->shortcodes[] = new vnpay\Shortcodes\Thankyou; + } + + public function responseListener() + { + if (isset($_GET['type'])) { + switch ($_GET['type']) { + case 'international': + $this->responses[] = new vnpayInternationalResponse; + break; + + } + } + } + + + public function renderPages() + { + $checkRenderPage = (!get_option('vnpay_settings')) ? false : get_option('vnpay_settings'); + if ($checkRenderPage != false) return; + if (!empty($this->pages)) { + foreach ($this->pages as $slug => $args) { + $page = new vnpay\Page($args); + } + update_option('vnpay_settings', true); + } + } + + public function vnpayWoocommerceTemplates($template, $template_name, $template_path) + { + global $woocommerce; + + $_template = $template; + + if (!$template_path) $template_path = $woocommerce->template_url; + + $plugin_path = __DIR__ . '/woocommerce/'; + + $template = locate_template( + array( + $template_path . $template_name, + $template_name + ) + ); + + if (!$template && file_exists( $plugin_path . $template_name)) + + $template = $plugin_path . $template_name; + + if (!$template) $template = $_template; + + return $template; + } +} + +new vnpay; \ No newline at end of file