Skip to content

Commit

Permalink
Merge pull request #49 from Affirm/dev_v3.6.0
Browse files Browse the repository at this point in the history
Modal checkout compatibility code for GoMage one page checkout extension
  • Loading branch information
Dipti Bele authored Oct 26, 2018
2 parents dfbcf8e + 92d54a7 commit 8444678
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies:

package: validate_version
mkdir -p ./var/
cd ./extension && tar -cvf ../var/Affirm_Affirm-3.5.9.tgz *
cd ./extension && tar -cvf ../var/Affirm_Affirm-3.6.0.tgz *
cd ./build && ./magento-tar-to-connect.phar affirm_tar_to_connect_config.php

clean:
Expand Down
8 changes: 4 additions & 4 deletions build/affirm_tar_to_connect_config.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
return array(
'base_dir' => realpath('../var/'),
'archive_files' => 'Affirm_Affirm-3.5.9.tgz',
'archive_files' => 'Affirm_Affirm-3.6.0.tgz',
'extension_name' => 'Affirm_Magento',
'skip_version_compare' => true,
'extension_version' => '3.5.9',
'archive_connect' => 'Affirm_Affirm-3.5.9.tgz',
'extension_version' => '3.6.0',
'archive_connect' => 'Affirm_Affirm-3.6.0.tgz',
'path_output' => realpath('../var/'),

'stability' => 'stable',
Expand All @@ -19,5 +19,5 @@
'author_user' => 'affirm',
'author_email' => '[email protected]',
'php_min' => '5.2.0',
'php_max' => '6.0.0',
'php_max' => '7.2.0',
);
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 @@ -36,7 +36,7 @@
<config>
<modules>
<Affirm_Affirm>
<version>3.5.9</version>
<version>3.6.0</version>
</Affirm_Affirm>
</modules>
<global>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
<?xml version="1.0"?>
<!--
~ /*
~ * BSD 3-Clause License
~ *
~ * Copyright (c) 2018, Affirm
~ * All rights reserved.
~ *
~ * Redistribution and use in source and binary forms, with or without
~ * modification, are permitted provided that the following conditions are met:
~ *
~ * Redistributions of source code must retain the above copyright notice, this
~ * list of conditions and the following disclaimer.
~ *
~ * Redistributions in binary form must reproduce the above copyright notice,
~ * this list of conditions and the following disclaimer in the documentation
~ * and/or other materials provided with the distribution.
~ *
~ * Neither the name of the copyright holder nor the names of its
~ * contributors may be used to endorse or promote products derived from
~ * this software without specific prior written permission.
~ *
~ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
~ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
~ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
~ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
~ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
~ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
~ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
~ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
~ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
~ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
~ */
-->

<layout>
<default>
<reference name="head">
Expand All @@ -11,13 +45,13 @@
<text helper="affirm/getAffirmJs" />
</action>
</block>
</reference>
<reference name="after_body_start">
<block type="affirm/promo_pixel_code" name="affirm_pixel_code">
<action method="setTemplate" ifconfig="affirmpromo/pixel/enabled">
<template>affirm/promo/pixel/code.phtml</template>
</action>
</block>
<reference name="after_body_start">
<block type="affirm/promo_pixel_code" name="affirm_pixel_code">
<action method="setTemplate" ifconfig="affirmpromo/pixel/enabled">
<template>affirm/promo/pixel/code.phtml</template>
</action>
</block>
</reference>
</reference>
</default>
<checkout_cart_index>
Expand Down Expand Up @@ -139,6 +173,15 @@
</action>
</reference>
</aw_onestepcheckout_index_index>
<gomage_checkout_onepage_index> <!-- For GoMage checkout extension -->
<reference name="head">
<action method="addItem">
<type>skin_js</type>
<name helper="affirm/getAffirmCheckoutJsScript" />
</action>
<block type="core/template" name="affirm.js.checkout" template="affirm/affirm/checkout/review/opc.phtml"/>
</reference>
</gomage_checkout_onepage_index>
<checkout_onepage_success> <!-- To add pixel for enhanced analytics -->
<reference name="head" before="-">
<block type="affirm/promo_pixel_confirm" name="affirm_pixel_javascript" template="affirm/promo/pixel/confirm.phtml"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,27 @@ if (Mage::helper('affirm')->isCheckoutFlowTypeModal()) {
}
/* End - For AW OneStepCheckout */

/* Start - For GoMage Checkout */
function callGoMageCheckoutForAffirm(){
var formData = Form.serialize($('gcheckout-onepage-form'), true);
var validator = new Validation('gcheckout-onepage-form');
if (validator.validate()) {
new Ajax.Request('<?php echo Mage::helper("affirm")->getOPCCheckoutUrl();?>', {
method: 'post',
parameters: formData,
onSuccess: function (transport) {
callAffirmModalCheckout(formData);
return;
},
on403: function () {
document.location.reload();
}
}
);
}
}
/* End - For GoMage Checkout */

//]]>
</script>
<?php
Expand Down
12 changes: 6 additions & 6 deletions extension/package.xml
100644 → 100755

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions extension/skin/frontend/base/default/js/affirm/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,22 @@ document.observe('dom:loaded', function () {
);
}
}

// This is for GoMage checkout
if ($('gcheckout-onepage-form')) {
if (typeof Lightcheckout.prototype.saveorder == 'function') {
Lightcheckout.prototype.saveorder = Lightcheckout.prototype.saveorder.wrap(
function (parentMethod) {
if (isAffirmMethod()) {
callGoMageCheckoutForAffirm();
} else {
return parentMethod();
}

}
);
}
}
});

window.addEventListener('load', function() {
Expand Down

0 comments on commit 8444678

Please sign in to comment.