diff --git a/lib/Twocheckout.php b/lib/Twocheckout.php index b843a1b..e0972bd 100644 --- a/lib/Twocheckout.php +++ b/lib/Twocheckout.php @@ -7,7 +7,7 @@ abstract class Twocheckout public static $format = "json"; public static $apiBaseUrl = "https://www.2checkout.com/api/"; public static $error; - const VERSION = '0.1.1'; + const VERSION = '0.1.2'; static function setCredentials($user, $pass) { diff --git a/lib/Twocheckout/TwocheckoutCharge.php b/lib/Twocheckout/TwocheckoutCharge.php index 59ae28b..b24a5cd 100644 --- a/lib/Twocheckout/TwocheckoutCharge.php +++ b/lib/Twocheckout/TwocheckoutCharge.php @@ -20,6 +20,32 @@ public static function form($params, $type='Checkout') } } + public static function direct($params, $type='Checkout') + { + echo '
'; + + foreach ($params as $key => $value) + { + echo ''; + } + + if ($type == 'auto') { + echo '
'; + echo ''; + } else { + echo ''; + echo ''; + } + + echo ''; + } + public static function link($params) { $url = 'https://www.2checkout.com/checkout/purchase?'.http_build_query($params, '', '&'); diff --git a/test/ChargeTest.php b/test/ChargeTest.php index 3e8253a..5207cac 100644 --- a/test/ChargeTest.php +++ b/test/ChargeTest.php @@ -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 = '
' + - '' + - '' + - '' + - '' + - '' + - '
'; - $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 = '
' + - '' + - '' + - '' + - '' + - '
' + - ''; - $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 = '
' + + '' + + '' + + '' + + '' + + '' + + '
'; + $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 = '
' + + '' + + '' + + '' + + '' + + '
' + + ''; + $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' => 'christensoncraig@gmail.com', + 'street_address' => '123 test st', + 'city' => 'Columbus', + 'state' => 'Ohio', + 'zip' => '43123', + 'country' => 'USA' + ); + $test = '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
' + + ''; + $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' => 'christensoncraig@gmail.com', + 'street_address' => '123 test st', + 'city' => 'Columbus', + 'state' => 'Ohio', + 'zip' => '43123', + 'country' => 'USA' + ); + $test = '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
' + + '' + + ''; + $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); + } } diff --git a/test/SaleTest.php b/test/SaleTest.php index 28b39c0..b665666 100644 --- a/test/SaleTest.php +++ b/test/SaleTest.php @@ -37,7 +37,7 @@ public function testSaleRefundSale() $sale = Twocheckout_Sale::refund($params, 'array'); $this->assertEquals("OK", sizeof($sale['response_code'])); } catch (Twocheckout_Error $e) { - $this->assertEquals("Invoice was already refunded.", $e->getMessage()); + $this->assertEquals("Invoice too old to refund.", $e->getMessage()); } }