Skip to content

Commit

Permalink
OctopusDeploy release: 4.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
securesubmit-buildmaster committed Jul 28, 2022
1 parent b92712f commit 55dddb1
Show file tree
Hide file tree
Showing 23 changed files with 1,457 additions and 31 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

## Latest version
#### Enhancements:
- GP-API: Add PayLink service

#### Bug Fixes:
- GP-API: Fix mapping issue on APMs

## v4.0.4 (07/14/2022)
#### Enhancements:
- GP-API: Add mapping for some missing fields on response 3DS2 initiate step
- GP-ECOM: Add missing optional fields HPP_CUSTOMER_PHONENUMBER_HOME and HPP_CUSTOMER_PHONENUMBER_WORK
- Update Open Banking endpoints
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>4.0.4</releaseNumber>
<releaseNumber>4.0.5</releaseNumber>
</xml>
9 changes: 0 additions & 9 deletions src/Builders/AuthorizationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,6 @@ class AuthorizationBuilder extends TransactionBuilder
/** @var PhoneNumber */
public $shippingPhone;

/** string */
public $paymentLinkId;

/** @var RemittanceReferenceType */
public $remittanceReferenceType;

Expand Down Expand Up @@ -1411,12 +1408,6 @@ public function withPhoneNumber($phoneCountryCode, $number, $type)
return $this;
}

public function withPaymentLinkId($paymentLinkId)
{
$this->paymentLinkId = $paymentLinkId;
return $this;
}

public function withRemittanceReference($remittanceReferenceType, $remittanceReferenceValue)
{
$this->remittanceReferenceType = $remittanceReferenceType;
Expand Down
6 changes: 6 additions & 0 deletions src/Builders/ManagementBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@ protected function setupValidations()

$this->validations->of(TransactionType::TOKEN_UPDATE)
->check('paymentMethod')->isInstanceOf(CreditCardData::class);

$this->validations->of(TransactionType::PAYLINK_UPDATE)
->check('amount')->isNotNull()
->check('usageMode')->isNotNullInSubProperty('payLinkData')
->check('usageLimit')->isNotNullInSubProperty('payLinkData')
->check('type')->isNotNullInSubProperty('payLinkData');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use GlobalPayments\Api\Entities\Enums\GatewayProvider;
use GlobalPayments\Api\Entities\Enums\ManualEntryMethod;
use GlobalPayments\Api\Entities\Enums\CaptureMode;
use GlobalPayments\Api\Entities\Enums\PayLinkStatus;
use GlobalPayments\Api\Entities\Enums\PaymentEntryMode;
use GlobalPayments\Api\Entities\Enums\PaymentType;
use GlobalPayments\Api\Entities\Enums\PhoneNumberType;
Expand All @@ -22,6 +23,7 @@
use GlobalPayments\Api\Entities\GpApi\DTO\PaymentMethod;
use GlobalPayments\Api\Entities\GpApi\GpApiRequest;
use GlobalPayments\Api\Entities\IRequestBuilder;
use GlobalPayments\Api\Entities\PayLinkData;
use GlobalPayments\Api\Entities\PhoneNumber;
use GlobalPayments\Api\Mapping\EnumMapping;
use GlobalPayments\Api\PaymentMethods\CreditCardData;
Expand Down Expand Up @@ -115,6 +117,41 @@ public function buildRequest(BaseBuilder $builder, $config)
$builder->clientTransactionId : GenerationUtils::getGuid();
$requestData['payment_method'] = $this->createPaymentMethodParam($builder, $config);
break;
case TransactionType::CREATE:
if ($builder->payLinkData instanceof PayLinkData) {
/** @var PayLinkData $payLink */
$payLink = $builder->payLinkData;
$endpoint = GpApiRequest::PAYLINK_ENDPOINT;
$verb = 'POST';
$requestData['account_name'] = $config->accessTokenInfo->transactionProcessingAccountName;
$requestData['type'] = $payLink->type;
$requestData['usage_mode'] = $payLink->usageMode;
$requestData['usage_limit'] = (string) $payLink->usageLimit;
$requestData['reference'] = $builder->clientTransactionId;
$requestData['name'] = $payLink->name;
$requestData['description'] = $builder->description;
$requestData['shippable'] = isset($payLink->isShippable) ?
json_encode($payLink->isShippable) : false;
$requestData['shipping_amount'] = StringUtils::toNumeric($payLink->shippingAmount);
$requestData['expiration_date'] = !empty($payLink->expirationDate) ?
(new \DateTime($payLink->expirationDate))->format('Y-m-d\TH:i:s\Z') : null;
//@TODO - remove status when GP-API will fix the issue (status shouldn't be sent in request)
$requestData['status'] = PayLinkStatus::ACTIVE;
$requestData['images'] = $payLink->images;
$requestData['transactions'] = [
'amount' => StringUtils::toNumeric($builder->amount),
'channel' => $config->channel,
'currency' => $builder->currency,
'country' => $config->country,
'allowed_payment_methods' => $payLink->allowedPaymentMethods
];
$requestData['notifications'] = [
'return_url' => $payLink->returnUrl,
'status_url' => $payLink->statusUpdateUrl,
'cancel_url' => $payLink->cancelUrl
];
}
break;
default:
return '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,29 @@ public function buildRequest(BaseBuilder $builder, $config)
]
];
break;
case TransactionType::PAYLINK_UPDATE:
$endpoint = GpApiRequest::PAYLINK_ENDPOINT . '/' . $builder->paymentLinkId;
$verb = 'PATCH';
$payload = [
'usage_mode'=> $builder->payLinkData->usageMode ?? null,
'usage_limit' => $builder->payLinkData->usageLimit ?? null,
'name' => $builder->payLinkData->name ?? null,
'description' => $builder->description ?? null,
'type' => $builder->payLinkData->type ?? null,
'status' => $builder->payLinkData->status ?? null,
'shippable' => isset($builder->payLinkData->shippable) ?
json_encode($builder->payLinkData->shippable) : null,
'shipping_amount' => !empty($builder->payLinkData->shippingAmount) ?
StringUtils::toNumeric($builder->payLinkData->shippingAmount) : null,
'transactions' => [
'amount' => !empty($builder->amount) ? StringUtils::toNumeric($builder->amount) : null
],
'expiration_date' => !empty($payLink->expirationDate) ?
(new \DateTime($payLink->expirationDate))->format('Y-m-d\TH:i:s\Z') : null,

'images' => $builder->payLinkData->images ?? null,
];
break;
default:
return null;
}
Expand Down
15 changes: 15 additions & 0 deletions src/Builders/RequestBuilder/GpApi/GpApiReportRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,21 @@ public function buildRequest(BaseBuilder $builder, $config)
'http_response_code' => $builder->searchBuilder->httpResponseCode
];
break;
case ReportType::PAYLINK_DETAIL:
$endpoint = GpApiRequest::PAYLINK_ENDPOINT . '/' . $builder->searchBuilder->payLinkId;
$verb = 'GET';
break;
case ReportType::FIND_PAYLINK_PAGED:
$endpoint = GpApiRequest::PAYLINK_ENDPOINT;
$verb = 'GET';
$this->addBasicParams($queryParams, $builder);
$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['order'] = $builder->order;
$queryParams['order_by'] = $builder->payLinkOrderBy;
break;
default:
return null;
}
Expand Down
29 changes: 29 additions & 0 deletions src/Builders/TransactionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use GlobalPayments\Api\Builders\BaseBuilder\Validations;
use GlobalPayments\Api\Entities\Enums\TransactionModifier;
use GlobalPayments\Api\Entities\Exceptions\ArgumentException;
use GlobalPayments\Api\Entities\PayLinkData;
use GlobalPayments\Api\Entities\PayLinkResponse;
use GlobalPayments\Api\Entities\Transaction;

abstract class TransactionBuilder extends BaseBuilder
Expand Down Expand Up @@ -69,6 +71,20 @@ abstract class TransactionBuilder extends BaseBuilder
*/
public $supplementaryData;

/**
* Entity specific to PayLink service
*
* @var PayLinkData
*/
public $payLinkData;

/**
*A unique identifier generated by Global Payments to identify the payment link.
*
* string
*/
public $paymentLinkId;

/**
* Instantiates a new builder
*
Expand Down Expand Up @@ -149,4 +165,17 @@ public function withSupplementaryData($key, $value = null)

return $this;
}

public function withPayLinkData(PayLinkData $payLinkData)
{
$this->payLinkData = $payLinkData;

return $this;
}

public function withPaymentLinkId($paymentLinkId)
{
$this->paymentLinkId = $paymentLinkId;
return $this;
}
}
17 changes: 17 additions & 0 deletions src/Builders/TransactionReportBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use GlobalPayments\Api\Entities\Enums\ActionSortProperty;
use GlobalPayments\Api\Entities\Enums\DepositSortProperty;
use GlobalPayments\Api\Entities\Enums\DisputeSortProperty;
use GlobalPayments\Api\Entities\Enums\PayLinkSortProperty;
use GlobalPayments\Api\Entities\Enums\SortDirection;
use GlobalPayments\Api\Entities\Enums\StoredPaymentMethodSortProperty;
use GlobalPayments\Api\Entities\Enums\TransactionModifier;
Expand Down Expand Up @@ -74,6 +75,9 @@ class TransactionReportBuilder extends ReportBuilder
*/
public $actionOrderBy;

/** @var PayLinkSortProperty */
public $payLinkOrderBy;

/**
* @var SortDirection
*/
Expand Down Expand Up @@ -257,6 +261,12 @@ public function withBankPaymentId($bankPaymentId)
return $this;
}

public function withPayLinkId($payLinkId)
{
$this->searchBuilder->payLinkId = $payLinkId;
return $this;
}

/**
* Set the gateway order for the criteria
* @param string $sortProperty sorting property
Expand Down Expand Up @@ -293,6 +303,10 @@ public function orderBy($sortProperty, $sortDirection = SortDirection::DESC)
$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 @@ -318,5 +332,8 @@ protected function setupValidations()

$this->validations->of(ReportType::DOCUMENT_DISPUTE_DETAIL)
->check('disputeDocumentId')->isNotNullInSubProperty('searchBuilder');

$this->validations->of(ReportType::PAYLINK_DETAIL)
->check('payLinkId')->isNotNullInSubProperty('searchBuilder');
}
}
10 changes: 10 additions & 0 deletions src/Entities/Enums/PayLinkSortProperty.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace GlobalPayments\Api\Entities\Enums;

use GlobalPayments\Api\Entities\Enum;

class PayLinkSortProperty extends Enum
{
const TIME_CREATED = 'TIME_CREATED';
}
14 changes: 14 additions & 0 deletions src/Entities/Enums/PayLinkStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace GlobalPayments\Api\Entities\Enums;

use GlobalPayments\Api\Entities\Enum;

class PayLinkStatus extends Enum
{
const ACTIVE = 'ACTIVE';
const INACTIVE = 'INACTIVE';
const CLOSED = 'CLOSED';
const EXPIRED = 'EXPIRED';
const PAID = 'PAID';
}
8 changes: 8 additions & 0 deletions src/Entities/Enums/PayLinkType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace GlobalPayments\Api\Entities\Enums;

class PayLinkType
{
const PAYMENT = 'PAYMENT';
}
2 changes: 2 additions & 0 deletions src/Entities/Enums/ReportType.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ 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 PAYLINK_DETAIL = 16777216; // 1 << 24
const FIND_PAYLINK_PAGED = 33554432; // 1 << 25
}
1 change: 1 addition & 0 deletions src/Entities/Enums/TransactionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ class TransactionType extends Enum
const DISPUTE_CHALLENGE = 18014398509481984; // 1 << 54
const REAUTH = 36028797018963968; // 1 << 55
const CONFIRM = 72057594037927936; // 1 << 56
const PAYLINK_UPDATE = 144115188075855872; // 1 << 57
}
3 changes: 2 additions & 1 deletion src/Entities/GpApi/GpApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ class GpApiRequest extends Request
const BATCHES_ENDPOINT = '/batches';
const ACTIONS_ENDPOINT = '/actions';
const MERCHANT_MANAGEMENT_ENDPOINT = '/merchants';
const DCC_ENDPOINT= '/currency-conversions';
const DCC_ENDPOINT = '/currency-conversions';
const PAYLINK_ENDPOINT = '/links';
}
Loading

0 comments on commit 55dddb1

Please sign in to comment.