diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03f733ce..864e7ce3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,13 @@
## Latest version
#### Enhancements:
+- GP-ECOM: Add HPP capture billing/shipping address
+- Add intl and mbstring extensions on composer
+- GP-API: Refacto reporting for disputes / search stored payment methods / LodgingData
+
+## v3.1.0 (05/05/2022)
+#### Enhancements:
+
- GP-ECOM: Add bank payment (open banking) service
- GP-API: Update usage mode, cardholder name and card number on a stored payment method
- Portico: Updated code for Secure3D and WalletData Element
diff --git a/composer.json b/composer.json
index 2d24e427..bca0dd9f 100644
--- a/composer.json
+++ b/composer.json
@@ -16,7 +16,9 @@
"ext-dom": "*",
"ext-openssl": "*",
"ext-json": "*",
- "ext-zlib": "*"
+ "ext-zlib": "*",
+ "ext-intl": "*",
+ "ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "~5.0",
diff --git a/examples/hpp/example.html b/examples/hpp/example.html
index 100ccb96..22e174d7 100644
--- a/examples/hpp/example.html
+++ b/examples/hpp/example.html
@@ -1,20 +1,38 @@
-
+
+
\ No newline at end of file
diff --git a/examples/hpp/get-json.php b/examples/hpp/get-json.php
index 21ef9e53..f2ea8797 100644
--- a/examples/hpp/get-json.php
+++ b/examples/hpp/get-json.php
@@ -12,6 +12,7 @@
use GlobalPayments\Api\Entities\Exceptions\ApiException;
use GlobalPayments\Api\Services\HostedService;
+
// configure client, request and HPP settings
$config = new GpEcomConfig();
$config->merchantId = "openbankingsandbox";
@@ -21,6 +22,7 @@
$config->enableBankPayment = true;
$config->hostedPaymentConfig = new HostedPaymentConfig();
$config->hostedPaymentConfig->version = HppVersion::VERSION_2;
+
$service = new HostedService($config);
// Add 3D Secure 2 Mandatory and Recommended Fields
@@ -28,6 +30,12 @@
$hostedPaymentData->customerEmail = "james.mason@example.com";
$hostedPaymentData->customerPhoneMobile = "44|07123456789";
$hostedPaymentData->addressesMatch = false;
+if (isset($_REQUEST['captureAddress'])) {
+ $hostedPaymentData->addressCapture = filter_var($_REQUEST['captureAddress'], FILTER_VALIDATE_BOOLEAN);
+}
+if (isset($_REQUEST['notReturnAddress'])) {
+ $hostedPaymentData->notReturnAddress = filter_var($_REQUEST['notReturnAddress'], FILTER_VALIDATE_BOOLEAN);
+}
$hostedPaymentData->customerCountry = 'GB';
$hostedPaymentData->customerFirstName = 'James';
@@ -58,13 +66,14 @@
$bankPayment->sortCode = '406650';
$bankPayment->accountName = 'AccountName';
+$hostedPaymentData->bankPayment = $bankPayment;
+
try {
$hppJson = $service->charge(19.99)
->withCurrency("GBP")
->withHostedPaymentData($hostedPaymentData)
->withAddress($billingAddress, AddressType::BILLING)
->withAddress($shippingAddress, AddressType::SHIPPING)
- ->withPaymentMethod($bankPayment)
->withRemittanceReference(RemittanceReferenceType::TEXT, 'Nike Bounce Shoes')
->serialize();
//with this, we can pass our json to the client side
diff --git a/metadata.xml b/metadata.xml
index 72c2c822..0f73eb45 100644
--- a/metadata.xml
+++ b/metadata.xml
@@ -1,3 +1,3 @@
- 3.1.0
+ 3.1.1
\ No newline at end of file
diff --git a/src/Builders/ManagementBuilder.php b/src/Builders/ManagementBuilder.php
index f46d2877..ec06f0dc 100644
--- a/src/Builders/ManagementBuilder.php
+++ b/src/Builders/ManagementBuilder.php
@@ -8,7 +8,7 @@
use GlobalPayments\Api\Entities\Enums\TaxType;
use GlobalPayments\Api\Entities\Enums\TransactionModifier;
use GlobalPayments\Api\Entities\Enums\TransactionType;
-use GlobalPayments\Api\Entities\Lodging;
+use GlobalPayments\Api\Entities\LodgingData;
use GlobalPayments\Api\Entities\Transaction;
use GlobalPayments\Api\PaymentMethods\CreditCardData;
use GlobalPayments\Api\PaymentMethods\ECheck;
@@ -187,8 +187,8 @@ class ManagementBuilder extends TransactionBuilder
/** @var DccRateData */
public $dccRateData;
- /** @var Lodging */
- public $lodging;
+ /** @var LodgingData */
+ public $lodgingData;
/** @var string */
public $tagData;
@@ -617,13 +617,13 @@ public function withPaymentMethodUsageMode($value)
/**
* Set the lodging details
*
- * @param Lodging $lodging
+ * @param LodgingData $lodging
*
* @return $this
*/
- public function withLodging($lodging)
+ public function withLodgingData($lodgingData)
{
- $this->lodging = $lodging;
+ $this->lodgingData = $lodgingData;
return $this;
}
diff --git a/src/Builders/TransactionReportBuilder.php b/src/Builders/TransactionReportBuilder.php
index 2512056a..15b0b453 100644
--- a/src/Builders/TransactionReportBuilder.php
+++ b/src/Builders/TransactionReportBuilder.php
@@ -7,6 +7,7 @@
use GlobalPayments\Api\Entities\Enums\DisputeSortProperty;
use GlobalPayments\Api\Entities\Enums\SortDirection;
use GlobalPayments\Api\Entities\Enums\StoredPaymentMethodSortProperty;
+use GlobalPayments\Api\Entities\Enums\TransactionModifier;
use GlobalPayments\Api\Entities\Enums\TransactionSortProperty;
use GlobalPayments\Api\Entities\Enums\ReportType;
use GlobalPayments\Api\Entities\Enums\TimeZoneConversion;
@@ -96,6 +97,8 @@ class TransactionReportBuilder extends ReportBuilder
*/
public $reportType;
+ public $transactionModifier = TransactionModifier::NONE;
+
/**
* @internal
* @var TimeZoneConversion
@@ -106,6 +109,7 @@ public function __construct($activity)
{
parent::__construct($activity);
+ $this->transactionType = $activity;
$this->searchBuilder = new SearchCriteriaBuilder($this);
}
@@ -311,5 +315,8 @@ protected function setupValidations()
$this->validations->of(ReportType::ACTIVITY)
->check('transactionId')->isNull();
+
+ $this->validations->of(ReportType::DOCUMENT_DISPUTE_DETAIL)
+ ->check('disputeDocumentId')->isNotNullInSubProperty('searchBuilder');
}
}
diff --git a/src/Entities/Enums/ReportType.php b/src/Entities/Enums/ReportType.php
index 3ed32645..b04b0af6 100644
--- a/src/Entities/Enums/ReportType.php
+++ b/src/Entities/Enums/ReportType.php
@@ -8,6 +8,8 @@ class ReportType extends Enum
{
const FIND_TRANSACTIONS = 1;
const ACTIVITY = 2; // 1 << 1;
+ const FIND_BANK_PAYMENT = 4; // 1 << 2
+ const DOCUMENT_DISPUTE_DETAIL = 8; // 1 << 3
const TRANSACTION_DETAIL = 128; // 1 << 7;
const FIND_DEPOSITS = 256; //1 << 8
const FIND_DISPUTES = 512; // 1 << 9
@@ -25,5 +27,4 @@ class ReportType extends Enum
const STORED_PAYMENT_METHOD_DETAIL = 2097152; // 1 << 21
const FIND_ACTIONS_PAGED = 4194304; // 1 << 22
const ACTION_DETAIL = 8388608; // 1 << 23
- const FIND_BANK_PAYMENT = 4; // 1 << 2
}
diff --git a/src/Entities/Enums/ServiceEndpoints.php b/src/Entities/Enums/ServiceEndpoints.php
index 6cb2385f..4b8a6905 100644
--- a/src/Entities/Enums/ServiceEndpoints.php
+++ b/src/Entities/Enums/ServiceEndpoints.php
@@ -27,5 +27,5 @@ class ServiceEndpoints extends Enum
const GP_API_TEST = "https://apis.sandbox.globalpay.com/ucp";
const GP_API_PRODUCTION = "https://apis.globalpay.com/ucp";
const OPEN_BANKING_TEST = 'https://beta.sandbox.globalpay-ecommerce.com/openbanking';
- const OPEN_BANKING_PRODUCTION = '';
+ const OPEN_BANKING_PRODUCTION = 'https://beta.globalpay-ecommerce.com/openbanking';
}
diff --git a/src/Entities/GpApi/GpApiManagementRequestBuilder.php b/src/Entities/GpApi/GpApiManagementRequestBuilder.php
index 90ac06ca..bea19622 100644
--- a/src/Entities/GpApi/GpApiManagementRequestBuilder.php
+++ b/src/Entities/GpApi/GpApiManagementRequestBuilder.php
@@ -10,7 +10,7 @@
use GlobalPayments\Api\Entities\Enums\TransactionType;
use GlobalPayments\Api\Entities\GpApi\DTO\Card;
use GlobalPayments\Api\Entities\IRequestBuilder;
-use GlobalPayments\Api\Entities\Lodging;
+use GlobalPayments\Api\Entities\LodgingData;
use GlobalPayments\Api\Entities\LodgingItems;
use GlobalPayments\Api\Mapping\EnumMapping;
use GlobalPayments\Api\PaymentMethods\CreditCardData;
@@ -148,9 +148,9 @@ public function buildRequest(BaseBuilder $builder, $config)
$endpoint = GpApiRequest::TRANSACTION_ENDPOINT . '/' . $builder->paymentMethod->transactionId . '/incremental';
$verb = 'POST';
$payload['amount'] = StringUtils::toNumeric($builder->amount);
- if (!empty($builder->lodging)) {
- /** @var Lodging $lodging */
- $lodging = $builder->lodging;
+ if (!empty($builder->lodgingData)) {
+ /** @var LodgingData $lodging */
+ $lodging = $builder->lodgingData;
if (!empty($lodging->items)) {
$lodgingItems = [];
/** @var LodgingItems $item */
@@ -167,10 +167,10 @@ public function buildRequest(BaseBuilder $builder, $config)
$payload['lodging'] = [
'booking_reference' => $lodging->bookingReference,
'duration_days' => $lodging->durationDays,
- 'date_checked_in' => !empty($lodging->dateCheckedIn) ?
- (new \DateTime($lodging->dateCheckedIn))->format('Y-m-d') : null,
- 'date_checked_out' => !empty($lodging->dateCheckedOut) ?
- (new \DateTime($lodging->dateCheckedOut))->format('Y-m-d') : null,
+ 'date_checked_in' => !empty($lodging->checkedInDate) ?
+ (new \DateTime($lodging->checkedInDate))->format('Y-m-d') : null,
+ 'date_checked_out' => !empty($lodging->checkedOutDate) ?
+ (new \DateTime($lodging->checkedOutDate))->format('Y-m-d') : null,
'daily_rate_amount' => !empty($lodging->dailyRateAmount) ?
StringUtils::toNumeric($lodging->dailyRateAmount) : null,
'lodging.charge_items' => !empty($lodgingItems) ? $lodgingItems : null
diff --git a/src/Entities/GpApi/GpApiReportRequestBuilder.php b/src/Entities/GpApi/GpApiReportRequestBuilder.php
index cfb0ad13..f446d0fe 100644
--- a/src/Entities/GpApi/GpApiReportRequestBuilder.php
+++ b/src/Entities/GpApi/GpApiReportRequestBuilder.php
@@ -77,7 +77,7 @@ public function buildRequest(BaseBuilder $builder, $config)
$queryParams['batch_id'] = $builder->searchBuilder->batchId;
$queryParams['entry_mode'] = $builder->searchBuilder->paymentEntryMode;
$queryParams['name'] = $builder->searchBuilder->name;
- $queryParams['payment_method'] = $builder->searchBuilder->paymentMethod;
+ $queryParams['payment_method'] = $builder->searchBuilder->paymentMethodName;
$queryParams = array_merge($queryParams, $this->getTransactionParams($builder));
break;
case ReportType::FIND_SETTLEMENT_TRANSACTIONS_PAGED:
@@ -103,9 +103,11 @@ public function buildRequest(BaseBuilder $builder, $config)
case ReportType::DISPUTE_DETAIL:
$endpoint = GpApiRequest::DISPUTES_ENDPOINT . '/' . $builder->searchBuilder->disputeId;
$verb = 'GET';
- if ($builder->searchBuilder->disputeDocumentId) {
- $endpoint .= '/documents/' . $builder->searchBuilder->disputeDocumentId;
- }
+ break;
+ case ReportType::DOCUMENT_DISPUTE_DETAIL:
+ $endpoint = GpApiRequest::DISPUTES_ENDPOINT . '/' . $builder->searchBuilder->disputeId . '/documents/' .
+ $builder->searchBuilder->disputeDocumentId;
+ $verb = 'GET';
break;
case ReportType::FIND_DISPUTES_PAGED:
$endpoint = GpApiRequest::DISPUTES_ENDPOINT;
diff --git a/src/Entities/HostedPaymentData.php b/src/Entities/HostedPaymentData.php
index 97ef9808..074dc4de 100644
--- a/src/Entities/HostedPaymentData.php
+++ b/src/Entities/HostedPaymentData.php
@@ -3,6 +3,7 @@
namespace GlobalPayments\Api\Entities;
use GlobalPayments\Api\Entities\Enums\AlternativePaymentType;
+use GlobalPayments\Api\PaymentMethods\BankPayment;
/**
* Data collection to supplement a hosted payment page.
@@ -18,6 +19,20 @@ class HostedPaymentData
*/
public $addressesMatch;
+ /**
+ * Determines whether the address forms will be displayed on the HPP
+ *
+ * @var boolean
+ */
+ public $addressCapture;
+
+ /**
+ * Determines whether or not the HPP response will contain the address and contact information.
+ *
+ * @var boolean
+ */
+ public $notReturnAddress;
+
/**
* Determines the challenge request preference for 3DS 2.0.
*
@@ -107,6 +122,9 @@ class HostedPaymentData
/** @var array */
public $presetPaymentMethods = [];
+ /** @var BankPayment */
+ public $bankPayment;
+
/**
* Instantiates a new `HostedPaymentData` object.
*
diff --git a/src/Entities/Lodging.php b/src/Entities/Lodging.php
deleted file mode 100644
index 3465cea5..00000000
--- a/src/Entities/Lodging.php
+++ /dev/null
@@ -1,24 +0,0 @@
- */
- public $items;
-}
\ No newline at end of file
diff --git a/src/Entities/LodgingData.php b/src/Entities/LodgingData.php
new file mode 100644
index 00000000..1791f11c
--- /dev/null
+++ b/src/Entities/LodgingData.php
@@ -0,0 +1,48 @@
+ */
+ public $items;
+}
diff --git a/src/Entities/Reporting/LodgingData.php b/src/Entities/Reporting/LodgingData.php
deleted file mode 100644
index 1fc5ccb6..00000000
--- a/src/Entities/Reporting/LodgingData.php
+++ /dev/null
@@ -1,30 +0,0 @@
-transactionType == TransactionType::SALE) ? "1" : "0"
);
- if ($builder->paymentMethod instanceof BankPayment) {
+ if (
+ !empty($builder->hostedPaymentData->bankPayment) &&
+ $builder->hostedPaymentData->bankPayment instanceof BankPayment
+ ) {
$this->buildOpenBankingHppRequest($builder);
- $toHash = implode('.', [
- $timestamp,
- $this->merchantId,
- $orderId,
- $amount,
- $builder->currency,
- !empty($builder->paymentMethod->sortCode) ? $builder->paymentMethod->sortCode : '',
- !empty($builder->paymentMethod->accountNumber) ? $builder->paymentMethod->accountNumber : '',
- !empty($builder->paymentMethod->iban) ? $builder->paymentMethod->iban : '',
- ]);
- list($tagHashName, $tagHashValue) = $this->mapShaHash($toHash);
- $this->setSerializeData($tagHashName, $tagHashValue);
-
- return GenerationUtils::convertArrayToJson($this->serializeData, $this->hostedPaymentConfig->version);
}
-
$this->setSerializeData('COMMENT1', $builder->description);
if (isset($this->hostedPaymentConfig->requestTransactionStabilityScore)) {
@@ -637,6 +625,12 @@ public function serializeRequest(AuthorizationBuilder $builder)
if (!empty($hostedPaymentData->customerLastName)) {
$this->setSerializeData('HPP_CUSTOMER_LASTNAME', $hostedPaymentData->customerLastName);
}
+ if (!empty($hostedPaymentData->customerFirstName) && !empty($hostedPaymentData->customerLastName)) {
+ $this->setSerializeData(
+ 'HPP_NAME',
+ $hostedPaymentData->customerFirstName . ' ' . $hostedPaymentData->customerLastName
+ );
+ }
if (!empty($hostedPaymentData->merchantResponseUrl)) {
$this->setSerializeData('MERCHANT_RESPONSE_URL', $hostedPaymentData->merchantResponseUrl);
}
@@ -687,20 +681,29 @@ public function serializeRequest(AuthorizationBuilder $builder)
CountryUtils::getNumericCodeByCountry($builder->billingAddress->country)
);
}
-
+
$this->setSerializeData('VAR_REF', $builder->clientTransactionId);
$this->setSerializeData('HPP_LANG', $this->hostedPaymentConfig->language);
$this->setSerializeData('MERCHANT_RESPONSE_URL', $this->hostedPaymentConfig->responseUrl);
$this->setSerializeData('CARD_PAYMENT_BUTTON', $this->hostedPaymentConfig->paymentButtonText);
if (!empty($builder->hostedPaymentData)) {
- $this->setSerializeData('HPP_CUSTOMER_EMAIL', $builder->hostedPaymentData->customerEmail);
- $this->setSerializeData('HPP_CUSTOMER_PHONENUMBER_MOBILE', $builder->hostedPaymentData->customerPhoneMobile);
- $this->setSerializeData('HPP_CHALLENGE_REQUEST_INDICATOR', $builder->hostedPaymentData->challengeRequest);
- if (isset($builder->hostedPaymentData->addressesMatch)) {
- $this->setSerializeData('HPP_ADDRESS_MATCH_INDICATOR', $builder->hostedPaymentData->addressesMatch ? 'TRUE' : 'FALSE');
+ $hostedPaymentData = $builder->hostedPaymentData;
+ $this->setSerializeData('HPP_CUSTOMER_EMAIL', $hostedPaymentData->customerEmail);
+ $this->setSerializeData('HPP_CUSTOMER_PHONENUMBER_MOBILE', $hostedPaymentData->customerPhoneMobile);
+ $this->setSerializeData('HPP_PHONE', $hostedPaymentData->customerPhoneMobile);
+ $this->setSerializeData('HPP_CHALLENGE_REQUEST_INDICATOR', $hostedPaymentData->challengeRequest);
+ if (isset($hostedPaymentData->addressesMatch)) {
+ $this->setSerializeData('HPP_ADDRESS_MATCH_INDICATOR', $hostedPaymentData->addressesMatch ? 'TRUE' : 'FALSE');
+ }
+ if (!empty($hostedPaymentData->supplementaryData)) {
+ $this->serializeSupplementaryData($hostedPaymentData->supplementaryData);
+ }
+
+ if (isset($hostedPaymentData->addressCapture)) {
+ $this->setSerializeData('HPP_CAPTURE_ADDRESS', $hostedPaymentData->addressCapture == true);
}
- if (!empty($builder->hostedPaymentData->supplementaryData)) {
- $this->serializeSupplementaryData($builder->hostedPaymentData->supplementaryData);
+ if (isset($hostedPaymentData->notReturnAddress)) {
+ $this->setSerializeData('HPP_DO_NOT_RETURN_ADDRESS', $hostedPaymentData->notReturnAddress == true);
}
}
if (isset($this->hostedPaymentConfig->cardStorageEnabled)) {
@@ -769,11 +772,24 @@ public function serializeRequest(AuthorizationBuilder $builder)
$toHash[] = $this->hostedPaymentConfig->fraudFilterMode;
}
+ if (
+ !empty($builder->hostedPaymentData->bankPayment) &&
+ $builder->hostedPaymentData->bankPayment instanceof BankPayment
+ ) {
+ $bankPayment = $builder->hostedPaymentData->bankPayment;
+ $toHash = array_merge($toHash, [
+ !empty($bankPayment->sortCode) ? $bankPayment->sortCode : '',
+ !empty($bankPayment->accountNumber) ? $bankPayment->accountNumber : '',
+ !empty($bankPayment->iban) ? $bankPayment->iban : ''
+ ]);
+ }
+
if (!empty($builder->dynamicDescriptor)) {
$this->serializeData["CHARGE_DESCRIPTION"] = $builder->dynamicDescriptor;
}
- $this->serializeData["SHA1HASH"] = GenerationUtils::generateHash($this->sharedSecret, implode('.', $toHash));
+ list($tagHashName, $tagHashValue) = $this->mapShaHash(implode('.', $toHash));
+ $this->setSerializeData($tagHashName, $tagHashValue);
return GenerationUtils::convertArrayToJson($this->serializeData, $this->hostedPaymentConfig->version);
}
@@ -795,7 +811,7 @@ private function mapShaHash($toHash)
*/
private function buildOpenBankingHppRequest($builder)
{
- $paymentMethod = $builder->paymentMethod;
+ $paymentMethod = $builder->hostedPaymentData->bankPayment;
$this->setSerializeData(
'HPP_OB_PAYMENT_SCHEME',
!empty($paymentMethod->bankPaymentType) ?
@@ -809,16 +825,6 @@ private function buildOpenBankingHppRequest($builder)
$this->setSerializeData('HPP_OB_DST_ACCOUNT_SORT_CODE', $paymentMethod->sortCode);
if (!empty($builder->hostedPaymentData)) {
$hostedPaymentData = $builder->hostedPaymentData;
- if (!empty($hostedPaymentData->transactionStatusUrl)) {
- $this->setSerializeData('HPP_TX_STATUS_URL', $hostedPaymentData->transactionStatusUrl);
- }
- if (!empty($hostedPaymentData->merchantResponseUrl)) {
- $this->setSerializeData('MERCHANT_RESPONSE_URL', $hostedPaymentData->merchantResponseUrl);
- }
- if (!empty($hostedPaymentData->presetPaymentMethods)) {
- $this->setSerializeData('PM_METHODS', implode( '|', $hostedPaymentData->presetPaymentMethods));
- }
-
$this->setSerializeData('HPP_OB_CUSTOMER_COUNTRIES', $hostedPaymentData->customerCountry);
}
}
diff --git a/src/Mapping/GpApiMapping.php b/src/Mapping/GpApiMapping.php
index dab5c666..c96dc20d 100644
--- a/src/Mapping/GpApiMapping.php
+++ b/src/Mapping/GpApiMapping.php
@@ -175,15 +175,12 @@ public static function mapReportResponse($response, $reportType)
array_push($report->result, self::mapDepositSummary($deposit));
}
break;
- case ReportType::DISPUTE_DETAIL:
- if ($response->action->type == 'DOCUMENT_SINGLE'){
- $report = new DisputeDocument();
- $report->id = $response->id;
- $report->b64_content = $response->b64_content;
- } else {
- $report = self::mapDisputeSummary($response);
- }
+ case ReportType::DOCUMENT_DISPUTE_DETAIL:
+ $report = new DisputeDocument();
+ $report->id = $response->id;
+ $report->b64_content = $response->b64_content;
break;
+ case ReportType::DISPUTE_DETAIL:
case ReportType::SETTLEMENT_DISPUTE_DETAIL:
$report = self::mapDisputeSummary($response);
break;
diff --git a/src/Services/ReportingService.php b/src/Services/ReportingService.php
index 42b2c944..36c4370e 100644
--- a/src/Services/ReportingService.php
+++ b/src/Services/ReportingService.php
@@ -120,6 +120,12 @@ public static function actionDetail($actionId)
->withActionId($actionId);
}
+ public static function documentDisputeDetail($disputeId)
+ {
+ return (new TransactionReportBuilder(ReportType::DOCUMENT_DISPUTE_DETAIL))
+ ->withDisputeId($disputeId);
+ }
+
public static function bankPaymentDetail($id)
{
return (new TransactionReportBuilder(ReportType::FIND_BANK_PAYMENT))
diff --git a/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.php b/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.php
index 484237c7..d20f44a2 100644
--- a/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.php
+++ b/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.php
@@ -13,7 +13,7 @@
use GlobalPayments\Api\Entities\Enums\TransactionSortProperty;
use GlobalPayments\Api\Entities\Enums\TransactionStatus;
use GlobalPayments\Api\Entities\Exceptions\GatewayException;
-use GlobalPayments\Api\Entities\Lodging;
+use GlobalPayments\Api\Entities\LodgingData;
use GlobalPayments\Api\Entities\LodgingItems;
use GlobalPayments\Api\Entities\Reporting\SearchCriteria;
use GlobalPayments\Api\Entities\Reporting\TransactionSummary;
@@ -609,11 +609,11 @@ public function testIncrementalAuth()
$this->assertEquals('SUCCESS', $transaction->responseCode);
$this->assertEquals(TransactionStatus::PREAUTHORIZED, $transaction->responseMessage);
- $lodgingInfo = new Lodging();
+ $lodgingInfo = new LodgingData();
$lodgingInfo->bookingReference = 's9RpaDwXq1sPRkbP';
$lodgingInfo->durationDays = 10;
- $lodgingInfo->dateCheckedIn = date('Y-m-d H:i:s');
- $lodgingInfo->dateCheckedOut = date('Y-m-d H:i:s', strtotime("+7 days"));
+ $lodgingInfo->checkedInDate = date('Y-m-d H:i:s');
+ $lodgingInfo->checkedOutDate = date('Y-m-d H:i:s', strtotime("+7 days"));
$lodgingInfo->dailyRateAmount = '13.49';
$item1 = new LodgingItems();
$item1->types = [LodgingItemType::NO_SHOW];
@@ -624,7 +624,7 @@ public function testIncrementalAuth()
$transaction = $transaction->additionalAuth(10)
->withCurrency($this->currency)
- ->withLodging($lodgingInfo)
+ ->withLodgingData($lodgingInfo)
->execute();
$this->assertNotNull($transaction);
diff --git a/test/Integration/Gateways/GpApiConnector/DccCardNotPresentTest.php b/test/Integration/Gateways/GpApiConnector/DccCardNotPresentTest.php
index 815db6f3..acdde82a 100644
--- a/test/Integration/Gateways/GpApiConnector/DccCardNotPresentTest.php
+++ b/test/Integration/Gateways/GpApiConnector/DccCardNotPresentTest.php
@@ -331,7 +331,9 @@ private function assertTransactionResponse($transaction, $transactionStatus, $ex
$this->assertNotNull($transaction);
$this->assertEquals('SUCCESS', $transaction->responseCode);
$this->assertEquals($transactionStatus, $transaction->responseMessage);
- $this->assertEquals($expectedDccValue, $transaction->dccRateData->cardHolderAmount);
+ if ($transactionStatus !== TransactionStatus::REVERSED) {
+ $this->assertEquals($expectedDccValue, $transaction->dccRateData->cardHolderAmount);
+ }
}
private function getAmount($dccDetails)
diff --git a/test/Integration/Gateways/GpApiConnector/GpApiAchTest.php b/test/Integration/Gateways/GpApiConnector/GpApiAchTest.php
index 027e0698..8dd70fc9 100644
--- a/test/Integration/Gateways/GpApiConnector/GpApiAchTest.php
+++ b/test/Integration/Gateways/GpApiConnector/GpApiAchTest.php
@@ -123,13 +123,14 @@ public function testCheckRefundExistingSale()
->orderBy(TransactionSortProperty::TIME_CREATED, SortDirection::DESC)
->where(SearchCriteria::START_DATE, $startDate)
->andWith(SearchCriteria::END_DATE, $endDate)
- ->andWith(SearchCriteria::PAYMENT_METHOD, PaymentMethodName::BANK_TRANSFER)
+ ->andWith(SearchCriteria::PAYMENT_METHOD_NAME, PaymentMethodName::BANK_TRANSFER)
->andWith(SearchCriteria::PAYMENT_TYPE, PaymentType::SALE)
->andWith(DataServiceCriteria::AMOUNT, 11)
->execute();
} catch (ApiException $e) {
$this->fail('Find transactions by type failed: ' . $e->getMessage());
}
+
$this->assertNotNull($response);
$this->assertNotEmpty($response->result);
$transactionSummary = reset($response->result);
@@ -157,7 +158,7 @@ public function testCheckReauthorize()
->orderBy(TransactionSortProperty::TIME_CREATED, SortDirection::DESC)
->where(SearchCriteria::START_DATE, $startDate)
->andWith(SearchCriteria::END_DATE, $endDate)
- ->andWith(SearchCriteria::PAYMENT_METHOD, PaymentMethodName::BANK_TRANSFER)
+ ->andWith(SearchCriteria::PAYMENT_METHOD_NAME, PaymentMethodName::BANK_TRANSFER)
->andWith(SearchCriteria::PAYMENT_TYPE, PaymentType::SALE)
->andWith(DataServiceCriteria::AMOUNT, $amount)
->execute();
diff --git a/test/Integration/Gateways/GpApiConnector/ReportingDisputesTest.php b/test/Integration/Gateways/GpApiConnector/ReportingDisputesTest.php
index 1c178d0d..133d8c00 100644
--- a/test/Integration/Gateways/GpApiConnector/ReportingDisputesTest.php
+++ b/test/Integration/Gateways/GpApiConnector/ReportingDisputesTest.php
@@ -17,9 +17,10 @@
use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig;
use GlobalPayments\Api\Services\ReportingService;
use GlobalPayments\Api\ServicesContainer;
-use PHPUnit\Framework\TestCase;
+use GlobalPayments\Api\Utils\GenerationUtils;
use GlobalPayments\Api\Utils\Logging\Logger;
use GlobalPayments\Api\Utils\Logging\SampleRequestLogger;
+use PHPUnit\Framework\TestCase;
class ReportingDisputesTest extends TestCase
{
@@ -40,11 +41,13 @@ public function setUpConfig()
$config->appId = 'oDVjAddrXt3qPJVPqQvrmgqM2MjMoHQS';
$config->appKey = 'DHUGdzpjXfTbjZeo';
$config->environment = Environment::TEST;
-// $config->requestLogger = new SampleRequestLogger(new Logger("logs"));
+ $config->requestLogger = new SampleRequestLogger(new Logger("logs"));
return $config;
}
+ #region Report Disputes
+
public function testReportDisputeDetail()
{
$disputeId = 'DIS_SAND_abcd1234';
@@ -332,11 +335,15 @@ public function testReportFindDisputes_Order_By_Id_With_Stage_Chargeback()
}
}
+ #endregion
+
+ #region Get a Document associated with a Dispute
+
public function testFindDocumentAssociatedWithDispute()
{
$disputeId = 'DIS_SAND_abcd1235';
$documentId = 'DOC_MyEvidence_234234AVCDE-1';
- $response = ReportingService::disputeDetail($disputeId)
+ $response = ReportingService::documentDisputeDetail($disputeId)
->where(SearchCriteria::DISPUTE_DOCUMENT_ID, $documentId)
->execute();
@@ -346,6 +353,47 @@ public function testFindDocumentAssociatedWithDispute()
$this->assertNotEmpty($response->b64_content);
}
+ public function testFindDocumentAssociatedWithDispute_RandomDisputeId()
+ {
+ $disputeId = GenerationUtils::getGuid();
+ $documentId = 'DOC_MyEvidence_234234AVCDE-1';
+
+ $exceptionCaught = false;
+ try {
+ ReportingService::documentDisputeDetail($disputeId)
+ ->where(SearchCriteria::DISPUTE_DOCUMENT_ID, $documentId)
+ ->execute();
+ } catch (GatewayException $e) {
+ $exceptionCaught = true;
+ $this->assertEquals('40073', $e->responseCode);
+ $this->assertEquals('Status Code: INVALID_REQUEST_DATA - 101,Unable to locate dispute record for that ID. Please recheck the ID provided.', $e->getMessage());
+ } finally {
+ $this->assertTrue($exceptionCaught);
+ }
+ }
+
+ public function testFindDocumentAssociatedWithDispute_RandomDocumentId()
+ {
+ $disputeId = "DIS_SAND_abcd1235";
+ $documentId = GenerationUtils::getGuid();
+
+ $exceptionCaught = false;
+ try {
+ ReportingService::documentDisputeDetail($disputeId)
+ ->where(SearchCriteria::DISPUTE_DOCUMENT_ID, $documentId)
+ ->execute();
+ } catch (GatewayException $e) {
+ $exceptionCaught = true;
+ $this->assertEquals('40071', $e->responseCode);
+ $this->assertEquals('Status Code: MANDATORY_DATA_MISSING - 128,No document found, please recheck the values provided', $e->getMessage());
+ } finally {
+ $this->assertTrue($exceptionCaught);
+ }
+ }
+
+ #endregion
+
+ #region Settlement disputes
/***************************************
* Settlement disputes *
***************************************/
@@ -619,6 +667,10 @@ public function testReportFindSettlementDisputes_FilterBy_WrongSystemHierarchy()
$this->assertTrue(count($summary->result) == 0);
}
+ #endregion
+
+ #region Accept and Challenge Dispute
+
public function testReportDisputeAcceptance()
{
$disputeId = "DIS_SAND_abcd1234";
@@ -761,6 +813,8 @@ public function testReportDisputeChallengeWrongId()
}
}
+ #endregion
+
public function testFindSettlementDisputesPaged_FilterBy_DepositId()
{
$depositReference = 'DEP_2342423443';
diff --git a/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.php b/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.php
index 66b3c581..b2c61f39 100644
--- a/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.php
+++ b/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.php
@@ -517,7 +517,7 @@ public function testReportFindTransactionsBy_TokenFirst6_and_TokenLast4_and_Paym
->orderBy(TransactionSortProperty::TIME_CREATED)
->where(SearchCriteria::TOKEN_FIRST_SIX, $tokenFirst6)
->andWith(SearchCriteria::TOKEN_LAST_FOUR, $tokenLast4)
- ->andWith(SearchCriteria::PAYMENT_METHOD, PaymentMethodName::DIGITAL_WALLET)
+ ->andWith(SearchCriteria::PAYMENT_METHOD_NAME, PaymentMethodName::DIGITAL_WALLET)
->andWith(SearchCriteria::START_DATE, $startDate)
->execute();
} catch (ApiException $e) {
@@ -542,7 +542,7 @@ public function testReportFindTransactionsBy_TokenFirst6_and_TokenLast4_and_Wron
->orderBy(TransactionSortProperty::TIME_CREATED)
->where(SearchCriteria::TOKEN_FIRST_SIX, $tokenFirst6)
->andWith(SearchCriteria::TOKEN_LAST_FOUR, $tokenLast4)
- ->andWith(SearchCriteria::PAYMENT_METHOD, PaymentMethodName::CARD)
+ ->andWith(SearchCriteria::PAYMENT_METHOD_NAME, PaymentMethodName::CARD)
->andWith(SearchCriteria::START_DATE, $startDate)
->execute();
} catch (ApiException $e) {
@@ -673,7 +673,7 @@ public function testReportFindTransactionsByPaymentMethod()
$response = ReportingService::findTransactionsPaged(1, 10)
->orderBy(TransactionSortProperty::TIME_CREATED, SortDirection::DESC)
->where(SearchCriteria::START_DATE, $startDate)
- ->andWith(SearchCriteria::PAYMENT_METHOD, PaymentMethodName::BANK_TRANSFER)
+ ->andWith(SearchCriteria::PAYMENT_METHOD_NAME, PaymentMethodName::BANK_TRANSFER)
->execute();
} catch (ApiException $e) {
$this->fail('Find transactions by payment method failed: ' . $e->getMessage());
diff --git a/test/Integration/Gateways/RealexConnector/HppTest.php b/test/Integration/Gateways/RealexConnector/HppTest.php
index 5dafb711..854703c6 100644
--- a/test/Integration/Gateways/RealexConnector/HppTest.php
+++ b/test/Integration/Gateways/RealexConnector/HppTest.php
@@ -913,6 +913,37 @@ public function testBasicChargeAlternativePayment()
$this->assertEquals($hostedPaymentData->merchantResponseUrl, $parsedResponse->responseValues['MERCHANT_RESPONSE_URL']);
}
+ public function testCaptureBillingShippingInfo()
+ {
+ $config = new GpEcomConfig();
+ $config->merchantId = "MerchantId";
+ $config->accountId = "internet";
+ $config->refundPassword = "refund";
+ $config->sharedSecret = "secret";
+ $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay";
+ $config->hostedPaymentConfig = new HostedPaymentConfig();
+ $config->hostedPaymentConfig->language = "GB";
+ $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response";
+ $config->hostedPaymentConfig->version = HppVersion::VERSION_2;
+
+ $service = new HostedService($config);
+ $client = new RealexHppClient("secret");
+
+ $hostedPaymentData = new HostedPaymentData();
+ $hostedPaymentData->addressCapture = true;
+ $hostedPaymentData->notReturnAddress = false;
+
+ $json = $service->charge(19)
+ ->withCurrency("EUR")
+ ->withAddress($this->billingAddress, AddressType::BILLING)
+ ->withAddress($this->shippingAddress, AddressType::SHIPPING)
+ ->withHostedPaymentData($hostedPaymentData)
+ ->serialize();
+ $response = json_decode($json, true);
+ $this->assertEquals(true, $response['HPP_CAPTURE_ADDRESS']);
+ $this->assertEquals(false, $response['HPP_DO_NOT_RETURN_ADDRESS']);
+ }
+
public function testOpenBankingInitiate()
{
$config = new GpEcomConfig();
@@ -937,13 +968,14 @@ public function testOpenBankingInitiate()
$bankPayment->accountNumber = '12345678';
$bankPayment->sortCode = '406650';
$bankPayment->accountName = 'AccountName';
+ $hostedPaymentData->bankPayment = $bankPayment;
+
$client = new RealexHppClient($config->sharedSecret, ShaHashType::SHA256);
$service = new HostedService($config);
$json = $service->charge(10.99)
->withCurrency("GBP")
- ->withPaymentMethod($bankPayment)
->withHostedPaymentData($hostedPaymentData)
->withRemittanceReference(RemittanceReferenceType::TEXT, 'Nike Bounce Shoes')
->serialize();
diff --git a/test/Integration/Gateways/RealexConnector/OpenBankingTest.php b/test/Integration/Gateways/RealexConnector/OpenBankingTest.php
index da3b54ea..f1d59c86 100644
--- a/test/Integration/Gateways/RealexConnector/OpenBankingTest.php
+++ b/test/Integration/Gateways/RealexConnector/OpenBankingTest.php
@@ -112,7 +112,7 @@ public function testBankPaymentList_EmptyList()
public function testBankPaymentListWithReturnPii()
{
$startDate = (new \DateTime())->modify('-29 day');
- $endDate = (new \DateTime())->modify('-28 day');
+ $endDate = (new \DateTime())->modify('-1 day');
$response = ReportingService::findBankPaymentTransactions(1, 10)
->where(SearchCriteria::START_DATE, $startDate)
->andWith(SearchCriteria::END_DATE, $endDate)