Plugin Directory

Changeset 2655871


Ignore:
Timestamp:
01/11/2022 02:14:58 PM (4 years ago)
Author:
taiflywire
Message:

Updated to v1.0.4

Location:
flywire-payment-gateway/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • flywire-payment-gateway/trunk/CHANGELOG

    r2618228 r2655871  
    22All notable changes to this project will be documented in this file.
    33 
     4
     5## [1.0.4] - 2022-01-11
     6
     7### Added
     8- subunit config setting which will determine the amount sent to Flywire
    49
    510## [1.0.3] - 2021-10-21
  • flywire-payment-gateway/trunk/flywire-payment-gateway.php

    r2618228 r2655871  
    66 * Author: Flywire
    77 * Author URI: http://www.flywire.com/
    8  * Version: 1.0.3
     8 * Version: 1.0.4
    99 * Text Domain: flywire-payment-gateway
    1010 * Domain Path: /i18n/languages/
     
    113113         */
    114114        public $portal;
     115
     116        /**
     117         * Number of sub-units in the currency, e.g. 100 cents in 1 dollar
     118         *
     119         * @var string
     120         */
     121        public $number_of_subunits_in_currency;
    115122
    116123        /**
     
    181188
    182189            // Define user set variables
    183             $this->title          = $this->get_option( 'title' );
    184             $this->description    = $this->get_option( 'description' );
    185             $this->enabled        = $this->get_option( 'enabled' );
    186             $this->testmode       = 'yes' === $this->get_option( 'testmode' );
    187             $this->complete_order = 'yes' === $this->get_option( 'complete_order' );
    188             $this->on_guaranteed  = 'yes' === $this->get_option( 'complete_on_guaranteed' );
    189             $this->portal         = $this->testmode ? $this->get_option( 'demo_portal' ) : $this->get_option( 'prod_portal' );
    190             $this->instructions   = $this->get_option( 'instructions' );
    191             $this->field_mapping  = $this->get_option( 'field_mapping' );
    192             $this->api_url        = WC()->api_request_url( 'WC_Gateway_Flywire' );
    193             $this->order_notes    = 'yes' === $this->get_option( 'enable_notes' );
    194             self::$log_enabled    = 'yes' === $this->get_option( 'enable_log' );
     190            $this->title                          = $this->get_option( 'title' );
     191            $this->description                    = $this->get_option( 'description' );
     192            $this->enabled                        = $this->get_option( 'enabled' );
     193            $this->testmode                       = 'yes' === $this->get_option( 'testmode' );
     194            $this->number_of_subunits_in_currency = $this->get_option( 'number_of_subunits_in_currency' );
     195            $this->complete_order                 = 'yes' === $this->get_option( 'complete_order' );
     196            $this->on_guaranteed                  = 'yes' === $this->get_option( 'complete_on_guaranteed' );
     197            $this->portal                         = $this->testmode ? $this->get_option( 'demo_portal' ) : $this->get_option( 'prod_portal' );
     198            $this->instructions                   = $this->get_option( 'instructions' );
     199            $this->field_mapping                  = $this->get_option( 'field_mapping' );
     200            $this->api_url                        = WC()->api_request_url( 'WC_Gateway_Flywire' );
     201            $this->order_notes                    = 'yes' === $this->get_option( 'enable_notes' );
     202            self::$log_enabled                    = 'yes' === $this->get_option( 'enable_log' );
    195203
    196204            // Actions
     
    282290                    'default'     => "{\r\n\t\"sender_country\":\"{{billing_country}}\",\r\n\t\"sender_first_name\":\"{{billing_first_name}}\",\r\n\t\"sender_last_name\":\"{{billing_last_name}}\",\r\n\t\"sender_address1\":\"{{billing_address_1}}\",\r\n\t\"sender_phone\":\"{{billing_phone}}\",\r\n\t\"sender_city\":\"{{billing_city}}\",\r\n\t\"sender_zip\":\"{{billing_postcode}}\",\r\n\t\"sender_email\":\"{{billing_email}}\",\r\n\t\"student_first_name\":\"{{billing_first_name}}\",\r\n\t\"student_last_name\":\"{{billing_last_name}}\",\r\n\t\"student_email\":\"{{billing_email}}\"\r\n}",
    283291                    'desc_tip'    => true,
     292                ),
     293
     294                'number_of_subunits_in_currency' => array(
     295                    'title'       => __( 'Number of Sub-units In Currency', 'flywire-payment-gateway' ),
     296                    'type'        => 'text',
     297                    'default'     => '100',
     298                    'description' => __( 'There 100 subunits in most currenies e.g. USD/GBP/EUR and 1 subunit in JPY.', 'flywire-payment-gateway' )
    284299                ),
    285300
     
    443458
    444459        /**
     460         * Validate the number_of_subunits_in_currency. Enforce that it is a number
     461         *
     462         * @param string $key The new setting key
     463         * @param string $value The new setting value
     464         * @param array $fields All form fields
     465         *
     466         * @return string
     467         */
     468        protected function validate_number_of_subunits_in_currency( string $key, string $value, array $fields ): string {
     469            if ( false === is_numeric( $value ) ) {
     470                throw new Exception( '<strong>' . $fields[ $key ]['title'] . '</strong> is not numeric. Expected values are 1, 10, 100 or 1000. Please check with your Solutions Consultant if you are unsure of the value to use.' );
     471            }
     472
     473            return $value;
     474        }
     475
     476        /**
    445477         * Logging method.
    446478         *
  • flywire-payment-gateway/trunk/includes/flywire-payment-gateway-request.php

    r2618228 r2655871  
    4040
    4141    /**
     42     * Number of sub-units in the currency.  e.g. 100 cents in 1 dollar
     43     *
     44     * @var bool
     45     */
     46    public $number_of_subunits_in_currency;
     47
     48    /**
    4249     * Webhook URL
    4350     *
     
    6168     */
    6269    public function __construct( WC_Gateway_Flywire $gateway, string $order_id ) {
    63         $this->order      = wc_get_order( $order_id );
    64         $this->mapping    = json_decode( $gateway->field_mapping );
    65         $this->portal     = apply_filters( 'flywpg_portal_code', $gateway->portal, $this->order, $gateway->testmode );
    66         $this->testmode   = $gateway->testmode;
    67         $this->api_url    = $gateway->api_url;
    68         $this->return_url = $gateway->get_return_url( $this->order );
     70        $this->order                          = wc_get_order( $order_id );
     71        $this->mapping                        = json_decode( $gateway->field_mapping );
     72        $this->portal                         = apply_filters( 'flywpg_portal_code', $gateway->portal, $this->order, $gateway->testmode );
     73        $this->number_of_subunits_in_currency = intval($gateway->number_of_subunits_in_currency, 10);
     74        $this->testmode                       = $gateway->testmode;
     75        $this->api_url                        = $gateway->api_url;
     76        $this->return_url                     = $gateway->get_return_url( $this->order );
    6977    }
    7078
     
    8290        $settings['locale']      = substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 );
    8391        $settings['recipient']   = $this->portal;
    84         $settings['amount']      = intval( $this->order->get_total() * 100 );
     92        $settings['amount']      = intval( $this->order->get_total() * $this->number_of_subunits_in_currency );
    8593        $settings['return_url']  = $this->return_url;
    8694        $settings['callback_id'] = $this->order->get_id();
  • flywire-payment-gateway/trunk/readme.txt

    r2618228 r2655871  
    33Tags: woocommerce, credit card, bank transfer, pay, payment gateway
    44Requires at least: 5.7
    5 Tested up to: 5.8
    6 Stable tag: 1.0.3
     5Tested up to: 5.8.3
     6Stable tag: 1.0.4
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    2828== Changelog ==
    2929
     30= 1.0.4 =
     31* Added subunit config setting which will determine the amount sent to Flywire
     32
    3033= 1.0.3 =
    3134* Removed custom Flywire thank you page, moved to WooCommerce standard order complete page
Note: See TracChangeset for help on using the changeset viewer.