I'm creating a payment module, which has to get the amount of the order in the page that will redirect you to the payment provider.
Here are the lines of code I use in my RedirectBLock:
$session = Mage::getSingleton('checkout/session');
$this->order = Mage::getModel('sales/order')
->loadByIncrementId($session->getLastRealOrderId());
$this->amount = sprintf("%.2f", $this->order->getGrandTotal());
When I use the code in a database filled with the sample data from magento, and do the order on my local website, everything is working fine (eg I can see that the grandTotal was retrieved).
However, it doesn't work when I use a test database with Ecomdev_PhpUnit.
Here is my fixture.yml
scope:
website:
- website_id: 1
code: english_website
name: English Website
default_group_id: 1
group:
- group_id: 1
website_id: 1
name: English Store group
default_store_id: 1
root_category_id: 1
store:
- store_id: 1
website_id: 1
group_id: 1
code: uk
name: English Store
is_active: 1
config:
default/catalog/price/scope: 1
default/dev/template/allow_symlink: 1
stores/default/dev/template/allow_symlink: 1
stores/admin/dev/template/allow_symlink: 1
stores/french/dev/template/allow_symlink: 1
stores/german/dev/template/allow_symlink: 1
websites/admin/dev/template/allow_symlink: 1
websites/base/dev/template/allow_symlink: 1
default/carriers/freeshipping/active: 1
eav:
customer:
- entity_id: 1
email: test@mail.com
password_hash: ''
catalog_product:
- entity_id: 1
type_id: simple
sku: book
name: Book
short_description: Book
description: Book
attribute_set_id: 4 # Product entity
url_key: book
stock:
qty: 100.00
is_in_stock: 1
website_ids:
- english_website
/websites:
english_website:
special_price: 7.99
category_ids:
- 1 # Default Category
price: 12.99
tax_class_id: 2 # Taxable Goods
status: 1 # Enabled
visibility: 4 # Visible in Catalog & Search
This is how I trigger the request to the saveOrder route:
$this->reset();
$postData = array(
"payment"=>array(
"method"=>"custom"
),
);
$this->getRequest()
->setMethod('POST')
->setPost($postData);
$formKey = Mage::getSingleton('core/session')->getFormKey();
$this->dispatch('checkout/onepage/saveOrder/form_key/'.$formKey);
$this->assertResponseHttpCode(200);
$rawBody = $this->getResponse()
->getOutputBody();
$this->assertResponseBodyContains('redirect');
Aucun commentaire:
Enregistrer un commentaire