public function __construct(WC_XR_Payment $payment)
 {
     // Set Endpoint
     $this->set_endpoint('Payments');
     // Set the XML
     $this->set_body('<Payments>' . $payment->to_xml() . '</Payments>');
 }
 /**
  * Get payment by order
  *
  * @param WC_Order $order
  *
  * @return WC_XR_Payment
  */
 public function get_payment_by_order($order)
 {
     // Get the XERO invoice ID
     $invoice_id = get_post_meta($order->id, '_xero_invoice_id', true);
     // Get the XERO currency rate
     $currency_rate = get_post_meta($order->id, '_xero_currencyrate', true);
     // Date time object of order data
     $order_dt = new DateTime($order->order_date);
     // Settings object
     $settings = new WC_XR_Settings();
     // The Payment object
     $payment = new WC_XR_Payment();
     // Set the invoice ID
     $payment->set_invoice_id($invoice_id);
     // Set the Payment Account code
     $payment->set_code($settings->get_option('payment_account'));
     // Set the payment date
     $payment->set_date($order_dt->format('Y-m-d'));
     // Set the currency rate
     $payment->set_currency_rate($currency_rate);
     // Set the amount
     $payment->set_amount($order->order_total);
     return $payment;
 }