Changeset 2436825
- Timestamp:
- 12/10/2020 06:22:03 PM (5 years ago)
- Location:
- woo-yuansfer/trunk
- Files:
-
- 10 added
- 20 edited
-
README.md (modified) (2 diffs)
-
assets/css/yuansfer-storefront-styles.css (modified) (1 diff)
-
assets/css/yuansfer-styles.css (modified) (1 diff)
-
assets/css/yuansfer-twentyseventeen-styles.css (modified) (1 diff)
-
assets/images/creditcard.png (added)
-
assets/images/paypal.svg (added)
-
assets/images/venmo.svg (added)
-
includes/abstracts/abstract-wc-yuansfer-payment-gateway.php (modified) (22 diffs)
-
includes/admin/class-wc-yuansfer-admin-notices.php (modified) (2 diffs)
-
includes/admin/yuansfer-alipay-settings.php (modified) (1 diff)
-
includes/admin/yuansfer-creditcard-settings.php (added)
-
includes/admin/yuansfer-paypal-settings.php (added)
-
includes/admin/yuansfer-settings.php (modified) (1 diff)
-
includes/admin/yuansfer-venmo-settings.php (added)
-
includes/admin/yuansfer-wechatpay-settings.php (modified) (1 diff)
-
includes/class-wc-gateway-yuansfer.php (modified) (5 diffs)
-
includes/class-wc-yuansfer-api.php (modified) (4 diffs)
-
includes/class-wc-yuansfer-customer.php (modified) (2 diffs)
-
includes/class-wc-yuansfer-helper.php (modified) (9 diffs)
-
includes/class-wc-yuansfer-mobile-detect.php (added)
-
includes/class-wc-yuansfer-order-handler.php (modified) (4 diffs)
-
includes/class-wc-yuansfer-webhook-handler.php (modified) (4 diffs)
-
includes/compat/class-wc-yuansfer-pre-orders-compat.php (modified) (2 diffs)
-
includes/payment-methods/class-wc-gateway-yuansfer-alipay.php (modified) (6 diffs)
-
includes/payment-methods/class-wc-gateway-yuansfer-creditcard.php (added)
-
includes/payment-methods/class-wc-gateway-yuansfer-paypal.php (added)
-
includes/payment-methods/class-wc-gateway-yuansfer-venmo.php (added)
-
includes/payment-methods/class-wc-gateway-yuansfer-wechatpay.php (modified) (4 diffs)
-
uninstall.php (modified) (1 diff)
-
woocommerce-yuansfer.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-yuansfer/trunk/README.md
r2141379 r2436825 2 2 3 3 ``` 4 Contributors: yuansfer -team5 Tags: yuansfer, payment request, unionpay, alipay, wechat pay, woocommerce, automattic4 Contributors: yuansfer 5 Tags: yuansfer, payment request, unionpay, alipay, wechat pay, credit card, paypal, venmo, woocommerce, automattic 6 6 Requires at least: 4.4 7 Tested up to: 4.97 Tested up to: 5.4 8 8 Requires PHP: 5.6 9 Stable tag: 4.1.79 Stable tag: 3.0.0 10 10 License: GPLv3 11 11 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 102 102 == Changelog == 103 103 104 = 3.0.0 - 2020-11-07 = 105 * Update to v3 API 106 * Add payment method: paypal, venmo 107 108 = 2.0.1 - 2020-11-06 = 109 * Fix WeChat Pay terminal settings 110 111 = 2.0.0 - 2020-11-06 = 112 * Change version for consistency 113 * Add mobile detect 114 115 = 1.2.3 - 2020-10-22 = 116 * Remove useless parameters for refund 117 118 = 1.2.2 - 2020-08-02 = 119 * Add CNY support 120 121 = 1.2.1 - 2020-07-20 = 122 * Fix retry error of update customer 123 * Skip customerNo when disable create account of credit card 124 125 = 1.2.0 - 2020-07-19 = 126 * Update to new version of Yuansfer API 127 * Add create customer for credit card 128 * WC require up to 3.0 129 130 = 1.1.0 - 2020-07-14 = 131 * Add payment method: credit card 132 * Add support for new API parameter: rmbAmount 133 * Fix status error after order creation 134 104 135 = 1.0.0 - 2019-05-30 = 105 136 First Release -
woo-yuansfer/trunk/assets/css/yuansfer-storefront-styles.css
r2141376 r2436825 3 3 #add_payment_method #payment .payment_method_yuansfer_wechatpay label[for=payment_method_yuansfer_wechatpay] { display: block; padding-left: 1.41575em; } 4 4 #add_payment_method #payment .payment_method_yuansfer_lakalapay label[for=payment_method_yuansfer_lakalapay] { display: block; padding-left: 1.41575em; } 5 #add_payment_method #payment .payment_method_yuansfer_creditcard label[for=payment_method_yuansfer_creditcard] { display: block; padding-left: 1.41575em; } 6 #add_payment_method #payment .payment_method_yuansfer_paypal label[for=payment_method_yuansfer_paypal] { display: block; padding-left: 1.41575em; } 7 #add_payment_method #payment .payment_method_yuansfer_venmo label[for=payment_method_yuansfer_venmo] { display: block; padding-left: 1.41575em; } -
woo-yuansfer/trunk/assets/css/yuansfer-styles.css
r2141376 r2436825 14 14 #add_payment_method #payment .payment_method_yuansfer_alipay { position: relative; } 15 15 #add_payment_method #payment .payment_method_yuansfer_wechatpay { position: relative; } 16 #add_payment_method #payment .payment_method_yuansfer_creditcard { position: relative; } 17 #add_payment_method #payment .payment_method_yuansfer_paypal { position: relative; } 18 #add_payment_method #payment .payment_method_yuansfer_venmo { position: relative; } 16 19 #add_payment_method #payment input#payment_method_yuansfer { position: absolute; top: 6px; } 17 20 #add_payment_method #payment input#payment_method_yuansfer_alipay { position: absolute; top: 6px; } 18 21 #add_payment_method #payment input#payment_method_yuansfer_wechatpay { position: absolute; top: 6px; } 22 #add_payment_method #payment input#payment_method_yuansfer_creditcard { position: absolute; top: 6px; } 23 #add_payment_method #payment input#payment_method_yuansfer_paypal { position: absolute; top: 6px; } 24 #add_payment_method #payment input#payment_method_yuansfer_venmo { position: absolute; top: 6px; } 19 25 #add_payment_method #payment .payment_method_yuansfer label[for=payment_method_yuansfer] { display: block; padding-left: 20px; } 20 26 #add_payment_method #payment .payment_method_yuansfer_alipay label[for=payment_method_yuansfer_alipay] { display: block; padding-left: 20px; } 21 27 #add_payment_method #payment .payment_method_yuansfer_wechatpay label[for=payment_method_yuansfer_wechatpay] { display: block; padding-left: 20px; } 28 #add_payment_method #payment .payment_method_yuansfer_creditcard label[for=payment_method_yuansfer_creditcard] { display: block; padding-left: 20px; } 29 #add_payment_method #payment .payment_method_yuansfer_paypal label[for=payment_method_yuansfer_paypal] { display: block; padding-left: 20px; } 30 #add_payment_method #payment .payment_method_yuansfer_venmo label[for=payment_method_yuansfer_venmo] { display: block; padding-left: 20px; } 22 31 #add_payment_method #payment ul.payment_methods li img.yuansfer-icon { float: right; max-width: 40px; padding-left: 3px; margin: 0; } 23 32 #add_payment_method #payment ul.payment_methods li img.yuansfer-alipay-icon { max-width: 50px; } 24 33 #add_payment_method #payment ul.payment_methods li img.yuansfer-wechatpay-icon { max-width: 50px; } 34 #add_payment_method #payment ul.payment_methods li img.yuansfer-creditcard-icon { max-width: 50px; } 35 #add_payment_method #payment ul.payment_methods li img.yuansfer-paypal-icon { max-width: 50px; } 36 #add_payment_method #payment ul.payment_methods li img.yuansfer-venmo-icon { max-width: 50px; } 25 37 #add_payment_method #payment ul.payment_methods .yuansfer-card-group { position: relative; } -
woo-yuansfer/trunk/assets/css/yuansfer-twentyseventeen-styles.css
r2141376 r2436825 2 2 #add_payment_method #payment .payment_method_yuansfer_alipay label[for=payment_method_yuansfer_alipay] { display: block; padding-left: 20px; } 3 3 #add_payment_method #payment .payment_method_yuansfer_wechatpay label[for=payment_method_yuansfer_wechatpay] { display: block; padding-left: 20px; } 4 #add_payment_method #payment .payment_method_yuansfer_creditcard label[for=payment_method_yuansfer_creditcard] { display: block; padding-left: 20px; } 5 #add_payment_method #payment .payment_method_yuansfer_paypal label[for=payment_method_yuansfer_paypal] { display: block; padding-left: 20px; } 6 #add_payment_method #payment .payment_method_yuansfer_venmo label[for=payment_method_yuansfer_venmo] { display: block; padding-left: 20px; } 4 7 5 8 .woocommerce-PaymentMethods li { list-style-type: none; } -
woo-yuansfer/trunk/includes/abstracts/abstract-wc-yuansfer-payment-gateway.php
r2141376 r2436825 39 39 public $merchant_no; 40 40 public $store_no; 41 public $manager_no; 42 p ublic $manager_password;41 42 protected $detect; 43 43 44 44 /** … … 69 69 $this->statement_descriptor = !empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : ''; 70 70 71 $this->manager_no = !empty($main_settings['manager_no']) ? $main_settings['manager_no'] : '';72 $this->manager_password = !empty($main_settings['manager_password']) ? $main_settings['manager_password'] : '';73 74 71 if ($this->testmode) { 75 72 $this->api_token = !empty($main_settings['test_api_token']) ? $main_settings['test_api_token'] : ''; … … 78 75 add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); 79 76 add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); 77 78 $this->detect = new WC_Yuansfer_Mobile_Detect(); 79 } 80 81 protected function get_terminal($wechat = false) 82 { 83 if ($this->detect->isMobile()) { 84 if ($wechat) { 85 return $this->detect->is('WeChat') ? 'WAP' : 'MWEB'; 86 } 87 88 return 'WAP'; 89 } 90 91 return 'ONLINE'; 80 92 } 81 93 … … 86 98 */ 87 99 public function get_supported_currency() { 88 return apply_filters('wc_yuansfer_ alipay_supported_currencies', array(100 return apply_filters('wc_yuansfer_supported_currencies', array( 89 101 'USD', 90 'CAD', 91 // 'EUR', 92 // 'AUD', 93 // 'GBP', 94 // 'HKD', 95 // 'JPY', 96 // 'NZD', 97 // 'SGD', 98 102 'CNY', 99 103 )); 100 104 } … … 299 303 'alipay' => '<img src="' . WC_YUANSFER_PLUGIN_URL . '/assets/images/alipay.svg" class="yuansfer-alipay-icon yuansfer-icon" alt="Alipay" width="52" />', 300 304 'wechatpay' => '<img src="' . WC_YUANSFER_PLUGIN_URL . '/assets/images/wechatpay.png" class="yuansfer-wechatpay-icon yuansfer-icon" alt="Wechat Pay" width="90" />', 305 'creditcard' => '<img src="' . WC_YUANSFER_PLUGIN_URL . '/assets/images/creditcard.png" class="yuansfer-creditcard-icon yuansfer-icon" alt="Credit Card" width="90" />', 306 'paypal' => '<img src="' . WC_YUANSFER_PLUGIN_URL . '/assets/images/paypal.svg" class="yuansfer-paypal-icon yuansfer-icon" alt="PayPal" width="90" />', 307 'venmo' => '<img src="' . WC_YUANSFER_PLUGIN_URL . '/assets/images/venmo.svg" class="yuansfer-venmo-icon yuansfer-icon" alt="Venmo" width="90" />', 301 308 ) ); 302 309 } … … 332 339 */ 333 340 public function get_yuansfer_customer_id($order) { 334 $customer = get_user_meta( WC_Yuansfer_Helper::is_pre_30() ? $order->customer_user :$order->get_customer_id(), '_yuansfer_customer_id', true);341 $customer = get_user_meta($order->get_customer_id(), '_yuansfer_customer_id', true); 335 342 336 343 if (empty($customer)) { 337 344 // Try to get it via the order. 338 if (WC_Yuansfer_Helper::is_pre_30()) { 339 return get_post_meta($order->id, '_yuansfer_customer_id', true); 340 } else { 341 return $order->get_meta('_yuansfer_customer_id', true); 342 } 343 } else { 344 return $customer; 345 } 345 return $order->get_meta('_yuansfer_customer_id', true); 346 } 347 348 return $customer; 346 349 } 347 350 … … 354 357 public function get_yuansfer_return_url($order = null) { 355 358 if (is_object($order)) { 356 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id :$order->get_id();359 $order_id = $order->get_id(); 357 360 $args = array( 358 361 'utm_nooverride' => '1', … … 386 389 $statement_descriptor = ! empty($settings['statement_descriptor']) ? str_replace("'", '', $settings['statement_descriptor']) : ''; 387 390 $post_data = array(); 388 $post_data['currency'] = strtolower( WC_Yuansfer_Helper::is_pre_30() ? $order->get_order_currency() :$order->get_currency());391 $post_data['currency'] = strtolower($order->get_currency()); 389 392 $post_data['amount'] = WC_Yuansfer_Helper::get_yuansfer_amount($order->get_total(), $post_data['currency']); 390 393 $post_data['description'] = sprintf(__('%1$s - Order %2$s', 'woocommerce-yuansfer'), wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES), $order->get_order_number()); 391 $billing_email = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_email :$order->get_billing_email();392 $billing_first_name = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_first_name :$order->get_billing_first_name();393 $billing_last_name = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_last_name :$order->get_billing_last_name();394 $billing_email = $order->get_billing_email(); 395 $billing_first_name = $order->get_billing_first_name(); 396 $billing_last_name = $order->get_billing_last_name(); 394 397 395 398 if (!empty($billing_email) && apply_filters('wc_yuansfer_send_yuansfer_receipt', false)) { … … 397 400 } 398 401 399 switch ( WC_Yuansfer_Helper::is_pre_30() ? $order->payment_method :$order->get_payment_method()) {402 switch ($order->get_payment_method()) { 400 403 case 'yuansfer': 401 404 if (!empty($statement_descriptor)) { … … 414 417 ); 415 418 416 if ($this->has_subscription( WC_Yuansfer_Helper::is_pre_30() ? $order->id :$order->get_id())) {419 if ($this->has_subscription($order->get_id())) { 417 420 $metadata += array( 418 421 'payment_type' => 'recurring', … … 447 450 WC_Yuansfer_Logger::log('Processing response: ' . print_r($response, true)); 448 451 449 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id :$order->get_id();452 $order_id = $order->get_id(); 450 453 451 454 $captured = (isset($response->captured) && $response->captured) ? 'yes' : 'no'; 452 455 453 456 // Store charge data. 454 WC_Yuansfer_Helper::is_pre_30() ? update_post_meta($order_id, '_yuansfer_charge_captured', $captured) :$order->update_meta_data('_yuansfer_charge_captured', $captured);457 $order->update_meta_data('_yuansfer_charge_captured', $captured); 455 458 456 459 // Store other data such as fees. … … 475 478 */ 476 479 if ('pending' === $response->status) { 477 $order_stock_reduced = WC_Yuansfer_Helper::is_pre_30() ? get_post_meta($order_id, '_order_stock_reduced', true) :$order->get_meta('_order_stock_reduced', true);480 $order_stock_reduced = $order->get_meta('_order_stock_reduced', true); 478 481 479 482 if (!$order_stock_reduced) { 480 WC_Yuansfer_Helper::is_pre_30() ? $order->reduce_order_stock() :wc_reduce_stock_levels($order_id);483 wc_reduce_stock_levels($order_id); 481 484 } 482 485 483 WC_Yuansfer_Helper::is_pre_30() ? update_post_meta($order_id, '_transaction_id', $response->id) :$order->set_transaction_id($response->id);486 $order->set_transaction_id($response->id); 484 487 /* translators: transaction id */ 485 488 $order->update_status('on-hold', sprintf(__('Yuansfer charge awaiting payment: %s.', 'woocommerce-yuansfer'), $response->id)); … … 500 503 } 501 504 } else { 502 WC_Yuansfer_Helper::is_pre_30() ? update_post_meta($order_id, '_transaction_id', $response->id) :$order->set_transaction_id($response->id);505 $order->set_transaction_id($response->id); 503 506 504 507 if ($order->has_status(array('pending', 'failed'))) { 505 WC_Yuansfer_Helper::is_pre_30() ? $order->reduce_order_stock() :wc_reduce_stock_levels($order_id);508 wc_reduce_stock_levels($order_id); 506 509 } 507 510 … … 536 539 * 537 540 * @param object $order 538 * @return object$details541 * @return array $details 539 542 */ 540 543 public function get_owner_details($order) { 541 $billing_first_name = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_first_name : $order->get_billing_first_name(); 542 $billing_last_name = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_last_name : $order->get_billing_last_name(); 543 544 $details = array(); 545 546 $name = $billing_first_name . ' ' . $billing_last_name; 547 $email = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_email : $order->get_billing_email(); 548 $phone = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_phone : $order->get_billing_phone(); 544 $details = array( 545 'firstName' => $order->get_billing_first_name(), 546 'lastName' => $order->get_billing_last_name(), 547 'customerCode' => $order->get_customer_id(), 548 'street' => $order->get_billing_address_1() . ' ' . $order->get_billing_address_2(), 549 'city' => $order->get_billing_city(), 550 'state' => $order->get_billing_state(), 551 'country' => $order->get_billing_country(), 552 'zip' => $order->get_billing_postcode(), 553 ); 554 555 $email = $order->get_billing_email(); 556 $phone = $order->get_billing_phone(); 557 $company = $order->get_billing_company(); 558 559 if (!empty($email)) { 560 $details['email'] = $email; 561 } 549 562 550 563 if (!empty($phone)) { 551 $details['phone'] = $phone; 552 } 553 554 if (!empty($name)) { 555 $details['name'] = $name; 556 } 557 558 if (!empty($email)) { 559 $details['email'] = $email; 560 } 561 562 $details['address']['line1'] = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_address_1 : $order->get_billing_address_1(); 563 $details['address']['line2'] = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_address_2 : $order->get_billing_address_2(); 564 $details['address']['state'] = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_state : $order->get_billing_state(); 565 $details['address']['city'] = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_city : $order->get_billing_city(); 566 $details['address']['postal_code'] = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_postcode : $order->get_billing_postcode(); 567 $details['address']['country'] = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_country : $order->get_billing_country(); 568 569 return (object) apply_filters('wc_yuansfer_owner_details', $details, $order); 564 $details['phone'] = $phone; 565 } 566 567 if (!empty($company)) { 568 $details['company'] = $company; 569 } 570 571 572 573 return $details; 570 574 } 571 575 … … 694 698 695 699 if ($order) { 696 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id :$order->get_id();700 $order_id = $order->get_id(); 697 701 698 702 $yuansfer_customer_id = get_post_meta($order_id, '_yuansfer_customer_id', true); … … 702 706 } 703 707 704 $source_id = WC_Yuansfer_Helper::is_pre_30() ? get_post_meta($order_id, '_yuansfer_source_id', true) :$order->get_meta('_yuansfer_source_id', true);708 $source_id = $order->get_meta('_yuansfer_source_id', true); 705 709 706 710 // Since 4.0.0, we changed card to source so we need to account for that. 707 711 if (empty($source_id)) { 708 $source_id = WC_Yuansfer_Helper::is_pre_30() ? get_post_meta($order_id, '_yuansfer_card_id', true) :$order->get_meta('_yuansfer_card_id', true);712 $source_id = $order->get_meta('_yuansfer_card_id', true); 709 713 710 714 // Take this opportunity to update the key name. 711 WC_Yuansfer_Helper::is_pre_30() ? update_post_meta($order_id, '_yuansfer_source_id', $source_id) :$order->update_meta_data('_yuansfer_source_id', $source_id);715 $order->update_meta_data('_yuansfer_source_id', $source_id); 712 716 713 717 if (is_callable(array($order, 'save'))) { … … 743 747 */ 744 748 public function save_source_to_order($order, $source) { 745 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id : $order->get_id();746 747 749 // Store source in the order. 748 750 if ($source->customer) { 749 if (WC_Yuansfer_Helper::is_pre_30()) { 750 update_post_meta($order_id, '_yuansfer_customer_id', $source->customer); 751 } else { 752 $order->update_meta_data('_yuansfer_customer_id', $source->customer); 753 } 754 } 755 756 if ($source->source) { 757 if (WC_Yuansfer_Helper::is_pre_30()) { 758 update_post_meta($order_id, '_yuansfer_source_id', $source->source); 759 } else { 760 $order->update_meta_data('_yuansfer_source_id', $source->source); 761 } 751 $order->update_meta_data('_yuansfer_customer_id', $source->customer); 762 752 } 763 753 … … 775 765 */ 776 766 public function update_fees($order, $balance_transaction_id) { 777 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id :$order->get_id();767 $order_id = $order->get_id(); 778 768 779 769 $balance_transaction = WC_Yuansfer_API::retrieve('balance/history/' . $balance_transaction_id); … … 813 803 */ 814 804 public function update_currency($order, $balance_transaction_id) { 815 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id :$order->get_id();805 $order_id = $order->get_id(); 816 806 817 807 $balance_transaction = WC_Yuansfer_API::retrieve('balance/history/' . $balance_transaction_id); … … 848 838 $request['storeNo'] = $this->store_no; 849 839 850 if (WC_Yuansfer_Helper::is_pre_30()) { 851 $request['reference'] = get_post_meta($order_id, '_yuansfer_reference', true); 852 $order_currency = get_post_meta($order_id, '_order_currency', true); 853 } else { 854 $request['reference'] = $order->get_meta('_yuansfer_reference', true); 855 $order_currency = $order->get_currency(); 856 } 857 858 if (!is_null($amount)) { 859 $request['amount'] = WC_Yuansfer_Helper::get_yuansfer_amount($amount, $order_currency); 860 } 861 862 if (!empty($this->manager_no)) { 863 $request['managerAccountNo'] = $this->manager_no; 864 $request['password'] = $this->manager_password; 840 $request['reference'] = $order->get_meta('_yuansfer_reference', true); 841 $currency = $order->get_currency(); 842 if (!$currency) { 843 $currency = get_woocommerce_currency(); 865 844 } 845 $request['currency'] = $currency; 846 847 if (is_null($amount)) { 848 $amount = $order->get_total(); 849 } 850 $request['refundAmount'] = WC_Yuansfer_Helper::get_yuansfer_amount($amount, $currency); 866 851 867 852 WC_Yuansfer_Logger::log("Info: Beginning refund for order {$order->get_transaction_id()} for the amount of {$amount}"); … … 869 854 $request = apply_filters('wc_yuansfer_refund_request', $request, $order); 870 855 871 $response = WC_Yuansfer_API::request($request, 'securepayRefund');856 $response = WC_Yuansfer_API::request($request, WC_Yuansfer_API::REFUND); 872 857 873 858 if (empty($response->ret_code) || $response->ret_code !== '000100') { … … 879 864 if (!empty($response->result->refundTransactionId)) { 880 865 $newId = $response->result->refundTransactionId; 881 WC_Yuansfer_Helper::is_pre_30() ? update_post_meta($order_id, '_yuansfer_refund_id', $newId) :$order->update_meta_data('_yuansfer_refund_id', $newId);866 $order->update_meta_data('_yuansfer_refund_id', $newId); 882 867 883 868 /* translators: 1) dollar amount 2) transaction id 3) refund message */ -
woo-yuansfer/trunk/includes/admin/class-wc-yuansfer-admin-notices.php
r2141376 r2436825 70 70 return array( 71 71 'Alipay' => 'WC_Gateway_Yuansfer_Alipay', 72 'WechatPay' => 'WC_Gateway_Yuansfer_Wechatpay', 72 'WechatPay' => 'WC_Gateway_Yuansfer_Wechatpay', 73 'CreditCard' => 'WC_Gateway_Yuansfer_Creditcard', 74 'PayPal' => 'WC_Gateway_Yuansfer_Paypal', 75 'Venmo' => 'WC_Gateway_Yuansfer_Venmo', 73 76 ); 74 77 } … … 187 190 update_option('wc_yuansfer_show_alipay_notice', 'no'); 188 191 break; 189 case 'WechatPay': 190 update_option('wc_yuansfer_show_wechatpay_notice', 'no'); 192 case 'WechatPay': 193 update_option('wc_yuansfer_show_wechatpay_notice', 'no'); 194 break; 195 case 'CreditCard': 196 update_option('wc_yuansfer_show_creditcard_notice', 'no'); 197 break; 198 case 'PayPal': 199 update_option('wc_yuansfer_show_paypal_notice', 'no'); 200 break; 201 case 'Venmo': 202 update_option('wc_yuansfer_show_venmo_notice', 'no'); 191 203 break; 192 204 } -
woo-yuansfer/trunk/includes/admin/yuansfer-alipay-settings.php
r2141376 r2436825 35 35 'desc_tip' => true, 36 36 ), 37 'settle_currency' => array( 38 'title' => __('Settle currency for CNY', 'woocommerce-yuansfer'), 39 'type' => 'select', 40 'description' => __('If the payment currency is "CNY", which currency is used for settlement.', 'woocommerce-yuansfer'), 41 'default' => 'USD', 42 'desc_tip' => true, 43 'options' => array( 44 'USD' => 'USD', 45 'GBP' => 'GBP', 46 ), 47 ), 37 48 ) 38 49 ); -
woo-yuansfer/trunk/includes/admin/yuansfer-settings.php
r2141376 r2436825 70 70 'desc_tip' => true, 71 71 ), 72 'manager_no' => array(73 'title' => __('Store Manager No', 'woocommerce-yuansfer'),74 'type' => 'text',75 'description' => __('Required when store manager validation is set for refund', 'woocommerce-yuansfer'),76 'default' => '',77 'desc_tip' => true,78 ),79 'manager_password' => array(80 'title' => __('Store Manager Password', 'woocommerce-yuansfer'),81 'type' => 'password',82 'description' => __('Store manager validation password.', 'woocommerce-yuansfer'),83 'default' => '',84 'desc_tip' => true,85 ),86 72 'logging' => array( 87 73 'title' => __('Logging', 'woocommerce-yuansfer'), -
woo-yuansfer/trunk/includes/admin/yuansfer-wechatpay-settings.php
r2141376 r2436825 25 25 'type' => 'text', 26 26 'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-yuansfer'), 27 'default' => __('We chat Pay (Yuansfer)', 'woocommerce-yuansfer'),27 'default' => __('WeChat Pay (Yuansfer)', 'woocommerce-yuansfer'), 28 28 'desc_tip' => true, 29 29 ), -
woo-yuansfer/trunk/includes/class-wc-gateway-yuansfer.php
r2141376 r2436825 73 73 $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); 74 74 $total = $order->get_total(); 75 $user_email = WC_Yuansfer_Helper::is_pre_30() ? $order->billing_email :$order->get_billing_email();75 $user_email = $order->get_billing_email(); 76 76 } else { 77 77 if ($user->ID) { … … 168 168 */ 169 169 public function create_source($order) { 170 $currency = WC_Yuansfer_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency(); 171 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id : $order->get_id(); 170 $currency = $order->get_currency(); 171 if (!$currency) { 172 $currency = get_woocommerce_currency(); 173 } 174 $order_id = $order->get_id(); 172 175 $return_url = $this->get_yuansfer_return_url($order); 173 176 $post_data = array(); 174 177 $post_data['merchantNo'] = $this->merchant_no; 175 178 $post_data['storeNo'] = $this->store_no; 176 $post_data['amount'] = WC_Yuansfer_Helper::get_yuansfer_amount($order->get_total(), $currency); 177 $post_data['currency'] = strtoupper($currency); 178 $post_data['vendor'] = 'unionpay'; 179 $post_data['reference'] = $order_id . ':' . uniqid('unionpay:'); 180 $post_data['ipnUrl'] = WC_Yuansfer_Helper::get_webhook_url(); 181 $post_data['callbackUrl'] = $return_url; 182 $post_data['terminal'] = 'ONLINE'; 179 $currency = strtoupper($currency); 180 181 $supportedCurrency = $this->get_supported_currency(); 182 if (!in_array($currency, $supportedCurrency, true)) { 183 throw new WC_Yuansfer_Exception('Union Pay only support "' . implode('", "', $supportedCurrency). '" for currency'); 184 } 185 186 $post_data['amount'] = WC_Yuansfer_Helper::get_yuansfer_amount($order->get_total(), $currency); 187 $post_data['currency'] = $currency; 188 $post_data['settleCurrency'] = 'USD'; 189 $post_data['vendor'] = 'unionpay'; 190 $post_data['reference'] = $order_id . ':' . uniqid('unionpay:'); 191 $post_data['ipnUrl'] = WC_Yuansfer_Helper::get_webhook_url(); 192 $post_data['callbackUrl'] = $return_url; 193 $post_data['terminal'] = $this->get_terminal(); 194 195 if ($post_data['terminal'] === 'WAP') { 196 $post_data['osType'] = $this->detect->is('iOS') ? 'IOS' : 'ANDROID'; 197 } 183 198 184 199 if (!empty($this->statement_descriptor)) { … … 188 203 WC_Yuansfer_Logger::log('Info: Begin creating UnionPay source'); 189 204 190 return WC_Yuansfer_API::request(apply_filters('wc_yuansfer_unionpay_source', $post_data, $order), 'securepay');205 return WC_Yuansfer_API::request(apply_filters('wc_yuansfer_unionpay_source', $post_data, $order), WC_Yuansfer_API::SECURE_PAY); 191 206 } 192 207 … … 209 224 $this->validate_minimum_order_amount($order); 210 225 211 // This comes from the create account checkbox in the checkout page. 212 $create_account = !empty($_POST['createaccount']) ? true : false; 213 214 if ($create_account) { 215 $new_customer_id = WC_Yuansfer_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(); 216 $new_yuansfer_customer = new WC_Yuansfer_Customer($new_customer_id); 217 $new_yuansfer_customer->create_customer(); 226 $response = $this->create_source($order); 227 228 if (empty($response->ret_code) || $response->ret_code !== '000100') { 229 $order->add_order_note($response->ret_msg); 230 231 throw new WC_Yuansfer_Exception($response->ret_msg); 218 232 } 219 220 $response = $this->create_source($order);221 222 if (\strpos($response, 'error') === 0) {223 $order->add_order_note($response);224 225 throw new WC_Yuansfer_Exception($response, $response);226 }227 228 if (WC_Yuansfer_Helper::is_pre_30()) {229 update_post_meta($order_id, '_yuansfer_response', $response);230 } else {231 $order->update_meta_data('_yuansfer_response', $response);232 $order->save();233 }234 235 $order->payment_complete();236 233 237 234 WC_Yuansfer_Logger::log('Info: Redirecting to UnionPay...'); … … 239 236 return array( 240 237 'result' => 'success', 241 'redirect' => WC_Yuansfer_Helper::get_redirect_url($order_id),238 'redirect' => $response->result->cashierUrl, 242 239 ); 243 240 } catch (WC_Yuansfer_Exception $e) { -
woo-yuansfer/trunk/includes/class-wc-yuansfer-api.php
r2141376 r2436825 12 12 13 13 const KEY = 'verifySign'; 14 const VERSION = 'v2'; 14 15 const SECURE_PAY = '/online/v3/secure-pay'; 16 const REFUND = '/app-data-search/v3/refund'; 17 const CUSTOMER_ADD = '/creditpay/v2/customer/add'; 18 const CUSTOMER_EDIT = '/creditpay/v2/customer/edit'; 15 19 16 20 /** 17 21 * Yuansfer API URL 18 22 */ 19 const PRODUCTION_URL = 'https://mapi.yuansfer.com /appTransaction';20 const TEST_URL = 'https://mapi.yuansfer.yunkeguan.com /appTransaction';23 const PRODUCTION_URL = 'https://mapi.yuansfer.com'; 24 const TEST_URL = 'https://mapi.yuansfer.yunkeguan.com'; 21 25 22 26 /** … … 122 126 123 127 $verifySign = $params[static::KEY]; 128 unset($params[static::KEY]); 124 129 125 130 return $verifySign === static::generate_sign($params); … … 142 147 143 148 $response = wp_safe_remote_post( 144 self::get_url() . '/' . self::VERSION . '/' .$api,149 self::get_url() . $api, 145 150 array( 146 151 'method' => $method, … … 157 162 throw new WC_Yuansfer_Exception(print_r($response, true), __('There was a problem connecting to the Yuansfer API endpoint.', 'woocommerce-yuansfer')); 158 163 } 159 160 if ($api === 'securepay') {161 if (WC_Yuansfer_Helper::is_html((string)$response['body'])) {162 return $response['body'];163 } else {164 WC_Yuansfer_Logger::log('Error Response: ' . print_r($response['body']) . PHP_EOL . PHP_EOL . 'Failed request: ' . print_r(array(165 'api' => $api,166 'request' => $request,167 ), true ));168 169 if (WC_Yuansfer_Helper::is_json((string)$response['body'])) {170 $res_json = json_decode((string)$response['body']);171 $errmsg = $res_json->retMsg;172 } else {173 $errmsg = __('Internal Server Error.', 'woocommerce-yuansfer');174 }175 throw new WC_Yuansfer_Exception(print_r($response, true), $errmsg);176 }177 }178 164 179 165 return json_decode($response['body']); -
woo-yuansfer/trunk/includes/class-wc-yuansfer-customer.php
r2141376 r2436825 1 1 <?php 2 if ( !defined('ABSPATH')) {3 exit;2 if ( ! defined( 'ABSPATH' ) ) { 3 exit; 4 4 } 5 5 … … 11 11 class WC_Yuansfer_Customer { 12 12 13 /** 14 * Yuansfer customer ID 15 * @var string 16 */ 17 private $id = ''; 18 19 /** 20 * WP User ID 21 * @var integer 22 */ 23 private $user_id = 0; 24 25 /** 26 * Data from API 27 * @var array 28 */ 29 private $customer_data = array(); 30 31 /** 32 * Constructor 33 * @param int $user_id The WP user ID 34 */ 35 public function __construct($user_id = 0) { 36 if ($user_id) { 37 $this->set_user_id($user_id); 38 $this->set_id(get_user_meta($user_id, '_yuansfer_customer_id', true)); 39 } 40 } 41 42 /** 43 * Get Yuansfer customer ID. 44 * @return string 45 */ 46 public function get_id() { 47 return $this->id; 48 } 49 50 /** 51 * Set Yuansfer customer ID. 52 * @param [type] $id [description] 53 */ 54 public function set_id($id) { 55 // Backwards compat for customer ID stored in array format. (Pre 3.0) 56 if (is_array($id) && isset($id['customer_id'])) { 57 $id = $id['customer_id']; 58 59 update_user_meta($this->get_user_id(), '_yuansfer_customer_id', $id); 60 } 61 62 $this->id = wc_clean($id); 63 } 64 65 /** 66 * User ID in WordPress. 67 * @return int 68 */ 69 public function get_user_id() { 70 return absint($this->user_id); 71 } 72 73 /** 74 * Set User ID used by WordPress. 75 * @param int $user_id 76 */ 77 public function set_user_id($user_id) { 78 $this->user_id = absint($user_id); 79 } 80 81 /** 82 * Get user object. 83 * @return WP_User 84 */ 85 protected function get_user() { 86 return $this->get_user_id() ? get_user_by('id', $this->get_user_id()) : false; 87 } 88 89 /** 90 * Store data from the Yuansfer API about this customer 91 */ 92 public function set_customer_data($data) { 93 $this->customer_data = $data; 94 } 95 96 /** 97 * Create a customer via API. 98 * @param array $args 99 * @return WP_Error|int 100 */ 101 public function create_customer($args = array()) { 102 $billing_email = isset($_POST['billing_email']) ? filter_var($_POST['billing_email'], FILTER_SANITIZE_EMAIL) : ''; 103 $user = $this->get_user(); 104 105 if ($user) { 106 $billing_first_name = get_user_meta($user->ID, 'billing_first_name', true); 107 $billing_last_name = get_user_meta($user->ID, 'billing_last_name', true); 108 $description = __('Name', 'woocommerce-yuansfer') . ': ' . $billing_first_name . ' ' . $billing_last_name . ' ' . __('Username', 'woocommerce-yuansfer') . ': ' . $user->user_login; 109 110 $defaults = array( 111 'email' => $user->user_email, 112 'description' => $description, 113 ); 114 } else { 115 $defaults = array( 116 'email' => $billing_email, 117 'description' => '', 118 ); 119 } 120 121 $metadata = array(); 122 123 $defaults['metadata'] = apply_filters('wc_yuansfer_customer_metadata', $metadata, $user); 124 125 $args = wp_parse_args($args, $defaults); 126 $response = WC_Yuansfer_API::request(apply_filters('wc_yuansfer_create_customer_args', $args), 'customers'); 127 128 if (!empty($response->error)) { 129 throw new WC_Yuansfer_Exception(print_r($response, true), $response->error->message); 130 } 131 132 $this->set_id($response->id); 133 $this->clear_cache(); 134 $this->set_customer_data($response); 135 136 if ($this->get_user_id()) { 137 update_user_meta($this->get_user_id(), '_yuansfer_customer_id', $response->id); 138 } 139 140 do_action('woocommerce_yuansfer_add_customer', $args, $response); 141 142 return $response->id; 143 } 144 145 /** 146 * Checks to see if error is of invalid request 147 * error and it is no such customer. 148 * 149 * @param array $error 150 */ 151 public function is_no_such_customer_error($error) { 152 return ( 153 $error && 154 'invalid_request_error' === $error->type && 155 preg_match('/No such customer/i', $error->message) 156 ); 157 } 158 159 /** 160 * Add a source for this yuansfer customer. 161 * @param string $source_id 162 * @param bool $retry 163 * @return WP_Error|int 164 */ 165 public function add_source($source_id, $retry = true) { 166 if (!$this->get_id()) { 167 $this->set_id($this->create_customer()); 168 } 169 170 $response = WC_Yuansfer_API::request(array( 171 'source' => $source_id, 172 ), 'customers/' . $this->get_id() . '/sources'); 173 174 $wc_token = false; 175 176 if (!empty($response->error)) { 177 // It is possible the WC user once was linked to a customer on Yuansfer 178 // but no longer exists. Instead of failing, lets try to create a 179 // new customer. 180 if ($this->is_no_such_customer_error($response->error)) { 181 delete_user_meta($this->get_user_id(), '_yuansfer_customer_id'); 182 $this->create_customer(); 183 return $this->add_source($source_id, false); 184 } else { 185 return $response; 186 } 187 } elseif (empty($response->id)) { 188 return new WP_Error('error', __('Unable to add payment source.', 'woocommerce-yuansfer')); 189 } 190 191 // Add token to WooCommerce. 192 if ($this->get_user_id() && class_exists('WC_Payment_Token_CC')) { 193 if (!empty($response->type)) { 194 switch ($response->type) { 195 case 'alipay': 196 break; 197 default: 198 if ('source' === $response->object && 'card' === $response->type) { 199 $wc_token = new WC_Payment_Token_CC(); 200 $wc_token->set_token($response->id); 201 $wc_token->set_gateway_id('yuansfer'); 202 $wc_token->set_card_type(strtolower($response->card->brand)); 203 $wc_token->set_last4($response->card->last4); 204 $wc_token->set_expiry_month($response->card->exp_month); 205 $wc_token->set_expiry_year($response->card->exp_year); 206 } 207 break; 208 } 209 } else { 210 // Legacy. 211 $wc_token = new WC_Payment_Token_CC(); 212 $wc_token->set_token($response->id); 213 $wc_token->set_gateway_id('yuansfer'); 214 $wc_token->set_card_type(strtolower($response->brand)); 215 $wc_token->set_last4($response->last4); 216 $wc_token->set_expiry_month($response->exp_month); 217 $wc_token->set_expiry_year($response->exp_year); 218 } 219 220 $wc_token->set_user_id($this->get_user_id()); 221 $wc_token->save(); 222 } 223 224 $this->clear_cache(); 225 226 do_action('woocommerce_yuansfer_add_source', $this->get_id(), $wc_token, $response, $source_id); 227 228 return $response->id; 229 } 230 231 /** 232 * Get a customers saved sources using their Yuansfer ID. 233 * 234 * @param string $customer_id 235 * @return array 236 */ 237 public function get_sources() { 238 if (!$this->get_id()) { 239 return array(); 240 } 241 242 $sources = get_transient('yuansfer_sources_' . $this->get_id()); 243 244 $response = WC_Yuansfer_API::request(array( 245 'limit' => 100, 246 ), 'customers/' . $this->get_id() . '/sources', 'GET'); 247 248 if (!empty($response->error)) { 249 return array(); 250 } 251 252 if (is_array($response->data)) { 253 $sources = $response->data; 254 } 255 256 return empty($sources) ? array() : $sources; 257 } 258 259 /** 260 * Delete a source from yuansfer. 261 * @param string $source_id 262 */ 263 public function delete_source($source_id) { 264 if (!$this->get_id()) { 265 return false; 266 } 267 268 $response = WC_Yuansfer_API::request(array(), 'customers/' . $this->get_id() . '/sources/' . sanitize_text_field($source_id), 'DELETE'); 269 270 $this->clear_cache(); 271 272 if (empty($response->error)) { 273 do_action('wc_yuansfer_delete_source', $this->get_id(), $response); 274 275 return true; 276 } 277 278 return false; 279 } 280 281 /** 282 * Set default source in Yuansfer 283 * @param string $source_id 284 */ 285 public function set_default_source($source_id) { 286 $response = WC_Yuansfer_API::request(array( 287 'default_source' => sanitize_text_field($source_id), 288 ), 'customers/' . $this->get_id(), 'POST'); 289 290 $this->clear_cache(); 291 292 if (empty($response->error)) { 293 do_action('wc_yuansfer_set_default_source', $this->get_id(), $response); 294 295 return true; 296 } 297 298 return false; 299 } 300 301 /** 302 * Deletes caches for this users cards. 303 */ 304 public function clear_cache() { 305 delete_transient('yuansfer_sources_' . $this->get_id()); 306 delete_transient('yuansfer_customer_' . $this->get_id()); 307 $this->customer_data = array(); 308 } 13 /** 14 * Yuansfer customer ID 15 * @var string 16 */ 17 private $id = ''; 18 19 /** 20 * WP User ID 21 * @var integer 22 */ 23 private $user_id = 0; 24 25 /** 26 * Data from API 27 * @var array 28 */ 29 private $customer_data = array(); 30 31 public $merchant_no; 32 public $store_no; 33 34 /** 35 * Constructor 36 * @param int $user_id The WP user ID 37 */ 38 public function __construct( $user_id = 0 ) { 39 if ( $user_id ) { 40 $this->set_user_id( $user_id ); 41 $this->set_id( $this->get_id_from_meta( $user_id ) ); 42 } 43 44 $main_settings = get_option('woocommerce_yuansfer_settings'); 45 $this->merchant_no = !empty($main_settings['merchant_no']) ? $main_settings['merchant_no'] : ''; 46 $this->store_no = !empty($main_settings['store_no']) ? $main_settings['store_no'] : ''; 47 } 48 49 /** 50 * Get Yuansfer customer ID. 51 * @return string 52 */ 53 public function get_id() { 54 return $this->id; 55 } 56 57 /** 58 * Set Yuansfer customer ID. 59 * @param [type] $id [description] 60 */ 61 public function set_id( $id ) { 62 // Backwards compat for customer ID stored in array format. (Pre 3.0) 63 if ( is_array( $id ) && isset( $id['customer_id'] ) ) { 64 $id = $id['customer_id']; 65 66 $this->update_id_in_meta( $id ); 67 } 68 69 $this->id = wc_clean( $id ); 70 } 71 72 /** 73 * User ID in WordPress. 74 * @return int 75 */ 76 public function get_user_id() { 77 return absint( $this->user_id ); 78 } 79 80 /** 81 * Set User ID used by WordPress. 82 * @param int $user_id 83 */ 84 public function set_user_id( $user_id ) { 85 $this->user_id = absint( $user_id ); 86 } 87 88 /** 89 * Get user object. 90 * @return WP_User 91 */ 92 protected function get_user() { 93 return $this->get_user_id() ? get_user_by( 'id', $this->get_user_id() ) : false; 94 } 95 96 /** 97 * Store data from the Yuansfer API about this customer 98 */ 99 public function set_customer_data( $data ) { 100 $this->customer_data = $data; 101 } 102 103 /** 104 * Generates the customer request, used for both creating and updating customers. 105 * 106 * @param array $args Additional arguments (optional). 107 * @return array 108 */ 109 protected function generate_customer_request( $args = array() ) { 110 $args += array( 111 'merchantNo' => $this->merchant_no, 112 'storeNo' => $this->store_no, 113 ); 114 115 return $args; 116 } 117 118 /** 119 * Create a customer via API. 120 * @param array $args 121 * @return WP_Error|int 122 */ 123 public function create_customer($args) { 124 $args['groupCode'] = 'HPP'; 125 $args = $this->generate_customer_request( $args ); 126 $response = WC_Yuansfer_API::request( $args, WC_Yuansfer_API::CUSTOMER_ADD ); 127 128 if ( empty( $response->ret_code ) || $response->ret_code !== '000100' ) { 129 throw new WC_Yuansfer_Exception( print_r( $response, true ), $response->error->message ); 130 } 131 132 $customer = $response->customerInfo; 133 134 $this->set_id( $customer->customerNo ); 135 $this->clear_cache(); 136 $this->set_customer_data( $customer ); 137 138 if ( $this->get_user_id() ) { 139 $this->update_id_in_meta( $customer->customerNo ); 140 } 141 142 do_action( 'woocommerce_yuansfer_add_customer', $args, $response ); 143 144 return $customer->customerNo; 145 } 146 147 /** 148 * Updates the Yuansfer customer through the API. 149 * 150 * @param array $args 151 * @param bool $is_retry Whether the current call is a retry (optional, defaults to false). If true, then an exception will be thrown instead of further retries on error. 152 * 153 * @return string Customer ID 154 * 155 * @throws WC_Yuansfer_Exception 156 */ 157 public function update_customer( $args, $is_retry = false ) { 158 if ( empty( $this->get_id() ) ) { 159 throw new WC_Yuansfer_Exception( 'id_required_to_update_user', __( 'Attempting to update a Yuansfer customer without a customer ID.', 'woocommerce-gateway-yuansfer' ) ); 160 } 161 162 $args['customerNo'] = $this->get_id(); 163 $args = $this->generate_customer_request($args); 164 $response = WC_Yuansfer_API::request( $args, WC_Yuansfer_API::CUSTOMER_EDIT ); 165 166 if ( empty( $response->ret_code ) || $response->ret_code !== '000100' ) { 167 if ( ! $is_retry && $this->is_no_such_customer_error( $response->ret_msg ) ) { 168 // This can happen when switching the main Yuansfer account or importing users from another site. 169 // If not already retrying, recreate the customer and then try updating it again. 170 $this->recreate_customer(); 171 return $this->update_customer( $args, true ); 172 } 173 174 throw new WC_Yuansfer_Exception( $response->ret_msg ); 175 } 176 177 $this->clear_cache(); 178 $this->set_customer_data( $response->customerInfo ); 179 180 do_action( 'woocommerce_yuansfer_update_customer', $args, $response ); 181 182 return $this->get_id(); 183 } 184 185 /** 186 * Checks to see if error is of invalid request 187 * error and it is no such customer. 188 * 189 * @since 4.1.2 190 * @param array $error 191 */ 192 public function is_no_such_customer_error( $error ) { 193 return ( 194 $error && 195 preg_match( '/No such customer/i', $error ) 196 ); 197 } 198 199 /** 200 * Deletes caches for this users cards. 201 */ 202 public function clear_cache() { 203 delete_transient( 'yuansfer_customer_' . $this->get_id() ); 204 $this->customer_data = array(); 205 } 206 207 /** 208 * Retrieves the Yuansfer Customer ID from the user meta. 209 * 210 * @param int $user_id The ID of the WordPress user. 211 * @return string|bool Either the Yuansfer ID or false. 212 */ 213 public function get_id_from_meta( $user_id ) { 214 return get_user_option( '_yuansfer_customer_id', $user_id ); 215 } 216 217 /** 218 * Updates the current user with the right Yuansfer ID in the meta table. 219 * 220 * @param string $id The Yuansfer customer ID. 221 */ 222 public function update_id_in_meta( $id ) { 223 update_user_option( $this->get_user_id(), '_yuansfer_customer_id', $id, false ); 224 } 225 226 /** 227 * Deletes the user ID from the meta table with the right key. 228 */ 229 public function delete_id_from_meta() { 230 delete_user_option( $this->get_user_id(), '_yuansfer_customer_id', false ); 231 } 232 233 /** 234 * Recreates the customer for this user. 235 * 236 * @return string ID of the new Customer object. 237 */ 238 private function recreate_customer() { 239 $this->delete_id_from_meta(); 240 return $this->create_customer(); 241 } 309 242 } -
woo-yuansfer/trunk/includes/class-wc-yuansfer-helper.php
r2141376 r2436825 25 25 } 26 26 27 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id : $order->get_id(); 28 29 return WC_Yuansfer_Helper::is_pre_30() ? get_post_meta($order_id, self::META_NAME_YUANSFER_CURRENCY, true) : $order->get_meta(self::META_NAME_YUANSFER_CURRENCY, true); 27 return $order->get_meta(self::META_NAME_YUANSFER_CURRENCY, true); 30 28 } 31 29 … … 41 39 } 42 40 43 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id : $order->get_id(); 44 45 WC_Yuansfer_Helper::is_pre_30() ? update_post_meta($order_id, self::META_NAME_YUANSFER_CURRENCY, $currency) : $order->update_meta_data(self::META_NAME_YUANSFER_CURRENCY, $currency); 41 $order->update_meta_data(self::META_NAME_YUANSFER_CURRENCY, $currency); 46 42 } 47 43 … … 57 53 } 58 54 59 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id : $order->get_id(); 60 61 $amount = WC_Yuansfer_Helper::is_pre_30() ? get_post_meta($order_id, self::META_NAME_FEE, true) : $order->get_meta(self::META_NAME_FEE, true); 55 $amount = $order->get_meta(self::META_NAME_FEE, true); 62 56 63 57 // If not found let's check for legacy name. 64 58 if (empty($amount)) { 65 $amount = WC_Yuansfer_Helper::is_pre_30() ? get_post_meta($order_id, self::LEGACY_META_NAME_FEE, true) :$order->get_meta(self::LEGACY_META_NAME_FEE, true);59 $amount = $order->get_meta(self::LEGACY_META_NAME_FEE, true); 66 60 67 61 // If found update to new name. … … 85 79 } 86 80 87 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id : $order->get_id(); 88 89 WC_Yuansfer_Helper::is_pre_30() ? update_post_meta($order_id, self::META_NAME_FEE, $amount) : $order->update_meta_data(self::META_NAME_FEE, $amount); 81 $order->update_meta_data(self::META_NAME_FEE, $amount); 90 82 } 91 83 … … 100 92 } 101 93 102 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id :$order->get_id();94 $order_id = $order->get_id(); 103 95 104 96 delete_post_meta($order_id, self::META_NAME_FEE); … … 117 109 } 118 110 119 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id : $order->get_id(); 120 121 $amount = WC_Yuansfer_Helper::is_pre_30() ? get_post_meta($order_id, self::META_NAME_NET, true) : $order->get_meta(self::META_NAME_NET, true); 111 $amount = $order->get_meta(self::META_NAME_NET, true); 122 112 123 113 // If not found let's check for legacy name. 124 114 if (empty($amount)) { 125 $amount = WC_Yuansfer_Helper::is_pre_30() ? get_post_meta($order_id, self::LEGACY_META_NAME_NET, true) :$order->get_meta(self::LEGACY_META_NAME_NET, true);115 $amount = $order->get_meta(self::LEGACY_META_NAME_NET, true); 126 116 127 117 // If found update to new name. … … 145 135 } 146 136 147 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id : $order->get_id(); 148 149 WC_Yuansfer_Helper::is_pre_30() ? update_post_meta($order_id, self::META_NAME_NET, $amount) : $order->update_meta_data(self::META_NAME_NET, $amount); 137 $order->update_meta_data(self::META_NAME_NET, $amount); 150 138 } 151 139 … … 160 148 } 161 149 162 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id :$order->get_id();150 $order_id = $order->get_id(); 163 151 164 152 delete_post_meta($order_id, self::META_NAME_NET); … … 320 308 } 321 309 322 /**323 * Check if WC version is pre 3.0.324 *325 * @return bool326 */327 public static function is_pre_30() {328 return version_compare(WC_VERSION, '3.0.0', '<');329 }330 331 310 /** 332 311 * Checks if WC version is less than passed in version. -
woo-yuansfer/trunk/includes/class-wc-yuansfer-order-handler.php
r2141376 r2436825 113 113 // Customer param wrong? The user may have been deleted on yuansfer's end. Remove customer_id. Can be retried without. 114 114 if ($this->is_no_such_customer_error($response->error)) { 115 if (WC_Yuansfer_Helper::is_pre_30()) { 116 delete_user_meta($order->customer_user, '_yuansfer_customer_id'); 117 delete_post_meta($order_id, '_yuansfer_customer_id'); 118 } else { 119 delete_user_meta($order->get_customer_id(), '_yuansfer_customer_id'); 120 $order->delete_meta_data('_yuansfer_customer_id'); 121 $order->save(); 122 } 115 delete_user_meta($order->get_customer_id(), '_yuansfer_customer_id'); 116 $order->delete_meta_data('_yuansfer_customer_id'); 117 $order->save(); 123 118 } 124 119 … … 206 201 $order = wc_get_order($order_id); 207 202 208 if ('yuansfer' === (WC_Yuansfer_Helper::is_pre_30() ? $order->payment_method : $order->get_payment_method())) {209 $charge = WC_Yuansfer_Helper::is_pre_30() ? get_post_meta($order_id, '_transaction_id', true) :$order->get_transaction_id();210 $captured = WC_Yuansfer_Helper::is_pre_30() ? get_post_meta($order_id, '_yuansfer_charge_captured', true) :$order->get_meta('_yuansfer_charge_captured', true);203 if ('yuansfer' === $order->get_payment_method()) { 204 $charge = $order->get_transaction_id(); 205 $captured = $order->get_meta('_yuansfer_charge_captured', true); 211 206 212 207 if ($charge && 'no' === $captured) { … … 228 223 /* translators: transaction id */ 229 224 $order->add_order_note(sprintf(__('Yuansfer charge complete (Charge ID: %s)', 'woocommerce-yuansfer'), $result->id)); 230 WC_Yuansfer_Helper::is_pre_30() ? update_post_meta($order_id, '_yuansfer_charge_captured', 'yes') :$order->update_meta_data('_yuansfer_charge_captured', 'yes');225 $order->update_meta_data('_yuansfer_charge_captured', 'yes'); 231 226 232 227 // Store other data such as fees 233 WC_Yuansfer_Helper::is_pre_30() ? update_post_meta($order_id, '_transaction_id', $result->id) :$order->set_transaction_id($result->id);228 $order->set_transaction_id($result->id); 234 229 235 230 if (isset($result->balance_transaction) && isset($result->balance_transaction->fee)) { … … 261 256 $order = wc_get_order($order_id); 262 257 263 if (strpos( WC_Yuansfer_Helper::is_pre_30() ? $order->payment_method :$order->get_payment_method(), 'yuansfer') === 0) {258 if (strpos($order->get_payment_method(), 'yuansfer') === 0) { 264 259 $this->process_refund($order_id); 265 260 -
woo-yuansfer/trunk/includes/class-wc-yuansfer-webhook-handler.php
r2141376 r2436825 60 60 } 61 61 62 $response = WC_Yuansfer_Helper::is_pre_30() ? get_post_meta($order_id, '_yuansfer_response', true) :$order->get_meta('_yuansfer_response', true);62 $response = $order->get_meta('_yuansfer_response', true); 63 63 64 64 if (!$response) { … … 80 80 81 81 if ($order) { 82 if (WC_Yuansfer_Helper::is_pre_30()) { 83 delete_post_meta($order_id, '_yuansfer_response'); 84 update_post_meta($order_id, '_yuansfer_reference', $reference); 85 } else { 86 $order->delete_meta_data('_yuansfer_response'); 87 $order->update_meta_data('_yuansfer_reference', $reference); 88 $order->save(); 89 } 82 $order->delete_meta_data('_yuansfer_response'); 83 $order->update_meta_data('_yuansfer_reference', $reference); 84 $order->save(); 90 85 } 91 86 … … 152 147 } 153 148 154 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id : $order->get_id();155 149 $status = $order->get_status(); 156 150 … … 160 154 161 155 // Store other data such as fees 162 WC_Yuansfer_Helper::is_pre_30() ? update_post_meta($order_id, '_transaction_id', $post['yuansferId']) :$order->set_transaction_id($post['yuansferId']);156 $order->set_transaction_id($post['yuansferId']); 163 157 164 158 $order->payment_complete($post['yuansferId']); 165 159 166 160 /* translators: transaction id */ 167 $order->add_order_note(sprintf(__('Yuansfer charge complete (ChargeID: %s)', 'woocommerce-yuansfer'), $post['yuansferId']));161 $order->add_order_note(sprintf(__('Yuansfer payment complete (Transaction ID: %s)', 'woocommerce-yuansfer'), $post['yuansferId'])); 168 162 169 163 if (is_callable(array($order, 'save'))) { -
woo-yuansfer/trunk/includes/compat/class-wc-yuansfer-pre-orders-compat.php
r2141376 r2436825 23 23 */ 24 24 public function remove_order_source_before_retry($order) { 25 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id :$order->get_id();25 $order_id = $order->get_id(); 26 26 delete_post_meta($order_id, '_yuansfer_source_id'); 27 27 // For BW compat will remove in the future. … … 34 34 */ 35 35 public function remove_order_customer_before_retry($order) { 36 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id :$order->get_id();36 $order_id = $order->get_id(); 37 37 delete_post_meta($order_id, '_yuansfer_customer_id'); 38 38 } -
woo-yuansfer/trunk/includes/payment-methods/class-wc-gateway-yuansfer-alipay.php
r2141376 r2436825 14 14 const ICON = 'alipay'; 15 15 16 protected $settle_currency_for_cny = 'USD'; 17 16 18 /** 17 19 * Constructor 18 20 */ 19 21 public function __construct() { 20 $this->id = 'yuansfer_alipay'; 21 $this->method_title = __('Yuansfer Alipay', 'woocommerce-yuansfer'); 22 $this->id = 'yuansfer_alipay'; 23 $this->method_title = __('Yuansfer Alipay', 'woocommerce-yuansfer'); 24 $this->settle_currency_for_cny = $this->get_option('settle_currency'); 22 25 23 26 parent::__construct(); … … 88 91 } 89 92 93 public function get_supported_currency() { 94 return apply_filters('wc_yuansfer_supported_currencies', array( 95 'USD', 'CNY', 'PHP', 'IDR', 'KRW', 'HKD', 'GBP' 96 )); 97 } 98 90 99 /** 91 100 * Creates the source for charge. … … 95 104 */ 96 105 public function create_source($order) { 97 $currency = WC_Yuansfer_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency(); 98 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id : $order->get_id(); 106 $currency = $order->get_currency(); 107 if (!$currency) { 108 $currency = get_woocommerce_currency(); 109 } 110 $order_id = $order->get_id(); 99 111 $return_url = $this->get_yuansfer_return_url($order); 100 112 $post_data = array(); 101 $post_data['merchantNo'] = $this->merchant_no;113 $post_data['merchantNo'] = $this->merchant_no; 102 114 $post_data['storeNo'] = $this->store_no; 103 $post_data['amount'] = WC_Yuansfer_Helper::get_yuansfer_amount($order->get_total(), $currency); 104 $post_data['currency'] = strtoupper($currency); 105 $post_data['vendor'] = 'alipay'; 106 $post_data['reference'] = $order_id . ':' . uniqid('alipay:'); 107 $post_data['ipnUrl'] = WC_Yuansfer_Helper::get_webhook_url(); 108 $post_data['callbackUrl'] = $return_url; 109 $post_data['terminal'] = 'ONLINE'; 115 $currency = strtoupper($currency); 116 $supportedCurrency = $this->get_supported_currency(); 117 if (in_array($currency, $supportedCurrency, true)) { 118 throw new WC_Yuansfer_Exception('Alipay only support "' . implode('", "', $supportedCurrency). '" for currency'); 119 } 120 121 $settleCurrency = 'USD'; 122 $amount = WC_Yuansfer_Helper::get_yuansfer_amount($order->get_total(), $currency); 123 124 switch ($currency) { 125 case 'PHP': 126 if ($amount < 1) { 127 throw new WC_Yuansfer_Exception('The minimum value is 1PHP'); 128 } 129 break; 130 131 case 'IDR': 132 if ($amount < 300) { 133 throw new WC_Yuansfer_Exception('The minimum value is 300IDR'); 134 } 135 break; 136 137 case 'KRW': 138 if ($amount < 50) { 139 throw new WC_Yuansfer_Exception('The minimum value is 50KRW'); 140 } 141 break; 142 143 case 'HKD': 144 if ($amount < 0.1) { 145 throw new WC_Yuansfer_Exception('The minimum value is 0.1HKD'); 146 } 147 break; 148 149 case 'GBP': 150 $settleCurrency = 'GBP'; 151 break; 152 153 case 'CNY': 154 if (in_array($this->settle_currency_for_cny, array('USD', 'GBP'), true)) { 155 $settleCurrency = $this->settle_currency_for_cny; 156 } 157 break; 158 } 159 160 $post_data['amount'] = $amount; 161 $post_data['currency'] = $currency; 162 $post_data['settleCurrency'] = $settleCurrency; 163 $post_data['vendor'] = 'alipay'; 164 $post_data['reference'] = $order_id . ':' . uniqid('alipay:'); 165 $post_data['ipnUrl'] = WC_Yuansfer_Helper::get_webhook_url(); 166 $post_data['callbackUrl'] = $return_url; 167 $post_data['terminal'] = $this->get_terminal(); 168 169 if ($post_data['terminal'] === 'WAP') { 170 $post_data['osType'] = $this->detect->is('iOS') ? 'IOS' : 'ANDROID'; 171 } 110 172 111 173 if (!empty($this->statement_descriptor)) { … … 115 177 WC_Yuansfer_Logger::log('Info: Begin creating Alipay source'); 116 178 117 return WC_Yuansfer_API::request(apply_filters('wc_yuansfer_alipay_source', $post_data, $order), 'securepay');179 return WC_Yuansfer_API::request(apply_filters('wc_yuansfer_alipay_source', $post_data, $order), WC_Yuansfer_API::SECURE_PAY); 118 180 } 119 181 … … 136 198 $this->validate_minimum_order_amount($order); 137 199 138 // This comes from the create account checkbox in the checkout page. 139 $create_account = !empty($_POST['createaccount']) ? true : false; 140 141 if ($create_account) { 142 $new_customer_id = WC_Yuansfer_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(); 143 $new_yuansfer_customer = new WC_Yuansfer_Customer($new_customer_id); 144 $new_yuansfer_customer->create_customer(); 200 $response = $this->create_source($order); 201 202 if (empty($response->ret_code) || $response->ret_code !== '000100') { 203 $order->add_order_note($response->ret_msg); 204 205 throw new WC_Yuansfer_Exception($response->ret_msg); 145 206 } 146 147 $response = $this->create_source($order);148 149 if (\strpos($response, 'error') === 0) {150 $order->add_order_note($response);151 152 throw new WC_Yuansfer_Exception($response, $response);153 }154 155 if (WC_Yuansfer_Helper::is_pre_30()) {156 update_post_meta($order_id, '_yuansfer_response', $response);157 } else {158 $order->update_meta_data('_yuansfer_response', $response);159 $order->save();160 }161 162 $order->payment_complete();163 207 164 208 WC_Yuansfer_Logger::log('Info: Redirecting to Alipay...'); … … 166 210 return array( 167 211 'result' => 'success', 168 'redirect' => WC_Yuansfer_Helper::get_redirect_url($order_id),212 'redirect' => $response->result->cashierUrl, 169 213 ); 170 214 } catch (WC_Yuansfer_Exception $e) { -
woo-yuansfer/trunk/includes/payment-methods/class-wc-gateway-yuansfer-wechatpay.php
r2141376 r2436825 93 93 */ 94 94 public function create_source($order) { 95 $currency = WC_Yuansfer_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency(); 96 $order_id = WC_Yuansfer_Helper::is_pre_30() ? $order->id : $order->get_id(); 95 $currency = $order->get_currency(); 96 if (!$currency) { 97 $currency = get_woocommerce_currency(); 98 } 99 $order_id = $order->get_id(); 97 100 $return_url = $this->get_yuansfer_return_url($order); 98 101 $post_data = array(); 99 102 $post_data['merchantNo'] = $this->merchant_no; 100 103 $post_data['storeNo'] = $this->store_no; 104 $currency = strtoupper($currency); 105 $supportedCurrency = $this->get_supported_currency(); 106 if (!in_array($currency, $supportedCurrency, true)) { 107 throw new WC_Yuansfer_Exception('WeChat Pay only support "' . implode('", "', $supportedCurrency). '" for currency'); 108 } 109 101 110 $post_data['amount'] = WC_Yuansfer_Helper::get_yuansfer_amount($order->get_total(), $currency); 102 $post_data['currency'] = strtoupper($currency); 111 $post_data['currency'] = $currency; 112 $post_data['settleCurrency'] = 'USD'; 103 113 $post_data['vendor'] = 'wechatpay'; 104 114 $post_data['reference'] = $order_id . ':' . uniqid('wechatpay:'); 105 115 $post_data['ipnUrl'] = WC_Yuansfer_Helper::get_webhook_url(); 106 116 $post_data['callbackUrl'] = $return_url; 107 $post_data['terminal'] = 'ONLINE'; 117 $post_data['terminal'] = $this->get_terminal(true); 118 119 if ($post_data['terminal'] === 'WAP' || $post_data['terminal'] === 'MWEB') { 120 $post_data['osType'] = $this->detect->is('iOS') ? 'IOS' : 'ANDROID'; 121 } 108 122 109 123 if (!empty($this->statement_descriptor)) { … … 113 127 WC_Yuansfer_Logger::log('Info: Begin creating WeChat Pay source'); 114 128 115 return WC_Yuansfer_API::request(apply_filters('wc_yuansfer_wechatpay_source', $post_data, $order), 'securepay');129 return WC_Yuansfer_API::request(apply_filters('wc_yuansfer_wechatpay_source', $post_data, $order), WC_Yuansfer_API::SECURE_PAY); 116 130 } 117 131 … … 134 148 $this->validate_minimum_order_amount($order); 135 149 136 // This comes from the create account checkbox in the checkout page.137 $create_account = !empty($_POST['createaccount']) ? true : false;138 139 if ($create_account) {140 $new_customer_id = WC_Yuansfer_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id();141 $new_yuansfer_customer = new WC_Yuansfer_Customer($new_customer_id);142 $new_yuansfer_customer->create_customer();143 }144 145 150 $response = $this->create_source($order); 146 151 147 if ( \strpos($response, 'error') === 0) {148 $order->add_order_note($response );152 if (empty($response->ret_code) || $response->ret_code !== '000100') { 153 $order->add_order_note($response->ret_msg); 149 154 150 throw new WC_Yuansfer_Exception($response , $response);155 throw new WC_Yuansfer_Exception($response->ret_msg); 151 156 } 152 153 if (WC_Yuansfer_Helper::is_pre_30()) {154 update_post_meta($order_id, '_yuansfer_response', $response);155 } else {156 $order->update_meta_data('_yuansfer_response', $response);157 $order->save();158 }159 160 $order->payment_complete();161 157 162 158 WC_Yuansfer_Logger::log('Info: Redirecting to Wechat Pay...'); … … 164 160 return array( 165 161 'result' => 'success', 166 'redirect' => WC_Yuansfer_Helper::get_redirect_url($order_id),162 'redirect' => $response->result->cashierUrl, 167 163 ); 168 164 } catch (WC_Yuansfer_Exception $e) { -
woo-yuansfer/trunk/uninstall.php
r2141376 r2436825 21 21 delete_option('wc_yuansfer_show_keys_notice'); 22 22 delete_option('wc_yuansfer_show_alipay_notice'); 23 delete_option('wc_yuansfer_show_wechatpay_notice'); 23 delete_option('wc_yuansfer_show_wechatpay_notice'); 24 delete_option('wc_yuansfer_show_creditcard_notice'); 25 delete_option('wc_yuansfer_show_paypal_notice'); 26 delete_option('wc_yuansfer_show_venmo_notice'); 24 27 delete_option('wc_yuansfer_version'); 25 28 delete_option('woocommerce_yuansfer_alipay_settings'); 26 delete_option('woocommerce_yuansfer_wechatpay_settings'); 29 delete_option('woocommerce_yuansfer_wechatpay_settings'); 30 delete_option('woocommerce_yuansfer_creditcard_settings'); 31 delete_option('woocommerce_yuansfer_paypal_settings'); 32 delete_option('woocommerce_yuansfer_venmo_settings'); 27 33 } -
woo-yuansfer/trunk/woocommerce-yuansfer.php
r2141376 r2436825 2 2 /* 3 3 * Plugin Name: WooCommerce Yuansfer 4 * Plugin URI: https://wordpress.org/plugins/woo commerce-yuansfer/4 * Plugin URI: https://wordpress.org/plugins/woo-yuansfer/ 5 5 * Description: Provides a Yuansfer Payment Gateway 6 * Author: FlyingHail7 * Author URI: https://www. flyinghail.net/8 * Version: 1.0.09 * WC requires at least: 2.610 * WC tested up to: 3.46 * Author: Yuansfer 7 * Author URI: https://www.yuansfer.com/ 8 * Version: 3.0.0 9 * WC requires at least: 3.0 10 * WC tested up to: 4.3 11 11 */ 12 12 … … 35 35 * Required minimums and constants 36 36 */ 37 define('WC_YUANSFER_VERSION', ' 1.0.0');37 define('WC_YUANSFER_VERSION', '3.0.0'); 38 38 define('WC_YUANSFER_MIN_PHP_VER', '5.6.0'); 39 define('WC_YUANSFER_MIN_WC_VER', ' 2.6.0');39 define('WC_YUANSFER_MIN_WC_VER', '3.0'); 40 40 define('WC_YUANSFER_MAIN_FILE', __FILE__); 41 41 define('WC_YUANSFER_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__)))); … … 112 112 require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-yuansfer-alipay.php'; 113 113 require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-yuansfer-wechatpay.php'; 114 require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-yuansfer-creditcard.php'; 115 require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-yuansfer-paypal.php'; 116 require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-yuansfer-venmo.php'; 114 117 require_once __DIR__ . '/includes/class-wc-yuansfer-order-handler.php'; 115 118 require_once __DIR__ . '/includes/class-wc-yuansfer-payment-tokens.php'; 116 119 require_once __DIR__ . '/includes/class-wc-yuansfer-customer.php'; 120 require_once __DIR__ . '/includes/class-wc-yuansfer-mobile-detect.php'; 117 121 118 122 if (is_admin()) { … … 180 184 $methods[] = 'WC_Gateway_Yuansfer_Alipay'; 181 185 $methods[] = 'WC_Gateway_Yuansfer_Wechatpay'; 182 186 $methods[] = 'WC_Gateway_Yuansfer_Creditcard'; 187 $methods[] = 'WC_Gateway_Yuansfer_Paypal'; 188 $methods[] = 'WC_Gateway_Yuansfer_Venmo'; 183 189 return $methods; 184 190 } … … 192 198 $sections['yuansfer'], 193 199 $sections['yuansfer_alipay'], 194 $sections['yuansfer_wechatpay'] 200 $sections['yuansfer_wechatpay'], 201 $sections['yuansfer_creditcard'], 202 $sections['yuansfer_paypal'], 203 $sections['yuansfer_venmo'] 195 204 ); 196 205 … … 198 207 $sections['yuansfer_alipay'] = __('Yuansfer Alipay', 'woocommerce-yuansfer'); 199 208 $sections['yuansfer_wechatpay'] = __('Yuansfer WeChat Pay', 'woocommerce-yuansfer'); 209 $sections['yuansfer_creditcard'] = __('Yuansfer Credit Card', 'woocommerce-yuansfer'); 210 $sections['yuansfer_paypal'] = __('Yuansfer PayPal', 'woocommerce-yuansfer'); 211 $sections['yuansfer_venmo'] = __('Yuansfer Venmo', 'woocommerce-yuansfer'); 200 212 201 213 return $sections;
Note: See TracChangeset
for help on using the changeset viewer.