Skip to content

Commit

Permalink
Merge pull request #41 from paypay/improvements/PP-45058
Browse files Browse the repository at this point in the history
Improvements/pp 45058
  • Loading branch information
Shreyansh Pandey committed Sep 23, 2020
2 parents e3229b0 + 83a0024 commit 1ef6180
Show file tree
Hide file tree
Showing 13 changed files with 460 additions and 123 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ run_staging:
vendor/bin/phpunit --testdox --debug tests/QrTest.php
vendor/bin/phpunit --testdox --debug tests/PaymentTest.php
vendor/bin/phpunit --testdox --debug tests/UserTest.php
vendor/bin/phpunit --testdox --debug tests/WalletTest.php
vendor/bin/phpunit --testdox --debug tests/WalletTest.php
run_coverage:
clear
cd mock && java -jar wiremock.jar --verbose &
sleep 7
vendor/bin/phpunit --coverage-clover build/logs/clover.xml --testdox --debug -c phpunit.xml.dist
vendor/bin/php-coveralls -v
22 changes: 22 additions & 0 deletions mock/mappings/CreateACLink.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"request": {
"method": "POST",
"urlPath": "/v1/qr/sessions"
},
"response": {
"status": 201,
"headers": {
"Content-Type": "application/json"
},
"jsonBody": {
"resultInfo": {
"code": "SUCCESS",
"message": "Success",
"codeId": "08100001"
},
"data": {
"linkQRCodeURL": "https://PayPayAuthURL.com"
}
}
}
}
8 changes: 7 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
<log type="coverage-php" target="./build/cov/clover.xml"/>
</logging>
<testsuites>
<testsuite name="Core Classes">
<file> tests/CoreClassesTest.php</file>
</testsuite>
<testsuite name="Payloads">
<file> tests/PayloadsTest.php</file>
</testsuite>
<testsuite name="QR Code">
<file> tests/QrTest.php</file>

</testsuite>
<testsuite name="Payments">
<file> tests/PaymentTest.php</file>
Expand All @@ -21,6 +26,7 @@
<file> tests/RefundTest.php</file>
</testsuite>
<testsuite name="User">
<file>tests/PipelinedAccountLinkTest.php</file>
<file> tests/UserTest.php</file>
<file> tests/WalletTest.php </file>
</testsuite>
Expand Down
1 change: 0 additions & 1 deletion src/Controllers/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use PayPay\OpenPaymentAPI\Models\CapturePaymentAuthPayload;
use PayPay\OpenPaymentAPI\Models\CreatePaymentPayload;
use PayPay\OpenPaymentAPI\Models\RevertAuthPayload;
use PayPay\OpenPaymentAPI\Models\UserAuthUrlInfo;
use Exception;
use PayPay\OpenPaymentAPI\Client;
use PayPay\OpenPaymentAPI\Models\CreateContinuousPaymentPayload;
Expand Down
4 changes: 0 additions & 4 deletions src/Controllers/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ class User extends Controller
* @param Client $MainInstance Instance of invoking client class
* @param Array $auth API credentials
*/
public function __construct($MainInstance, $auth)
{
parent::__construct($MainInstance, $auth);
}


/**
Expand Down
2 changes: 1 addition & 1 deletion src/Models/AccountLinkPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function getRedirectType()

/**
* Set the value of redirectType
* @param string $redirectType
* @param string $redirectType "APP_DEEP_LINK" or "WEB_LINK"
*
* @return self
*/
Expand Down
11 changes: 11 additions & 0 deletions src/Models/BasePaymentInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public function setMetadata($metadata)

return $this;
}

/**
* Set the value of orderItems
* @param array $orderItems
Expand Down Expand Up @@ -222,4 +223,14 @@ public function setMerchantPaymentId($merchantPaymentId)

return $this;
}

/**
* Get order Items
*
* @return array
*/
public function getOrderItems()
{
return $this->orderItems;
}
}
105 changes: 0 additions & 105 deletions src/Models/userAuthInfo.php

This file was deleted.

123 changes: 123 additions & 0 deletions tests/CoreClassesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

use PayPay\OpenPaymentAPI\Client;
use PayPay\OpenPaymentAPI\ClientException;

require_once('TestBoilerplate.php');

class CoreClassesTest extends TestBoilerplate
{
function testClientNoAuth()
{
try {
$client = new Client();
} catch (ClientException $e) {
$this->assertStringContainsString('Invalid auth credentials', $e->getMessage());
}
}
function testClientBaExtNwClient()
{
$config = [
/** @phpstan-ignore-next-line */
'API_KEY' => "API_KEY_STRING",
/** @phpstan-ignore-next-line */
'API_SECRET' => "API_KEY_STRING",
/** @phpstan-ignore-next-line */
'MERCHANT_ID' => "MERCHANT_IDENTIFIER_STRING"
];
$client = new Client($config, false, new GuzzleHttp\Client());

$collector["URL"] = $client->GetConfig("API_URL");
$collector["ENDPOINT"] = $client->GetEndpoint('SUBSCRIPTION');
$collector["ENDPOINT_VERSION"] = $client->GetEndpointVersion('SUBSCRIPTION');
$collector["MERCHANT_ID"] = $client->GetMid();
foreach ($collector as $key => $value) {
$this->assertNotNull($value, "${key} invalid");
}
}
function testClientBadNwClient()
{
$config = [
/** @phpstan-ignore-next-line */
'API_KEY' => "API_KEY_STRING",
/** @phpstan-ignore-next-line */
'API_SECRET' => "API_KEY_STRING",
/** @phpstan-ignore-next-line */
'MERCHANT_ID' => "MERCHANT_IDENTIFIER_STRING"
];
try {
$client = new Client($config, false, 2);
} catch (ClientException $e) {
$this->assertStringContainsString("Invalid request handler",$e->getMessage());
}
}

function testClientStaging()
{
$config = [
/** @phpstan-ignore-next-line */
'API_KEY' => "API_KEY_STRING",
/** @phpstan-ignore-next-line */
'API_SECRET' => "API_KEY_STRING",
/** @phpstan-ignore-next-line */
'MERCHANT_ID' => "MERCHANT_IDENTIFIER_STRING"
];
$client = new Client($config);
$collector["URL"] = $client->GetConfig("API_URL");
$collector["ENDPOINT"] = $client->GetEndpoint('SUBSCRIPTION');
$collector["ENDPOINT_VERSION"] = $client->GetEndpointVersion('SUBSCRIPTION');
$collector["MERCHANT_ID"] = $client->GetMid();
foreach ($collector as $key => $value) {
$this->assertNotNull($value, "${key} invalid");
}
}
function testClientProduction()
{
$config = [
/** @phpstan-ignore-next-line */
'API_KEY' => "API_KEY_STRING",
/** @phpstan-ignore-next-line */
'API_SECRET' => "API_KEY_STRING",
/** @phpstan-ignore-next-line */
'MERCHANT_ID' => "MERCHANT_IDENTIFIER_STRING"
];
$client = new Client($config, true);
$collector["URL"] = $client->GetConfig("API_URL");
$collector["ENDPOINT"] = $client->GetEndpoint('SUBSCRIPTION');
$collector["ENDPOINT_VERSION"] = $client->GetEndpointVersion('SUBSCRIPTION');
$collector["MERCHANT_ID"] = $client->GetMid();
foreach ($collector as $key => $value) {
$this->assertNotNull($value, "${key} invalid");
}
}
function testClientTestMode()
{
$config = [
/** @phpstan-ignore-next-line */
'API_KEY' => "API_KEY_STRING",
/** @phpstan-ignore-next-line */
'API_SECRET' => "API_KEY_STRING",
/** @phpstan-ignore-next-line */
'MERCHANT_ID' => "MERCHANT_IDENTIFIER_STRING"
];
$client = new Client($config, "test");
$collector["URL"] = $client->GetConfig("API_URL");
$collector["ENDPOINT"] = $client->GetEndpoint('SUBSCRIPTION');
$collector["ENDPOINT_VERSION"] = $client->GetEndpointVersion('SUBSCRIPTION');
$collector["MERCHANT_ID"] = $client->GetMid();
foreach ($collector as $key => $value) {
$this->assertNotNull($value, "${key} invalid");
}
}
function testClientNoMid()
{
$config = [
/** @phpstan-ignore-next-line */
'API_KEY' => "API_KEY_STRING",
/** @phpstan-ignore-next-line */
'API_SECRET' => "API_KEY_STRING",
];
$client = new Client($config);
$this->assertFalse($client->GetMid());
}
}
16 changes: 16 additions & 0 deletions tests/DecodeAccountLinkResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
require_once('TestBoilerplate.php');

use PayPay\OpenPaymentAPI\Models\AccountLinkPayload;

class AccountLinkTest extends TestBoilerplate
{

function testDecode(){
$uaresponse = $this->config['uaresponse'];
$data = $this->client->user->decodeUserAuth($uaresponse);
var_dump($data);
$this->assertTrue(isset($data['userAuthorizationId']));
}
}

Loading

0 comments on commit 1ef6180

Please sign in to comment.