Plugin Directory

Changeset 2592996


Ignore:
Timestamp:
09/03/2021 01:19:16 AM (5 years ago)
Author:
taiflywire
Message:

Updating trunk to 1.0.2

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

Legend:

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

    r2584468 r2592996  
    22All notable changes to this project will be documented in this file.
    33 
     4
     5## [1.0.2] - 2021-09-03
     6
     7### Added
     8- support for custom checkout fields saved in the Order metadata
    49
    510## [1.0.1] - 2021-08-17
  • flywire-payment-gateway/trunk/README.md

    r2571153 r2592996  
    1 # Woocommerce
     1# Flywire for WooCommerce
    22
    3 Custom payment gateway for WooCommerce
     3Flywire payment gateway for WooCommerce
  • flywire-payment-gateway/trunk/flywire-payment-gateway.php

    r2584468 r2592996  
    11<?php
    22/**
    3  * Plugin Name: Flywire Payment Gateway
     3 * Plugin Name: Flywire for WooCommerce
    44 * Plugin URI: http://www.flywire.com/
    55 * Description: Enable Flywire payments option for WooCommerce
    66 * Author: Flywire
    77 * Author URI: http://www.flywire.com/
    8  * Version: 1.0.1
     8 * Version: 1.0.2
    99 * Text Domain: flywire-payment-gateway
    1010 * Domain Path: /i18n/languages/
     
    146146
    147147/**
    148  * Flywire Payment Gateway
     148 * Flywire for WooCommerce
    149149 *
    150150 * Provides a Flywire Payment Gateway
     
    281281
    282282            if ( ! $this->is_valid_for_use() ) {
    283                 WC_Gateway_Flywire::log( 'Flywire Payment Gateway is not valid for use' );
     283                WC_Gateway_Flywire::log( 'Flywire for WooCommerce is not valid for use' );
    284284                $this->enabled = 'no';
    285285            } else {
     
    356356                    'type'        => 'textarea',
    357357                    'description' => __( 'JSON configuration to define how WooCommerce fields will map to Flywire fields.  Should be supplied by your Flywire Relationship Manager or Solutions Consultant.', 'flywire-payment-gateway' ),
    358                     'default'     => '',
    359                     'desc_tip'    => true,
    360                 ),
    361 
    362                 'testmode' => array(
    363                     'title'       => __( 'Test Mode', 'flywire-payment-gateway' ),
    364                     'type'        => 'checkbox',
    365                     'label'       => __( 'Use Demo environment', 'flywire-payment-gateway' ),
    366                     'default'     => 'yes',
     358                    '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}",
     359                    'desc_tip'    => true,
    367360                ),
    368361
     
    405398                    'type'        => 'title',
    406399                    'description' => __( 'Please contact your Relationship Manager if you need help determining these values.', 'flywire-payment-gateway' ),
     400                ),
     401
     402                'testmode' => array(
     403                    'title'       => __( 'Test Mode', 'flywire-payment-gateway' ),
     404                    'type'        => 'checkbox',
     405                    'label'       => __( 'Use Demo environment', 'flywire-payment-gateway' ),
     406                    'default'     => 'yes',
    407407                ),
    408408
  • flywire-payment-gateway/trunk/includes/flywire-payment-gateway-request.php

    r2584468 r2592996  
    156156    /**
    157157     * Replaces tokens - e.g. {{name}} - in a template string with values from a given object
     158     * Use {{custom.name}} for custom fields
    158159     *
    159160     * @param string $template template string
     
    163164     */
    164165    protected static function expand_template( string $template, $obj ): string {
    165         $re = '/{{([a-z0-9_]+)}}/';
     166        $re = '/{{(custom\.)?([a-z0-9_.]+)}}/';
    166167        preg_match_all( $re, $template, $matches, PREG_SET_ORDER );
    167168
    168169        while ( count( $matches ) ) {
    169             if ( ! method_exists( $obj, 'get_' . $matches[0][1] ) ) {
    170                 wc_add_notice( __( 'Field mapping failed: Method get_' . $matches[0][1] . '() not found.' ) );
     170            if ( 'custom.' == $matches[0][1] ) { // custom field in metadata
     171                $key = substr( $matches[0][2], 0, 1 ) === "_" ? $matches[0][2] : '_' . $matches[0][2];
     172                $value = $obj->get_meta( $key );
     173                if ('' == $value)
     174                    $value = $obj->get_meta( ltrim($key, '_') ); // try without underscore
     175            } else { // native WC Order field
     176                if ( ! method_exists( $obj, 'get_' . $matches[0][2] ) ) {
     177                    wc_add_notice( __( 'Field mapping failed: Method get_' . $matches[0][2] . '() not found.' ) );
     178                }
     179                $value = call_user_func( array( $obj, 'get_' . $matches[0][2] ) );
    171180            }
    172             $value    = call_user_func( array( $obj, 'get_' . $matches[0][1] ) );
    173181            $template = str_replace( $matches[0][0], $value, $template );
    174182
  • flywire-payment-gateway/trunk/readme.txt

    r2584468 r2592996  
    1 === Flywire Payment Gateway ===
     1=== Flywire for WooCommerce ===
    22Contributors: taiflywire
    33Tags: credit card, bank transfer, pay
    44Requires at least: 5.7
    5 Tested up to: 5.7.4
    6 Stable tag: 1.0.1
     5Tested up to: 5.8
     6Stable tag: 1.0.2
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    2828== Changelog ==
    2929
     30= 1.0.2 =
     31* Added support for custom checkout fields saved in the Order metadata
     32
    3033= 1.0.1 =
    3134* Updated filter 'flywpg_portal_code' to add test mode parameter
     
    3639== Disclaimer ==
    3740
    38 By incorporating Flywire Payment Gateway scripts and related materials contained in the plugin file (collectively, the "Plugin") onto your website, you acknowledge and agree to the following:
     41By incorporating Flywire for WooCommerce scripts and related materials contained in the plugin file (collectively, the "Plugin") onto your website, you acknowledge and agree to the following:
    3942
    4043The Plugin is only available for use by customers using Flywire's services, which use is subject to Flywire's onboarding process and your contractual agreement with Flywire.
Note: See TracChangeset for help on using the changeset viewer.