Changeset 2745338
- Timestamp:
- 06/20/2022 02:36:09 PM (4 years ago)
- Location:
- drip-payments/trunk
- Files:
-
- 3 edited
-
drip-payments.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
-
src/DripUtils.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
drip-payments/trunk/drip-payments.php
r2744264 r2745338 4 4 * Description: Forneça a Drip como opção de pagamento para pedidos do WooCommerce. 5 5 * Author: Drip 6 * Version: 1. 2.26 * Version: 1.3.0 7 7 */ 8 8 … … 341 341 342 342 $checkout_id = sanitize_text_field($_GET['checkoutId']); 343 $checkout = $this->checkout_request->getCheckout($checkout_id); 343 try { 344 $checkout = $this->checkout_request->getCheckout($checkout_id); 345 if ($checkout == false) { 346 throw new Exception("Cannot find checkout on Drip"); 347 } 348 } catch (Exception $e) { 349 wp_die(esc_attr('Could not get checkout from drip backend: ' . $checkout_id), 'Drip', array('response' => 500)); 350 } 344 351 345 352 if ($checkout) { 346 $order_id = $checkout->merchantCode; 347 $order = wc_get_order($order_id); 348 } 349 350 if (!$order || $order->get_payment_method() != $this->id) { 353 try { 354 $order_id = $checkout->merchantCode; 355 $order = wc_get_order($order_id); 356 if ($order == false) { 357 throw new Exception("Cannot find order by merchantCode"); 358 } 359 } catch (Exception $e) { 360 wp_die(esc_attr('Could not order from store, merchantCode on drip: ' . $order_id), 'Drip', array('response' => 500)); 361 } 362 } 363 364 if ($order->get_payment_method() != $this->id) { 351 365 self::log("FINISHED in order check"); 352 wp_die(esc_attr('Could not get order details for drip order: ' . $checkout_id), 'Drip', array('response' => 500)); 353 } 354 355 $headers = $this->getRequestHeaders(); 366 wp_die(esc_attr('Payment method from checkout ' . $checkout_id . ' is not from Drip'), 'Drip', array('response' => 500)); 367 } 368 369 try { 370 $headers = $this->getRequestHeaders(); 371 } catch (Exception $e) { 372 wp_die(esc_attr('Cannot get headers from request, actual headers: ' . json_encode($headers)), 'Drip', array('response' => 500)); 373 } 356 374 357 375 $accept_json = str_contains($headers["Accept"], "json"); … … 361 379 362 380 if (!$order->is_paid()) { 363 $order->add_order_note('Ordem aprovada pela Drip.'); 364 $order->payment_complete($checkout->checkout_id); 365 $order->update_meta_data('drip_paid_checkout_id', $checkout_id); 366 $order->save(); 381 try { 382 $order->add_order_note('Ordem aprovada pela Drip.'); 383 $order->payment_complete($checkout->checkout_id); 384 $order->update_meta_data('drip_paid_checkout_id', $checkout_id); 385 $order->save(); 386 } catch (Exception $e) { 387 wp_die(esc_attr('Cannot update order to paid status'), 'Drip', array('response' => 500)); 388 } 367 389 } 368 390 if ($accept_json) { … … 377 399 378 400 if (!$order->has_status('failed')) { 379 $order->add_order_note(esc_attr(sprintf(__('Ordem rejeitada pela Drip. Drip Checkout ID: %s.', 'woo_drip')), $checkout_id)); 380 $order->update_status('failed'); 401 try { 402 $order->add_order_note(esc_attr(sprintf(__('Ordem rejeitada pela Drip. Drip Checkout ID: %s.', 'woo_drip')), $checkout_id)); 403 $order->update_status('failed'); 404 } catch (Exception $e) { 405 wp_die(esc_attr('Cannot update order to paid status'), 'Drip', array('response' => 500)); 406 } 381 407 } 382 408 if ($accept_json) { -
drip-payments/trunk/readme.txt
r2744264 r2745338 5 5 Tested up to: 6.0 6 6 Requires PHP: 7.0 7 Stable tag: 1. 2.27 Stable tag: 1.3.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
drip-payments/trunk/src/DripUtils.php
r2744264 r2745338 11 11 const DRIP_PAYMENTS_BASE_URI_PRODUCTION = 'https://drip-be.usedrip.com.br/api/'; 12 12 13 const DRIP_PAYMENTS_ACTUAL_PLUGIN_VERSION = '1. 2.2';13 const DRIP_PAYMENTS_ACTUAL_PLUGIN_VERSION = '1.3.0'; 14 14 } 15 15
Note: See TracChangeset
for help on using the changeset viewer.