-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding direct checkout to Charge class
- Loading branch information
Craig Christenson
committed
Apr 25, 2013
1 parent
01b4bbf
commit ddbcf88
Showing
4 changed files
with
149 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,55 +5,128 @@ | |
class TestCharge extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testChargeForm() | ||
{ | ||
$params = array( | ||
'sid' => '1817037', | ||
'mode' => '2CO', | ||
'li_0_name' => 'Test Product', | ||
'li_0_price' => '0.01' | ||
); | ||
$test = '<form id="2checkout" action="https://www.2checkout.com/checkout/purchase" method="post">' + | ||
'<input type="hidden" name="sid" value="1817037"/>' + | ||
'<input type="hidden" name="mode" value="2CO"/>' + | ||
'<input type="hidden" name="li_0_name" value="Test Product"/>' + | ||
'<input type="hidden" name="li_0_price" value="0.01"/>' + | ||
'<input type="submit" value="Click Here!" />' + | ||
'</form>'; | ||
$result = Twocheckout_Charge::form($params, "Click Here!"); | ||
$this->assertEquals($test, $result); | ||
} | ||
|
||
public function testChargeFormAuto() | ||
{ | ||
$params = array( | ||
'sid' => '1817037', | ||
'mode' => '2CO', | ||
'li_0_name' => 'Test Product', | ||
'li_0_price' => '0.01' | ||
); | ||
$test = '<form id="2checkout" action="https://www.2checkout.com/checkout/purchase" method="post">' + | ||
'<input type="hidden" name="sid" value="1817037"/>' + | ||
'<input type="hidden" name="mode" value="2CO"/>' + | ||
'<input type="hidden" name="li_0_name" value="Test Product"/>' + | ||
'<input type="hidden" name="li_0_price" value="0.01"/>' + | ||
'<input type="submit" value="Click here if you are not redirected automatically" /></form>' + | ||
'<script type="text/javascript">document.getElementById(\'2checkout\').submit();</script>'; | ||
$result = Twocheckout_Charge::form($params, 'auto'); | ||
$this->assertEquals($test, $result); | ||
} | ||
|
||
public function testChargeLink() | ||
{ | ||
public function testChargeForm() | ||
{ | ||
$params = array( | ||
'sid' => '1817037', | ||
'mode' => '2CO', | ||
'li_0_name' => 'Test Product', | ||
'li_0_price' => '0.01' | ||
); | ||
$test = '<form id="2checkout" action="https://www.2checkout.com/checkout/purchase" method="post">' + | ||
'<input type="hidden" name="sid" value="1817037"/>' + | ||
'<input type="hidden" name="mode" value="2CO"/>' + | ||
'<input type="hidden" name="li_0_name" value="Test Product"/>' + | ||
'<input type="hidden" name="li_0_price" value="0.01"/>' + | ||
'<input type="submit" value="Click Here!" />' + | ||
'</form>'; | ||
$result = Twocheckout_Charge::form($params, "Click Here!"); | ||
$this->assertEquals($test, $result); | ||
} | ||
|
||
public function testChargeFormAuto() | ||
{ | ||
$params = array( | ||
'sid' => '1817037', | ||
'mode' => '2CO', | ||
'li_0_name' => 'Test Product', | ||
'li_0_price' => '0.01' | ||
); | ||
$test = '<form id="2checkout" action="https://www.2checkout.com/checkout/purchase" method="post">' + | ||
'<input type="hidden" name="sid" value="1817037"/>' + | ||
'<input type="hidden" name="mode" value="2CO"/>' + | ||
'<input type="hidden" name="li_0_name" value="Test Product"/>' + | ||
'<input type="hidden" name="li_0_price" value="0.01"/>' + | ||
'<input type="submit" value="Click here if you are not redirected automatically" /></form>' + | ||
'<script type="text/javascript">document.getElementById(\'2checkout\').submit();</script>'; | ||
$result = Twocheckout_Charge::form($params, 'auto'); | ||
$this->assertEquals($test, $result); | ||
} | ||
|
||
public function testDirect() | ||
{ | ||
$params = array( | ||
'sid' => '1817037', | ||
'mode' => '2CO', | ||
'li_0_name' => 'Test Product', | ||
'li_0_price' => '0.01', | ||
'card_holder_name' => 'Testing Tester', | ||
'email' => '[email protected]', | ||
'street_address' => '123 test st', | ||
'city' => 'Columbus', | ||
'state' => 'Ohio', | ||
'zip' => '43123', | ||
'country' => 'USA' | ||
); | ||
$test = '<form id="2checkout" action="https://www.2checkout.com/checkout/purchase" method="post">' + | ||
'<input type="hidden" name="sid" value="1817037"/>' + | ||
'<input type="hidden" name="mode" value="2CO"/>' + | ||
'<input type="hidden" name="li_0_name" value="Test Product"/>' + | ||
'<input type="hidden" name="li_0_price" value="0.01"/>' + | ||
'<input type="hidden" name="card_holder_name" value="Testing Tester"/>' + | ||
'<input type="hidden" name="email" value="[email protected]"/>' + | ||
'<input type="hidden" name="street_address" value="123 test st"/>' + | ||
'<input type="hidden" name="city" value="Columbus"/>' + | ||
'<input type="hidden" name="state" value="Ohio"/>' + | ||
'<input type="hidden" name="zip" value="43123"/>' + | ||
'<input type="hidden" name="country" value="USA"/>' + | ||
'<input type="submit" value="Click Here!" /></form>' + | ||
'<script src="https://www.2checkout.com/static/checkout/javascript/direct.min.js"></script>'; | ||
$result = Twocheckout_Charge::direct($params, "Click Here!"); | ||
$this->assertEquals($test, $result); | ||
} | ||
|
||
public function testDirectAuto() | ||
{ | ||
$params = array( | ||
'sid' => '1817037', | ||
'mode' => '2CO', | ||
'li_0_name' => 'Test Product', | ||
'li_0_price' => '0.01', | ||
'card_holder_name' => 'Testing Tester', | ||
'email' => '[email protected]', | ||
'street_address' => '123 test st', | ||
'city' => 'Columbus', | ||
'state' => 'Ohio', | ||
'zip' => '43123', | ||
'country' => 'USA' | ||
); | ||
$test = '<form id="2checkout" action="https://www.2checkout.com/checkout/purchase" method="post">' + | ||
'<input type="hidden" name="sid" value="1817037"/>' + | ||
'<input type="hidden" name="mode" value="2CO"/>' + | ||
'<input type="hidden" name="li_0_name" value="Test Product"/>' + | ||
'<input type="hidden" name="li_0_price" value="0.01"/>' + | ||
'<input type="hidden" name="card_holder_name" value="Testing Tester"/>' + | ||
'<input type="hidden" name="email" value="[email protected]"/>' + | ||
'<input type="hidden" name="street_address" value="123 test st"/>' + | ||
'<input type="hidden" name="city" value="Columbus"/>' + | ||
'<input type="hidden" name="state" value="Ohio"/>' + | ||
'<input type="hidden" name="zip" value="43123"/>' + | ||
'<input type="hidden" name="country" value="USA"/>' + | ||
'<input type="submit" value="Click here if the payment form does not open automatically." /></form>' + | ||
'<script type="text/javascript"> | ||
function submitForm() { | ||
document.getElementById("tco_lightbox").style.display = "block"; | ||
document.getElementById("2checkout").submit(); | ||
} | ||
setTimeout("submitForm()", 2000); | ||
</script>' + | ||
'<script src="https://www.2checkout.com/static/checkout/javascript/direct.min.js"></script>'; | ||
$result = Twocheckout_Charge::direct($params, 'auto'); | ||
$this->assertEquals($test, $result); | ||
} | ||
|
||
public function testChargeLink() | ||
{ | ||
$params = array( | ||
'sid' => '1817037', | ||
'mode' => '2CO', | ||
'li_0_name' => 'Test Product', | ||
'li_0_price' => '0.01' | ||
'sid' => '1817037', | ||
'mode' => '2CO', | ||
'li_0_name' => 'Test Product', | ||
'li_0_price' => '0.01' | ||
); | ||
$test = 'https://www.2checkout.com/checkout/purchase?sid=1817037&mode=2CO&li_0_name=Test+Product&li_0_price=0.01'; | ||
$result = Twocheckout_Charge::link($params); | ||
$this->assertEquals($test, $result); | ||
} | ||
$test = 'https://www.2checkout.com/checkout/purchase?sid=1817037&mode=2CO&li_0_name=Test+Product&li_0_price=0.01'; | ||
$result = Twocheckout_Charge::link($params); | ||
$this->assertEquals($test, $result); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters