Skip to content

Commit

Permalink
Added paymentCCWithOrderIdAndCard to UnitTests
Browse files Browse the repository at this point in the history
  • Loading branch information
emog committed Nov 10, 2017
1 parent fac35b4 commit 4efdddd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/CreditCardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,22 @@ public function testPaymentCCWithCard()
$this->assertContains('orderId', $response);
}

public function testPaymentCCWithOrderIdAndCard()
{
//TestCaseHelper::openOrderAndReturnOrderId() will create a new sessionToken
$orderId = TestCaseHelper::openOrderAndReturnOrderId();
$params = $this->getExampleData();
$params['cardData'] = SimpleData::getCarData();
$params['orderId'] = $orderId;

$response = $this->_service->paymentCC($params);
$this->assertContains('orderId', $response);
}

public function getExampleData()
{
$params = [
'sessionToken' => TestCaseHelper::getSessionToken(),
// "orderId" => "",
'userTokenId' => TestCaseHelper::getUserTokenId(),
'clientRequestId' => '',
'transactionType' => 'Auth',
Expand Down
27 changes: 27 additions & 0 deletions tests/TestCaseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Monolog\Logger;
use SafeCharge\Api\RestClient;
use SafeCharge\Api\Service\AuthenticationManagement;
use SafeCharge\Api\Service\OrdersManagement;
use SafeCharge\Api\Service\Payments\CreditCard;
use SafeCharge\Api\Service\UsersManagement;

Expand Down Expand Up @@ -131,4 +132,30 @@ public static function createAndReturnTransaction($amount = 10, $isAuth = false)
return $response;
}

public static function openOrderAndReturnOrderId()
{
$service = new OrdersManagement(self::getClient());
self::setSessionToken(null);
$params = [
'sessionToken' => TestCaseHelper::getSessionToken(),
'userTokenId' => TestCaseHelper::getUserTokenId(),
'clientUniqueId' => '',
'clientRequestId' => '',
'currency' => 'USD',
'amount' => "10",
'amountDetails' => SimpleData::getAmountDetails(),
'items' => SimpleData::getItems(),
'deviceDetails' => SimpleData::getDeviceDetails(),
'userDetails' => SimpleData::getUserDetails(),
'shippingAddress' => SimpleData::getShippingAddress(),
'billingAddress' => SimpleData::getBillingAddress(),
'dynamicDescriptor' => SimpleData::getDynamicDescriptor(),
'merchantDetails' => SimpleData::getMerchantDetails(),
'addendums' => SimpleData::getAddEndUms(),
];

$response = $service->openOrder($params);
return $response['orderId'];
}

}

0 comments on commit 4efdddd

Please sign in to comment.