/** * Sets attendee data on attendee posts * * @since 4.1 * * @param int $attendee_id Attendee Ticket Post ID * @param WPSC_Purchase_Log $purchase_log WPEC purchase log object * @param int $product_id WPEC Product ID * @param int $order_attendee_id Attendee number in submitted order */ public function save_attendee_meta_to_ticket($attendee_id, $purchase_log, $product_id, $order_attendee_id) { $meta = wpsc_get_purchase_meta($purchase_log->get('id'), Tribe__Tickets_Plus__Meta::META_KEY, true); if (!isset($meta[$product_id])) { return; } if (!isset($meta[$product_id][$order_attendee_id])) { return; } update_post_meta($attendee_id, Tribe__Tickets_Plus__Meta::META_KEY, $meta[$product_id][$order_attendee_id]); }
/** * Records the Protection Eligibility status to the Purchase Log on * DoExpressCheckout Call * * @return void */ public function log_protection_status($response) { $params = $response->get_params(); if (isset($params['PAYMENTINFO_0_PROTECTIONELIGIBILITY'])) { $elg = $params['PAYMENTINFO_0_PROTECTIONELIGIBILITY']; } else { $elg = false; } $paypal_log = wpsc_get_purchase_meta($this->purchase_log->get('id'), 'paypal_ec_details', true); $paypal_log['protection'] = $elg; wpsc_update_purchase_meta($this->purchase_log->get('id'), 'paypal_ec_details', $paypal_log); }
/** * pre_auth_box function. * * @access public * @return void */ public function authorization_box() { $actions = array(); $order_id = $this->log->get('id'); // Get ids $amazon_authorization_id = $this->log->get('amazon_authorization_id'); $amazon_reference_id = $this->log->get('amazon_reference_id'); $amazon_capture_id = $this->log->get('amazon_capture_id'); $amazon_refund_ids = wpsc_get_purchase_meta($order_id, 'amazon_refund_id'); ?> <div class="metabox-holder"> <div id="wpsc-amazon-payments" class="postbox"> <h3 class='hndle'><?php _e('Amazon Payments', 'wpsc'); ?> </h3> <div class='inside'> <p><?php _e('Current status: ', 'wpsc'); echo wp_kses_data($this->log->get('amazon-status')); ?> </p> <?php if ($amazon_capture_id) { $amazon_capture_state = $this->get_capture_state($amazon_capture_id); switch ($amazon_capture_state) { case 'Pending': echo wpautop(sprintf(__('Capture Reference %s is <strong>%s</strong>.', 'wpsc'), $amazon_capture_id, $amazon_capture_state) . ' <a href="#" data-action="refresh" class="refresh">' . __('Refresh', 'wpsc') . '</a>'); // Admin will need to re-check this, so clear the stored value $this->clear_stored_states($order_id); break; case 'Declined': echo wpautop(__('The capture was declined.', 'wpsc')); $actions['authorize'] = array('id' => $amazon_reference_id, 'button' => __('Re-authorize?', 'wpsc')); break; case 'Completed': echo wpautop(sprintf(__('Capture Reference %s is <strong>%s</strong>.', 'wpsc'), $amazon_capture_id, $amazon_capture_state) . ' <a href="#" class="toggle_refund">' . __('Make a refund?', 'wpsc') . '</a>'); // Refund form ?> <p class="refund_form" style="display:none"> <input type="number" step="any" style="width:100%" class="amazon_refund_amount" value="<?php echo $this->log->get('totalprice'); ?> " /> <input type="text" style="width:100%" class="amazon_refund_note" placeholder="<?php _e('Add a note about this refund', 'wpsc'); ?> " /><br/> <a href="#" class="button" data-action="refund" data-id="<?php echo esc_attr($amazon_capture_id); ?> "><?php _e('Refund', 'wpsc'); ?> </a> </form> <?php break; case 'Closed': echo wpautop(sprintf(__('Capture Reference %s is <strong>%s</strong>.', 'wpsc'), $amazon_capture_id, $amazon_capture_state)); break; } // Display refunds if ($amazon_refund_ids) { $refunds = (array) $this->log->get('amazon_refunds'); foreach ($amazon_refund_ids as $amazon_refund_id) { if (isset($refunds[$amazon_refund_id])) { if (empty($refunds[$amazon_refund_id]['note'])) { $refunds[$amazon_refund_id]['note'] = _x('no note was entered', 'Amazon refund default note', 'wpsc'); } echo wpautop(sprintf(__('Refund %s of %s is <strong>%s</strong> (%s).', 'wpsc'), $amazon_refund_id, wpsc_currency_display($refunds[$amazon_refund_id]['amount']), $refunds[$amazon_refund_id]['state'], $refunds[$amazon_refund_id]['note'])); } else { $response = $this->gateway->api_request(array('Action' => 'GetRefundDetails', 'AmazonRefundId' => $amazon_refund_id)); if (!is_wp_error($response) && !isset($response['Error']['Message'])) { $note = $response['GetRefundDetailsResult']['RefundDetails']['SellerRefundNote']; $state = $response['GetRefundDetailsResult']['RefundDetails']['RefundStatus']['State']; $amount = $response['GetRefundDetailsResult']['RefundDetails']['RefundAmount']['Amount']; echo wpautop(sprintf(__('Refund %s of %s is <strong>%s</strong> (%s).', 'wpsc'), $amazon_refund_id, wpsc_currency_display($amount), $state, $note)); if ($state == 'Completed') { $refunds[$amazon_refund_id] = array('state' => $state, 'amount' => $amount, 'note' => $note); } } } } $this->log->set('amazon_refunds', $refunds)->save(); } } elseif ($amazon_authorization_id) { $amazon_authorization_state = $this->get_authorization_state($order_id, $amazon_authorization_id); echo wpautop(sprintf(__('Auth Reference %s is <strong>%s</strong>.', 'wpsc'), $amazon_reference_id, $amazon_authorization_state) . ' <a href="#" data-action="refresh" class="refresh">' . __('Refresh', 'wpsc') . '</a>'); switch ($amazon_authorization_state) { case 'Open': $actions['capture'] = array('id' => $amazon_authorization_id, 'button' => __('Capture funds', 'wpsc')); $actions['close_authorization'] = array('id' => $amazon_authorization_id, 'button' => __('Close Authorization', 'wpsc')); break; case 'Pending': echo wpautop(__('You cannot capture funds while the authorization is pending. Try again later.', 'wpsc')); // Admin will need to re-check this, so clear the stored value $this->clear_stored_states($order_id); break; case 'Closed': case 'Declined': $actions['authorize'] = array('id' => $amazon_reference_id, 'button' => __('Authorize again', 'wpsc')); break; } } elseif ($amazon_reference_id) { $amazon_reference_state = $this->get_reference_state($amazon_reference_id); echo wpautop(sprintf(__('Order Reference %s is <strong>%s</strong>.', 'wpsc'), $amazon_reference_id, $amazon_reference_state) . ' <a href="#" data-action="refresh" class="refresh">' . __('Refresh', 'wpsc') . '</a>'); switch ($amazon_reference_state) { case 'Open': $actions['authorize'] = array('id' => $amazon_reference_id, 'button' => __('Authorize', 'wpsc')); $actions['authorize_capture'] = array('id' => $amazon_reference_id, 'button' => __('Authorize & Capture', 'wpsc')); break; case 'Suspended': echo wpautop(__('The reference has been suspended. Another form of payment is required.', 'wpsc')); break; case 'Canceled': case 'Suspended': echo wpautop(__('The reference has been cancelled/closed. No authorizations can be made.', 'wpsc')); break; } } if (!empty($actions)) { echo '<p class="buttons">'; foreach ($actions as $action_name => $action) { echo '<a href="#" class="button" data-action="' . $action_name . '" data-id="' . $action['id'] . '">' . $action['button'] . '</a> '; } echo '</p>'; } ?> <script type="text/javascript"> jQuery( document ).ready( function( $ ) { $('#wpsc-amazon-payments').on( 'click', 'a.button, a.refresh', function( e ) { var $this = $( this ); e.preventDefault(); var data = { action: 'amazon_order_action', security: '<?php echo wp_create_nonce("amazon_order_action"); ?> ', order_id: '<?php echo $order_id; ?> ', amazon_action: $this.data('action'), amazon_id: $this.data('id'), amazon_refund_amount: jQuery('.amazon_refund_amount').val(), amazon_refund_note: jQuery('.amazon_refund_note').val(), }; // Ajax action $.post( ajaxurl, data, function( result ) { location.reload(); }, 'json' ); return false; }); $('#wpsc-amazon-payments').on( 'click', 'a.toggle_refund', function(){ jQuery('.refund_form').slideToggle(); return false; }); } ); </script> </div> </div> </div> <?php }
/** * Records the Protection Eligibility status to the Purchase Log * after the purchase process * * @param PHP_Merchant_Paypal_Pro_Response $response * @return void */ public function log_protection_status($response) { $params = $response->get_params(); $elg = $params['PROTECTIONELIGIBILITY']; $paypal_log = wpsc_get_purchase_meta($this->purchase_log->get('id'), 'paypal_pro_details', true); $paypal_log['protection'] = $elg; wpsc_update_purchase_meta($this->purchase_log->get('id'), 'paypal_pro_details', $paypal_log); }
/** * Retrieve purchase meta fields, based on purchase ID. * * The purchase meta fields are retrieved from the cache where possible, * so the function is optimized to be called more than once. * This meta data function mirrors a corresponding wordpress post meta function. * * @since 3.8.14 * * @param int $purchase_id purchase ID. * @return array */ function wpsc_get_purchase_custom($purchase_id = 0) { $purchase_id = absint($purchase_id); return wpsc_get_purchase_meta($purchase_id); }
private function set_meta_props() { foreach (wpsc_get_purchase_custom($this->get('id')) as $key => $value) { $this->meta_data[$key] = wpsc_get_purchase_meta($this->get('id'), $key, true); } $this->set_total_shipping(); $this->set_gateway_name(); $this->set_shipping_method_names(); }
/** * pre_auth_box function. * * @access public * @return void */ public function authorization_box() { $actions = array(); $order_id = $this->log->get('id'); // Get ids $wp_transaction_id = $this->log->get('wp_transactionId'); $wp_auth_code = $this->log->get('wp_authcode'); $wp_order_status = $this->log->get('wp_order_status'); //Don't change order status if a refund has been requested $wp_refund_set = wpsc_get_purchase_meta($order_id, 'worldpay_refunded', true); $order_info = $this->refresh_transaction_info($wp_transaction_id, !(bool) $wp_refund_set); ?> <div class="metabox-holder"> <div id="wpsc-worldpay-payments" class="postbox"> <h3 class='hndle'><?php _e('WorldPay Payments', 'wp-e-commerce'); ?> </h3> <div class='inside'> <p><?php _e('Current status: ', 'wp-e-commerce'); echo wp_kses_data($this->log->get('worldpay-status')); ?> </p> <p><?php _e('Transaction ID: ', 'wp-e-commerce'); echo wp_kses_data($wp_transaction_id); ?> </p> <?php //Show actions based on order status switch ($wp_order_status) { case 'Open': //Order is only authorized and still not captured/voided $actions['capture'] = array('id' => $wp_transaction_id, 'button' => __('Capture funds', 'wp-e-commerce')); // if (!$order_info['settled']) { //Void $actions['void'] = array('id' => $wp_transaction_id, 'button' => __('Void order', 'wp-e-commerce')); } break; case 'Completed': //Order has been captured or its a direct payment if ($order_info['settled']) { //Refund $actions['refund'] = array('id' => $wp_transaction_id, 'button' => __('Refund order', 'wp-e-commerce')); } else { //Void $actions['void'] = array('id' => $wp_transaction_id, 'button' => __('Void order', 'wp-e-commerce')); } break; case 'Refunded': //Order is settled and a refund has been requested $wp_refund_id = wpsc_get_purchase_meta($order_id, 'worldpay_refund_id', true); if ($wp_refund_id) { //Get refund order status to check if its eligible for a void (not settled) $refund_status = $this->refresh_transaction_info($wp_refund_id, false); if (!$refund_status['settled']) { //Show void only if not settled. $actions['void_refund'] = array('id' => $wp_refund_id, 'button' => __('Void Refund request', 'wp-e-commerce')); } } break; case 'Voided': break; } if (!empty($actions)) { echo '<p class="buttons">'; foreach ($actions as $action_name => $action) { echo '<a href="#" class="button" data-action="' . $action_name . '" data-id="' . $action['id'] . '">' . $action['button'] . '</a> '; } echo '</p>'; } ?> <script type="text/javascript"> jQuery( document ).ready( function( $ ) { $('#wpsc-worldpay-payments').on( 'click', 'a.button, a.refresh', function( e ) { var $this = $( this ); e.preventDefault(); var data = { action: 'worldpay_order_action', security: '<?php echo wp_create_nonce("wp_order_action"); ?> ', order_id: '<?php echo $order_id; ?> ', worldpay_action: $this.data('action'), worldpay_id: $this.data('id'), worldpay_refund_amount: $('.worldpay_refund_amount').val(), }; // Ajax action $.post( ajaxurl, data, function( result ) { location.reload(); }, 'json' ); return false; }); } ); </script> </div> </div> </div> <?php }