Skip to content

Commit

Permalink
Merge pull request #153 from antondrob/master
Browse files Browse the repository at this point in the history
Update customer reorder
  • Loading branch information
markusbrunke authored Aug 2, 2022
2 parents 6e844a0 + 95e67e0 commit bf9ecfe
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The Reepay plugin extends WooCommerce allowing you to take payments on your stor
See installation guide right here: https://intercom.help/reepay/reepay-plugins/woocommerce-plugin

== Changelog ==
v 1.4.27 - Update customer after reorder
v 1.4.26 - Fix reorder after cancel
v 1.4.25 - Fix duplicated handle, remove settle button for already settled items
v 1.4.24 - Bugfix
Expand Down
9 changes: 9 additions & 0 deletions includes/abstracts/abstract-wc-gateway-reepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,15 @@ public function process_payment( $order_id ) {
'https://checkout-api.reepay.com/v1/session/charge',
$params
);

if(!empty($customer_handle) && $order->get_customer_id() == 0){
$this->api->request(
'PUT',
'https://api.reepay.com/v1/customer/'.$customer_handle,
$params['order']['customer']
);
}

if ( is_wp_error( $result ) ) {
/** @var WP_Error $result */
if ( 'yes' === $this->handle_failover ) {
Expand Down
17 changes: 15 additions & 2 deletions includes/class-wc-reepay-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,14 @@ public function request( $method, $url, $params = array() ) {
return new WP_Error( $data['code'], sprintf( __( 'API Error: %s - %s.', 'reepay-checkout-gateway' ), $data['error'], $data['message'] ) );
}

return new WP_Error( $http_code,
sprintf( __( 'API Error (request): %s. HTTP Code: %s', 'reepay-checkout-gateway' ), $body, $http_code ) );
if(!empty($data['code']) && !empty($data['error'])){
return new WP_Error( $http_code,
sprintf( __( 'API Error (request): %s. Error Code: %s', 'reepay-checkout-gateway' ), $data['error'], $data['code'] ) );
}else{
return new WP_Error( $http_code,
sprintf( __( 'API Error (request): %s. HTTP Code: %s', 'reepay-checkout-gateway' ), $body, $http_code ) );
}

default:
return new WP_Error( $http_code, __( 'Unknown error.', 'reepay-checkout-gateway' ) );
}
Expand Down Expand Up @@ -772,6 +778,13 @@ public function get_customer_handle_order( $order_id ) {
$order = wc_get_order( $order_id );

$handle = $this->get_customer_handle_online( $order );
if(!empty($handle)){
return $handle;
}

if($order->get_customer_id() == 0){
$handle = $order->get_meta( '_reepay_customer' );
}

if ( empty( $handle ) ) {
if ( $order->get_customer_id() > 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion reepay-woocommerce-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Provides a Payment Gateway through Reepay for WooCommerce.
* Author: reepay
* Author URI: http://reepay.com
* Version: 1.4.26
* Version: 1.4.27
* Text Domain: reepay-checkout-gateway
* Domain Path: /languages
* WC requires at least: 3.0.0
Expand Down

0 comments on commit bf9ecfe

Please sign in to comment.