Changeset 2566392
- Timestamp:
- 07/17/2021 06:44:28 PM (5 years ago)
- Location:
- woo-pelecard-gateway/trunk
- Files:
-
- 7 edited
-
includes/Api.php (modified) (1 diff)
-
includes/Gateway.php (modified) (8 diffs)
-
includes/Order.php (modified) (2 diffs)
-
includes/Plugin.php (modified) (1 diff)
-
includes/Transaction.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
-
woocommerce-pelecard-gateway.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
woo-pelecard-gateway/trunk/includes/Api.php
r2460563 r2566392 245 245 } 246 246 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 247 255 Log::info( sprintf( 'CHARGE WITH TOKEN (%s)', $gateway->get_action_type() ) ); 248 256 if ( 0 < $order->get_id() ) { -
woo-pelecard-gateway/trunk/includes/Gateway.php
r2556027 r2566392 9 9 use WC_Payment_Tokens; 10 10 use WC_Subscription; 11 use WC_Subscriptions_Cart;12 11 13 12 /** … … 34 33 */ 35 34 protected $current_language; 35 36 /** 37 * @var int $total_payments 38 */ 39 protected $total_payments = 1; 36 40 37 41 /** … … 392 396 } 393 397 394 return WC_Subscriptions_Cart::cart_contains_subscription();398 return \WC_Subscriptions_Cart::cart_contains_subscription(); 395 399 } 396 400 … … 913 917 $this->order_mark_as_chargeable( $order ); 914 918 $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 } 915 925 } 916 926 … … 927 937 public function order_mark_as_chargeable( WC_Order $order ) { 928 938 $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 929 951 $order->save_meta_data(); 930 952 } … … 998 1020 $subscription->save_meta_data(); 999 1021 } 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(); 1000 1031 } 1001 1032 … … 1101 1132 1102 1133 $this->set_action_type( 'J4' ); 1134 $this->set_total_payments( self::get_order_total_payments( $order ) ); 1103 1135 1104 1136 try { … … 1127 1159 1128 1160 /** 1161 * @param \WC_Order $order 1162 * 1129 1163 * @return int 1130 1164 */ 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 */ 1131 1174 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; 1134 1177 } 1135 1178 1136 1179 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; 1137 1191 } 1138 1192 -
woo-pelecard-gateway/trunk/includes/Order.php
r2466033 r2566392 49 49 * @param \WC_Order $order 50 50 * 51 * @return array|\Pelecard\Transaction[]51 * @return \Pelecard\Transaction[] 52 52 */ 53 53 public function get_transactions( WC_Order $order ) { … … 113 113 add_action( 'wp_ajax_wpg_charge_order', [ Gateway::instance(), 'charge_by_order' ] ); 114 114 } 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 } 115 132 } -
woo-pelecard-gateway/trunk/includes/Plugin.php
r2556027 r2566392 18 18 * @var string $version 19 19 */ 20 public static $version = '1.4. 7';20 public static $version = '1.4.8'; 21 21 22 22 /** -
woo-pelecard-gateway/trunk/includes/Transaction.php
r2556027 r2566392 2 2 3 3 namespace Pelecard; 4 5 use WC_Data;6 use WC_Meta_Data;7 use WC_Payment_Token_CC;8 4 9 5 /** 10 6 * Class Transaction 11 7 */ 12 class Transaction extends WC_Data {8 class Transaction extends \WC_Data { 13 9 14 10 const META_KEY = '_wpg_transaction'; … … 197 193 $meta = (array) $meta; 198 194 if ( isset( $meta['key'], $meta['value'] ) ) { 199 $this->meta_data[] = new WC_Meta_Data( [195 $this->meta_data[] = new \WC_Meta_Data( [ 200 196 'key' => $meta['key'], 201 197 'value' => $meta['value'], … … 375 371 * @return \WC_Payment_Token_CC 376 372 */ 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(); 379 375 $token->set_gateway_id( $gateway->id ); 380 376 $token->set_token( $this->get_token() ); … … 493 489 494 490 /** 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 /** 495 502 * @return bool 496 503 */ … … 523 530 524 531 /** 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 /** 525 545 * @param string $context 526 546 * -
woo-pelecard-gateway/trunk/readme.txt
r2556027 r2566392 3 3 Tags: e-commerce, payments, gateway, checkout, pelecard, invoices, woo commerce, subscriptions 4 4 Requires at least: 5.5 5 Tested up to: 5. 76 Stable tag: 1.4. 75 Tested up to: 5.8 6 Stable tag: 1.4.8 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 55 55 56 56 == 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. 57 61 58 62 = 1.4.7 = -
woo-pelecard-gateway/trunk/woocommerce-pelecard-gateway.php
r2556027 r2566392 4 4 * Plugin URI: https://wordpress.org/plugins/woo-pelecard-gateway/ 5 5 * Description: Extends WooCommerce with Pelecard payment gateway. 6 * Version: 1.4. 76 * Version: 1.4.8 7 7 * Author: Ido Friedlander 8 8 * Author URI: https://profiles.wordpress.org/idofri/
Note: See TracChangeset
for help on using the changeset viewer.