/** * Sets attendee data on order posts * * @since 4.1 * * @param ShoppPurchase $purchase ShoppPurchase object */ public function save_attendee_meta_to_order($data) { $purchase_log = new WPSC_Purchase_Log($data['purchase_log_id']); $order_items = $purchase_log->get_cart_contents(); // Bail if the order is empty if (empty($order_items)) { return; } $product_ids = array(); // gather product ids foreach ((array) $order_items as $item) { if (empty($item->prodid)) { continue; } $product_ids[] = $item->prodid; } $meta_object = Tribe__Tickets_Plus__Main::instance()->meta(); // build the custom meta data that will be stored in the order meta if (!($order_meta = $meta_object->build_order_meta($product_ids))) { return; } // store the custom meta on the order $result = wpsc_add_purchase_meta($purchase_log->get('id'), Tribe__Tickets_Plus__Meta::META_KEY, $order_meta, true); // clear out product custom meta data cookies foreach ($product_ids as $product_id) { $meta_object->clear_meta_cookie_data($product_id); } }
/** * Refund a payment * * @param string $capture_id * @param float $amount * @param string $note */ public function refund_payment($capture_id, $amount, $note) { if ($this->log->get('gateway') == 'amazon-payments') { if ($this->doing_ipn) { return; } $base_country = new WPSC_Country(wpsc_get_base_country()); if ('US' == $base_country->get_isocode() && $amount > $this->log->get('totalprice')) { $this->log->set('amazon-status', __('Unable to refund funds via amazon:', 'wpsc') . ' ' . __('Refund amount is greater than order total.', 'wpsc'))->save(); return; } elseif ($amount > min($this->log->get('totalprice') * 1.15, $this->log->get('totalprice') + 75)) { $this->log->set('amazon-status', __('Unable to refund funds via amazon:', 'wpsc') . ' ' . __('Refund amount is greater than the max refund amount.', 'wpsc'))->save(); return; } $response = $this->gateway->api_request(array('Action' => 'Refund', 'AmazonCaptureId' => $capture_id, 'RefundReferenceId' => $this->log->get('id') . '-' . current_time('timestamp', true), 'RefundAmount.Amount' => $amount, 'RefundAmount.CurrencyCode' => strtoupper($this->gateway->get_currency_code()), 'SellerRefundNote' => $note)); if (is_wp_error($response)) { $this->log->set('amazon-status', __('Unable to refund funds via amazon:', 'wpsc') . ' ' . $response->get_error_message())->save(); } elseif (isset($response['Error']['Message'])) { $this->log->set('amazon-status', $response['Error']['Message'])->save(); } else { $refund_id = $response['RefundResult']['RefundDetails']['AmazonRefundId']; $this->log->set('amazon-status', sprintf(__('Refunded %s (%s)', 'wpsc'), wpsc_currency_display($amount), $note))->save(); $this->log->set('processed', WPSC_Purchase_Log::REFUNDED)->save(); wpsc_add_purchase_meta($this->log->get('id'), 'amazon_refund_id', $refund_id); } } }
/** * Refund payment * * @param string $transaction_id */ public function refund_payment($transaction_id) { if ($this->log->get('gateway') == 'worldpay') { $params = array('amount' => $this->log->get('totalprice'), 'transactionId' => $transaction_id); $response = $this->gateway->execute('Payments/Refund', $params); if (is_wp_error($response)) { throw new Exception($response->get_error_message()); } wpsc_add_purchase_meta($this->log->get('id'), 'worldpay_refunded', true); wpsc_add_purchase_meta($this->log->get('id'), 'worldpay_refund_id', $response['ResponseBody']->transaction->transactionId); $this->log->set('worldpay-status', sprintf(__('Refunded (Transaction ID: %s)', 'wp-e-commerce'), $response['ResponseBody']->transaction->transactionId))->save(); $this->log->set('processed', WPSC_Purchase_Log::REFUNDED)->save(); $this->log->set('wp_order_status', 'Refunded')->save(); $this->log->set('transactid', $response['ResponseBody']->transaction->transactionId)->save(); } }