Skip to content

Commit bffcff2

Browse files
committed
Merge pull request #8 from craigchristenson/onepagecheckout
Adding support for onestepcheckout and refactoring standard and IWD checkout
2 parents 13785d1 + 0d6bd56 commit bffcff2

File tree

8 files changed

+2666
-130
lines changed

8 files changed

+2666
-130
lines changed

app/code/local/Twocheckout/Api/Model/Payment.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,14 @@ public function getDemo() {
3737
return $demo;
3838
}
3939

40-
public function getApiUrl()
40+
public function getEnvJS()
4141
{
4242
if ($this->getDemo()) {
43-
$link = '<script src="https://sandbox.2checkout.com/checkout/api/script/publickey/key.js"></script>
44-
<script src="https://sandbox.2checkout.com/checkout/api/2co.min.js"></script>';
43+
$result = "<script>var TcoEnv='sandbox'</script>";
4544
} else {
46-
$link = '<script src="https://www.2checkout.com/checkout/api/script/publickey/key.js"></script>
47-
<script src="https://www.2checkout.com/checkout/api/2co.min.js"></script>';
45+
$result = "<script>var TcoEnv='production'</script>";
4846
}
49-
return $link;
47+
return $result;
5048
}
5149

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

111109
} catch (Twocheckout_Error $e) {
112-
Mage::throwException(Mage::helper('paygate')->__($e->getMessage()));
110+
Mage::throwException(Mage::helper('paygate')->__('Authorization Failed'));
113111
}
114112

115113
if ($charge['response']['responseCode'] == 'APPROVED') {
Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
<layout version="0.1.0">
22
<checkout_onepage_index>
33
<reference name="head">
4-
<block type="core/template" name="twocheckout.script" template="twocheckout/script.phtml"/>
5-
<action method="addJs"><file>twocheckout/paymentForm.js</file></action>
4+
<block type="core/template" name="twocheckout.script" template="twocheckout/script.phtml"/>
5+
<action method="addJs"><file>twocheckout/2co.js</file></action>
6+
<action method="addJs"><file>twocheckout/paymentForm.js</file></action>
67
</reference>
78
</checkout_onepage_index>
8-
9+
<opc_index_index>
10+
<reference name="head">
11+
<block type="core/template" name="twocheckout.script" template="twocheckout/script.phtml"/>
12+
<action method="addJs"><file>twocheckout/2co.js</file></action>
13+
<action method="addJs"><file>twocheckout/paymentFormIWD.js</file></action>
14+
</reference>
15+
</opc_index_index>
16+
<onestepcheckout_index_index>
17+
<reference name="head">
18+
<block type="core/template" name="twocheckout.script" template="twocheckout/script.phtml"/>
19+
<action method="addJs"><file>twocheckout/2co.js</file></action>
20+
<action method="addJs"><file>twocheckout/paymentFormOneStep.js</file></action>
21+
</reference>
22+
</onestepcheckout_index_index>
923
</layout>
Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,50 @@
1-
<?php $_code = $this->getMethodCode() ?>
2-
<div>
3-
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
4-
<li>
5-
<label for="<?php echo $_code ?>_number" class="required"><em>*</em><?php echo $this->__("Card Number") ?></label>
6-
<div class="input-box">
7-
<table>
8-
<tr>
9-
<td><input value="" type="text" id="ccNo" class="required-entry input-text"/></td>
10-
<td><div id="<?php echo $_code ?>_card_icon"></div></td>
11-
</tr>
12-
</table>
13-
</div>
14-
</li>
15-
<li>
16-
<label for="<?php echo $_code ?>_cvc" class="required"><em>*</em><?php echo $this->__("CVC") ?></label>
17-
<div class="input-box">
18-
<input value="" type="text" id="cvv" class="required-entry"/>
19-
</div>
20-
</li>
21-
<li>
22-
<label for="<?php echo $_code ?>_expiry_month" class="required"><em>*</em><?php echo $this->__("Expiration Date") ?></label>
23-
<div class="input-box">
24-
<div class="v-fix">
25-
<select id="expMonth" class="month">
26-
<?php foreach ($this->getTwocheckoutCcMonths() as $k => $v): ?>
27-
<option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $this->getInfoData($_code . '_expiry_month')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
28-
<?php endforeach ?>
29-
</select>
30-
</div>
31-
<div class="v-fix">
32-
<select id="expYear" class="year">
33-
<?php foreach ($this->getTwocheckoutCcYears() as $k => $v): ?>
34-
<option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $this->getInfoData($_code . '_expiry_year')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
35-
<?php endforeach ?>
36-
</select>
37-
</div>
38-
</div>
39-
</li>
40-
<li>
41-
<input id="twocheckout_token" name="token" type="hidden" value="" />
42-
<input id="publishableKey" type="hidden" value="<?php echo $this->getPublicKey(); ?>" />
43-
<input id="sellerId" type="hidden" maxlength="16" width="20" value="<?php echo $this->getSellerId(); ?>" />
44-
</li>
45-
</ul>
46-
</div>
47-
<div id="infoArea"></div>
1+
<?php $_code = $this->getMethodCode() ?>
2+
<div>
3+
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
4+
<li>
5+
<label for="<?php echo $_code ?>_number" class="required"><em>*</em><?php echo $this->__("Card Number") ?></label>
6+
<div class="input-box">
7+
<table>
8+
<tr>
9+
<td><input value="" type="text" pattern="\d*" id="ccNo" class="required-entry input-text validate-cc-number" autocomplete="off"/></td>
10+
</tr>
11+
</table>
12+
</div>
13+
</li>
14+
<li>
15+
<label for="<?php echo $_code ?>_cvc" class="required"><em>*</em><?php echo $this->__("CVC") ?></label>
16+
<div class="cvv tco-input-cvv">
17+
<input value="" type="text" pattern="\d*" id="cvv" class="required-entry input-text" autocomplete="off" />
18+
</div>
19+
</li>
20+
<li>
21+
<label for="<?php echo $_code ?>_expiry_month" class="required"><em>*</em><?php echo $this->__("Expiration Date") ?></label>
22+
<div class="input-box">
23+
<div class="v-fix">
24+
<select id="expMonth" class="month required-entry">
25+
<?php foreach ($this->getTwocheckoutCcMonths() as $k => $v): ?>
26+
<option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $this->getInfoData($_code . '_expiry_month')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
27+
<?php endforeach ?>
28+
</select>
29+
</div>
30+
<div class="v-fix">
31+
<select id="expYear" class="year required-entry">
32+
<?php foreach ($this->getTwocheckoutCcYears() as $k => $v): ?>
33+
<option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $this->getInfoData($_code . '_expiry_year')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
34+
<?php endforeach ?>
35+
</select>
36+
</div>
37+
</div>
38+
</li>
39+
<li><div id="<?php echo $_code ?>_card_icon"></div></li>
40+
<li>
41+
<input id="twocheckout_token" name="token" type="hidden" value="" />
42+
<input id="publishableKey" type="hidden" value="<?php echo $this->getPublicKey(); ?>" />
43+
<input id="sellerId" type="hidden" maxlength="16" width="20" value="<?php echo $this->getSellerId(); ?>" />
44+
</li>
45+
</ul>
46+
</div>
47+
<div id="infoArea"></div>
48+
<style>
49+
.tco-input-cvv {width:100px;}
50+
</style>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?php $twocheckout = Mage::getModel('twocheckout/payment'); ?>
2-
<?php echo $twocheckout->getApiUrl(); ?>
2+
<?php echo $twocheckout->getEnvJS(); ?>

0 commit comments

Comments
 (0)