Pengyi

Untitled

May 22nd, 2020
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. $order->refund->location_id = $this->get_order_meta( $order, 'square_location_id' );
  2.         $order->refund->tender_id   = $this->get_order_meta( $order, 'authorization_code' );
  3.  
  4.         if ( ! $order->refund->tender_id ) {
  5.  
  6.             try {
  7.  
  8.                 $response = $this->get_api()->get_transaction( $order->refund->trans_id, $order->refund->location_id );
  9.  
  10.                 if ( ! $response->get_authorization_code() ) {
  11.                     throw new Framework\SV_WC_Plugin_Exception( 'Tender missing' );
  12.                 }
  13.  
  14.                 $this->update_order_meta( $order, 'authorization_code', $response->get_authorization_code() );
  15.                 $this->update_order_meta( $order, 'square_location_id', $response->get_location_id() );
  16.  
  17.                 $order->refund->location_id = $response->get_location_id();
  18.                 $order->refund->tender_id   = $response->get_authorization_code();
  19.  
  20.             } catch ( Framework\SV_WC_Plugin_Exception $exception ) {
  21.  
  22.                 return new \WP_Error( 'wc_square_refund_tender_missing', __( 'Could not find original transaction tender. Please refund this transaction from your Square dashboard.', 'woocommerce-square' ) );
  23.             }
  24.         }
Add Comment
Please, Sign In to add comment