Skip to content

Commit 78b1060

Browse files
Merge pull request #38 from 2Checkout/CC-212
CC-212 Update php library for new test method
2 parents cbac8da + f1f4436 commit 78b1060

12 files changed

Lines changed: 57 additions & 345 deletions

lib/Twocheckout.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ abstract class Twocheckout
66
public static $privateKey;
77
public static $username;
88
public static $password;
9-
public static $sandbox;
109
public static $verifySSL = true;
1110
public static $baseUrl = 'https://www.2checkout.com';
1211
public static $error;
1312
public static $format = 'array';
14-
const VERSION = '0.3.1';
13+
const VERSION = '0.4.0';
1514

1615
public static function sellerId($value = null) {
1716
self::$sid = $value;
@@ -29,16 +28,6 @@ public static function password($value = null) {
2928
self::$password = $value;
3029
}
3130

32-
public static function sandbox($value = null) {
33-
if ($value == 1 || $value == true) {
34-
self::$sandbox = true;
35-
self::$baseUrl = 'https://sandbox.2checkout.com';
36-
} else {
37-
self::$sandbox = false;
38-
self::$baseUrl = 'https://www.2checkout.com';
39-
}
40-
}
41-
4231
public static function verifySSL($value = null) {
4332
if ($value == 0 || $value == false) {
4433
self::$verifySSL = false;
@@ -57,8 +46,6 @@ public static function format($value = null) {
5746
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutApi.php');
5847
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutSale.php');
5948
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutProduct.php');
60-
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutCoupon.php');
61-
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutOption.php');
6249
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutUtil.php');
6350
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutError.php');
6451
require(dirname(__FILE__) . '/Twocheckout/TwocheckoutReturn.php');

lib/Twocheckout/Api/TwocheckoutCoupon.php

Lines changed: 0 additions & 42 deletions
This file was deleted.

lib/Twocheckout/Api/TwocheckoutOption.php

Lines changed: 0 additions & 42 deletions
This file was deleted.

lib/Twocheckout/Api/TwocheckoutSale.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,4 @@ public static function ship($params=array()) {
9393
return Twocheckout_Util::returnResponse($result);
9494
}
9595

96-
public static function reauth($params=array()) {
97-
$request = new Twocheckout_Api_Requester();
98-
$urlSuffix ='/api/sales/reauth';
99-
$result = $request->doCall($urlSuffix, $params);
100-
return Twocheckout_Util::returnResponse($result);
101-
}
102-
10396
}

test/ChargeTest.php

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class TestCharge extends PHPUnit_Framework_TestCase
88
public function testChargeForm()
99
{
1010
$params = array(
11-
'sid' => '1817037',
11+
'sid' => 'your seller id',
1212
'mode' => '2CO',
1313
'li_0_name' => 'Test Product',
1414
'li_0_price' => '0.01'
@@ -19,7 +19,7 @@ public function testChargeForm()
1919
public function testChargeFormAuto()
2020
{
2121
$params = array(
22-
'sid' => '1817037',
22+
'sid' => 'your seller id',
2323
'mode' => '2CO',
2424
'li_0_name' => 'Test Product',
2525
'li_0_price' => '0.01'
@@ -30,11 +30,11 @@ public function testChargeFormAuto()
3030
public function testDirect()
3131
{
3232
$params = array(
33-
'sid' => '1817037',
33+
'sid' => 'your seller id',
3434
'mode' => '2CO',
3535
'li_0_name' => 'Test Product',
3636
'li_0_price' => '0.01',
37-
'card_holder_name' => 'Testing Tester',
37+
'card_holder_name' => 'John Doe',
3838
'email' => '[email protected]',
3939
'street_address' => '123 test st',
4040
'city' => 'Columbus',
@@ -47,13 +47,12 @@ public function testDirect()
4747

4848
public function testDirectAuto()
4949
{
50-
Twocheckout::sandbox(true);
5150
$params = array(
52-
'sid' => '1817037',
51+
'sid' => 'your seller id',
5352
'mode' => '2CO',
5453
'li_0_name' => 'Test Product',
5554
'li_0_price' => '0.01',
56-
'card_holder_name' => 'Testing Tester',
55+
'card_holder_name' => 'John Doe',
5756
'email' => '[email protected]',
5857
'street_address' => '123 test st',
5958
'city' => 'Columbus',
@@ -66,9 +65,8 @@ public function testDirectAuto()
6665

6766
public function testChargeLink()
6867
{
69-
Twocheckout::sandbox(true);
7068
$params = array(
71-
'sid' => '1817037',
69+
'sid' => 'your seller id',
7270
'mode' => '2CO',
7371
'li_0_name' => 'Test Product',
7472
'li_0_price' => '0.01'
@@ -78,19 +76,19 @@ public function testChargeLink()
7876

7977
public function testChargeAuth()
8078
{
81-
Twocheckout::privateKey('BE632CB0-BB29-11E3-AFB6-D99C28100996');
82-
Twocheckout::sellerId('901248204');
83-
Twocheckout::sandbox(true);
79+
Twocheckout::privateKey('your private key');
80+
Twocheckout::sellerId('your seller id');
8481

8582
try {
8683
$charge = Twocheckout_Charge::auth(array(
87-
"sellerId" => "901248204",
84+
"sellerId" => "your seller id",
85+
"demo" =>true,
8886
"merchantOrderId" => "123",
89-
"token" => 'MjFiYzIzYjAtYjE4YS00ZmI0LTg4YzYtNDIzMTBlMjc0MDlk',
87+
"token" => 'MDY3OTMwMWUtODg5NS00NmFmLWJhNjgtYjMxYTI1ZjhkOWU3',
9088
"currency" => 'USD',
9189
"total" => '10.00',
9290
"billingAddr" => array(
93-
"name" => 'Testing Tester',
91+
"name" => 'John Doe',
9492
"addrLine1" => '123 Test St',
9593
"city" => 'Columbus',
9694
"state" => 'OH',
@@ -100,7 +98,7 @@ public function testChargeAuth()
10098
"phoneNumber" => '555-555-5555'
10199
),
102100
"shippingAddr" => array(
103-
"name" => 'Testing Tester',
101+
"name" => 'John Doe',
104102
"addrLine1" => '123 Test St',
105103
"city" => 'Columbus',
106104
"state" => 'OH',
@@ -110,9 +108,9 @@ public function testChargeAuth()
110108
"phoneNumber" => '555-555-5555'
111109
)
112110
));
113-
$this->assertEquals('APPROVED', $charge['response']['responseCode']);
111+
$this->assertSame('APPROVED', $charge['response']['responseCode']);
114112
} catch (Twocheckout_Error $e) {
115-
$this->assertEquals('Bad request - parameter error', $e->getMessage());
113+
$this->assertSame('Bad request - parameter error', $e->getMessage());
116114
}
117115
}
118116
}

test/CompanyTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@ class TwocheckoutTest extends PHPUnit_Framework_TestCase
55

66
public function setUp()
77
{
8-
Twocheckout::username('testlibraryapi901248204');
9-
Twocheckout::password('testlibraryapi901248204PASS');
10-
Twocheckout::sandbox(true);
8+
Twocheckout::username('username');
9+
Twocheckout::password('pass');
1110
}
1211

1312
public function testCompanyRetrieve()
1413
{
1514
$company = Twocheckout_Company::retrieve();
16-
$this->assertEquals("901248204", $company['vendor_company_info']['vendor_id']);
15+
$this->assertSame("250111206876", $company['vendor_company_info']['vendor_id']);
1716
}
1817

1918
public function testContactRetrieve()
2019
{
2120
$company = Twocheckout_Contact::retrieve();
22-
$this->assertEquals("901248204", $company['vendor_contact_info']['vendor_id']);
21+
$this->assertSame("250111206876", $company['vendor_contact_info']['vendor_id']);
2322
}
2423

25-
}
24+
}

test/CouponTest.php

Lines changed: 0 additions & 68 deletions
This file was deleted.

test/NotificationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function testNotificationCheck()
1515
'secret' => 'tango'
1616
);
1717
$result = Twocheckout_Notification::check($params, 'tango');
18-
$this->assertEquals("Success", $result['response_code']);
18+
$this->assertSame("Success", $result['response_code']);
1919
}
2020

21-
}
21+
}

0 commit comments

Comments
 (0)