Skip to content

Commit

Permalink
Merge pull request #8 from craigchristenson/onepagecheckout
Browse files Browse the repository at this point in the history
Adding support for onestepcheckout and refactoring standard and IWD checkout
  • Loading branch information
jmcconnell91 committed Nov 14, 2014
2 parents 13785d1 + 0d6bd56 commit bffcff2
Show file tree
Hide file tree
Showing 8 changed files with 2,666 additions and 130 deletions.
12 changes: 5 additions & 7 deletions app/code/local/Twocheckout/Api/Model/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@ public function getDemo() {
return $demo;
}

public function getApiUrl()
public function getEnvJS()
{
if ($this->getDemo()) {
$link = '<script src="https://sandbox.2checkout.com/checkout/api/script/publickey/key.js"></script>
<script src="https://sandbox.2checkout.com/checkout/api/2co.min.js"></script>';
$result = "<script>var TcoEnv='sandbox'</script>";
} else {
$link = '<script src="https://www.2checkout.com/checkout/api/script/publickey/key.js"></script>
<script src="https://www.2checkout.com/checkout/api/2co.min.js"></script>';
$result = "<script>var TcoEnv='production'</script>";
}
return $link;
return $result;
}

public function __construct()
Expand Down Expand Up @@ -109,7 +107,7 @@ public function capture(Varien_Object $payment, $amount)
$charge = Twocheckout_Charge::auth($params);

} catch (Twocheckout_Error $e) {
Mage::throwException(Mage::helper('paygate')->__($e->getMessage()));
Mage::throwException(Mage::helper('paygate')->__('Authorization Failed'));
}

if ($charge['response']['responseCode'] == 'APPROVED') {
Expand Down
20 changes: 17 additions & 3 deletions app/design/frontend/base/default/layout/twocheckout.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
<layout version="0.1.0">
<checkout_onepage_index>
<reference name="head">
<block type="core/template" name="twocheckout.script" template="twocheckout/script.phtml"/>
<action method="addJs"><file>twocheckout/paymentForm.js</file></action>
<block type="core/template" name="twocheckout.script" template="twocheckout/script.phtml"/>
<action method="addJs"><file>twocheckout/2co.js</file></action>
<action method="addJs"><file>twocheckout/paymentForm.js</file></action>
</reference>
</checkout_onepage_index>

<opc_index_index>
<reference name="head">
<block type="core/template" name="twocheckout.script" template="twocheckout/script.phtml"/>
<action method="addJs"><file>twocheckout/2co.js</file></action>
<action method="addJs"><file>twocheckout/paymentFormIWD.js</file></action>
</reference>
</opc_index_index>
<onestepcheckout_index_index>
<reference name="head">
<block type="core/template" name="twocheckout.script" template="twocheckout/script.phtml"/>
<action method="addJs"><file>twocheckout/2co.js</file></action>
<action method="addJs"><file>twocheckout/paymentFormOneStep.js</file></action>
</reference>
</onestepcheckout_index_index>
</layout>
97 changes: 50 additions & 47 deletions app/design/frontend/base/default/template/twocheckout/form.phtml
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
<?php $_code = $this->getMethodCode() ?>
<div>
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
<li>
<label for="<?php echo $_code ?>_number" class="required"><em>*</em><?php echo $this->__("Card Number") ?></label>
<div class="input-box">
<table>
<tr>
<td><input value="" type="text" id="ccNo" class="required-entry input-text"/></td>
<td><div id="<?php echo $_code ?>_card_icon"></div></td>
</tr>
</table>
</div>
</li>
<li>
<label for="<?php echo $_code ?>_cvc" class="required"><em>*</em><?php echo $this->__("CVC") ?></label>
<div class="input-box">
<input value="" type="text" id="cvv" class="required-entry"/>
</div>
</li>
<li>
<label for="<?php echo $_code ?>_expiry_month" class="required"><em>*</em><?php echo $this->__("Expiration Date") ?></label>
<div class="input-box">
<div class="v-fix">
<select id="expMonth" class="month">
<?php foreach ($this->getTwocheckoutCcMonths() as $k => $v): ?>
<option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $this->getInfoData($_code . '_expiry_month')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
<?php endforeach ?>
</select>
</div>
<div class="v-fix">
<select id="expYear" class="year">
<?php foreach ($this->getTwocheckoutCcYears() as $k => $v): ?>
<option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $this->getInfoData($_code . '_expiry_year')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
<?php endforeach ?>
</select>
</div>
</div>
</li>
<li>
<input id="twocheckout_token" name="token" type="hidden" value="" />
<input id="publishableKey" type="hidden" value="<?php echo $this->getPublicKey(); ?>" />
<input id="sellerId" type="hidden" maxlength="16" width="20" value="<?php echo $this->getSellerId(); ?>" />
</li>
</ul>
</div>
<div id="infoArea"></div>
<?php $_code = $this->getMethodCode() ?>
<div>
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
<li>
<label for="<?php echo $_code ?>_number" class="required"><em>*</em><?php echo $this->__("Card Number") ?></label>
<div class="input-box">
<table>
<tr>
<td><input value="" type="text" pattern="\d*" id="ccNo" class="required-entry input-text validate-cc-number" autocomplete="off"/></td>
</tr>
</table>
</div>
</li>
<li>
<label for="<?php echo $_code ?>_cvc" class="required"><em>*</em><?php echo $this->__("CVC") ?></label>
<div class="cvv tco-input-cvv">
<input value="" type="text" pattern="\d*" id="cvv" class="required-entry input-text" autocomplete="off" />
</div>
</li>
<li>
<label for="<?php echo $_code ?>_expiry_month" class="required"><em>*</em><?php echo $this->__("Expiration Date") ?></label>
<div class="input-box">
<div class="v-fix">
<select id="expMonth" class="month required-entry">
<?php foreach ($this->getTwocheckoutCcMonths() as $k => $v): ?>
<option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $this->getInfoData($_code . '_expiry_month')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
<?php endforeach ?>
</select>
</div>
<div class="v-fix">
<select id="expYear" class="year required-entry">
<?php foreach ($this->getTwocheckoutCcYears() as $k => $v): ?>
<option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $this->getInfoData($_code . '_expiry_year')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
<?php endforeach ?>
</select>
</div>
</div>
</li>
<li><div id="<?php echo $_code ?>_card_icon"></div></li>
<li>
<input id="twocheckout_token" name="token" type="hidden" value="" />
<input id="publishableKey" type="hidden" value="<?php echo $this->getPublicKey(); ?>" />
<input id="sellerId" type="hidden" maxlength="16" width="20" value="<?php echo $this->getSellerId(); ?>" />
</li>
</ul>
</div>
<div id="infoArea"></div>
<style>
.tco-input-cvv {width:100px;}
</style>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php $twocheckout = Mage::getModel('twocheckout/payment'); ?>
<?php echo $twocheckout->getApiUrl(); ?>
<?php echo $twocheckout->getEnvJS(); ?>
Loading

0 comments on commit bffcff2

Please sign in to comment.