Plugin Directory

Changeset 2566392


Ignore:
Timestamp:
07/17/2021 06:44:28 PM (5 years ago)
Author:
idofri
Message:

new version-20210717

Location:
woo-pelecard-gateway/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • woo-pelecard-gateway/trunk/includes/Api.php

    r2460563 r2566392  
    245245        }
    246246
     247        // 3DSecure params
     248        $three_d_secure_params = Order::get_3ds_params( $order );
     249        if ( ! empty( $three_d_secure_params ) ) {
     250            $args['Eci'] = $three_d_secure_params[0];
     251            $args['XID'] = $three_d_secure_params[1];
     252            $args['Cavv'] = $three_d_secure_params[2];
     253        }
     254
    247255        Log::info( sprintf( 'CHARGE WITH TOKEN (%s)', $gateway->get_action_type() ) );
    248256        if ( 0 < $order->get_id() ) {
  • woo-pelecard-gateway/trunk/includes/Gateway.php

    r2556027 r2566392  
    99use WC_Payment_Tokens;
    1010use WC_Subscription;
    11 use WC_Subscriptions_Cart;
    1211
    1312/**
     
    3433     */
    3534    protected $current_language;
     35
     36    /**
     37     * @var int $total_payments
     38     */
     39    protected $total_payments = 1;
    3640
    3741    /**
     
    392396        }
    393397
    394         return WC_Subscriptions_Cart::cart_contains_subscription();
     398        return \WC_Subscriptions_Cart::cart_contains_subscription();
    395399    }
    396400
     
    913917            $this->order_mark_as_chargeable( $order );
    914918            $this->order_save_auth_number( $order, $transaction );
     919            $this->order_save_total_payments( $order, $transaction );
     920
     921            $three_d_secure_params = $transaction->get_3ds_params();
     922            if ( ! empty( $three_d_secure_params ) ) {
     923                $this->order_save_3ds_params( $order, $three_d_secure_params );
     924            }
    915925        }
    916926
     
    927937    public function order_mark_as_chargeable( WC_Order $order ) {
    928938        $order->update_meta_data( '_wpg_is_chargeable', true );
     939        $order->save_meta_data();
     940    }
     941
     942    /**
     943     * @param \WC_Order $order
     944     * @param array     $params
     945     */
     946    public function order_save_3ds_params( WC_Order $order, array $params ) {
     947        $order->update_meta_data( '_wpg_3ds_eci', $params[0] );
     948        $order->update_meta_data( '_wpg_3ds_xid', $params[1] );
     949        $order->update_meta_data( '_wpg_3ds_cavv', $params[2] );
     950
    929951        $order->save_meta_data();
    930952    }
     
    9981020            $subscription->save_meta_data();
    9991021        }
     1022    }
     1023
     1024    /**
     1025     * @param \WC_Order             $order
     1026     * @param \Pelecard\Transaction $transaction
     1027     */
     1028    public function order_save_total_payments( WC_Order $order, Transaction $transaction ) {
     1029        $order->update_meta_data( '_wpg_total_payments', $transaction->get_total_payments() );
     1030        $order->save_meta_data();
    10001031    }
    10011032
     
    11011132
    11021133        $this->set_action_type( 'J4' );
     1134        $this->set_total_payments( self::get_order_total_payments( $order ) );
    11031135
    11041136        try {
     
    11271159
    11281160    /**
     1161     * @param \WC_Order $order
     1162     *
    11291163     * @return int
    11301164     */
     1165    public static function get_order_total_payments( \WC_Order $order ): int {
     1166        $total_payments = (int) $order->get_meta( '_wpg_total_payments' );
     1167
     1168        return $total_payments ?: 1;
     1169    }
     1170
     1171    /**
     1172     * @return int
     1173     */
    11311174    public function get_total_payments(): int {
    1132         if ( null === WC()->session ) {
    1133             return 1;
     1175        if ( is_admin() || null === WC()->session ) {
     1176            return $this->total_payments;
    11341177        }
    11351178
    11361179        return (int) WC()->session->get( 'total_payments' );
     1180    }
     1181
     1182    /**
     1183     * @param int $total_payments
     1184     *
     1185     * @return $this
     1186     */
     1187    public function set_total_payments( int $total_payments ) {
     1188        $this->total_payments = $total_payments;
     1189
     1190        return $this;
    11371191    }
    11381192
  • woo-pelecard-gateway/trunk/includes/Order.php

    r2466033 r2566392  
    4949     * @param \WC_Order $order
    5050     *
    51      * @return array|\Pelecard\Transaction[]
     51     * @return \Pelecard\Transaction[]
    5252     */
    5353    public function get_transactions( WC_Order $order ) {
     
    113113        add_action( 'wp_ajax_wpg_charge_order', [ Gateway::instance(), 'charge_by_order' ] );
    114114    }
     115
     116    /**
     117     * Get order's 3DSecure params
     118     *
     119     * @param \WC_Order $order
     120     *
     121     * @return array
     122     */
     123    public static function get_3ds_params( WC_Order $order ): array {
     124        $params = array_filter( [
     125            $order->get_meta( '_wpg_3ds_eci' ),
     126            $order->get_meta( '_wpg_3ds_xid' ),
     127            $order->get_meta( '_wpg_3ds_cavv' ),
     128        ] );
     129
     130        return 3 === count( $params ) ? $params : [];
     131    }
    115132}
  • woo-pelecard-gateway/trunk/includes/Plugin.php

    r2556027 r2566392  
    1818     * @var string $version
    1919     */
    20     public static $version = '1.4.7';
     20    public static $version = '1.4.8';
    2121
    2222    /**
  • woo-pelecard-gateway/trunk/includes/Transaction.php

    r2556027 r2566392  
    22
    33namespace Pelecard;
    4 
    5 use WC_Data;
    6 use WC_Meta_Data;
    7 use WC_Payment_Token_CC;
    84
    95/**
    106 * Class Transaction
    117 */
    12 class Transaction extends WC_Data {
     8class Transaction extends \WC_Data {
    139
    1410    const META_KEY = '_wpg_transaction';
     
    197193            $meta = (array) $meta;
    198194            if ( isset( $meta['key'], $meta['value'] ) ) {
    199                 $this->meta_data[] = new WC_Meta_Data( [
     195                $this->meta_data[] = new \WC_Meta_Data( [
    200196                    'key' => $meta['key'],
    201197                    'value' => $meta['value'],
     
    375371     * @return \WC_Payment_Token_CC
    376372     */
    377     public function get_token_object( Gateway $gateway ): WC_Payment_Token_CC {
    378         $token = new WC_Payment_Token_CC();
     373    public function get_token_object( Gateway $gateway ): \WC_Payment_Token_CC {
     374        $token = new \WC_Payment_Token_CC();
    379375        $token->set_gateway_id( $gateway->id );
    380376        $token->set_token( $this->get_token() );
     
    493489
    494490    /**
     491     * @param string $context
     492     *
     493     * @return int
     494     */
     495    public function get_total_payments( $context = 'view' ): int {
     496        $total_payments = (int) $this->get_meta( 'TotalPayments', true, $context );
     497
     498        return $total_payments ?: 1;
     499    }
     500
     501    /**
    495502     * @return bool
    496503     */
     
    523530
    524531    /**
     532     * @return array
     533     */
     534    public function get_3ds_params(): array {
     535        $params = array_filter( [
     536            $this->get_meta( 'Eci' ),
     537            $this->get_meta( 'XID' ),
     538            $this->get_meta( 'Cavv' ),
     539        ] );
     540
     541        return 3 === count( $params ) ? $params : [];
     542    }
     543
     544    /**
    525545     * @param string $context
    526546     *
  • woo-pelecard-gateway/trunk/readme.txt

    r2556027 r2566392  
    33Tags: e-commerce, payments, gateway, checkout, pelecard, invoices, woo commerce, subscriptions
    44Requires at least: 5.5
    5 Tested up to: 5.7
    6 Stable tag: 1.4.7
     5Tested up to: 5.8
     6Stable tag: 1.4.8
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5555
    5656== Changelog ==
     57
     58= 1.4.8 =
     59* Add 3D-Secure params to J4 after J5 requests.
     60* Save total-payments for later use when doing J5 transactions.
    5761
    5862= 1.4.7 =
  • woo-pelecard-gateway/trunk/woocommerce-pelecard-gateway.php

    r2556027 r2566392  
    44 * Plugin URI: https://wordpress.org/plugins/woo-pelecard-gateway/
    55 * Description: Extends WooCommerce with Pelecard payment gateway.
    6  * Version: 1.4.7
     6 * Version: 1.4.8
    77 * Author: Ido Friedlander
    88 * Author URI: https://profiles.wordpress.org/idofri/
Note: See TracChangeset for help on using the changeset viewer.