Skip to content

Commit

Permalink
OctopusDeploy release: 7.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
securesubmit-buildmaster committed May 2, 2023
1 parent 05cfa8c commit cf0bb83
Show file tree
Hide file tree
Showing 34 changed files with 1,035 additions and 237 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

## Latest Version
#### Enhancements:
- GP-API: Manage merchant accounts for partner solution
(https://developer.globalpay.com/api/accounts)
- GP-ECOM: Add to the mapping response fields: acs_reference_number & acs_signed_content for the authentication source MOBILE_SDK

## v7.0.1 (04/04/2023)
#### Enhancements:
- Portico/Heartland: improvements to transaction request building logic
- GP-API: Unit tests update on fraud management and APMs
- GP-ECOM: Unit test update on 3DS
Expand Down
2 changes: 1 addition & 1 deletion metadata.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<xml>
<releaseNumber>7.0.1</releaseNumber>
<releaseNumber>7.0.2</releaseNumber>
</xml>
36 changes: 30 additions & 6 deletions src/Builders/PayFacBuilder.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
namespace GlobalPayments\Api\Builders;

use GlobalPayments\Api\Entities\Address;
use GlobalPayments\Api\Entities\AddressCollection;
use GlobalPayments\Api\Entities\Customer;
use GlobalPayments\Api\Entities\Enums\AddressType;
use GlobalPayments\Api\Entities\Enums\PaymentMethodFunction;
use GlobalPayments\Api\Entities\Enums\StatusChangeReason;
use GlobalPayments\Api\Entities\PayFac\UserReference;
Expand Down Expand Up @@ -99,6 +102,9 @@ class PayFacBuilder extends BaseBuilder
/** @var string */
public $idempotencyKey;

/** @var AddressCollection */
public $addresses;

const UPLOAD_FILE_TYPES = [
'tif', 'tiff', 'bmp', 'jpg', 'jpeg', 'gif', 'png', 'doc', 'docx'
];
Expand Down Expand Up @@ -128,13 +134,14 @@ public function execute($configName = 'default')
{
parent::execute($configName);
$client = ServicesContainer::instance()->getPayFac($configName);
switch ($this->transactionModifier)
{
case TransactionModifier::MERCHANT:
return $client->processBoardingUser($this);
default:
return $client->processPayFac($this);
if (
method_exists($client, "hasBuiltInMerchantManagementService") &&
$client->hasBuiltInMerchantManagementService()
) {
return $client->processBoardingUser($this);
}

return $client->processPayFac($this);
}

public function __get($name)
Expand Down Expand Up @@ -254,6 +261,12 @@ protected function setupValidations()
)
->with(TransactionModifier::MERCHANT)
->check('userId')->isNotNull();

$this->validations->of(
TransactionType::CREATE
)
->with(TransactionModifier::MERCHANT)
->check('userPersonalData')->isNotNull();
}

/*
Expand Down Expand Up @@ -562,4 +575,15 @@ public function withIdempotencyKey($value)

return $this;
}

public function withAddress(Address $address, $type = AddressType::BILLING)
{
if (!isset($this->addresses)) {
$this->addresses = new AddressCollection();
}

$this->addresses->add($address, $type);

return $this;
}
}
9 changes: 9 additions & 0 deletions src/Builders/ReportBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use GlobalPayments\Api\Entities\Enums\ReportType;
use GlobalPayments\Api\Entities\Enums\TimeZoneConversion;
use GlobalPayments\Api\Entities\Enums\TransactionType;
use GlobalPayments\Api\Entities\Reporting\SearchCriteriaBuilder;
use GlobalPayments\Api\ServicesContainer;

abstract class ReportBuilder extends BaseBuilder
Expand Down Expand Up @@ -64,6 +65,14 @@ public function execute($configName = 'default')
return $client->processReport($this);
}

/**
* @return SearchCriteriaBuilder
*/
public function where($criteria, $value)
{
return $this->searchBuilder->andWith($criteria, $value);
}

/**
* Set the gateway paging criteria for the report
* @param $page
Expand Down
97 changes: 56 additions & 41 deletions src/Builders/RequestBuilder/GpApi/GpApiPayFacRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function buildRequest(BaseBuilder $builder, $config)
$requestData = $queryParams = null;
switch ($builder->transactionType) {
case TransactionType::CREATE:
if (TransactionModifier::MERCHANT) {
if ($builder->transactionModifier == TransactionModifier::MERCHANT) {
$endpoint = GpApiRequest::MERCHANT_MANAGEMENT_ENDPOINT;
$verb = 'POST';
if (empty($builder->userPersonalData)) {
Expand All @@ -64,21 +64,37 @@ public function buildRequest(BaseBuilder $builder, $config)
$requestData = $this->buildCreateMerchantRequest();
}
break;
case TransactionType::EDIT:
if (TransactionModifier::MERCHANT) {
$endpoint = GpApiRequest::MERCHANT_MANAGEMENT_ENDPOINT . '/' . $builder->userReference->userId;
$verb = 'PATCH';
$requestData = $this->buildEditMerchantRequest();
}
break;
case TransactionType::FETCH:
if (TransactionModifier::MERCHANT) {
if ($builder->transactionModifier == TransactionModifier::MERCHANT) {
$endpoint = GpApiRequest::MERCHANT_MANAGEMENT_ENDPOINT . '/' . $builder->userId;
$verb = 'GET';
}
break;
case TransactionType::EDIT:
$verb = 'PATCH';
if ($builder->transactionModifier == TransactionModifier::MERCHANT) {
$endpoint = GpApiRequest::MERCHANT_MANAGEMENT_ENDPOINT . '/' . $builder->userReference->userId;
$requestData = $this->buildEditMerchantRequest();
} else {
$endpoint = '';
if (!empty($builder->userReference->userId)) {
$endpoint = GpApiRequest::MERCHANT_MANAGEMENT_ENDPOINT . '/' . $builder->userReference->userId;
}
$endpoint .= GpApiRequest::ACCOUNTS_ENDPOINT . '/' . $builder->accountNumber;
$requestData['payer'] = [
'payment_method' => [
'name' => $this->builder->creditCardInformation instanceof CreditCardData ?
$this->builder->creditCardInformation->cardHolderName : null,
'card' => $this->builder->creditCardInformation instanceof CreditCardData ?
$this->mapCreditCardInfo($this->builder->creditCardInformation) : null
],
'billing_address' =>
!empty($this->builder->addresses) && $this->builder->addresses->offsetExists(AddressType::BILLING) ?
$this->mapAddress($this->builder->addresses->get(AddressType::BILLING), 'alpha2') : null
];
}
default:
return '';
break;
}

if (empty($endpoint)) {
Expand Down Expand Up @@ -120,27 +136,21 @@ private function mapBankTransferInfo(BankAccountData $bankAccountData)
'name' => $bankAccountData->bankName,
'code' => $bankAccountData->routingNumber, //@TODO confirmantion from GP-API team
'international_code' => '', //@TODO
'address' => [
'line_1' => $bankAccountData->bankAddress->streetAddress1 ?? null,
'line_2' => $bankAccountData->bankAddress->streetAddress2 ?? null,
'line_3' => $bankAccountData->bankAddress->streetAddress3 ?? null,
'city' => $bankAccountData->bankAddress->city ?? null,
'postal_code' => $bankAccountData->bankAddress->postalCode ?? null,
'state' => $bankAccountData->bankAddress->state ?? null,
'country' => !empty($bankAccountData->bankAddress) ?
CountryUtils::getCountryCodeByCountry($bankAccountData->bankAddress->countryCode) : '',
]
'address' => !empty($bankAccountData->bankAddress) ?
$this->mapAddress($bankAccountData->bankAddress, 'alpha2') : null,
]
];
}

private function mapCreditCardInfo(CreditCardData $creditCardInformation)
{
return [
'name' => $creditCardInformation->cardHolderName,
'number' => $creditCardInformation->number,
'expiry_month' => substr($creditCardInformation->expMonth, 2, 2),
'expiry_year' => substr($creditCardInformation->expYear, 0, 2)
'expiry_month' => !empty($creditCardInformation->expMonth) ?
substr($creditCardInformation->expMonth, 0, 2) : null,
'expiry_year' => !empty($creditCardInformation->expYear) ?
substr($creditCardInformation->expYear, 2, 2) : null,
'cvv' => $creditCardInformation->cvn ?? null
];
}

Expand Down Expand Up @@ -179,20 +189,33 @@ private function setAddressList()
}
/** @var Address $address */
foreach ($addressList as $addressType => $address) {
$addresses[] = [
'line_1' => $address->streetAddress1,
'line_2' => $address->streetAddress2,
'city' => $address->city,
'postal_code' => $address->postalCode,
'state' => $address->state,
'country' => CountryUtils::getCountryCodeByCountry($address->countryCode),
'functions' => [$addressType]
];
$addresses[] = $this->mapAddress($address, 'alpha2') + ['functions' => [$addressType]];
}

return $addresses ?? [];
}

private function mapAddress(Address $address, $countryCodeType = null)
{
switch ($countryCodeType)
{
case 'alpha2':
$countryCode = CountryUtils::getCountryCodeByCountry($address->countryCode);
break;
default:
$countryCode = $address->countryCode;
}
return [
'line_1' => $address->streetAddress1,
'line_2' => $address->streetAddress2,
'line_3' => $address->streetAddress3,
'city' => $address->city,
'state' => $address->state,
'postal_code' => $address->postalCode,
'country' => $countryCode,
];
}

/**
* Request body for POST /merchants
*
Expand Down Expand Up @@ -271,15 +294,7 @@ private function setPersonList()
'job_title' => $person->jobTitle
];
if (!empty($person->address)) {
$personInfo['address'] = [
'line_1' => $person->address->streetAddress1,
'line_2' => $person->address->streetAddress2,
'line_3' => $person->address->streetAddress3,
'city' => $person->address->city,
'state' => $person->address->state,
'postal_code' => $person->address->postalCode,
'country' => $person->address->countryCode,
];
$personInfo['address'] = self::mapAddress($person->address);
}
if (!empty($person->homePhone)) {
$personInfo['contact_phone'] = [
Expand Down
38 changes: 36 additions & 2 deletions src/Builders/RequestBuilder/GpApi/GpApiReportRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,42 @@ public function buildRequest(BaseBuilder $builder, $config)
case ReportType::FIND_MERCHANTS_PAGED:
$endpoint = GpApiRequest::MERCHANT_MANAGEMENT_ENDPOINT;
$verb = 'GET';
$queryParams['page'] = $builder->page;
$queryParams['page_size'] = $builder->pageSize;
$this->addBasicParams($queryParams, $builder);
$queryParams['status'] = $builder->searchBuilder->accountStatus ?? null;
$queryParams['order'] = $builder->order ?? null;
$queryParams['order_by'] = $builder->accountOrderBy ?? null;
break;
case ReportType::FIND_ACCOUNTS_PAGED:
$endpoint = GpApiRequest::ACCOUNTS_ENDPOINT;
if (!empty($builder->searchBuilder->merchantId)) {
$endpoint = GpApiRequest::MERCHANT_MANAGEMENT_ENDPOINT . '/' .
$builder->searchBuilder->merchantId . $endpoint;
}
$verb = 'GET';
$this->addBasicParams($queryParams, $builder);
$queryParams['order'] = $builder->order ?? null;
$queryParams['order_by'] = $builder->accountOrderBy ?? null;
$queryParams['from_time_created'] = !empty($builder->searchBuilder->startDate) ?
$builder->searchBuilder->startDate->format('Y-m-d') : null;
$queryParams['to_time_created'] = !empty($builder->searchBuilder->endDate) ?
$builder->searchBuilder->endDate->format('Y-m-d') : null;
$queryParams['status'] = $builder->searchBuilder->accountStatus ?? null;
$queryParams['name'] = $builder->searchBuilder->accountName ?? null;
$queryParams['id'] = $builder->searchBuilder->resourceId ?? null;
break;
case ReportType::FIND_ACCOUNT_DETAIL:
$endpoint = GpApiRequest::ACCOUNTS_ENDPOINT. '/'. $builder->searchBuilder->accountId;
if (!empty($builder->searchBuilder->address)) {
$endpoint .= '/addresses';
$queryParams = [
'page' => $builder->page,
'page_size' => $builder->pageSize,
'postal_code' => $builder->searchBuilder->address->postalCode ?? null,
'line_1' => $builder->searchBuilder->address->streetAddress1 ?? null,
'line_2' => $builder->searchBuilder->address->streetAddress2 ?? null
];
}
$verb = 'GET';
break;
default:
throw new ArgumentException(sprintf("Unknown report type!"));
Expand Down
16 changes: 2 additions & 14 deletions src/Builders/TransactionReportBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace GlobalPayments\Api\Builders;

use GlobalPayments\Api\Entities\Enums\MerchantAccountsSortProperty;
use GlobalPayments\Api\Entities\Enums\ActionSortProperty;
use GlobalPayments\Api\Entities\Enums\DepositSortProperty;
use GlobalPayments\Api\Entities\Enums\DisputeSortProperty;
Expand Down Expand Up @@ -288,37 +289,32 @@ public function withPayLinkId($payLinkId)
*/
public function orderBy($sortProperty, $sortDirection = SortDirection::DESC)
{
$this->order = $sortDirection;
switch ($this->reportType) {
case ReportType::FIND_TRANSACTIONS:
case ReportType::FIND_TRANSACTIONS_PAGED:
case ReportType::FIND_SETTLEMENT_TRANSACTIONS:
case ReportType::FIND_SETTLEMENT_TRANSACTIONS_PAGED:
$this->transactionOrderBy = $sortProperty;
$this->order = $sortDirection;
break;
case ReportType::FIND_DEPOSITS:
case ReportType::FIND_DEPOSITS_PAGED:
$this->depositOrderBy = $sortProperty;
$this->order = $sortDirection;
break;
case ReportType::FIND_DISPUTES:
case ReportType::FIND_DISPUTES_PAGED:
case ReportType::FIND_SETTLEMENT_DISPUTES:
case ReportType::FIND_SETTLEMENT_DISPUTES_PAGED:
$this->disputeOrderBy = $sortProperty;
$this->order = $sortDirection;
break;
case ReportType::FIND_STORED_PAYMENT_METHODS_PAGED:
$this->storedPaymentMethodOrderBy = $sortProperty;
$this->order = $sortDirection;
break;
case ReportType::FIND_ACTIONS_PAGED:
$this->actionOrderBy = $sortProperty;
$this->order = $sortDirection;
break;
case ReportType::FIND_PAYLINK_PAGED:
$this->payLinkOrderBy = $sortProperty;
$this->order = $sortDirection;
break;
default:
throw new \InvalidArgumentException("Invalid order found");
Expand All @@ -327,14 +323,6 @@ public function orderBy($sortProperty, $sortDirection = SortDirection::DESC)
return $this;
}

/**
* @return SearchCriteriaBuilder
*/
public function where($criteria, $value)
{
return $this->searchBuilder->andWith($criteria, $value);
}

protected function setupValidations()
{
$this->validations->of(ReportType::TRANSACTION_DETAIL)
Expand Down
Loading

0 comments on commit cf0bb83

Please sign in to comment.