Changeset 3206321
- Timestamp:
- 12/11/2024 12:06:20 PM (16 months ago)
- Location:
- yoco-payment-gateway
- Files:
-
- 20 edited
- 1 copied
-
tags/3.8.1 (copied) (copied from yoco-payment-gateway/trunk)
-
tags/3.8.1/assets/images/yoco-2024.svg (modified) (1 diff)
-
tags/3.8.1/readme.txt (modified) (3 diffs)
-
tags/3.8.1/src/Gateway/Notes.php (modified) (2 diffs)
-
tags/3.8.1/src/Gateway/PaymentStatusScheduler.php (modified) (6 diffs)
-
tags/3.8.1/src/Gateway/Refunds/Actions.php (modified) (1 diff)
-
tags/3.8.1/src/Helpers/Logger.php (modified) (2 diffs)
-
tags/3.8.1/src/Integrations/Yoco/Requests/Refund.php (modified) (1 diff)
-
tags/3.8.1/src/Integrations/Yoco/Webhooks/Processors/PaymentWebhookProcessor.php (modified) (3 diffs)
-
tags/3.8.1/src/Repositories/OrdersRepository.php (modified) (4 diffs)
-
tags/3.8.1/yoco_wc_payment_gateway.php (modified) (1 diff)
-
trunk/assets/images/yoco-2024.svg (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/src/Gateway/Notes.php (modified) (2 diffs)
-
trunk/src/Gateway/PaymentStatusScheduler.php (modified) (6 diffs)
-
trunk/src/Gateway/Refunds/Actions.php (modified) (1 diff)
-
trunk/src/Helpers/Logger.php (modified) (2 diffs)
-
trunk/src/Integrations/Yoco/Requests/Refund.php (modified) (1 diff)
-
trunk/src/Integrations/Yoco/Webhooks/Processors/PaymentWebhookProcessor.php (modified) (3 diffs)
-
trunk/src/Repositories/OrdersRepository.php (modified) (4 diffs)
-
trunk/yoco_wc_payment_gateway.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
yoco-payment-gateway/tags/3.8.1/assets/images/yoco-2024.svg
r3200836 r3206321 1 <?xml version="1.0" encoding="UTF-8"?> 2 <svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1490.16 359.74"> 3 <defs> 4 <style> 5 .cls-1 { 6 fill: #00a9e0; 7 stroke-width: 0px; 8 } 9 </style> 10 </defs> 11 <g id="Layer_1-2" data-name="Layer 1"> 12 <g> 13 <g> 14 <path class="cls-1" d="M139.07,248.27L0,12.43h133.02l65.82,119.97h4.16L269.31,12.33h130.24l-139.07,235.94v99.04h-121.54l.13-99.04Z"/> 15 <path class="cls-1" d="M767.56,180.83c0-111.95,77.4-177.97,191.9-177.97,56.1,0,95.47,13.86,126.53,32.05v112.9h-.93c-37.99-26.41-70.91-41.63-111.69-41.63-49.13,0-84.34,26.41-84.34,73.68s36.14,73.19,83.86,73.19c42.19,0,76.03-14.82,112.17-42.09h.93v114.32c-25.59,15.32-70.36,31.56-127.45,31.56-118.24.03-190.97-64.08-190.97-176.02Z"/> 16 <path class="cls-1" d="M1106.35,179.88c0-111.94,74.14-179.88,191.91-179.88s191.9,67.94,191.9,179.88-74.14,179.85-191.9,179.85-191.91-67.91-191.91-179.85ZM1371.82,179.88c0-49.29-27.8-77.51-73.56-77.51s-73.21,28.23-73.21,77.51,27.34,77.48,73.21,77.48,73.66-28.23,73.66-77.48h-.09Z"/> 17 </g> 18 <path class="cls-1" d="M364.35,179.88C364.35,67.94,438.49,0,556.25,0s191.91,67.94,191.91,179.88-74.18,179.85-191.91,179.85-191.9-67.91-191.9-179.85ZM629.81,179.88c0-49.29-27.83-77.51-73.56-77.51s-73.24,28.23-73.24,77.51,27.35,77.48,73.24,77.48,73.66-28.23,73.66-77.48h-.1Z"/> 19 </g> 20 </g> 21 </svg> 1 <?xml version="1.0" encoding="UTF-8"?><svg data-name="Layer 2" viewBox="0 0 1490.2 359.74" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:#00a9e0;stroke-width:0px;}</style></defs><g data-name="Layer 1"><path class="cls-1" d="M139.07,248.27L0,12.43h133.02l65.82,119.97h4.16L269.31,12.33h130.24l-139.07,235.94v99.04h-121.54l.13-99.04Z"/><path class="cls-1" d="M767.56,180.83c0-111.95,77.4-177.97,191.9-177.97,56.1,0,95.47,13.86,126.53,32.05v112.9h-.93c-37.99-26.41-70.91-41.63-111.69-41.63-49.13,0-84.34,26.41-84.34,73.68s36.14,73.19,83.86,73.19c42.19,0,76.03-14.82,112.17-42.09h.93v114.32c-25.59,15.32-70.36,31.56-127.45,31.56-118.24.03-190.97-64.08-190.97-176.02Z"/><path class="cls-1" d="m1106.4 179.88c0-111.94 74.14-179.88 191.91-179.88s191.9 67.94 191.9 179.88-74.14 179.85-191.9 179.85-191.91-67.91-191.91-179.85zm265.47 0c0-49.29-27.8-77.51-73.56-77.51s-73.21 28.23-73.21 77.51 27.34 77.48 73.21 77.48 73.66-28.23 73.66-77.48h-0.09z"/><path class="cls-1" d="m364.35 179.88c0-111.94 74.14-179.88 191.9-179.88s191.91 67.94 191.91 179.88-74.18 179.85-191.91 179.85-191.9-67.91-191.9-179.85zm265.46 0c0-49.29-27.83-77.51-73.56-77.51s-73.24 28.23-73.24 77.51 27.35 77.48 73.24 77.48 73.66-28.23 73.66-77.48h-0.1z"/></g></svg> -
yoco-payment-gateway/tags/3.8.1/readme.txt
r3201014 r3206321 3 3 Tags: woocommerce,payment gateway 4 4 Requires at least: 5.0.0 5 Tested up to: 6. 65 Tested up to: 6.7 6 6 Requires PHP: 7.4.0 7 Stable tag: 3.8. 07 Stable tag: 3.8.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 21 21 ### Why use the Yoco Payments for WooCommerce plugin? 22 22 23 * Variety of payment options from credit/debit cards on (Visa, Mastercard, AmEx), Apple Pay, Google Pay and InstantEFT.24 23 * No hidden or monthly fees 25 24 * Get paid the same day with [Yoco Instant Payouts](https://www.yoco.com/za/instant-payout/) (if eligible) … … 138 137 == Changelog == 139 138 139 = 3.8.1 = 140 141 * Improved fix for duplicate payment complete notification. 142 140 143 = 3.8.0 = 141 144 -
yoco-payment-gateway/tags/3.8.1/src/Gateway/Notes.php
r3067423 r3206321 3 3 namespace Yoco\Gateway; 4 4 5 use WC_Abstract_Order; 5 6 use WC_Order; 6 7 use Yoco\Helpers\Logger; … … 74 75 } 75 76 76 public function addNote( WC_Order $order, string $note ): int { 77 public function addNote( WC_Abstract_Order $order, string $note ): int { 78 if ( ! $order instanceof WC_Order ) { 79 return 0; 80 } 77 81 return $order->add_order_note( $note ); 78 82 } -
yoco-payment-gateway/tags/3.8.1/src/Gateway/PaymentStatusScheduler.php
r3177082 r3206321 112 112 ); 113 113 114 if ( 'completed' === $payment_status && true === $order->payment_complete( $payment_id ) ) { 115 yoco( Metadata::class )->updateOrderPaymentId( $order, $payment_id ); 116 continue; 114 if ( 115 'completed' === $payment_status 116 && true === $order->payment_complete( $payment_id ) 117 ) { 118 /** 119 * Fires an action hook after a Yoco payment has been completed for an order. 120 * 121 * @param WC_Order $order The order object. 122 * @param string $payment_id The ID of the completed Yoco payment. 123 * 124 * @since 1.0.0 125 */ 126 do_action( 'yoco_payment_gateway/payment/completed', $order, $payment_id ); 127 128 $this->remove_order( $order_id ); 129 } else { 130 $this->update_order( $order_id, $payment_status ); 117 131 } 118 119 $this->update_order( $order_id, $payment_status );120 121 132 } catch ( \Throwable $th ) { 122 133 yoco( Logger::class )->logError( sprintf( 'Failed to handle order payment status update. %s', $th->getMessage() ) ); … … 126 137 127 138 public function maybe_update_order_payment_status() { 139 // if webhook is running bail. 140 if ( get_transient( 'yoco_webhook_processing' ) ) { 141 return; 142 } 128 143 129 144 if ( isset( $_GET['key'] ) && is_order_received_page() ) { … … 184 199 185 200 public function process_order( $order_id ) { 186 201 set_transient( 'yoco_order_processing_' . $order_id, true, 10 ); 187 202 $order = wc_get_order( $order_id ); 188 203 … … 196 211 } 197 212 213 198 214 // If we have payment ID saved in meta this means payment was successful and we can remove order from the list. 199 215 if ( ! empty( yoco( Metadata::class )->getOrderPaymentId( $order ) ) ) { 200 216 $this->remove_order( $order->get_id() ); 217 218 delete_transient( 'yoco_order_processing_' . $order->get_id() ); 201 219 return; 202 220 } … … 207 225 $data = $request->get(); 208 226 if ( 200 !== $data['code'] ) { 227 delete_transient( 'yoco_order_processing_' . $order->get_id() ); 209 228 return; 210 229 } … … 213 232 $payment_id = $data['body']['paymentId']; 214 233 215 if ( 'completed' === $payment_status && true === $order->payment_complete( $payment_id ) ) { 216 yoco( Metadata::class )->updateOrderPaymentId( $order, $payment_id ); 234 if ( 235 'completed' === $payment_status 236 && empty( $order->get_date_paid() ) 237 && true === $order->payment_complete( $payment_id ) ) { 238 /** 239 * Fires an action hook after a Yoco payment has been completed for an order. 240 * 241 * @param WC_Order $order The order object. 242 * @param string $payment_id The ID of the completed Yoco payment. 243 * 244 * @since 1.0.0 245 */ 246 do_action( 'yoco_payment_gateway/payment/completed', $order, $payment_id ); 247 delete_transient( 'yoco_order_processing_' . $order->get_id() ); 217 248 } 218 249 } catch ( \Throwable $th ) { -
yoco-payment-gateway/tags/3.8.1/src/Gateway/Refunds/Actions.php
r3177082 r3206321 103 103 104 104 $args = array( 105 'amount' => $refund->amount / 100,106 'reason' => sprintf(105 'amount' => $refund->amount / 100, 106 'reason' => sprintf( 107 107 __( 'Refund requested via Yoco Portal. Refund ID (%s)', 'yoco_wc_payment_gateway' ), 108 108 $refund->id 109 109 ), 110 'order_id' => $order->get_id(),111 'refund_payment _method' => 'class_yoco_wc_payment_gateway',110 'order_id' => $order->get_id(), 111 'refund_payment' => true, 112 112 ); 113 113 -
yoco-payment-gateway/tags/3.8.1/src/Helpers/Logger.php
r3067423 r3206321 3 3 namespace Yoco\Helpers; 4 4 5 use WC_Log_Handler_File; 5 6 use WC_Log_Levels; 6 7 use Yoco\Installation\Installation; … … 46 47 if ( null === $this->error_log_files ) { 47 48 $this->error_log_files = array_filter( 48 \WC_Log_Handler_File::get_log_files(),49 function ( $file_name ) {49 WC_Log_Handler_File::get_log_files(), 50 function ( $file_name ) { 50 51 return false !== strpos( $file_name, 'yoco-gateway-' ) ? true : false; 51 52 } -
yoco-payment-gateway/tags/3.8.1/src/Integrations/Yoco/Requests/Refund.php
r3177082 r3206321 45 45 46 46 $args = array( 47 'amount' => $payload->getAmount() / 100,48 'reason' => sprintf(47 'amount' => $payload->getAmount() / 100, 48 'reason' => sprintf( 49 49 __( 'Refund requested via Yoco Portal. Refund ID (%s)', 'yoco_wc_payment_gateway' ), 50 50 $payload->getId() 51 51 ), 52 'order_id' => $order->get_id(),53 'refund_payment _method' => 'class_yoco_wc_payment_gateway',52 'order_id' => $order->get_id(), 53 'refund_payment' => true, 54 54 ); 55 55 -
yoco-payment-gateway/tags/3.8.1/src/Integrations/Yoco/Webhooks/Processors/PaymentWebhookProcessor.php
r3165767 r3206321 5 5 use WC_Order; 6 6 use WP_REST_Response; 7 use Yoco\Gateway\Metadata; 7 8 use Yoco\Helpers\Logger; 8 9 use Yoco\Integrations\Yoco\Webhooks\Models\WebhookPayload; … … 30 31 */ 31 32 public function process( WebhookPayload $payload ): WP_REST_Response { 32 update_option( 'yoco_webhook', current_time( 'mysql' ));33 set_transient( 'yoco_webhook_processing', true, 10 ); 33 34 $this->order = $this->getOrderByCheckoutId( $payload->getCheckoutId() ); 34 35 if ( null === $this->order ) { … … 36 37 } 37 38 38 if ( ! empty( $this->order->get_meta( 'yoco_order_payment_id', true ) ) ) { 39 if ( get_transient( 'yoco_order_processing_' . $this->order->get_id() ) ) { 40 return $this->sendFailResponse( 409, sprintf( 'Order #%s processing already started.', $this->order->get_id() ) ); 41 } 42 43 if ( $payload->getPaymentId() === yoco( Metadata::class )->getOrderPaymentId( $this->order ) ) { 44 delete_transient( 'yoco_order_processing_' . $this->order->get_id() ); 39 45 return $this->sendSuccessResponse(); 40 46 } 41 47 42 if ( true === $this->order->payment_complete( $payload->getPaymentId() ) ) { 48 if ( 49 $this->order->get_transaction_id() !== $payload->getPaymentId() 50 && true === $this->order->payment_complete( $payload->getPaymentId() ) 51 ) { 52 /** 53 * Fires an action hook after a Yoco payment has been completed for an order. 54 * 55 * @param WC_Order $order The order object. 56 * @param string $payload Yoco Payment data. 57 * 58 * @since 1.0.0 59 */ 43 60 do_action( 'yoco_payment_gateway/payment/completed', $this->order, $payload ); 44 61 62 delete_transient( 'yoco_order_processing_' . $this->order->get_id() ); 45 63 return $this->sendSuccessResponse(); 46 64 } else { 47 65 yoco( Logger::class )->logError( sprintf( 'Failed to complete payment of order #%s.', $this->order->get_id() ) ); 48 66 49 return $this->sendFailResponse( 500, sprintf( 'Failed to complete payment of order #%s.', $this->order->get_id() ) );67 return $this->sendFailResponse( 409, sprintf( 'Failed to complete payment of order #%s.', $this->order->get_id() ) ); 50 68 } 51 69 } -
yoco-payment-gateway/tags/3.8.1/src/Repositories/OrdersRepository.php
r3067423 r3206321 4 4 5 5 use Exception; 6 use WC_Abstract_Order; 6 7 use WC_Order; 7 8 use Yoco\Gateway\Metadata; … … 12 13 class OrdersRepository { 13 14 14 public static function getById( int $id ): ?WC_ Order {15 public static function getById( int $id ): ?WC_Abstract_Order { 15 16 $order = wc_get_order( $id ); 16 17 17 return is_a( $order, WC_ Order::class ) ? $order : null;18 return is_a( $order, WC_Abstract_Order::class ) ? $order : null; 18 19 } 19 20 … … 56 57 } 57 58 58 public static function getByYocoRefundId( string $refundId ): ?WC_ Order {59 public static function getByYocoRefundId( string $refundId ): ?WC_Abstract_Order { 59 60 $orders = wc_get_orders( 60 61 array( … … 72 73 $order = array_shift( $orders ); 73 74 74 return is_a( $order, WC_ Order::class ) ? $order : null;75 return is_a( $order, WC_Abstract_Order::class ) ? $order : null; 75 76 } 76 77 -
yoco-payment-gateway/tags/3.8.1/yoco_wc_payment_gateway.php
r3177082 r3206321 6 6 * Author: Yoco 7 7 * Author URI: https://www.yoco.com 8 * Version: 3.8. 08 * Version: 3.8.1 9 9 * Requires at least: 5.0.0 10 10 * Tested up to: 6.6 -
yoco-payment-gateway/trunk/assets/images/yoco-2024.svg
r3200836 r3206321 1 <?xml version="1.0" encoding="UTF-8"?> 2 <svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1490.16 359.74"> 3 <defs> 4 <style> 5 .cls-1 { 6 fill: #00a9e0; 7 stroke-width: 0px; 8 } 9 </style> 10 </defs> 11 <g id="Layer_1-2" data-name="Layer 1"> 12 <g> 13 <g> 14 <path class="cls-1" d="M139.07,248.27L0,12.43h133.02l65.82,119.97h4.16L269.31,12.33h130.24l-139.07,235.94v99.04h-121.54l.13-99.04Z"/> 15 <path class="cls-1" d="M767.56,180.83c0-111.95,77.4-177.97,191.9-177.97,56.1,0,95.47,13.86,126.53,32.05v112.9h-.93c-37.99-26.41-70.91-41.63-111.69-41.63-49.13,0-84.34,26.41-84.34,73.68s36.14,73.19,83.86,73.19c42.19,0,76.03-14.82,112.17-42.09h.93v114.32c-25.59,15.32-70.36,31.56-127.45,31.56-118.24.03-190.97-64.08-190.97-176.02Z"/> 16 <path class="cls-1" d="M1106.35,179.88c0-111.94,74.14-179.88,191.91-179.88s191.9,67.94,191.9,179.88-74.14,179.85-191.9,179.85-191.91-67.91-191.91-179.85ZM1371.82,179.88c0-49.29-27.8-77.51-73.56-77.51s-73.21,28.23-73.21,77.51,27.34,77.48,73.21,77.48,73.66-28.23,73.66-77.48h-.09Z"/> 17 </g> 18 <path class="cls-1" d="M364.35,179.88C364.35,67.94,438.49,0,556.25,0s191.91,67.94,191.91,179.88-74.18,179.85-191.91,179.85-191.9-67.91-191.9-179.85ZM629.81,179.88c0-49.29-27.83-77.51-73.56-77.51s-73.24,28.23-73.24,77.51,27.35,77.48,73.24,77.48,73.66-28.23,73.66-77.48h-.1Z"/> 19 </g> 20 </g> 21 </svg> 1 <?xml version="1.0" encoding="UTF-8"?><svg data-name="Layer 2" viewBox="0 0 1490.2 359.74" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:#00a9e0;stroke-width:0px;}</style></defs><g data-name="Layer 1"><path class="cls-1" d="M139.07,248.27L0,12.43h133.02l65.82,119.97h4.16L269.31,12.33h130.24l-139.07,235.94v99.04h-121.54l.13-99.04Z"/><path class="cls-1" d="M767.56,180.83c0-111.95,77.4-177.97,191.9-177.97,56.1,0,95.47,13.86,126.53,32.05v112.9h-.93c-37.99-26.41-70.91-41.63-111.69-41.63-49.13,0-84.34,26.41-84.34,73.68s36.14,73.19,83.86,73.19c42.19,0,76.03-14.82,112.17-42.09h.93v114.32c-25.59,15.32-70.36,31.56-127.45,31.56-118.24.03-190.97-64.08-190.97-176.02Z"/><path class="cls-1" d="m1106.4 179.88c0-111.94 74.14-179.88 191.91-179.88s191.9 67.94 191.9 179.88-74.14 179.85-191.9 179.85-191.91-67.91-191.91-179.85zm265.47 0c0-49.29-27.8-77.51-73.56-77.51s-73.21 28.23-73.21 77.51 27.34 77.48 73.21 77.48 73.66-28.23 73.66-77.48h-0.09z"/><path class="cls-1" d="m364.35 179.88c0-111.94 74.14-179.88 191.9-179.88s191.91 67.94 191.91 179.88-74.18 179.85-191.91 179.85-191.9-67.91-191.9-179.85zm265.46 0c0-49.29-27.83-77.51-73.56-77.51s-73.24 28.23-73.24 77.51 27.35 77.48 73.24 77.48 73.66-28.23 73.66-77.48h-0.1z"/></g></svg> -
yoco-payment-gateway/trunk/readme.txt
r3201014 r3206321 3 3 Tags: woocommerce,payment gateway 4 4 Requires at least: 5.0.0 5 Tested up to: 6. 65 Tested up to: 6.7 6 6 Requires PHP: 7.4.0 7 Stable tag: 3.8. 07 Stable tag: 3.8.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 21 21 ### Why use the Yoco Payments for WooCommerce plugin? 22 22 23 * Variety of payment options from credit/debit cards on (Visa, Mastercard, AmEx), Apple Pay, Google Pay and InstantEFT.24 23 * No hidden or monthly fees 25 24 * Get paid the same day with [Yoco Instant Payouts](https://www.yoco.com/za/instant-payout/) (if eligible) … … 138 137 == Changelog == 139 138 139 = 3.8.1 = 140 141 * Improved fix for duplicate payment complete notification. 142 140 143 = 3.8.0 = 141 144 -
yoco-payment-gateway/trunk/src/Gateway/Notes.php
r3067423 r3206321 3 3 namespace Yoco\Gateway; 4 4 5 use WC_Abstract_Order; 5 6 use WC_Order; 6 7 use Yoco\Helpers\Logger; … … 74 75 } 75 76 76 public function addNote( WC_Order $order, string $note ): int { 77 public function addNote( WC_Abstract_Order $order, string $note ): int { 78 if ( ! $order instanceof WC_Order ) { 79 return 0; 80 } 77 81 return $order->add_order_note( $note ); 78 82 } -
yoco-payment-gateway/trunk/src/Gateway/PaymentStatusScheduler.php
r3177082 r3206321 112 112 ); 113 113 114 if ( 'completed' === $payment_status && true === $order->payment_complete( $payment_id ) ) { 115 yoco( Metadata::class )->updateOrderPaymentId( $order, $payment_id ); 116 continue; 114 if ( 115 'completed' === $payment_status 116 && true === $order->payment_complete( $payment_id ) 117 ) { 118 /** 119 * Fires an action hook after a Yoco payment has been completed for an order. 120 * 121 * @param WC_Order $order The order object. 122 * @param string $payment_id The ID of the completed Yoco payment. 123 * 124 * @since 1.0.0 125 */ 126 do_action( 'yoco_payment_gateway/payment/completed', $order, $payment_id ); 127 128 $this->remove_order( $order_id ); 129 } else { 130 $this->update_order( $order_id, $payment_status ); 117 131 } 118 119 $this->update_order( $order_id, $payment_status );120 121 132 } catch ( \Throwable $th ) { 122 133 yoco( Logger::class )->logError( sprintf( 'Failed to handle order payment status update. %s', $th->getMessage() ) ); … … 126 137 127 138 public function maybe_update_order_payment_status() { 139 // if webhook is running bail. 140 if ( get_transient( 'yoco_webhook_processing' ) ) { 141 return; 142 } 128 143 129 144 if ( isset( $_GET['key'] ) && is_order_received_page() ) { … … 184 199 185 200 public function process_order( $order_id ) { 186 201 set_transient( 'yoco_order_processing_' . $order_id, true, 10 ); 187 202 $order = wc_get_order( $order_id ); 188 203 … … 196 211 } 197 212 213 198 214 // If we have payment ID saved in meta this means payment was successful and we can remove order from the list. 199 215 if ( ! empty( yoco( Metadata::class )->getOrderPaymentId( $order ) ) ) { 200 216 $this->remove_order( $order->get_id() ); 217 218 delete_transient( 'yoco_order_processing_' . $order->get_id() ); 201 219 return; 202 220 } … … 207 225 $data = $request->get(); 208 226 if ( 200 !== $data['code'] ) { 227 delete_transient( 'yoco_order_processing_' . $order->get_id() ); 209 228 return; 210 229 } … … 213 232 $payment_id = $data['body']['paymentId']; 214 233 215 if ( 'completed' === $payment_status && true === $order->payment_complete( $payment_id ) ) { 216 yoco( Metadata::class )->updateOrderPaymentId( $order, $payment_id ); 234 if ( 235 'completed' === $payment_status 236 && empty( $order->get_date_paid() ) 237 && true === $order->payment_complete( $payment_id ) ) { 238 /** 239 * Fires an action hook after a Yoco payment has been completed for an order. 240 * 241 * @param WC_Order $order The order object. 242 * @param string $payment_id The ID of the completed Yoco payment. 243 * 244 * @since 1.0.0 245 */ 246 do_action( 'yoco_payment_gateway/payment/completed', $order, $payment_id ); 247 delete_transient( 'yoco_order_processing_' . $order->get_id() ); 217 248 } 218 249 } catch ( \Throwable $th ) { -
yoco-payment-gateway/trunk/src/Gateway/Refunds/Actions.php
r3177082 r3206321 103 103 104 104 $args = array( 105 'amount' => $refund->amount / 100,106 'reason' => sprintf(105 'amount' => $refund->amount / 100, 106 'reason' => sprintf( 107 107 __( 'Refund requested via Yoco Portal. Refund ID (%s)', 'yoco_wc_payment_gateway' ), 108 108 $refund->id 109 109 ), 110 'order_id' => $order->get_id(),111 'refund_payment _method' => 'class_yoco_wc_payment_gateway',110 'order_id' => $order->get_id(), 111 'refund_payment' => true, 112 112 ); 113 113 -
yoco-payment-gateway/trunk/src/Helpers/Logger.php
r3067423 r3206321 3 3 namespace Yoco\Helpers; 4 4 5 use WC_Log_Handler_File; 5 6 use WC_Log_Levels; 6 7 use Yoco\Installation\Installation; … … 46 47 if ( null === $this->error_log_files ) { 47 48 $this->error_log_files = array_filter( 48 \WC_Log_Handler_File::get_log_files(),49 function ( $file_name ) {49 WC_Log_Handler_File::get_log_files(), 50 function ( $file_name ) { 50 51 return false !== strpos( $file_name, 'yoco-gateway-' ) ? true : false; 51 52 } -
yoco-payment-gateway/trunk/src/Integrations/Yoco/Requests/Refund.php
r3177082 r3206321 45 45 46 46 $args = array( 47 'amount' => $payload->getAmount() / 100,48 'reason' => sprintf(47 'amount' => $payload->getAmount() / 100, 48 'reason' => sprintf( 49 49 __( 'Refund requested via Yoco Portal. Refund ID (%s)', 'yoco_wc_payment_gateway' ), 50 50 $payload->getId() 51 51 ), 52 'order_id' => $order->get_id(),53 'refund_payment _method' => 'class_yoco_wc_payment_gateway',52 'order_id' => $order->get_id(), 53 'refund_payment' => true, 54 54 ); 55 55 -
yoco-payment-gateway/trunk/src/Integrations/Yoco/Webhooks/Processors/PaymentWebhookProcessor.php
r3165767 r3206321 5 5 use WC_Order; 6 6 use WP_REST_Response; 7 use Yoco\Gateway\Metadata; 7 8 use Yoco\Helpers\Logger; 8 9 use Yoco\Integrations\Yoco\Webhooks\Models\WebhookPayload; … … 30 31 */ 31 32 public function process( WebhookPayload $payload ): WP_REST_Response { 32 update_option( 'yoco_webhook', current_time( 'mysql' ));33 set_transient( 'yoco_webhook_processing', true, 10 ); 33 34 $this->order = $this->getOrderByCheckoutId( $payload->getCheckoutId() ); 34 35 if ( null === $this->order ) { … … 36 37 } 37 38 38 if ( ! empty( $this->order->get_meta( 'yoco_order_payment_id', true ) ) ) { 39 if ( get_transient( 'yoco_order_processing_' . $this->order->get_id() ) ) { 40 return $this->sendFailResponse( 409, sprintf( 'Order #%s processing already started.', $this->order->get_id() ) ); 41 } 42 43 if ( $payload->getPaymentId() === yoco( Metadata::class )->getOrderPaymentId( $this->order ) ) { 44 delete_transient( 'yoco_order_processing_' . $this->order->get_id() ); 39 45 return $this->sendSuccessResponse(); 40 46 } 41 47 42 if ( true === $this->order->payment_complete( $payload->getPaymentId() ) ) { 48 if ( 49 $this->order->get_transaction_id() !== $payload->getPaymentId() 50 && true === $this->order->payment_complete( $payload->getPaymentId() ) 51 ) { 52 /** 53 * Fires an action hook after a Yoco payment has been completed for an order. 54 * 55 * @param WC_Order $order The order object. 56 * @param string $payload Yoco Payment data. 57 * 58 * @since 1.0.0 59 */ 43 60 do_action( 'yoco_payment_gateway/payment/completed', $this->order, $payload ); 44 61 62 delete_transient( 'yoco_order_processing_' . $this->order->get_id() ); 45 63 return $this->sendSuccessResponse(); 46 64 } else { 47 65 yoco( Logger::class )->logError( sprintf( 'Failed to complete payment of order #%s.', $this->order->get_id() ) ); 48 66 49 return $this->sendFailResponse( 500, sprintf( 'Failed to complete payment of order #%s.', $this->order->get_id() ) );67 return $this->sendFailResponse( 409, sprintf( 'Failed to complete payment of order #%s.', $this->order->get_id() ) ); 50 68 } 51 69 } -
yoco-payment-gateway/trunk/src/Repositories/OrdersRepository.php
r3067423 r3206321 4 4 5 5 use Exception; 6 use WC_Abstract_Order; 6 7 use WC_Order; 7 8 use Yoco\Gateway\Metadata; … … 12 13 class OrdersRepository { 13 14 14 public static function getById( int $id ): ?WC_ Order {15 public static function getById( int $id ): ?WC_Abstract_Order { 15 16 $order = wc_get_order( $id ); 16 17 17 return is_a( $order, WC_ Order::class ) ? $order : null;18 return is_a( $order, WC_Abstract_Order::class ) ? $order : null; 18 19 } 19 20 … … 56 57 } 57 58 58 public static function getByYocoRefundId( string $refundId ): ?WC_ Order {59 public static function getByYocoRefundId( string $refundId ): ?WC_Abstract_Order { 59 60 $orders = wc_get_orders( 60 61 array( … … 72 73 $order = array_shift( $orders ); 73 74 74 return is_a( $order, WC_ Order::class ) ? $order : null;75 return is_a( $order, WC_Abstract_Order::class ) ? $order : null; 75 76 } 76 77 -
yoco-payment-gateway/trunk/yoco_wc_payment_gateway.php
r3177082 r3206321 6 6 * Author: Yoco 7 7 * Author URI: https://www.yoco.com 8 * Version: 3.8. 08 * Version: 3.8.1 9 9 * Requires at least: 5.0.0 10 10 * Tested up to: 6.6
Note: See TracChangeset
for help on using the changeset viewer.