Skip to content

Commit

Permalink
Merge pull request #6 from Affirm/dev
Browse files Browse the repository at this point in the history
[release] 2.0.2-rc (est. Wed 30 July 2014)
  • Loading branch information
perfmode committed Jul 30, 2014
2 parents f2b7fa5 + fa0d97b commit 1cc5440
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 54 deletions.
6 changes: 3 additions & 3 deletions DEVELOPER-README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
Contribute
----------

Read the Developer Notes

1. Fork the repo
2. Create your feature branch (```git checkout -b my-new-feature```).
3. Commit your changes (```git commit -am 'Added some feature'```)
4. Push to the branch (```git push origin my-new-feature```)
5. Create a Pull Request

**To run the tests:**
**To run unit tests:**

```
make dependencies
Expand All @@ -25,3 +23,5 @@ version in the following locations:
1. extension/app/code/community/Affirm/Affirm/etc/config.xml
1. extension/app/code/community/Affirm/AffirmPromo/etc/config.xml
1. build/affirm_tar_to_connect_config.php

To avoid drift, validate by executing `make validate_version`
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ Configure
Developers
----------

Read the [Developer Notes](DEVELOPER-NOTES.md)
Read the [Developer README](DEVELOPER-README.md)
4 changes: 2 additions & 2 deletions build/affirm_tar_to_connect_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
'archive_files' => 'Affirm_Magento.tar',
'extension_name' => 'Affirm_Magento',
'skip_version_compare' => true,
'extension_version' => '2.0.1',
'archive_connect' => 'Affirm_Magento-2.0.1.tgz',
'extension_version' => '2.0.2',
'archive_connect' => 'Affirm_Magento-2.0.2.tgz',
'path_output' => realpath('../var/'),

'stability' => 'stable',
Expand Down
Binary file modified docs/config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function pre_order($observer)
"module"=>$request->getModuleName(),
"params"=>$request->getParams(),
"method"=>$request->getMethod(),
"xhr"=>$request->isXmlHttpRequest(),
"POST"=>$_POST, #need post for some cross site issues
"quote_id"=>$quote->getId());
Mage::getSingleton('checkout/session')->setAffirmOrderRequest(serialize($order_request));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,19 @@ public function renderPreOrderAction()
{
$order = $this->getRequest()->getParam("order");
$string = $this->getLayout()->createBlock('affirm/payment_redirect')->setOrder($order)->toHtml();
$this->_getCheckoutSession()->setPreOrderRender($string);
$result = array("redirect"=>Mage::getUrl('*/*/redirectPreOrder'));
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
$serialized_request = Mage::getSingleton('checkout/session')->getAffirmOrderRequest();
$proxy_request = unserialize($serialized_request);

if (isset($proxy_request["xhr"]) && $proxy_request["xhr"])
{
$this->_getCheckoutSession()->setPreOrderRender($string);
$result = array("redirect"=>Mage::getUrl('*/*/redirectPreOrder'));
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
else
{
$this->getResponse()->setBody($string);
}
}

public function redirectPreOrderAction()
Expand Down Expand Up @@ -73,53 +83,55 @@ public function confirmAction()
Mage::register("affirm_token_code", $checkout_token);
$this->_forward($proxy_request["action"], $proxy_request["controller"], $proxy_request["module"], $proxy_request["params"]);

#need to actually execute the forward!
$front = Mage::app()->getFrontController();
$request = $this->getRequest();
foreach ($front->getRouters() as $router) {
if ($router->match($request)) {
break;

if ((isset($proxy_request["xhr"]) && $proxy_request["xhr"]))
{
#need to actually execute the forward!
$front = Mage::app()->getFrontController();
$request = $this->getRequest();
foreach ($front->getRouters() as $router) {
if ($router->match($request)) {
break;
}
}
}

try {
$orderResult = Mage::helper('core')->jsonDecode($this->getResponse()->getBody());
} catch (Exception $e) {
Mage::logException($e);
Mage::getSingleton('checkout/session')->addError("Error processing affirm order");
$this->_redirect('checkout/cart');
return;
}
try {
$orderResult = Mage::helper('core')->jsonDecode($this->getResponse()->getBody());
} catch (Exception $e) {
Mage::logException($e);
Mage::getSingleton('checkout/session')->addError("Error processing affirm order");
$this->_redirect('checkout/cart');
return;
}

if (isset($orderResult["success"]) && $orderResult["success"])
{
Mage::getSingleton('checkout/session')->setPreOrderRender(null);
Mage::getSingleton('checkout/session')->setLastAffirmSuccess($checkout_token);
$this->_redirect('checkout/onepage/success');
}
elseif(isset($orderResult["error_messages"]) && $orderResult["error"] && $orderResult["error_messages"])
{
// Very rarely, a merchant's extensively customized Checkout
// extension may be incompatible with the Affirm extension. To
// help discover this issue during testing, provide a useful
// message.
Mage::log("
Customer tried to checkout using Affirm.
The order could not be saved.
Your Checkout extension may not be compatible
with this version of the Affirm Extension.
Please contact Affirm Developer Support for more info");

Mage::getSingleton('checkout/session')->addError($orderResult["error_messages"]);
$this->_redirect('checkout/onepage');
}
else
{
Mage::getSingleton('checkout/session')->addError("Error encountered while processing affirm order");
$this->_redirect('checkout/cart');
return;
if (isset($orderResult["success"]) && $orderResult["success"])
{
Mage::getSingleton('checkout/session')->setPreOrderRender(null);
Mage::getSingleton('checkout/session')->setLastAffirmSuccess($checkout_token);
$this->_redirect('checkout/onepage/success');
}
elseif(isset($orderResult["error_messages"]) && $orderResult["error"] && $orderResult["error_messages"])
{
Mage::getSingleton('checkout/session')->addError($orderResult["error_messages"]);
$this->_redirect('checkout/onepage/index');
}
else
{
// Very rarely, a merchant's extensively customized Checkout
// extension may be incompatible with the Affirm extension.
// To help discover this issue during testing, provide a
// useful message.
Mage::log("Customer tried to checkout using Affirm.
The order could not be saved.
Your Checkout extension may not be compatible with this
version of the Affirm Extension.
Please contact Affirm Developer Support for more info");

Mage::getSingleton('checkout/session')->addError("Error encountered while processing affirm order");
$this->_redirect('checkout/cart');
return;
}
}

return;
}
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false);
Expand Down
2 changes: 1 addition & 1 deletion extension/app/code/community/Affirm/Affirm/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Affirm_Affirm>
<version>2.0.1</version>
<version>2.0.2</version>
</Affirm_Affirm>
</modules>
<global>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Affirm_AffirmPromo>
<version>2.0.1</version>
<version>2.0.2</version>
</Affirm_AffirmPromo>
</modules>
<global>
Expand Down

0 comments on commit 1cc5440

Please sign in to comment.