Plugin Directory

Changeset 2162618


Ignore:
Timestamp:
09/25/2019 02:59:51 AM (7 years ago)
Author:
payadvantage
Message:
  • Fix validation of international phone numbers in Woo Commerce plug-in.
  • Minor bug fixes.
Location:
pay-advantage/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • pay-advantage/trunk/README.txt

    r2094189 r2162618  
    33Tags: payment, online payments, credit cards, bpay
    44Requires at least: 4.6
    5 Tested up to: 5.1
    6 Stable tag: 2.0.0
     5Tested up to: 5.2.3
     6Stable tag: 2.1.0
    77Requires PHP: 5.2.4
    88License: GPLv2 or later
     
    4747
    4848= 1.1.0 =
    49 * Multiple updates, bug fixes and general improvements. Please ensure you update to this version.
     49* Multiple updates, bug fixes and general improvements.
    5050
    5151= 2.0.0 =
    52 * Multiple updates, settings page improvements. Please ensure you update to this version.
     52* Multiple updates, settings page improvements.
     53
     54= 2.1.0 =
     55* Fix validation of international phone numbers in Woo Commerce plug-in.
     56* Minor bug fixes.
     57* Please ensure you update to this version.
  • pay-advantage/trunk/admin/options-ajax.php

    r2094189 r2162618  
    8383    $auth = new Pay_Advantage_Auth();
    8484
    85     // TODO: Sanitize
    8685    $env = sanitize_user($_POST['payadvantageenv']);
    8786    $username = sanitize_user($_POST['payadvantageusername']);
  • pay-advantage/trunk/includes/class-payadvantage-activator.php

    r1946429 r2162618  
    11<?php
    22/**
    3  * This is meant to activate the plugin but having issues getting it working. on the todo list.
     3 * Code that runs upon activation of the Pay Advantage plugin.
    44 */
    55
     
    77
    88    /**
    9      * Short Description. (use period)
    10      *
    11      * Long Description.
    12      *
    139     * @since    1.0.0
    1410     */
  • pay-advantage/trunk/payadvantage.php

    r2094189 r2162618  
    1515 * Plugin Name:       Pay Advantage
    1616 * Plugin URI:        https://www.payadvantage.com.au/
    17  * Description:       This plugin adds a payment gateway to woo commerce as well as a widget for credit card and BPay donations.
    18  * Version:           2.0.0
     17 * Description:       This plugin adds a payment gateway to Woo Commerce as well as a widget for credit card and BPay payments.
     18 * Version:           2.1.0
    1919 * Author:            Pay Advantage
    2020 * Author URI:        ben.m@payadvantage.com
     
    2626
    2727/**
    28  * Currently plugin version.
    29  * Start at version 1.0.0 and use SemVer - https://semver.org
    30  * Rename this for your plugin and update it as you release new versions.
     28 * Current plugin version.
    3129 */
    32 define( 'PayAdvantage', '2.0.0' );
     30define( 'PayAdvantage', '2.1.0' );
    3331
    3432include( plugin_dir_path( __FILE__ ) . '/includes/payadvantage-files.php');
  • pay-advantage/trunk/public/payadvantage-creditcard-ajax.php

    r2094189 r2162618  
    2727    $validation_message = $validator->validate_credit_card_payment();
    2828
    29     $billing_data = array(
    30         'first_name' => sanitize_text_field( $_POST['payadvantagefirstname'] ),
    31         'last_name' => sanitize_text_field( $_POST['payadvantagelastname'] ),
    32         'email' => sanitize_text_field( $_POST['payadvantageemail'] )
    33     );
    34    
    3529    if ( strlen( $validation_message ) > PAYADV_DEFAULT_ERROR_LENGTH ) {
    3630        echo  $validation_message . ']}';
    3731        wp_die();
    3832    }
    39    
     33
     34    $billing_data = array(
     35        'first_name' => sanitize_text_field( $_POST['payadvantagefirstname'] ),
     36        'last_name' => sanitize_text_field( $_POST['payadvantagelastname'] ),
     37        'email' => sanitize_text_field( $_POST['payadvantageemail'] ),
     38        'mobile' => sanitize_text_field( $_POST['payadvantagemobile'] )
     39    );
     40
    4041    $payment_result = $credit_card_payment->process_credit_card_payment(
    4142        $billing_data,
  • pay-advantage/trunk/public/payadvantage-creditcard.php

    r2094189 r2162618  
    7878
    7979  /**
    80    * Queries the customer to see if their existing.
     80   * Queries the customer to see if they're existing.
    8181   */
    8282  private function customer_query_api_call($email, $first_name, $last_name)
     
    8888        'Content-Type' => 'application/json',
    8989        'Authorization' => "Bearer $this->access_token"
    90       )
     90      ),
     91      'timeout' => 30
    9192    );
    9293
     
    109110        'Authorization' => "Bearer $this->access_token"
    110111      ),
    111       'body' => $json_customer
     112      'body' => $json_customer,
     113      'timeout' => 30
    112114    );
    113115
     
    130132        'Authorization' => "Bearer $this->access_token"
    131133      ),
    132       'body' => $json_card_info
     134      'body' => $json_card_info,
     135      'timeout' => 30
    133136    );
    134137
     
    151154        'Authorization' => "Bearer $this->access_token"
    152155      ),
    153       'body' => $charges_json
     156      'body' => $charges_json,
     157      'timeout' => 30
    154158    );
    155159
  • pay-advantage/trunk/public/payadvantage-json-converter.php

    r2040227 r2162618  
    3737            'FirstName' => sanitize_text_field($_POST['payadvantagefirstname']),
    3838            'LastName' => sanitize_text_field($_POST['payadvantagelastname']),
    39             'Mobile' => sanitize_text_field($_POST['payadvantagemobile']),
     39            'Mobile' => $this->extract_phone_number( sanitize_text_field($_POST['payadvantagemobile']) ),
    4040            'Street' => $street,
    4141            'Suburb' => $suburb,
     
    5353     */
    5454    public function create_customer_json( $data ) {
    55         $mobile = null;
    56         $street = null;
    57         $city = null;
    58         $state = null;
    59         $post_code = null;
     55        $country_iso = null;
    6056
    61         if ( isset( $data['phone'] ) ) {
    62             $mobile = sanitize_text_field( $data['phone'] );
    63         }
    64 
    65         if( isset( $data['address_1'] ) ) {
    66             $street = sanitize_text_field( $data['address_1'] );
    67         }
    68 
    69         if( isset( $data['city'] ) ) {
    70             $city = sanitize_text_field( $data['city'] );
    71         }
    72 
    73         if( isset( $data['state'] ) ) {
    74             $state = sanitize_text_field( $data['state'] );
    75         }
    76 
    77         if( isset( $data['postcode'] ) ) {
    78             $post_code = sanitize_text_field( $data['postcode'] );
     57        if( !empty( $data['country'] ) ) {
     58            $country_iso = sanitize_text_field( $data['country'] );
    7959        }
    8060
     
    8565            'FirstName' => sanitize_text_field( $data['first_name'] ),
    8666            'LastName' => sanitize_text_field( $data['last_name'] ),
    87             'Mobile' => $mobile,
    88             'Suburb' => $city,
    89             'Street' => $street,
    90             'State' => $state,
    91             'Postcode' => $post_code
     67            'CountryISO3316' => $country_iso
    9268        );
    9369
     70        if( !empty( $data['address_1'] ) ) {
     71            $query['Street1'] = sanitize_text_field( $data['address_1'] );
     72        }
     73
     74        if( !empty( $data['city'] ) ) {
     75            $query['Suburb'] = sanitize_text_field( $data['city'] );
     76        }
     77
     78        if( !empty( $data['postcode'] ) ) {
     79            $query['Postcode'] = sanitize_text_field( $data['postcode'] );
     80        }
     81
     82        if( !empty( $data['state'] ) ) {
     83            $query['State'] = sanitize_text_field( $data['state'] );
     84        }
     85
     86        if ( !empty( $data['phone'] ) ) {
     87            $query['Phone'] = $this->extract_phone_number( sanitize_text_field( $data['phone'] ) );
     88            $query['PhoneCountryISO3316'] = $country_iso;
     89        }
     90
     91        if ( !empty( $data['mobile'] ) ) {
     92            $query['Mobile'] = $this->extract_phone_number( sanitize_text_field( $data['mobile'] ) );
     93            $query['MobileCountryISO3316'] = $country_iso;
     94        }
     95
    9496        return json_encode( $query );
     97    }
     98
     99    private function extract_phone_number ( $text_value ) {
     100        return preg_replace( '/[^0-9]/', '', $text_value );
    95101    }
    96102
  • pay-advantage/trunk/shared/payadvantage-auth.php

    r2094189 r2162618  
    4141                'Expect' => ''
    4242            ),
    43             'body' => json_encode($auth)
     43            'body' => json_encode($auth),
     44            'timeout' => 30
    4445        );
    4546        $response = wp_remote_post( $url, $data );       
Note: See TracChangeset for help on using the changeset viewer.