function processPayment($data, $form) { $amount = 0; $member = null; $billingAddress = null; $shippingAddress = null; $order = $this->Order(); if ($order) { $billingAddress = $order->BillingAddress(); $shippingAddress = $order->ShippingAddress(); $orderID = $order->ID; $amount = number_format($this->getAmountValue(), 2, '.', ''); $currency = $this->getAmountCurrency(); if ($member = $order->Member()) { $email = $member->Email; } } $this->write(); $timeStamp = time(); $fingerprint = self::create_fingerprint($this->ID, $timeStamp, $amount); $this->Hash = $fingerprint; $this->write(); //start creating object and end with $obj = new stdClass(); $obj->fields = array(); $obj->label = _t("AuthorizeDotNet.PAYNOW", "Pay now"); $obj->fingerprint = $fingerprint; //IMPORTANT! $obj->fields["x_invoice_num"] = $this->ID; //all the other stuff... $obj->fields["x_login"] = $this->Config()->get("api_login_id"); $obj->fields["x_amount"] = $amount; //$obj->fields["x_currency_code"] = $currency; $obj->fields["x_fp_sequence"] = $this->ID; $obj->fields["x_fp_timestamp"] = $timeStamp; $obj->fields["x_fp_hash"] = $fingerprint; $obj->fields["x_test_request"] = $this->isLiveMode() ? "false" : "true"; $obj->fields["x_show_form"] = $this->Config()->get("show_form_type"); $obj->fields["x_recurring_billing"] = "false"; $obj->fields["x_description"] = $order->Title(); $obj->fields["x_first_name"] = $billingAddress->FirstName; $obj->fields["x_last_name"] = $billingAddress->Surname; $obj->fields["x_company"] = ""; $obj->fields["x_address"] = $billingAddress->Address . " " . $billingAddress->Address2; $obj->fields["x_city"] = $billingAddress->City; $region = EcommerceRegion::get()->byID($billingAddress->RegionID); if ($region) { $obj->fields["x_state"] = $region->Code; } $obj->fields["x_zip"] = $billingAddress->PostalCode; $obj->fields["x_country"] = $billingAddress->Country; $obj->fields["x_phone"] = $billingAddress->Phone; $obj->fields["x_fax"] = ""; $obj->fields["x_email"] = $member->Email; $obj->fields["x_cust_id"] = $member->ID; $obj->fields["x_ship_to_first_name"] = $shippingAddress->ShippingFirstName; $obj->fields["x_ship_to_last_name"] = $shippingAddress->ShippingSurname; $obj->fields["x_ship_to_company"] = ""; $obj->fields["x_ship_to_address"] = $shippingAddress->ShippingAddress . " " . $shippingAddress->ShippingAddress2; $obj->fields["x_ship_to_city"] = $shippingAddress->ShippingCity; $region = EcommerceRegion::get()->byID($shippingAddress->ShippingRegionID); if ($region) { $obj->fields["x_ship_to_state"] = $region->Code; } $obj->fields["x_ship_to_zip"] = $shippingAddress->ShippingPostalCode; $obj->fields["x_ship_to_country"] = $shippingAddress->ShippingCountry; $obj->fields["x_receipt_link_method"] = "POST"; $obj->fields["x_receipt_link_text"] = _t("AuthorizeDotNet.FINALISE", "Finalise now"); $obj->fields["x_receipt_link_url"] = AuthorizeDotNetPxPayPayment_Handler::complete_link($timeStamp, true); $this->ValuesSubmitted = serialize($obj); $this->write(); return $this->executeURL($obj); }
public function getRegion() { $regionIDs = array("Billing" => 0, "Shipping" => 0); if ($this->BillingAddressID) { if ($billingAddress = $this->BillingAddress()) { if ($billingAddress->RegionID) { $regionIDs["Billing"] = $billingAddress->RegionID; } } } if ($this->CanHaveShippingAddress()) { if ($this->ShippingAddressID) { if ($shippingAddress = $this->ShippingAddress()) { if ($shippingAddress->ShippingRegionID) { $regionIDs["Shipping"] = $shippingAddress->ShippingRegionID; } } } } if (count($regionIDs)) { //note the double-check with $this->CanHaveShippingAddress() and get_use_.... if ($this->CanHaveShippingAddress() && EcommerceConfig::get("OrderAddress", "use_shipping_address_for_main_region_and_country") && $regionIDs["Shipping"]) { return EcommerceRegion::get()->byID($regionIDs["Shipping"]); } else { return EcommerceRegion::get()->byID($regionIDs["Billing"]); } } else { return EcommerceRegion::get()->byID(EcommerceRegion::get_region_from_ip()); } }
static function set_for_current_order_do_not_show_regions($a) { //We MERGE here because several modifiers may limit the countries self::$for_current_order_do_not_show_regions = array_merge($a, self::$for_current_order_do_not_show_regions); }
/** * sets region in order so that modifiers can be recalculated, etc... * @param Integer | String - $regionID you can use the ID or the code. * @return Boolean **/ public function setRegion($regionID) { if (EcommerceRegion::regionid_allowed($regionID)) { $this->currentOrder()->SetRegionFields($regionID); $this->addMessage(_t("ShoppingCart.REGIONUPDATED", "Region updated."), 'good'); return true; } else { $this->addMessage(_t("ORDER.NOTUPDATEDREGION", "Could not update region."), 'bad'); return false; } }
/** * * @return Int - region ID */ function getRegion() { $region = EcommerceRegion::get()->First(); if ($region) { return $region->ID; } }
/** * standard SS Method * saves the region code */ function onBeforeWrite() { parent::onBeforeWrite(); $fieldPrefix = $this->fieldPrefix(); $idField = $fieldPrefix . "RegionID"; if ($this->{$idField}) { $region = EcommerceRegion::get()->byID($this->{$idField}); if ($region) { $codeField = $fieldPrefix . "RegionCode"; $this->{$codeField} = $region->Code; } } }
/** * description of region and country being shipped to. * @return String */ protected function LiveRegionAndCountry() { $details = array(); $option = $this->Option(); if ($option) { $regionID = EcommerceRegion::get_region_id(); if ($regionID) { $region = EcommerceRegion::get()->byID($regionID); if ($region) { $details[] = $region->Name; } } $countryID = EcommerceCountry::get_country_id(); if ($countryID) { $country = EcommerceCountry::get()->byID($countryID); if ($country) { $details[] = $country->Name; } } } else { return _t("PickUpOrDeliveryModifier.NOTSELECTED", "No delivery option has been selected"); } if (count($details)) { return implode(", ", $details); } }
/** * put together a dropdown for the region field * @param String $name - name of the field * @return DropdownField **/ protected function getRegionField($name) { if (EcommerceRegion::show()) { $regionsForDropdown = EcommerceRegion::list_of_allowed_entries_for_dropdown(); $regionField = new DropdownField($name, EcommerceRegion::i18n_singular_name(), $regionsForDropdown); if (count($regionsForDropdown) < 2) { $regionField = $regionField->performReadonlyTransformation(); if (count($regionsForDropdown) < 1) { $regionField = new HiddenField($name, '', 0); } } } else { //adding region field here as hidden field to make the code easier below... $regionField = new HiddenField($name, '', 0); } $prefix = EcommerceConfig::get("OrderAddress", "field_class_and_id_prefix"); $regionField->addExtraClass($prefix . 'ajaxRegionField'); return $regionField; }