public function pressPaymentOption($name) { $checkout_pages = commerce_checkout_pages(); $checkout_page = $checkout_pages[$this->page_id]; $order = commerce_order_load($this->order_id); $response = parent::pressButton($name, array('ajax' => true), $order, $checkout_page); return $this->getResponse($response); }
public function __construct($order_id) { $this->order = commerce_order_load($order_id); $transaction_array = commerce_payment_transaction_load_multiple(array(), array('order_id' => $order_id)); $this->transaction = end($transaction_array); $this->includeFile('inc', 'commerce_stripe', 'includes/commerce_stripe.admin'); parent::__construct('commerce_stripe_capture_form', $this->order, $this->transaction); }
public function __construct($order_id = NULL) { if (is_null($order_id)) { global $user; $order = commerce_cart_order_load($user->uid); } else { $order = commerce_order_load($order_id); } $this->order_id = $order->order_id; $view = $this->getCartView(); $output = ''; parent::__construct(views_form_id($view), $view, $output); }
/** * Default constructor for the Commerce Order object. * * @param int $order_id * Order id if an existing order is to be loaded. */ public function __construct($order_id = NULL) { if (!is_null($order_id) && is_numeric($order_id)) { $order = commerce_order_load($order_id); if (!$order) { $this->setErrors("Order with id {$order_id} does not exist."); $this->setInitialized(FALSE); return; } } else { global $user; $order = commerce_order_new($user->uid); } parent::__construct($order); }
/** * Default constructor for the Commerce License object. * * @param int $license_id * License id if an existing license entity is to be loaded. */ public function __construct($license_id = NULL) { $args = func_get_args(); array_shift($args); $order_id = array_shift($args); if (is_null($order_id)) { $order_id = 0; } $order = commerce_order_load($order_id); if (!is_null($order_id)) { $license = commerce_license_get_order_licenses($order_id); if (!$license) { $this->setErrors("License for order id {$order_id} does not exist."); $this->setInitialized(FALSE); return; } } parent::__construct($license); }
/** * Build a state array for relay response processing * * @param $response * A web service converted response */ protected function buildRelayResponseState($response) { $state = array(); if (isset($response['amount']) && isset($response['currency_code'])) { $state['charge'] = array('amount' => commerce_currency_decimal_to_amount($response['amount'], $response['currency_code']), 'currency_code' => $response['currency_code']); } if (!empty($response['commerce_order_id'])) { $state['order'] = commerce_order_load($response['commerce_order_id']); } $customer = array(); if (!empty($response['customer_ref'])) { $customer['uid'] = $response['customer_ref']; } elseif (!empty($response['x_cust_id'])) { $customer['uid'] = $response['x_cust_id']; } if (!empty($response['client_email'])) { $customer['mail'] = $response['client_email']; } if (!empty($customer)) { $state['customer'] = (object) $customer; } // Add billing address per response parameters $state['billing_address'] = $this->createResponseBillingAddress($response); // Allow others to alter $alter_context = array('response' => $response); $this->controller->alter('hpp_relay_response_state', $state, $alter_context); // Resolve state $this->controller->resolvePaymentState($state); return $state; }
function _condenast_get_order_price_by_components($view) { // First look for an order_id argument. foreach ($view->argument as $name => $argument) { if ($argument instanceof commerce_order_handler_argument_order_order_id) { // If it is single value... if (count($argument->value) == 1) { // Load the order. if ($order = commerce_order_load(reset($argument->value))) { $price_item = $order->commerce_order_total['und'][0]; $total_price = commerce_currency_format($price_item['amount'], $price_item['currency_code'], $order); $components = array(); $weight = 0; foreach ($price_item['data']['components'] as $key => $component) { $component_type = commerce_price_component_type_load($component['name']); if (empty($components[$component['name']])) { $components[$component['name']] = array('title' => check_plain($component_type['display_title']), 'price' => commerce_price_component_total($price_item, $component['name']), 'weight' => $component_type['weight']); $weight = max($weight, $component_type['weight']); } } // If there is only a single component and its price equals the field's, // then remove it and just show the actual price amount. if (count($components) == 1 && in_array('base_price', array_keys($components))) { $components = array(); } // Sort the components by weight. uasort($components, 'drupal_sort_weight'); // Format the prices for display. foreach ($components as $key => &$component) { $component['formatted_price'] = commerce_currency_format($component['price']['amount'], $component['price']['currency_code'], $order); } } } } } return array('total' => $total_price, 'components' => $components); }
/** * Gets the order amount from a donation/order. * * Does not handle currency code. Assumes everything is in cents. * * @param int $did * Donation/order ID. * * @return int * The value in cents. */ protected function getValueFromOrder($did) { $order = commerce_order_load($did); $wrapper = entity_metadata_wrapper('commerce_order', $order); return $wrapper->commerce_order_total->amount->value(); }
function second_step_todopago($order, $return, $user, $ak) { $payment_method = commerce_payment_method_instance_load('bank_transfer|commerce_payment_bank_transfer'); $oOrder = commerce_order_load($order); TPLog($order, $oOrder->uid, $payment_method["settings"]["general"]["modo"])->info('second step'); $rta = call_GAA($order, $ak); return take_action($order, $rta); }
<?php define('DRUPAL_ROOT', dirname(__FILE__) . '/../../../../'); chdir(DRUPAL_ROOT); require './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); if (isset($_POST['SIGN'])) { $sign = strtoupper(md5(md5($_POST['SHOP_ID']) . '&' . md5($_POST["ORDER_ID"]) . '&' . md5($_POST['STATE']))); if ($_POST['SIGN'] == $sign) { switch ($_POST['STATE']) { case 'paid': $order = commerce_order_load($_POST["ORDER_ID"]); $order_wrapper = entity_metadata_wrapper('commerce_order', $order); $transaction = commerce_payment_transaction_new('ubrir', $order->order_id); $transaction->instance_id = $order->data['payment_method']; $transaction->amount = $order_wrapper->commerce_order_total->amount->value(); $transaction->currency_code = $order_wrapper->commerce_order_total->currency_code->value(); $transaction->status = COMMERCE_PAYMENT_STATUS_SUCCESS; $transaction->message = t('Оплата успешно совершена.'); commerce_payment_transaction_save($transaction); break; } } }