Skip to content

Commit

Permalink
Merge pull request #12 from pointcheckout/develop
Browse files Browse the repository at this point in the history
Bugs relating to latest WooCommerce plugin + minor default text rewrite
  • Loading branch information
max2u committed Apr 21, 2021
2 parents 6395e33 + 841ff9d commit a9a5826
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 65 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@ public function __construct()
if (is_admin()) {
$this->has_fields = true;
$this->init_form_fields();
$this->init_settings();
}

// Define user set variables
$this->method_title = __('PointCheckout Card', 'woocommerce');
$this->method_description = __('Have your customers pay with credit or debit cards via PointCheckout', 'woocommerce');
$this->title = PointCheckout_Card_Config::getInstance()->getTitle() ;
$this->description = PointCheckout_Card_Config::getInstance()->getDescription();
$this->paymentService = PointCheckout_Card_Payment::getInstance();
$this->config = PointCheckout_Card_Config::getInstance();
$this->icon = plugin_dir_url(__FILE__) . '../assets/images/mc-visa-network-logos.png';

if ( !$this->config->isLiveMode() ) {
$this->description .= ' ' . sprintf( __( 'TEST MODE ENABLED. You can use test cards only. ' .
'See the <a href="%s" target="_blank">PointCheckout WooCommerce Guide</a> for more details.', 'woocommerce' ),
'https://docs.pointcheckout.com/guides/woocommerce#testcards' );
$this->description = trim( $this->description );
}

// Actions
add_action('woocommerce_receipt_' . $this->id, array($this, 'receipt_page'));
Expand All @@ -35,7 +45,7 @@ function process_admin_options()
{
$result = parent::process_admin_options();
$settings = $this->settings;
$settings['enabled'] = isset($settings['enabled']) ? $settings['enabled'] : 0;
$settings['enabled'] = isset($settings['enabled']) ? $settings['enabled'] : 'no';

update_option('woocommerce_pointcheckout_card_settings', apply_filters('woocommerce_settings_api_sanitized_fields_pointcheckout_card', $settings));
return $result;
Expand Down Expand Up @@ -102,7 +112,7 @@ public function admin_options()
{
?>
<h3><?php _e('PointCheckout Card Payment', 'pointcheckout_card'); ?></h3>
<p><?php _e('Please fill in the below section to start accepting payments on your site! You can find all the required information in your <a href="https://www.pointcheckout.com/" target="_blank">PointCheckout website</a>.', 'pointcheckout_card'); ?></p>
<p><?php _e('Please fill in the below section to start accepting payments on your site via PointCheckout! Learn more at <a href="https://docs.pointcheckout.com/" target="_blank">PointCheckout</a>.', 'pointcheckout_card'); ?></p>


<table class="form-table">
Expand All @@ -113,23 +123,23 @@ public function admin_options()
<script>
jQuery(document).ready(function() {
jQuery('[name=save]').click(function() {
if (!jQuery('#woocommerce_pointcheckout_card_Api_Key').val()) {
alert('Please enter your Api Key!');
if (!jQuery('#woocommerce_pointcheckout_card_api_key').val()) {
alert('API key not configured');
return false;
}
if (!jQuery('#woocommerce_pointcheckout_card_Api_Secret').val()) {
alert('Please enter your Api Secret!');
if (!jQuery('#woocommerce_pointcheckout_card_api_secret').val()) {
alert('API secret not configured');
return false;
}
if (jQuery('#woocommerce_pointcheckout_card_allow_specific').val() == 1) {
if (!jQuery('#woocommerce_pointcheckout_card_specific_countries').val()) {
alert('You select to specifiy for applicable countries but you did not select any!');
alert('You enabled PointCheckout for specific countries but you did not select any');
return false;
}
}
if (jQuery('#woocommerce_pointcheckout_card_allow_user_specific').val() == 1) {
if (!jQuery('#woocommerce_pointcheckout_card_specific_user_roles').val()) {
alert('You select to specifiy for applicable user roles but you did not select any!');
alert('You enabled PointCheckout for speficic user roles but you did not select any');
return false;
}
}
Expand All @@ -152,55 +162,51 @@ function init_form_fields()
{
$staging_enabled = false;
$this->form_fields = array(
'enabled' => array(
'enabled' => array(
'title' => __('Enable/Disable', 'pointcheckout_card'),
'type' => 'select',
'label' => __('Enable the PointCheckout gateway', 'pointcheckout_card'),
'default' => '0',
'options' => array(
'1' => __('Enabled', 'pointcheckout_card'),
'0' => __('Disabled', 'pointcheckout_card'),
)
'type' => 'checkbox',
'label' => __('Enable card payments via PointCheckout', 'pointcheckout_card'),
'default' => 'no'
),
'title' => array(
'title' => __('Title', 'pointcheckout_card'),
'type' => 'text',
'description' => __('This is the payment method title the user sees during checkout.', 'pointcheckout_card'),
'default' => __('Card', 'pointcheckout_card')
'default' => __('Credit Card (via PointCheckout)', 'pointcheckout_card')
),
'description' => array(
'title' => __('Description', 'pointcheckout_card'),
'type' => 'text',
'description' => __('This is the description the user sees during checkout.', 'pointcheckout_card'),
'default' => __('Pay using your card', 'pointcheckout_card')
'default' => __('Comoplete your purchase using a credit or debit card.', 'pointcheckout_card')
),
'mode' => array(
'title' => 'Mode',
'type' => 'select',
'options' => $staging_enabled ? array(
'1' => __('live', 'pointcheckout_card'),
'0' => __('testing', 'pointcheckout_card'),
'1' => __('Live', 'pointcheckout_card'),
'0' => __('Test', 'pointcheckout_card'),
'2' => __('Staging', 'pointcheckout_card'),
) : array(
'1' => 'live',
'0' => 'testing',
'1' => 'Live',
'0' => 'Test',
),
'default' => '0',
'desc_tip' => true,
'description' => sprintf(__('Logs additional information. <br>Log file path: %s', 'pointcheckout_card'), 'Your admin panel -> WooCommerce -> System Status -> Logs'),
'placeholder' => '',
'class' => 'wc-enhanced-select',
),
'Api_Key' => array(
'title' => __('Api Key', 'pointcheckout_card'),
'api_key' => array(
'title' => __('API Key', 'pointcheckout_card'),
'type' => 'text',
'description' => __('Your Api Key, you can find in your PointCheckout account settings.', 'pointcheckout_card'),
'default' => '',
'desc_tip' => true,
'placeholder' => ''
),
'Api_Secret' => array(
'title' => __('Api Secret', 'pointcheckout_card'),
'api_secret' => array(
'title' => __('API Secret', 'pointcheckout_card'),
'type' => 'text',
'description' => __('Your Api Secret, you can find in your PointCheckout account settings.', 'pointcheckout_card'),
'default' => '',
Expand Down Expand Up @@ -266,8 +272,8 @@ function process_payment($order_id)
{
$order = new WC_Order($order_id);
if (!isset($_GET['response_code'])) {
update_post_meta($order->id, '_payment_method_title', 'Card');
update_post_meta($order->id, '_payment_method', 'pointcheckout_card');
update_post_meta($order->get_id(), '_payment_method_title', 'Card');
update_post_meta($order->get_id(), '_payment_method', 'pointcheckout_card');
}
$form = $this->paymentService->getPaymentRequestForm();
$note = $this->paymentService->getOrderHistoryMessage($form['response']->result->id, 0, $form['response']->result->status, '');
Expand All @@ -287,7 +293,7 @@ public function process_response()
{

global $woocommerce;
//send the secound call to pointcheckout to confirm payment
//send the secound call to pointcheckout to confirm payment
$success = $this->paymentService->checkPaymentStatus();

$order = wc_get_order($_REQUEST['reference']);
Expand Down
26 changes: 8 additions & 18 deletions pointcheckout_payment_card/includes/lib/class-pc-config.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php



class PointCheckout_Card_Config extends PointCheckout_Card_Parent
{

private static $instance;
private $Api_Secret;
private $Api_Key;
private $api_Secret;
private $api_Key;
private $Mode;
private $orderPlacement;
private $allowSpecific;
Expand All @@ -17,16 +15,16 @@ class PointCheckout_Card_Config extends PointCheckout_Card_Parent
private $new_order_status;
public $description;
public $title;


public function __construct()
{
parent::__construct();
$this->language = $this->_getShoppingCartConfig('language');
$this->enabled = $this->_getShoppingCartConfig('enabled');
$this->Api_Key = $this->_getShoppingCartConfig('Api_Key');
$this->api_key = $this->_getShoppingCartConfig('api_key');
$this->command = $this->_getShoppingCartConfig('command');
$this->Api_Secret = $this->_getShoppingCartConfig('Api_Secret');
$this->api_secret = $this->_getShoppingCartConfig('api_secret');
$this->Mode = $this->_getShoppingCartConfig('mode');
$this->orderPlacement = $this->_getShoppingCartConfig('order_placement');
$this->allowSpecific = $this->_getShoppingCartConfig('allow_specific');
Expand Down Expand Up @@ -59,8 +57,6 @@ public function getLanguage()
return 'en';
}



public function getEnabled()
{
return $this->enabled;
Expand All @@ -71,17 +67,11 @@ public function getMode()
return $this->Mode;
}





public function getSuccessOrderStatusId()
{
return $this->successOrderStatusId;
}



public function isActive()
{
if ($this->active) {
Expand Down Expand Up @@ -141,17 +131,17 @@ public function orderPlacementIsOnSuccess()

public function isEnabled()
{
return $this->enabled == 1 ? true : false;
return $this->enabled === 'yes';
}

public function getApiKey()
{
return $this->Api_Key;
return $this->api_key;
}

public function getApiSecret()
{
return $this->Api_Secret;
return $this->api_secret;
}

public function isLiveMode()
Expand Down
12 changes: 6 additions & 6 deletions pointcheckout_payment_card/includes/lib/class-pc-order.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public function getSessionOrderId()
{
return WC()->session->get('order_awaiting_payment');
}

public function clearSessionCurrentOrder()
{
return WC()->session->__unset('order_awaiting_payment');
}


public function getOrderId()
{
Expand Down Expand Up @@ -63,7 +63,7 @@ public function getCustomerName()

public function getCurrencyCode()
{
return $this->order->get_order_currency();
return $this->order->get_currency();
}

public function getCurrencyValue()
Expand All @@ -79,15 +79,15 @@ public function getTotal()
public function getTaxAmount(){
return $this->order->get_total_tax();
}

public function getShippingAmount(){
return $this->order->get_shipping_total();
}

public function getSubtotal(){
return $this->order->get_subtotal();
}

public function getDiscountAmount(){
return $this->order->get_discount_total();
}
Expand Down
6 changes: 3 additions & 3 deletions pointcheckout_payment_card/woocommerce-pointcheckout-card.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

/* Plugin Name: PointCheckout Card Payment
* Description: PointCheckout card payment allows your customer to pay for there cart using cards
* Version: 1.0.0
* Description: Have your customers pay with credit or debit cards via PointCheckout
* Version: 2.0.4
* Author: PointCheckout
* Author URI: https://www.pointcheckout.com/
* Author URI: https://docs.pointcheckout.com/guides/woocommerce
*/
$active_plugins = apply_filters('active_plugins', get_option('active_plugins'));
if (in_array('woocommerce/woocommerce.php', $active_plugins)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ function process_payment($order_id)
{
$order = new WC_Order($order_id);
if (!isset($_GET['response_code'])) {
update_post_meta($order->id, '_payment_method_title', 'PointCheckout');
update_post_meta($order->id, '_payment_method', 'pointcheckout_rewards');
update_post_meta($order->get_id(), '_payment_method_title', 'PointCheckout');
update_post_meta($order->get_id(), '_payment_method', 'pointcheckout_rewards');
}
$form = $this->paymentService->getPaymentRequestForm();
$note = $this->paymentService->getOrderHistoryMessage($form['response']->result->id, 0, $form['response']->result->status, '');
Expand All @@ -282,7 +282,7 @@ public function process_response()
{

global $woocommerce;
//send the secound call to pointcheckout to confirm payment
//send the secound call to pointcheckout to confirm payment
$success = $this->paymentService->checkPaymentStatus();

$order = wc_get_order($_REQUEST['reference']);
Expand Down
12 changes: 6 additions & 6 deletions pointcheckout_payment_rewards/includes/lib/class-pc-order.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public function getSessionOrderId()
{
return WC()->session->get('order_awaiting_payment');
}

public function clearSessionCurrentOrder()
{
return WC()->session->__unset('order_awaiting_payment');
}


public function getOrderId()
{
Expand Down Expand Up @@ -63,7 +63,7 @@ public function getCustomerName()

public function getCurrencyCode()
{
return $this->order->get_order_currency();
return $this->order->get_currency();
}

public function getCurrencyValue()
Expand All @@ -79,15 +79,15 @@ public function getTotal()
public function getTaxAmount(){
return $this->order->get_total_tax();
}

public function getShippingAmount(){
return $this->order->get_shipping_total();
}

public function getSubtotal(){
return $this->order->get_subtotal();
}

public function getDiscountAmount(){
return $this->order->get_discount_total();
}
Expand Down

0 comments on commit a9a5826

Please sign in to comment.