diff --git a/lib/Twocheckout.php b/lib/Twocheckout.php index 8da5b99..a67b67d 100755 --- a/lib/Twocheckout.php +++ b/lib/Twocheckout.php @@ -6,12 +6,11 @@ abstract class Twocheckout public static $privateKey; public static $username; public static $password; - public static $sandbox; public static $verifySSL = true; public static $baseUrl = 'https://www.2checkout.com'; public static $error; public static $format = 'array'; - const VERSION = '0.3.1'; + const VERSION = '0.4.0'; public static function sellerId($value = null) { self::$sid = $value; @@ -29,16 +28,6 @@ public static function password($value = null) { self::$password = $value; } - public static function sandbox($value = null) { - if ($value == 1 || $value == true) { - self::$sandbox = true; - self::$baseUrl = 'https://sandbox.2checkout.com'; - } else { - self::$sandbox = false; - self::$baseUrl = 'https://www.2checkout.com'; - } - } - public static function verifySSL($value = null) { if ($value == 0 || $value == false) { self::$verifySSL = false; @@ -57,8 +46,6 @@ public static function format($value = null) { require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutApi.php'); require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutSale.php'); require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutProduct.php'); -require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutCoupon.php'); -require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutOption.php'); require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutUtil.php'); require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutError.php'); require(dirname(__FILE__) . '/Twocheckout/TwocheckoutReturn.php'); diff --git a/lib/Twocheckout/Api/TwocheckoutCoupon.php b/lib/Twocheckout/Api/TwocheckoutCoupon.php deleted file mode 100644 index 2147d42..0000000 --- a/lib/Twocheckout/Api/TwocheckoutCoupon.php +++ /dev/null @@ -1,42 +0,0 @@ -doCall($urlSuffix, $params); - return Twocheckout_Util::returnResponse($result); - } - - public static function retrieve($params=array()) - { - $request = new Twocheckout_Api_Requester(); - if(array_key_exists("coupon_code",$params)) { - $urlSuffix = '/api/products/detail_coupon'; - } else { - $urlSuffix = '/api/products/list_coupons'; - } - $result = $request->doCall($urlSuffix, $params); - return Twocheckout_Util::returnResponse($result); - } - - public static function update($params=array()) - { - $request = new Twocheckout_Api_Requester(); - $urlSuffix = '/api/products/update_coupon'; - $result = $request->doCall($urlSuffix, $params); - return Twocheckout_Util::returnResponse($result); - } - - public static function delete($params=array()) - { - $request = new Twocheckout_Api_Requester(); - $urlSuffix = '/api/products/delete_coupon'; - $result = $request->doCall($urlSuffix, $params); - return Twocheckout_Util::returnResponse($result); - } - -} \ No newline at end of file diff --git a/lib/Twocheckout/Api/TwocheckoutOption.php b/lib/Twocheckout/Api/TwocheckoutOption.php deleted file mode 100644 index 5da95aa..0000000 --- a/lib/Twocheckout/Api/TwocheckoutOption.php +++ /dev/null @@ -1,42 +0,0 @@ -doCall($urlSuffix, $params); - return Twocheckout_Util::returnResponse($result); - } - - public static function retrieve($params=array()) - { - $request = new Twocheckout_Api_Requester(); - if(array_key_exists("option_id",$params)) { - $urlSuffix = '/api/products/detail_option'; - } else { - $urlSuffix = '/api/products/list_options'; - } - $result = $request->doCall($urlSuffix, $params); - return Twocheckout_Util::returnResponse($result); - } - - public static function update($params=array()) - { - $request = new Twocheckout_Api_Requester(); - $urlSuffix = '/api/products/update_option'; - $result = $request->doCall($urlSuffix, $params); - return Twocheckout_Util::returnResponse($result); - } - - public static function delete($params=array()) - { - $request = new Twocheckout_Api_Requester(); - $urlSuffix = '/api/products/delete_option'; - $result = $request->doCall($urlSuffix, $params); - return Twocheckout_Util::returnResponse($result); - } - -} \ No newline at end of file diff --git a/lib/Twocheckout/Api/TwocheckoutSale.php b/lib/Twocheckout/Api/TwocheckoutSale.php index def9663..9c042fe 100644 --- a/lib/Twocheckout/Api/TwocheckoutSale.php +++ b/lib/Twocheckout/Api/TwocheckoutSale.php @@ -93,11 +93,4 @@ public static function ship($params=array()) { return Twocheckout_Util::returnResponse($result); } - public static function reauth($params=array()) { - $request = new Twocheckout_Api_Requester(); - $urlSuffix ='/api/sales/reauth'; - $result = $request->doCall($urlSuffix, $params); - return Twocheckout_Util::returnResponse($result); - } - } diff --git a/test/ChargeTest.php b/test/ChargeTest.php index 6167008..5cc4c57 100755 --- a/test/ChargeTest.php +++ b/test/ChargeTest.php @@ -8,7 +8,7 @@ class TestCharge extends PHPUnit_Framework_TestCase public function testChargeForm() { $params = array( - 'sid' => '1817037', + 'sid' => 'your seller id', 'mode' => '2CO', 'li_0_name' => 'Test Product', 'li_0_price' => '0.01' @@ -19,7 +19,7 @@ public function testChargeForm() public function testChargeFormAuto() { $params = array( - 'sid' => '1817037', + 'sid' => 'your seller id', 'mode' => '2CO', 'li_0_name' => 'Test Product', 'li_0_price' => '0.01' @@ -30,11 +30,11 @@ public function testChargeFormAuto() public function testDirect() { $params = array( - 'sid' => '1817037', + 'sid' => 'your seller id', 'mode' => '2CO', 'li_0_name' => 'Test Product', 'li_0_price' => '0.01', - 'card_holder_name' => 'Testing Tester', + 'card_holder_name' => 'John Doe', 'email' => 'christensoncraig@gmail.com', 'street_address' => '123 test st', 'city' => 'Columbus', @@ -47,13 +47,12 @@ public function testDirect() public function testDirectAuto() { - Twocheckout::sandbox(true); $params = array( - 'sid' => '1817037', + 'sid' => 'your seller id', 'mode' => '2CO', 'li_0_name' => 'Test Product', 'li_0_price' => '0.01', - 'card_holder_name' => 'Testing Tester', + 'card_holder_name' => 'John Doe', 'email' => 'christensoncraig@gmail.com', 'street_address' => '123 test st', 'city' => 'Columbus', @@ -66,9 +65,8 @@ public function testDirectAuto() public function testChargeLink() { - Twocheckout::sandbox(true); $params = array( - 'sid' => '1817037', + 'sid' => 'your seller id', 'mode' => '2CO', 'li_0_name' => 'Test Product', 'li_0_price' => '0.01' @@ -78,19 +76,19 @@ public function testChargeLink() public function testChargeAuth() { - Twocheckout::privateKey('BE632CB0-BB29-11E3-AFB6-D99C28100996'); - Twocheckout::sellerId('901248204'); - Twocheckout::sandbox(true); + Twocheckout::privateKey('your private key'); + Twocheckout::sellerId('your seller id'); try { $charge = Twocheckout_Charge::auth(array( - "sellerId" => "901248204", + "sellerId" => "your seller id", + "demo" =>true, "merchantOrderId" => "123", - "token" => 'MjFiYzIzYjAtYjE4YS00ZmI0LTg4YzYtNDIzMTBlMjc0MDlk', + "token" => 'MDY3OTMwMWUtODg5NS00NmFmLWJhNjgtYjMxYTI1ZjhkOWU3', "currency" => 'USD', "total" => '10.00', "billingAddr" => array( - "name" => 'Testing Tester', + "name" => 'John Doe', "addrLine1" => '123 Test St', "city" => 'Columbus', "state" => 'OH', @@ -100,7 +98,7 @@ public function testChargeAuth() "phoneNumber" => '555-555-5555' ), "shippingAddr" => array( - "name" => 'Testing Tester', + "name" => 'John Doe', "addrLine1" => '123 Test St', "city" => 'Columbus', "state" => 'OH', @@ -110,9 +108,9 @@ public function testChargeAuth() "phoneNumber" => '555-555-5555' ) )); - $this->assertEquals('APPROVED', $charge['response']['responseCode']); + $this->assertSame('APPROVED', $charge['response']['responseCode']); } catch (Twocheckout_Error $e) { - $this->assertEquals('Bad request - parameter error', $e->getMessage()); + $this->assertSame('Bad request - parameter error', $e->getMessage()); } } } diff --git a/test/CompanyTest.php b/test/CompanyTest.php index 2c3df4a..6bdced2 100644 --- a/test/CompanyTest.php +++ b/test/CompanyTest.php @@ -5,21 +5,20 @@ class TwocheckoutTest extends PHPUnit_Framework_TestCase public function setUp() { - Twocheckout::username('testlibraryapi901248204'); - Twocheckout::password('testlibraryapi901248204PASS'); - Twocheckout::sandbox(true); + Twocheckout::username('username'); + Twocheckout::password('pass'); } public function testCompanyRetrieve() { $company = Twocheckout_Company::retrieve(); - $this->assertEquals("901248204", $company['vendor_company_info']['vendor_id']); + $this->assertSame("250111206876", $company['vendor_company_info']['vendor_id']); } public function testContactRetrieve() { $company = Twocheckout_Contact::retrieve(); - $this->assertEquals("901248204", $company['vendor_contact_info']['vendor_id']); + $this->assertSame("250111206876", $company['vendor_contact_info']['vendor_id']); } -} \ No newline at end of file +} diff --git a/test/CouponTest.php b/test/CouponTest.php deleted file mode 100755 index 6dc904a..0000000 --- a/test/CouponTest.php +++ /dev/null @@ -1,68 +0,0 @@ - 10 - ); - $coupons = Twocheckout_Coupon::retrieve($params); - $this->assertEquals("OK", $coupons['response_code']); - } - - public function testCouponCreate() - { - $params = array( - 'date_expire' => '2020-01-01', - 'type' => 'shipping', - 'minimum_purchase' => 1.00 - ); - $response = Twocheckout_Coupon::create($params); - $this->assertEquals("Coupon successfully created", $response['response_message']); - $params = array('coupon_code' => $response['coupon_code']); - Twocheckout_Coupon::delete($params); - } - - public function testCouponRetrieve() - { - $params = array( - 'coupon_code' => "1396528010" - ); - $coupon = Twocheckout_Coupon::retrieve($params); - $this->assertEquals("1396528010", $coupon['coupon']['coupon_code']); - } - - public function testCouponUpdate() - { - $params = array( - 'date_expire' => "2020-01-01", - 'coupon_code' => "1396528010" - ); - $response = Twocheckout_Coupon::update($params); - $this->assertEquals("Coupon updated successfully", $response['response_message']); - } - - public function testCouponDelete() - { - $params = array( - 'date_expire' => '2020-01-01', - 'type' => 'shipping', - 'minimum_purchase' => 1.00 - ); - $response = Twocheckout_Coupon::create($params); - $params = array('coupon_code' => $response['coupon_code']); - $response = Twocheckout_Coupon::delete($params); - $this->assertEquals("Coupon successfully deleted.", $response['response_message']); - } - -} \ No newline at end of file diff --git a/test/NotificationTest.php b/test/NotificationTest.php index ef7764c..2a8462b 100644 --- a/test/NotificationTest.php +++ b/test/NotificationTest.php @@ -15,7 +15,7 @@ public function testNotificationCheck() 'secret' => 'tango' ); $result = Twocheckout_Notification::check($params, 'tango'); - $this->assertEquals("Success", $result['response_code']); + $this->assertSame("Success", $result['response_code']); } -} \ No newline at end of file +} diff --git a/test/OptionTest.php b/test/OptionTest.php deleted file mode 100755 index b8453a3..0000000 --- a/test/OptionTest.php +++ /dev/null @@ -1,68 +0,0 @@ - 2 - ); - $options = Twocheckout_Option::retrieve($params); - $this->assertEquals(2, sizeof($options['options'])); - } - - public function testOptionCreate() - { - $params = array( - 'option_name' => "test", - 'option_value_name' => "test", - 'option_value_surcharge' => 0.01 - ); - $response = Twocheckout_Option::create($params); - $this->assertEquals("Option created successfully", $response['response_message']); - $params = array('option_id' => $response['option_id']); - Twocheckout_Option::delete($params); - } - - public function testOptionRetrieve() - { - $params = array( - 'option_id' => 9093717691995 - ); - $product = Twocheckout_Option::retrieve($params); - $this->assertEquals("9093717691995", $product['option'][0]['option_id']); - } - - public function testOptionUpdate() - { - $params = array( - 'option_name' => "test1", - 'option_id' => 9093717691995 - ); - $response = Twocheckout_Option::update($params); - $this->assertEquals("Option updated successfully", $response['response_message']); - } - - public function testOptionDelete() - { - $params = array( - 'option_name' => "test", - 'option_value_name' => "test", - 'option_value_surcharge' => 0.01 - ); - $response = Twocheckout_Option::create($params); - $params = array('option_id' => $response['option_id']); - $response = Twocheckout_Option::delete($params); - $this->assertEquals("Option deleted successfully", $response['response_message']); - } - -} \ No newline at end of file diff --git a/test/ProductTest.php b/test/ProductTest.php index ec0d2a0..6e806b0 100755 --- a/test/ProductTest.php +++ b/test/ProductTest.php @@ -7,9 +7,8 @@ class TestProduct extends PHPUnit_Framework_TestCase public function setUp() { - Twocheckout::username('testlibraryapi901248204'); - Twocheckout::password('testlibraryapi901248204PASS'); - Twocheckout::sandbox(true); + Twocheckout::username('username'); + Twocheckout::password('pass'); } public function testProductListRetrieve() @@ -18,7 +17,7 @@ public function testProductListRetrieve() 'pagesize' => 2 ); $products = Twocheckout_Product::retrieve($params); - $this->assertEquals(2, sizeof($products['products'])); + $this->assertSame(2, sizeof($products['products'])); } public function testProductCreate() @@ -28,40 +27,8 @@ public function testProductCreate() 'price' => 0.01 ); $response = Twocheckout_Product::create($params); - $this->assertEquals("Product successfully created", $response['response_message']); - $params = array('product_id' => $response['product_id']); - Twocheckout_Product::delete($params); - } - - public function testProductRetrieve() - { - $params = array( - 'product_id' => 9093717691932 - ); - $product = Twocheckout_Product::retrieve($params); - $this->assertEquals("9093717691932", $product['product']['product_id']); - } - - public function testProductUpdate() - { - $params = array( - 'name' => "test", - 'product_id' => 9093717691932 - ); - $response = Twocheckout_Product::update($params); - $this->assertEquals("Product successfully updated", $response['response_message']); - } + $this->assertSame("Product successfully created.", $response['response_message']); - public function testProductDelete() - { - $params = array( - 'name' => "test", - 'price' => 0.01 - ); - $response = Twocheckout_Product::create($params); - $params = array('product_id' => $response['product_id']); - $response = Twocheckout_Product::delete($params); - $this->assertEquals("Product successfully deleted.", $response['response_message']); } -} \ No newline at end of file +} diff --git a/test/ReturnTest.php b/test/ReturnTest.php index 3e59043..6f2bf75 100644 --- a/test/ReturnTest.php +++ b/test/ReturnTest.php @@ -14,7 +14,7 @@ public function testReturnCheck() 'order_number' => '4774380224' ); $result = Twocheckout_Return::check($params, 'tango'); - $this->assertEquals("Success", $result['response_code']); + $this->assertSame("Success", $result['response_code']); } -} \ No newline at end of file +} diff --git a/test/SaleTest.php b/test/SaleTest.php index 2f4827a..c369bb6 100755 --- a/test/SaleTest.php +++ b/test/SaleTest.php @@ -5,18 +5,17 @@ class TestSale extends PHPUnit_Framework_TestCase public function setUp() { - Twocheckout::username('testlibraryapi901248204'); - Twocheckout::password('testlibraryapi901248204PASS'); - Twocheckout::sandbox(true); + Twocheckout::username('username'); + Twocheckout::password('pass'); } public function testSaleRetrieve() { $params = array( - 'sale_id' => 9093717691800 + 'sale_id' => 250339324792 ); $sale = Twocheckout_Sale::retrieve($params); - $this->assertEquals("9093717691800", $sale['sale']['sale_id']); + $this->assertSame("250339323357", $sale['sale']['sale_id']); } public function testSaleRetrieveList() @@ -25,49 +24,49 @@ public function testSaleRetrieveList() 'pagesize' => 2 ); $sale = Twocheckout_Sale::retrieve($params); - $this->assertEquals(2, sizeof($sale['sale_summary'])); + $this->assertSame(2, sizeof($sale['sale_summary'])); } public function testSaleRefundSale() { $params = array( - 'sale_id' => 9093717691800, + 'sale_id' => 250339323357, 'category' => 1, 'comment' => 'Order never sent.' ); try { $sale = Twocheckout_Sale::refund($params); - $this->assertEquals("OK", sizeof($sale['response_code'])); + $this->assertSame("OK", ($sale['response_code'])); } catch (Twocheckout_Error $e) { - $this->assertEquals("Invoice was already refunded.", $e->getMessage()); + $this->assertSame("Amount greater than remaining balance on invoice.", $e->getMessage()); } } public function testSaleRefundLineitem() { $params = array( - 'lineitem_id' => 9093717693210, + 'lineitem_id' => 250339324796, 'category' => 1, 'comment' => 'Order never sent.' ); try { $sale = Twocheckout_Sale::refund($params); - $this->assertEquals("OK", $sale['response_code']); + $this->assertSame("OK", $sale['response_code']); } catch (Twocheckout_Error $e) { - $this->assertEquals("Lineitem was already refunded.", $e->getMessage()); + $this->assertSame("Lineitem amount greater than remaining balance on invoice.", $e->getMessage()); } } public function testSaleStopSale() { $params = array( - 'sale_id' => 9093717763224 + 'sale_id' => 250339328202 ); try { $response = Twocheckout_Sale::stop($params); - $this->assertEquals("OK", $response['response_code']); + $this->assertSame("OK", $response['response_code']); } catch (Twocheckout_Error $e) { - $this->assertEquals("No recurring lineitems to stop.", $e->getMessage()); + $this->assertSame("No recurring lineitems to stop.", $e->getMessage()); } } @@ -78,60 +77,49 @@ public function testSaleStopLineitem() ); try { $response = Twocheckout_Sale::stop($params); - $this->assertEquals("OK", $response['response_code']); + $this->assertSame("OK", $response['response_code']); } catch (Twocheckout_Error $e) { - $this->assertEquals("Lineitem is not scheduled to recur.", $e->getMessage()); + $this->assertSame("Lineitem is not scheduled to recur.", $e->getMessage()); } } public function testSaleActive() { $params = array( - 'sale_id' => 9093717763224 + 'sale_id' => 250339328202 ); try { $response = Twocheckout_Sale::active($params); - $this->assertEquals("OK", $response['response_code']); + $this->assertSame("OK", $response['response_code']); } catch (Twocheckout_Error $e) { - $this->assertEquals("No active recurring lineitems.", $e->getMessage()); + $this->assertSame("No active recurring lineitems.", $e->getMessage()); } } public function testSaleComment() { $params = array( - 'sale_id' => 9093717691800, + 'sale_id' => 250339328202, 'sale_comment' => "test" ); $result = Twocheckout_Sale::comment($params); - $this->assertEquals("Created comment successfully.", $result['response_message']); + $this->assertSame("Created comment successfully.", $result['response_message']); } public function testSaleShip() { $params = array( - 'sale_id' => 9093717691800, + 'sale_id' => 250339331047, 'tracking_number' => "test" ); try { $result = Twocheckout_Sale::ship($params); - $this->assertEquals("OK", $result['response_code']); + $this->assertSame("OK", $result['response_code']); } catch (Exception $e) { - $this->assertEquals("Sale already marked shipped.", $e->getMessage()); + $this->assertSame("Sale already marked shipped.", $e->getMessage()); } } - public function testSaleReauth() - { - $params = array( - 'sale_id' => 9093717691800 - ); - try { - $result = Twocheckout_Sale::reauth($params); - $this->assertEquals("OK", $result['response_code']); - } catch (Exception $e) { - $this->assertEquals("Payment is already pending or deposited and cannot be reauthorized.", $e->getMessage()); - } - } -} \ No newline at end of file + +}