function processPayment($data, $form) { $order = $this->Order(); //if currency has been pre-set use this $currency = $this->Amount->Currency; //if amout has been pre-set, use this $amount = $this->Amount->Amount; if ($order) { //amount may need to be adjusted to total outstanding //or amount may not have been set yet $amount = $order->TotalOutstanding(); //get currency from Order //this is better than the pre-set currency one //which may have been set to the default $currencyObject = $order->CurrencyUsed(); if ($currencyObject) { $currency = $currencyObject->Code; } } if (!$amount && !empty($data["Amount"])) { $amount = floatval($data["Amount"]); } if (!$currency && !empty($data["Currency"])) { $currency = floatval($data["Currency"]); } //final backup for currency if (!$currency) { $currency = EcommercePayment::site_currency(); } $this->Amount->Currency = $currency; $this->Amount->Amount = $amount; //no need to write here, as it will be done by BuildURL //$this->write(); $url = $this->buildURL($amount, $currency); return $this->executeURL($url); }
/** * Returns the currency used on the site. * @return String */ function Currency() { $currency = EcommercePayment::site_currency(); return $currency; }
function doAddNewPriceForm($data, $form) { $amount = $this->parseFloat($data["Amount"]); if ($this->MinimumAmount && $amount < $this->MinimumAmount) { $form->sessionMessage(_t("AnyPriceProductPage.ERRORINFORMTOOLOW", "Please enter a higher amount."), "bad"); $this->redirectBack(); return; } elseif ($this->MaximumAmount && $amount > $this->MaximumAmount) { $form->sessionMessage(_t("AnyPriceProductPage.ERRORINFORMTOOHIGH", "Please enter a lower amount."), "bad"); $this->redirectBack(); return; } Session::clear("AnyPriceProductPageAmount"); $obj = AnyPriceProductPage_ProductVariation::get()->filter(array("ProductID" => $this->ID, "Price" => $amount))->First(); //create new one if needed if (!$obj) { Currency::setCurrencySymbol(EcommercePayment::site_currency()); $titleDescriptor = new Currency("titleDescriptor"); $titleDescriptor->setValue($amount); $obj = new AnyPriceProductPage_ProductVariation(); $obj->Title = _t("AnyPriceProductPage.PAYMENTFOR", "Payment for: ") . $titleDescriptor->Nice(); $obj->Price = $amount; $obj->AllowPurchase = true; $obj->ProductID = $this->ID; $obj->write("Stage"); // line below does not work - suspected bug in framework Versioning System //$componentSet->add($obj); } //check if we have one now if (!$obj) { $obj = AnyPriceProductPage_ProductVariation::get()->filter(array("ProductID" => $this->ID, "Price" => $amount))->First(); } if ($obj) { $shoppingCart = ShoppingCart::singleton(); $shoppingCart->addBuyable($obj); } else { $form->sessionMessage(_t("AnyPriceProductPage.ERROROTHER", "Sorry, we could not add our entry."), "bad"); $this->redirectBack(); return; } $checkoutPage = CheckoutPage::get()->First(); if ($checkoutPage) { $this->redirect($checkoutPage->Link()); } return; }