Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added POC #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Resources/ExternalConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ function FutureDate($format){
return $retDate;
}

function CallTestLogging($testId, $apiName, $responseMessage){
function CallTestLogging($testId, $apiName, $assertMessage, $inputMessage){
$runtime = date('d-m-Y H:i:s');
$file = fopen("./CSV_Files/TestReport/TestResults.csv", "a+");
fputcsv($file, array($testId, $runtime, $apiName, $responseMessage));
$file = fopen("./SamplesQA/CSV_Files/TestReport/TestResults.csv", "a+");
fputcsv($file, array($testId, $apiName, $assertMessage, $inputMessage, $runtime));
fclose($file);
}

Expand All @@ -87,4 +87,4 @@ function downloadReport($downloadData, $fileName){
}
}

?>
?>
19 changes: 15 additions & 4 deletions Samples/Flex/CoreServices/GenerateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,32 @@ function GenerateKey()
'encryptionType' => "None",
];
$flexRequest = new CyberSource\Model\KeyParameters($flexRequestArr);
$flexRequestArr = json_decode($flexRequest);
echo "The Api Request Body: \n". json_encode($flexRequestArr, JSON_UNESCAPED_SLASHES) ."\n\n";
$api_response = list($response, $statusCode, $httpHeader)=null;
try {
$api_response = $api_instance->generatePublicKey($flexRequest);
print_r($api_response);
echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
$resBodyArr= json_decode($api_response[0]);
echo "The Api Response Body: \n". json_encode($resBodyArr, JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Api Response StatusCode: ".json_encode($api_response[1])."\n\n";
echo "The Api Response Header: \n".json_encode($api_response[2], JSON_UNESCAPED_SLASHES)."\n";


} catch (Cybersource\ApiException $e) {
print_r($e->getResponseBody());
print_r($e->getMessage());
echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Exception Response Body: \n";
print_r($e->getResponseBody()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getResponseHeaders()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getMessage());echo "\n\n";
}
}

// Call Sample Code
if(!defined('DO_NOT_RUN_SAMPLES')){
echo "GenerateKey Samplecode is Running.. \n";
echo "[BEGIN] EXECUTION OF SAMPLE CODE: GenerateKey\n\n";
GenerateKey();
}

Expand Down
23 changes: 17 additions & 6 deletions Samples/Flex/CoreServices/TokenizeCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,32 @@ function TokenizeCard($keyId, $publicKey)
'cardInfo' => $card_information
];
$flexRequest = new CyberSource\Model\TokenizeRequest($flexRequestArr);
$api_response = list($response,$statusCode,$httpHeader)=null;
$flexRequestArr = json_decode($flexRequest);
echo "The Api Request Body: \n". json_encode($flexRequestArr, JSON_UNESCAPED_SLASHES) ."\n\n";
$api_response = list($response,$statusCode,$httpHeader)=null;
try {
$api_response = $api_instance->tokenize($flexRequest);
print_r($api_response);
echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
$resBodyArr= json_decode($api_response[0]);
echo "The Api Response Body: \n". json_encode($resBodyArr, JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Api Response StatusCode: ".json_encode($api_response[1])."\n\n";
echo "The Api Response Header: \n".json_encode($api_response[2], JSON_UNESCAPED_SLASHES)."\n";
$verifyObj = new Verifier();
return $verifyObj->verifySignature($publicKey, $api_response);


} catch (Cybersource\ApiException $e) {
print_r($e->getResponseBody());
print_r($e->getMessage());
}
echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Exception Response Body: \n";
print_r($e->getResponseBody()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getResponseHeaders()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getMessage());echo "\n\n";
}
}
if(!defined('DO_NOT_RUN_SAMPLES')){
echo "TokenizeCard Samplecode is Processing\n";
echo "[BEGIN] EXECUTION OF SAMPLE CODE: TokenizeCard\n\n";
include_once __DIR__. DIRECTORY_SEPARATOR .'../KeyGenerationNoEnc.php';
$data = KeyGenerationNoEnc(true);
TokenizeCard($data[0], $data[1]);
Expand Down
3 changes: 2 additions & 1 deletion Samples/Flex/KeyGenerationNoEnc.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ function KeyGenerationNoEnc($flag)
'encryptionType' => "None",
];
$flexRequest = new CyberSource\Model\KeyParameters($flexRequestArr);
$api_response = list($response,$statusCode,$httpHeader)=null;

$api_response = list($response,$statusCode,$httpHeader)=null;
try {
$api_response = $api_instance->generatePublicKey($flexRequest);
$keyId = $api_response[0]['keyId'];
Expand Down
24 changes: 18 additions & 6 deletions Samples/Payments/CoreServices/CapturePayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,40 @@ function CapturePayment($flag)
];
//Creating model
$request = new CyberSource\Model\CapturePaymentRequest($requestArr);
$api_response = list($response,$statusCode,$httpHeader)=null;
$requestArr = json_decode($request);
$requestBody = $apiclient->dataMasking(json_encode($requestArr, JSON_UNESCAPED_SLASHES));
echo "The Request Payload : \n".$requestBody."\n\n";

$api_response = list($response,$statusCode,$httpHeader)=null;
try {
//Calling the Api
$api_response = $api_instance->capturePayment($request, $id);

if($flag == true){
//Returning the ID
echo "Fetching Capture ID: ".$api_response[0]['id']."\n";
return $api_response[0]['id'];
}else{
print_r($api_response);
$resBodyArr= json_decode($api_response[0]);
echo "The Api Response Body: \n". json_encode($resBodyArr, JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Api Response StatusCode: ".json_encode($api_response[1])."\n\n";
echo "The Api Response Header: \n".json_encode($api_response[2], JSON_UNESCAPED_SLASHES)."\n";
}
} catch (Cybersource\ApiException $e) {
print_r($e->getResponseBody());
print_r($e->getMessage());

echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Exception Response Body: \n";
print_r($e->getResponseBody()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getResponseHeaders()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getMessage());echo "\n\n";
}
}


// Call Sample Code
if(!defined('DO_NOT_RUN_SAMPLES')){
echo "Capture payment Samplecode is Running.. \n";
echo "[BEGIN] EXECUTION OF SAMPLE CODE: CapturePayment \n\n";
CapturePayment(false);

}
Expand Down
25 changes: 20 additions & 5 deletions Samples/Payments/CoreServices/ProcessAuthorizationReversal.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,41 @@ function ProcessAuthorizationReversal($flag)
];

$paymentRequest = new CyberSource\Model\AuthReversalRequest($paymentRequestArr);
$api_response = list($response,$statusCode,$httpHeader)=null;
$requestArr = json_decode($paymentRequest);
$requestBody = $apiclient->dataMasking(json_encode($requestArr, JSON_UNESCAPED_SLASHES));
echo "The Request Payload : \n".$requestBody."\n\n";

$api_response = list($response,$statusCode,$httpHeader)=null;
try {

$api_response = $api_instance->authReversal($id, $paymentRequest);

if($flag == true){
//Returning the ID
echo "Fetching Reversal: ".$api_response[0]['id']."\n";
return $api_response[0]['id'];
}else{
print_r($api_response);
$resBodyArr= json_decode($api_response[0]);
echo "The Api Response Body: \n". json_encode($resBodyArr, JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Api Response StatusCode: ".json_encode($api_response[1])."\n\n";
echo "The Api Response Header: \n".json_encode($api_response[2], JSON_UNESCAPED_SLASHES)."\n";
}

} catch (Cybersource\ApiException $e) {
print_r($e->getResponseBody());
print_r($e->getMessage());

echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Exception Response Body: \n";
print_r($e->getResponseBody()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getResponseHeaders()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getMessage());echo "\n\n";
}
}

// Call Sample Code
if(!defined('DO_NOT_RUN_SAMPLES')){
echo "ProcessAuthorizationReversal Samplecode is Running.. \n";
echo "[BEGIN] EXECUTION OF SAMPLE CODE: ProcessAuthorizationReversal \n\n";
ProcessAuthorizationReversal(false);

}
Expand Down
24 changes: 19 additions & 5 deletions Samples/Payments/CoreServices/ProcessCredit.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,41 @@ function ProcessCredit($flag)
];

$paymentRequest = new CyberSource\Model\CreateCreditRequest($paymentRequestArr);
$api_response = list($response,$statusCode,$httpHeader)=null;
$requestArr = json_decode($paymentRequest);
$requestBody = $apiclient->dataMasking(json_encode($requestArr, JSON_UNESCAPED_SLASHES));
echo "The Request Payload : \n".$requestBody."\n\n";
$api_response = list($response,$statusCode,$httpHeader)=null;
try {

$api_response = $api_instance->createCredit($paymentRequest);
if($flag ==true){
//Returning the ID
echo "Fetching Credit ID: ".$api_response[0]['id']."\n";
return $api_response[0]['id'];
}
else {
print_r($api_response);
echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
$resBodyArr= json_decode($api_response[0]);
echo "The Api Response Body: \n". json_encode($resBodyArr, JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Api Response StatusCode: ".json_encode($api_response[1])."\n\n";
echo "The Api Response Header: \n".json_encode($api_response[2], JSON_UNESCAPED_SLASHES)."\n";
}

} catch (Cybersource\ApiException $e) {
print_r($e->getResponseBody());
print_r($e->getMessage());

echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Exception Response Body: \n";
print_r($e->getResponseBody()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getResponseHeaders()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getMessage());echo "\n\n";
}
}

// Call Sample Code
if(!defined('DO_NOT_RUN_SAMPLES')){
echo "Process Credit Samplecode is Running.. \n";
echo "[BEGIN] EXECUTION OF SAMPLE CODE: ProcessCredit \n\n";
ProcessCredit(false);

}
Expand Down
23 changes: 17 additions & 6 deletions Samples/Payments/CoreServices/ProcessPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,41 @@ function ProcessPayment($flag)
];
//Creating model
$paymentRequest = new CyberSource\Model\CreatePaymentRequest($paymentRequestArr);
$api_response = list($response,$statusCode,$httpHeader)=null;
$requestArr = json_decode($paymentRequest);
$requestBody = $apiclient->dataMasking(json_encode($requestArr, JSON_UNESCAPED_SLASHES));
echo "The Api Request Body: \n". $requestBody."\n\n";
$api_response = list($response,$statusCode,$httpHeader)=null;
try {
//Calling the Api
$api_response = $api_instance->createPayment($paymentRequest);

if($flag =="true" || $flag =="notallow"){
//Returning the ID
echo "Fetching Payment ID: ".$api_response[0]['id']."\n";
return $api_response[0]['id'];
}
else {
print_r($api_response);
echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
$resBodyArr= json_decode($api_response[0]);
echo "The Api Response Body: \n". json_encode($resBodyArr, JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Api Response StatusCode: ".json_encode($api_response[1])."\n\n";
echo "The Api Response Header: \n".json_encode($api_response[2], JSON_UNESCAPED_SLASHES)."\n";
}

} catch (Cybersource\ApiException $e) {
print_r($e->getResponseBody());
print_r($e->getMessage());
echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Exception Response Body: \n";
print_r($e->getResponseBody()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getResponseHeaders()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getMessage());echo "\n\n";
}
}


// Call Sample Code
if(!defined('DO_NOT_RUN_SAMPLES')){
echo "Process payment Samplecode is Running.. \n";
echo "[BEGIN] EXECUTION OF SAMPLE CODE: ProcessPayment\n\n";
ProcessPayment("false");

}
Expand Down
22 changes: 17 additions & 5 deletions Samples/Payments/CoreServices/RefundCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,32 @@ function RefundCapture()
];

$paymentRequest = new CyberSource\Model\RefundCaptureRequest($paymentRequestArr);
$api_response = list($response,$statusCode,$httpHeader)=null;
$requestArr = json_decode($paymentRequest);
$requestBody = $apiclient->dataMasking(json_encode($requestArr, JSON_UNESCAPED_SLASHES));
echo "The Api Request Body: \n". $requestBody."\n\n";
$api_response = list($response,$statusCode,$httpHeader)=null;
try {
$api_response = $api_instance->refundCapture($paymentRequest, $id);
echo "<pre>";print_r($api_response);
echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
$resBodyArr= json_decode($api_response[0]);
echo "The Api Response Body: \n". json_encode($resBodyArr, JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Api Response StatusCode: ".json_encode($api_response[1])."\n\n";
echo "The Api Response Header: \n".json_encode($api_response[2], JSON_UNESCAPED_SLASHES)."\n";

} catch (Cybersource\ApiException $e) {
print_r($e->getResponseBody());
print_r($e->getMessage());
echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Exception Response Body: \n";
print_r($e->getResponseBody()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getResponseHeaders()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getMessage());echo "\n\n";
}
}

// Call Sample Code
if(!defined('DO_NOT_RUN_SAMPLES')){
echo "RefundCapture Samplecode is Running.. \n";
echo "[BEGIN] EXECUTION OF SAMPLE CODE: RefundCapture\n\n";
RefundCapture();

}
Expand Down
23 changes: 17 additions & 6 deletions Samples/Payments/CoreServices/RefundPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ function RefundPayment($flag)
];

$paymentRequest = new CyberSource\Model\RefundPaymentRequest($paymentRequestArr);

$api_response = list($response,$statusCode,$httpHeader)=null;
$requestArr = json_decode($paymentRequest);
$requestBody = $apiclient->dataMasking(json_encode($requestArr, JSON_UNESCAPED_SLASHES));
echo "The Api Request Body: \n". $requestBody."\n\n";
$api_response = list($response,$statusCode,$httpHeader)=null;
try {
$api_response = $api_instance->refundPayment($paymentRequest, $id);
if($flag ==true){
Expand All @@ -41,18 +43,27 @@ function RefundPayment($flag)
return $api_response[0]['id'];
}
else {
print_r($api_response);
echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
$resBodyArr= json_decode($api_response[0]);
echo "The Api Response Body: \n". json_encode($resBodyArr, JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Api Response StatusCode: ".json_encode($api_response[1])."\n\n";
echo "The Api Response Header: \n".json_encode($api_response[2], JSON_UNESCAPED_SLASHES)."\n";
}

} catch (Cybersource\ApiException $e) {
print_r($e->getResponseBody());
print_r($e->getMessage());
echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Exception Response Body: \n";
print_r($e->getResponseBody()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getResponseHeaders()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getMessage());echo "\n\n";
}
}

// Call Sample Code
if(!defined('DO_NOT_RUN_SAMPLES')){
echo "Refund Payment Samplecode is Running.. \n";
echo "[BEGIN] EXECUTION OF SAMPLE CODE: RefundPayment\n\n";
RefundPayment(false);

}
Expand Down
Loading