Skip to content

Commit

Permalink
Merge pull request #38 from 2Checkout/CC-212
Browse files Browse the repository at this point in the history
CC-212 Update php library for new test method
  • Loading branch information
craigchristenson authored May 12, 2020
2 parents cbac8da + f1f4436 commit 78b1060
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 345 deletions.
15 changes: 1 addition & 14 deletions lib/Twocheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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');
Expand Down
42 changes: 0 additions & 42 deletions lib/Twocheckout/Api/TwocheckoutCoupon.php

This file was deleted.

42 changes: 0 additions & 42 deletions lib/Twocheckout/Api/TwocheckoutOption.php

This file was deleted.

7 changes: 0 additions & 7 deletions lib/Twocheckout/Api/TwocheckoutSale.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
34 changes: 16 additions & 18 deletions test/ChargeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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' => '[email protected]',
'street_address' => '123 test st',
'city' => 'Columbus',
Expand All @@ -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' => '[email protected]',
'street_address' => '123 test st',
'city' => 'Columbus',
Expand All @@ -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'
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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());
}
}
}
11 changes: 5 additions & 6 deletions test/CompanyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

}
}
68 changes: 0 additions & 68 deletions test/CouponTest.php

This file was deleted.

4 changes: 2 additions & 2 deletions test/NotificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

}
}
Loading

0 comments on commit 78b1060

Please sign in to comment.