示例#1
0
 public function void($Event)
 {
     shopp_add_order_event($Event->order, 'voided', array('txnorigin' => $Event->txnid, 'txnid' => time(), 'gateway' => $this->module));
 }
示例#2
0
 public function void(OrderEventMessage $Event)
 {
     $Purchase = new ShoppPurchase($Event->order);
     shopp_add_order_event($Purchase->id, 'voided', array('txnorigin' => $Purchase->txnid, 'txnid' => time(), 'gateway' => $Event->gateway));
 }
示例#3
0
 /**
  * Interface processor for the order manager
  *
  * @author Jonathan Davis
  * @return void
  **/
 public function manager()
 {
     global $Shopp, $Notes;
     global $is_IIS;
     if (!current_user_can('shopp_orders')) {
         wp_die(__('You do not have sufficient permissions to access this page.', 'Shopp'));
     }
     $Purchase = ShoppPurchase();
     $Purchase->Customer = new ShoppCustomer($Purchase->customer);
     $Gateway = $Purchase->gateway();
     if (!empty($_POST["send-note"])) {
         $user = wp_get_current_user();
         shopp_add_order_event($Purchase->id, 'note', array('note' => stripslashes($_POST['note']), 'user' => $user->ID));
         $Purchase->load_events();
     }
     // Handle Order note processing
     if (!empty($_POST['note'])) {
         $this->addnote($Purchase->id, stripslashes($_POST['note']), !empty($_POST['send-note']));
     }
     if (!empty($_POST['delete-note'])) {
         $noteid = key($_POST['delete-note']);
         $Note = new ShoppMetaObject(array('id' => $noteid, 'type' => 'order_note'));
         $Note->delete();
     }
     if (!empty($_POST['edit-note'])) {
         $noteid = key($_POST['note-editor']);
         $Note = new ShoppMetaObject(array('id' => $noteid, 'type' => 'order_note'));
         $Note->value->message = stripslashes($_POST['note-editor'][$noteid]);
         $Note->save();
     }
     $Notes = new ObjectMeta($Purchase->id, 'purchase', 'order_note');
     if (isset($_POST['submit-shipments']) && isset($_POST['shipment']) && !empty($_POST['shipment'])) {
         $shipments = $_POST['shipment'];
         foreach ((array) $shipments as $shipment) {
             shopp_add_order_event($Purchase->id, 'shipped', array('tracking' => $shipment['tracking'], 'carrier' => $shipment['carrier']));
         }
         $updated = __('Shipping notice sent.', 'Shopp');
         // Save shipping carrier default preference for the user
         $userid = get_current_user_id();
         $setting = 'shopp_shipping_carrier';
         if (!get_user_meta($userid, $setting, true)) {
             add_user_meta($userid, $setting, $shipment['carrier']);
         } else {
             update_user_meta($userid, $setting, $shipment['carrier']);
         }
         unset($_POST['ship-notice']);
         $Purchase->load_events();
     }
     if (isset($_POST['order-action']) && 'refund' == $_POST['order-action']) {
         if (!current_user_can('shopp_refund')) {
             wp_die(__('You do not have sufficient permissions to carry out this action.', 'Shopp'));
         }
         $user = wp_get_current_user();
         $reason = (int) $_POST['reason'];
         $amount = Shopp::floatval($_POST['amount']);
         $Purchase->load_events();
         if (!empty($_POST['message'])) {
             $message = $_POST['message'];
             $Purchase->message['note'] = $message;
         }
         if ($amount <= $Purchase->captured - $Purchase->refunded) {
             if (!Shopp::str_true($_POST['send'])) {
                 // Force the order status
                 shopp_add_order_event($Purchase->id, 'notice', array('user' => $user->ID, 'kind' => 'refunded', 'notice' => __('Marked Refunded', 'Shopp')));
                 shopp_add_order_event($Purchase->id, 'refunded', array('txnid' => $Purchase->txnid, 'gateway' => $Gateway->module, 'amount' => $amount));
                 shopp_add_order_event($Purchase->id, 'voided', array('txnorigin' => $Purchase->txnid, 'txnid' => time(), 'gateway' => $Gateway->module));
             } else {
                 shopp_add_order_event($Purchase->id, 'refund', array('txnid' => $Purchase->txnid, 'gateway' => $Gateway->module, 'amount' => $amount, 'reason' => $reason, 'user' => $user->ID));
             }
             if (!empty($_POST['message'])) {
                 $this->addnote($Purchase->id, $_POST['message']);
             }
             $Purchase->load_events();
         } else {
             $this->notice(Shopp::__('Refund failed. Cannot refund more than the current balance.'), 'error');
         }
     }
     if (isset($_POST['order-action']) && 'cancel' == $_POST['order-action']) {
         if (!current_user_can('shopp_void')) {
             wp_die(__('You do not have sufficient permissions to carry out this action.', 'Shopp'));
         }
         // unset($_POST['refund-order']);
         $user = wp_get_current_user();
         $reason = (int) $_POST['reason'];
         $message = '';
         if (!empty($_POST['message'])) {
             $message = $_POST['message'];
             $Purchase->message['note'] = $message;
         } else {
             $message = 0;
         }
         if (!Shopp::str_true($_POST['send'])) {
             // Force the order status
             shopp_add_order_event($Purchase->id, 'notice', array('user' => $user->ID, 'kind' => 'cancelled', 'notice' => __('Marked Cancelled', 'Shopp')));
             shopp_add_order_event($Purchase->id, 'voided', array('txnorigin' => $Purchase->txnid, 'txnid' => time(), 'gateway' => $Gateway->module));
         } else {
             shopp_add_order_event($Purchase->id, 'void', array('txnid' => $Purchase->txnid, 'gateway' => $Gateway->module, 'reason' => $reason, 'user' => $user->ID, 'note' => $message));
         }
         if (!empty($_POST['message'])) {
             $this->addnote($Purchase->id, $_POST['message']);
         }
         $Purchase->load_events();
     }
     if (isset($_POST['billing']) && is_array($_POST['billing'])) {
         $Purchase->updates($_POST['billing']);
         $Purchase->save();
     }
     if (isset($_POST['shipping']) && is_array($_POST['shipping'])) {
         $shipping = array();
         foreach ($_POST['shipping'] as $name => $value) {
             $shipping["ship{$name}"] = $value;
         }
         $Purchase->updates($shipping);
         $Purchase->shipname = $shipping['shipfirstname'] . ' ' . $shipping['shiplastname'];
         $Purchase->save();
     }
     if (isset($_POST['order-action']) && 'update-customer' == $_POST['order-action'] && !empty($_POST['customer'])) {
         $Purchase->updates($_POST['customer']);
         $Purchase->save();
     }
     if (isset($_POST['cancel-edit-customer'])) {
         unset($_POST['order-action'], $_POST['edit-customer'], $_POST['select-customer']);
     }
     if (isset($_POST['order-action']) && 'new-customer' == $_POST['order-action'] && !empty($_POST['customer']) && !isset($_POST['cancel-edit-customer'])) {
         $Customer = new ShoppCustomer();
         $Customer->updates($_POST['customer']);
         $Customer->password = wp_generate_password(12, true);
         if ('wordpress' == shopp_setting('account_system')) {
             $Customer->create_wpuser();
         } else {
             unset($_POST['loginname']);
         }
         $Customer->save();
         if ((int) $Customer->id > 0) {
             $Purchase->copydata($Customer);
             $Purchase->save();
         } else {
             $this->notice(__('An unknown error occured. The customer could not be created.', 'Shopp'), 'error');
         }
     }
     if (isset($_GET['order-action']) && 'change-customer' == $_GET['order-action'] && !empty($_GET['customerid'])) {
         $Customer = new ShoppCustomer((int) $_GET['customerid']);
         if ((int) $Customer->id > 0) {
             $Purchase->copydata($Customer);
             $Purchase->customer = $Customer->id;
             $Purchase->save();
         } else {
             $this->notice(__('The selected customer was not found.', 'Shopp'), 'error');
         }
     }
     if (isset($_POST['save-item']) && !empty($_POST['lineid'])) {
         // Create a cart representation of the order to recalculate order totals
         $Cart = new ShoppCart();
         foreach ($Purchase->purchased as $OrderItem) {
             $CartItem = new Item($OrderItem);
             $Cart->contents[$OrderItem->id] = $CartItem;
         }
         $purchasedid = (int) $_POST['lineid'];
         $Purchased = $Purchase->purchased[$purchasedid];
         if ($Purchased->id) {
             $override_total = Shopp::floatval($_POST['total']) != $Purchased->total;
             // Override total
             $Item = $Cart->contents[$purchasedid];
             $Item->quantity($_POST['quantity']);
             $Item->unitprice = Shopp::floatval($_POST['unitprice']);
             $Item->retotal();
             $Purchased->quantity = $Item->quantity;
             $Purchased->unitprice = $Item->unitprice;
             $Purchased->unittax = $Item->unittax;
             $Purchased->total = $Item->total;
             if ($override_total) {
                 $Purchased->total = Shopp::floatval($_POST['total']);
             }
             $Purchased->save();
         }
         $Cart->retotal = true;
         $Cart->totals();
         $Purchase->copydata($Cart->Totals);
         $Purchase->save();
     }
     if (isset($_POST['charge']) && $Gateway && $Gateway->captures) {
         if (!current_user_can('shopp_capture')) {
             wp_die(__('You do not have sufficient permissions to carry out this action.', 'Shopp'));
         }
         $user = wp_get_current_user();
         shopp_add_order_event($Purchase->id, 'capture', array('txnid' => $Purchase->txnid, 'gateway' => $Purchase->gateway, 'amount' => $Purchase->capturable(), 'user' => $user->ID));
         $Purchase->load_events();
     }
     $base = shopp_setting('base_operations');
     $targets = shopp_setting('target_markets');
     $countries = array('' => '&nbsp;');
     $countrydata = Lookup::countries();
     foreach ($countrydata as $iso => $c) {
         if ($base['country'] == $iso) {
             $base_region = $c['region'];
         }
         $countries[$iso] = $c['name'];
     }
     $Purchase->_countries = $countries;
     $regions = Lookup::country_zones();
     $Purchase->_billing_states = array_merge(array('' => '&nbsp;'), (array) $regions[$Purchase->country]);
     $Purchase->_shipping_states = array_merge(array('' => '&nbsp;'), (array) $regions[$Purchase->shipcountry]);
     // Setup shipping carriers menu and JS data
     $carriers_menu = $carriers_json = array();
     $shipping_carriers = (array) shopp_setting('shipping_carriers');
     // The store-preferred shipping carriers
     $shipcarriers = Lookup::shipcarriers();
     // The full list of available shipping carriers
     $notrack = Shopp::__('No Tracking');
     // No tracking label
     $default = get_user_meta(get_current_user_id(), 'shopp_shipping_carrier', true);
     if (isset($shipcarriers[$default])) {
         $carriers_menu[$default] = $shipcarriers[$default]->name;
         $carriers_json[$default] = array($shipcarriers[$default]->name, $shipcarriers[$default]->trackpattern);
     } else {
         $carriers_menu['NOTRACKING'] = $notrack;
         $carriers_json['NOTRACKING'] = array($notrack, false);
     }
     $serviceareas = array('*', $base['country']);
     foreach ($shipcarriers as $code => $carrier) {
         if ($code == $default) {
             continue;
         }
         if (!empty($shipping_carriers) && !in_array($code, $shipping_carriers)) {
             continue;
         }
         if (!in_array($carrier->areas, $serviceareas)) {
             continue;
         }
         $carriers_menu[$code] = $carrier->name;
         $carriers_json[$code] = array($carrier->name, $carrier->trackpattern);
     }
     if (isset($shipcarriers[$default])) {
         $carriers_menu['NOTRACKING'] = $notrack;
         $carriers_json['NOTRACKING'] = array($notrack, false);
     }
     if (empty($statusLabels)) {
         $statusLabels = array('');
     }
     include $this->ui('order.php');
 }
示例#4
0
 /**
  * Handles product file download requests
  *
  * @author Jonathan Davis
  * @since 1.1
  *
  * @return void
  **/
 public function download()
 {
     $Shopp = Shopp::object();
     $download = $this->request['shopp_download'];
     $Purchase = false;
     $Purchased = false;
     if (defined('WP_ADMIN')) {
         $forbidden = false;
         $Download = new ProductDownload($download);
     } else {
         $Order = ShoppOrder();
         $accounts = 'none' != shopp_setting('account_system');
         $Download = new ProductDownload();
         $Download->loadby_dkey($download);
         $Purchased = $Download->purchased();
         $Purchase = new ShoppPurchase($Purchased->purchase);
         $Purchase->load_events();
         $name = $Purchased->name . (!empty($Purchased->optionlabel) ? ' (' . $Purchased->optionlabel . ')' : '');
         $forbidden = false;
         // Voided orders
         if ($Purchase->isvoid()) {
             shopp_add_error(Shopp::__('&quot;%s&quot; cannot be downloaded because the order has been cancelled.', $name));
             $forbidden = true;
         }
         // Purchase Completion check
         if (!$Purchase->ispaid() && !SHOPP_PREPAYMENT_DOWNLOADS) {
             shopp_add_error(Shopp::__('&quot;%s&quot; cannot be downloaded because payment has not been received yet.', $name));
             $forbidden = true;
         }
         // If accounts are used and this is not a guest account
         if ($accounts && Shopp::__('Guest') != ShoppCustomer()->type) {
             // User must be logged in when accounts are being used
             if (!ShoppCustomer()->loggedin()) {
                 shopp_add_error(Shopp::__('You must login to download purchases.'));
                 $forbidden = true;
             }
             // Logged in account must be the owner of the purchase
             if (ShoppCustomer()->id != $Purchase->customer) {
                 shopp_add_error(Shopp::__('You are not authorized to download the requested file.'));
                 $forbidden = true;
             }
         }
         // Download limit checking
         if (shopp_setting('download_limit') && $Purchased->downloads + 1 > shopp_setting('download_limit')) {
             shopp_add_error(Shopp::__('&quot;%s&quot; is no longer available for download because the download limit has been reached.', $name));
             $forbidden = true;
         }
         // Download expiration checking
         if (shopp_setting('download_timelimit') && $Purchased->created + shopp_setting('download_timelimit') < current_time('timestamp')) {
             shopp_add_error(Shopp::__('&quot;%s&quot; is no longer available for download because it has expired.', 'Shopp', $name));
             $forbidden = true;
         }
         // IP restriction checks
         if ('ip' == shopp_setting('download_restriction') && !empty($Purchase->ip) && $Purchase->ip != $_SERVER['REMOTE_ADDR']) {
             shopp_add_error(Shopp::__('&quot;%s&quot; cannot be downloaded because your computer could not be verified as the system the file was purchased from.', $name));
             $forbidden = true;
         }
         do_action_ref_array('shopp_download_request', array($Purchased));
     }
     if (apply_filters('shopp_download_forbidden', $forbidden, $Purchased)) {
         Shopp::redirect(add_query_arg('downloads', '', Shopp::url(false, 'account')), true, 303);
     }
     // Send the download
     $download = $Download->download();
     if (is_a($download, 'ShoppError')) {
         // If the result is an error redirect to the account downloads page
         Shopp::redirect(add_query_arg('downloads', '', Shopp::url(false, 'account')), true, 303);
     } else {
         do_action_ref_array('shopp_download_success', array($Purchased, $Purchase, $Download));
         // @deprecated use shopp_download_order_event instead
         shopp_add_order_event($Purchase->id, 'download', array('purchased' => $Purchased->id, 'download' => $Download->id, 'ip' => ShoppShopping()->ip, 'customer' => ShoppCustomer()->id));
     }
     exit;
 }
示例#5
0
/**
 * shopp_rmv_order_line - remove an order line by index
 *
 * @api
 * @since 1.2
 *
 * @param int $order (required) the order id to remove the line from
 * @param int $line (optional default:0) the index of the line to remove
 * @return bool true on success, false on failure
 **/
function shopp_rmv_order_line($order = false, $line = 0)
{
    $Lines = shopp_order_lines($order);
    $ids = array_keys($Lines);
    if (!isset($ids[$line])) {
        return false;
    }
    $id = $ids[$line];
    if (empty($Lines) || $line >= count($Lines)) {
        return false;
    }
    $Purchased = new ShoppPurchased();
    $Purchased->populate($Lines[$id]);
    $Purchase = shopp_order($order);
    $Purchase->subtotal -= $Purchased->unitprice * $Purchased->quantity;
    $Purchase->tax -= $Purchased->unittax * $Purchased->quantity;
    $Purchase->freight -= $Purchased->shipping;
    $total_removed = $Purchased->total + $Purchased->unittax * $Purchased->quantity + $Purchased->shipping;
    $Purchase->total -= $total_removed;
    $Purchased->delete();
    $Purchase->save();
    if ($Purchase->balance && $Purchase->balance >= $total_removed) {
        // invoice new amount
        shopp_add_order_event($Purchase->id, 'amt-voided', array('amount' => $total_removed));
    }
    return true;
}
示例#6
0
 /**
  * Converts a shopping session order to a Purchase record
  *
  * @author Jonathan Davis
  * @since 1.1
  *
  * @return void
  **/
 public function purchase(PurchaseOrderEvent $Event)
 {
     $Shopping = ShoppShopping();
     $changed = $this->changed();
     // No auth message, bail
     if (empty($Event)) {
         shopp_debug('Order failure: An empty order event message was received by the order processor.');
         return;
     }
     // Copy details from Auth message
     $this->txnstatus = $Event->name;
     $this->gateway = $Event->gateway;
     $paycard = Lookup::paycard($this->Billing->cardtype);
     $this->Billing->cardtype = !$paycard ? $this->Billing->cardtype : $paycard->name;
     $Paymethod = $this->Payments->selected();
     $shipoption = $this->Shiprates->selected();
     if (empty($this->inprogress)) {
         // Create a new order
         $Purchase = new ShoppPurchase();
     } elseif (empty(ShoppPurchase()->id)) {
         // Handle updates to an existing order from checkout reprocessing
         $Purchase = new ShoppPurchase($this->inprogress);
     } else {
         // Update existing order
         $Purchase = ShoppPurchase();
     }
     // Capture early event transaction IDs
     if (isset($Event->txnid)) {
         $Purchase->txnid = $this->txnid = $Event->txnid;
     }
     $Purchase->order = 0;
     $Purchase->copydata($this);
     $Purchase->copydata($this->Customer);
     $Purchase->copydata($this->Billing);
     $Purchase->copydata($this->Shipping, 'ship');
     $Purchase->copydata($this->Cart->Totals->data());
     $Purchase->subtotal = $Purchase->order;
     // Remap order to subtotal
     $Purchase->paymethod = $Paymethod->slug;
     $Purchase->customer = $this->Customer->id;
     $Purchase->taxing = shopp_setting_enabled('tax_inclusive') ? 'inclusive' : 'exclusive';
     $Purchase->freight = $this->Cart->total('shipping');
     $Purchase->shipoption = isset($shipoption->name) ? $shipoption->name : '';
     $Purchase->ip = $Shopping->ip;
     $Purchase->created = current_time('mysql');
     unset($Purchase->order);
     $Purchase->save();
     // Catch Purchase record save errors
     if (empty($Purchase->id)) {
         shopp_add_error(Shopp::__('The order could not be created because of a technical problem on the server. Please try again, or contact the website administrator.'));
         return;
     }
     ShoppPurchase($Purchase);
     // Process the order events if updating an existing order
     if (!empty($this->inprogress)) {
         if ($changed) {
             // The order has changed since the last order attempt
             // Rebuild purchased records from cart items
             $Purchase->delete_purchased();
             remove_action('shopp_order_event', array($Purchase, 'notifications'));
             // Void prior invoiced balance
             shopp_add_order_event($Purchase->id, 'voided', array('txnorigin' => '', 'txnid' => '', 'gateway' => $Purchase->gateway));
             // Recreate purchased records from the cart and re-invoice for the new order total
             $this->items($Purchase->id);
             $this->meta($Purchase);
             $this->invoice($Purchase);
             add_action('shopp_order_event', array($Purchase, 'notifications'));
         } elseif ('voided' == $Purchase->txnstatus) {
             $this->invoice($Purchase);
             // Re-invoice cancelled orders that are still in-progress @see #1930
         } elseif ($Purchase->did('invoiced')) {
             // Reet the order status to invoiced without invoicing it again @see #3301
             $Purchase->txnstatus = 'invoiced';
             $Purchase->save();
         }
         $this->process($Purchase);
         return;
     }
     $this->items($Purchase->id);
     // Create purchased records from the cart items
     $this->purchase = false;
     // Clear last purchase in prep for new purchase
     $this->inprogress = $Purchase->id;
     // Keep track of the purchase record in progress for transaction updates
     shopp_debug('Purchase ' . $Purchase->id . ' was successfully saved to the database.');
     // Start the transaction processing events
     do_action('shopp_purchase_order_created', $Purchase);
 }
示例#7
0
 private function process($event, ShoppPurchase $Purchase)
 {
     if (!$Purchase->lock()) {
         return false;
     }
     // Only process order updates if this process can get a lock
     $Message = $this->Message;
     if (in_array($event, array('sale', 'auth', 'capture'))) {
         $this->updates();
         // Make sure purchase orders are invoiced
         if ('purchase' === $Purchase->txnstatus) {
             ShoppOrder()->invoice($Purchase);
         } elseif ('invoiced' === $Purchase->txnstatus) {
             $this->sale($Purchase);
         } elseif ('capture' === $event) {
             if (!$Purchase->capturable()) {
                 return ShoppOrder()->success();
             }
             // Already captured
             if ('voided' === $Purchase->txnstatus) {
                 ShoppOrder()->invoice($Purchase);
             }
             // Reinvoice for cancel-reversals
             shopp_add_order_event($Purchase->id, 'capture', array('txnid' => $Purchase->txnid, 'gateway' => $Purchase->gateway, 'amount' => $Message->amount(), 'user' => $this->settings['label']));
         }
     } elseif ('void' == $event) {
         shopp_add_order_event($Purchase->id, 'void', array('txnid' => $Purchase->txnid, 'gateway' => $this->module, 'reason' => $Message->reversal(), 'user' => $this->settings['label'], 'note' => $Message->reversal()));
     } elseif ('refund' == $event) {
         shopp_add_order_event($Purchase->id, 'refund', array('txnid' => $Purchase->txnid, 'gateway' => $this->module, 'amount' => $Message->amount(), 'reason' => $Message->reversal(), 'user' => $this->settings['label']));
     } elseif ($txn_type = $Message->type()) {
         shopp_add_order_event($Purchase->id, 'review', array('kind' => 'txn_type', 'note' => $Message->type()));
     }
     $Purchase->unlock();
 }
示例#8
0
 /**
  * Auth
  *
  * @param OrderEventMessage $event
  */
 function auth($event)
 {
     $Order = $this->Order;
     $OrderTotals = $Order->Cart->Totals;
     $Billing = $Order->Billing;
     $Paymethod = $Order->paymethod();
     shopp_add_order_event($event->order, 'authed', array('txnid' => time(), 'amount' => $OrderTotals->total, 'fees' => 0, 'gateway' => $Paymethod->processor, 'paymethod' => $Paymethod->label, 'paytype' => $Billing->cardtype, 'payid' => $Billing->card));
 }
示例#9
0
 public function authed(ShoppPurchase $Order)
 {
     $Paymethod = $this->Order->paymethod();
     $Billing = $this->Order->Billing;
     shopp_add_order_event($Order->id, 'authed', array('txnid' => $_POST['order_number'], 'amount' => $_POST['total'], 'gateway' => $this->module, 'paymethod' => $Paymethod->label, 'paytype' => $Billing->cardtype, 'payid' => $Billing->card, 'capture' => true));
 }
 function sale($Event)
 {
     global $wpdb;
     $this->order_id = $Event->order;
     $this->order_desc = __('Order #', 'paymill') . $this->order_id;
     $this->order = $this->Order;
     $this->cart = $this->order->Cart;
     $this->total_complete = round(floatval($Event->amount) * 100);
     $this->total = $this->total_complete;
     $Billing = $this->order->Billing;
     $Paymethod = $this->order->paymethod();
     $this->client = $this->getCurrentClient();
     // client retrieved, now we are ready to process the payment
     if ($this->client->getId() !== false && strlen($this->client->getId()) > 0) {
         // load subscription class
         //$this->subscriptions		= new paymill_subscriptions('shopp');
         //$this->offers				= $this->subscriptions->offerGetList();
         // get the totals for pre authorization
         //$this->getTotals();
         // create payment object and preauthorization
         require_once PAYMILL_DIR . 'lib/integration/payment.inc.php';
         $this->paymentClass = new paymill_payment($this->client->getId(), $this->total_complete, $this->currency());
         // create payment object, as it should be used for next processing instead of the token.
         if ($GLOBALS['paymill_loader']->paymill_errors->status()) {
             $error = Shopp::__($GLOBALS['paymill_loader']->paymill_errors->getErrors());
             new ShoppError($error, 'paymill_error', SHOPP_TRXN_ERR);
             return shopp_add_order_event($Event->order, $Event->type . '-fail', array('amount' => $Event->amount, 'error' => 0, 'message' => $error, 'gateway' => $this->module));
             return false;
         }
         // process subscriptions & products
         if ($this->processSubscriptions() && $this->processProducts()) {
             // success
             // the order_id usually comes from the auth or sale event object $Event->order
             shopp_add_order_event($Event->order, 'authed', array('txnid' => $transaction['payment']['id'], 'amount' => $orderTotals->total, 'gateway' => $Event->gateway, 'paymethod' => $Paymethod->label, 'paytype' => $Billing->cardtype, 'payid' => $Billing->card));
             // either immediately after authed (in the case of a sale event)
             // or in response to a capture order event
             shopp_add_order_event($Event->order, 'captured', array('txnid' => $transaction['payment']['id'], 'amount' => $orderTotals->total, 'gateway' => $Event->gateway, 'fees' => 0));
             do_action('paymill_shopplugin_products_paid', array('total' => $total, 'currency' => $this->currency(), 'client' => $client['id']));
         } else {
             if ($GLOBALS['paymill_loader']->paymill_errors->status()) {
                 $GLOBALS['paymill_loader']->paymill_errors->getErrors();
             }
             return false;
         }
     } else {
         $GLOBALS['paymill_loader']->paymill_errors->setError(__('There was an issue with adding you as client for the payment process.', 'paymill'));
         return false;
     }
 }
示例#11
0
文件: Orders.php 项目: msigley/shopp
 public function charge()
 {
     if (!$this->form('charge')) {
         return;
     }
     extract($this->references);
     if (!$gateway_captures) {
         return;
     }
     if (!current_user_can('shopp_capture')) {
         wp_die(Shopp::__('You do not have sufficient permissions to carry out this action.'));
     }
     $user = wp_get_current_user();
     shopp_add_order_event($Purchase->id, 'capture', array('txnid' => $Purchase->txnid, 'gateway' => $Purchase->gateway, 'amount' => $Purchase->capturable(), 'user' => $user->ID));
 }
示例#12
0
 public function handler($type, OrderEventMessage $Event)
 {
     if (!isset($Event->txnid) || empty($Event->txnid)) {
         $Event->txnid = time();
     }
     if (Shopp::str_true($this->settings['error'])) {
         $error = Shopp::__("This is an example error message. Disable the 'always show an error' setting to stop displaying this error.");
         new ShoppError($error, 'testmode_error', SHOPP_TRXN_ERR);
         return shopp_add_order_event($Event->order, $Event->type . '-fail', array('amount' => $Event->amount, 'error' => 0, 'message' => $error, 'gateway' => $this->module));
     }
     shopp_add_order_event($Event->order, $type, array('txnid' => $Event->txnid, 'txnorigin' => $Event->txnid, 'fees' => 0, 'paymethod' => '', 'paytype' => '', 'payid' => '1111', 'amount' => $Event->amount, 'gateway' => $this->module));
 }