Skip to content

Commit

Permalink
OctopusDeploy release: 5.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
securesubmit-buildmaster committed Oct 4, 2022
1 parent 4dcb924 commit 937b361
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 32 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

## Latest version
#### Enhancements:
- GP-API: PayLink enhancements

## v5.0.2 (09/29/2022)
#### Enhancements:
- GP-API: Add fraud management feature
- GP-ECOM: Billing/Shipping country value should be ISO2 country code
- GP-API: Add missing request properties for /transactions and /initiate 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>5.0.2</releaseNumber>
<releaseNumber>5.0.3</releaseNumber>
</xml>
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ public function buildRequest(BaseBuilder $builder, $config)
$requestData['reference'] = $builder->clientTransactionId;
$requestData['name'] = $payLink->name;
$requestData['description'] = $builder->description;
$requestData['shippable'] = isset($payLink->isShippable) ?
json_encode($payLink->isShippable) : false;
$requestData['shippable'] = $payLink->isShippable == true ? 'YES' : 'NO';
$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;
Expand Down
10 changes: 10 additions & 0 deletions src/Builders/RequestBuilder/GpApi/GpApiReportRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ public function buildRequest(BaseBuilder $builder, $config)
$builder->searchBuilder->endDate->format('Y-m-d') : null;
$queryParams['order'] = $builder->order;
$queryParams['order_by'] = $builder->payLinkOrderBy;
$queryParams['status'] = $builder->searchBuilder->payLinkStatus;
$queryParams['usage_mode'] = $builder->searchBuilder->paymentMethodUsageMode;
$queryParams['name'] = $builder->searchBuilder->displayName;
$queryParams['amount'] = StringUtils::toNumeric($builder->searchBuilder->amount);;
$queryParams['description'] = $builder->searchBuilder->description;
$queryParams['reference'] = $builder->searchBuilder->referenceNumber;
$queryParams['country'] = $builder->searchBuilder->country;
$queryParams['currency'] = $builder->searchBuilder->currency;
$queryParams['expiration_date'] = !empty($builder->searchBuilder->expirationDate) ?
$builder->searchBuilder->expirationDate->format('Y-m-d') : null;
break;
default:
return null;
Expand Down
13 changes: 12 additions & 1 deletion src/Entities/Reporting/PayLinkSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class PayLinkSummary
*/
public $shippable;

/** @var string */
public $shippingAmount;

/**
* The number of times a link has been viewed.
* @var string
Expand All @@ -117,10 +120,18 @@ class PayLinkSummary
*/
public $images;

/**
* @var string
*/
public $amount;

/** @var string */
public $currency;

/**
* List of transactions attached to this payment link
*
* @var array<TransactionSummary>
*/
public $transactions;
public $transactions = [];
}
4 changes: 4 additions & 0 deletions src/Entities/Reporting/SearchCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,8 @@ class SearchCriteria extends Enum
const RISK_ASSESSMENT_MODE = 'riskAssessmentMode';
const RISK_ASSESSMENT_RESULT = 'riskAssessmentResult';
const RISK_ASSESSMENT_REASON_CODE = 'riskAssessmentReasonCode';
const PAYLINK_STATUS = 'payLinkStatus';
const PAYMENT_METHOD_USAGE_MODE = 'paymentMethodUsageMode';
const DESCRIPTION = 'description';
const EXPIRATION_DATE = 'expirationDate';
}
28 changes: 21 additions & 7 deletions src/Entities/Reporting/SearchCriteriaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
use GlobalPayments\Api\Entities\Enums\DisputeStatus;
use GlobalPayments\Api\Entities\Enums\FraudFilterMode;
use GlobalPayments\Api\Entities\Enums\FraudFilterResult;
use GlobalPayments\Api\Entities\Enums\PayLinkStatus;
use GlobalPayments\Api\Entities\Enums\PaymentEntryMode;
use GlobalPayments\Api\Entities\Enums\PaymentMethodUsageMode;
use GlobalPayments\Api\Entities\Enums\PaymentType;
use GlobalPayments\Api\Entities\Enums\PaymentMethodName;
use GlobalPayments\Api\Entities\Enums\ReasonCode;
Expand Down Expand Up @@ -479,6 +481,25 @@ class SearchCriteriaBuilder
*/
public $paymentMethod;

/**
* This is the PayLink id
*
* @var string
*/
public $payLinkId;

/** @var PaymentMethodUsageMode */
public $paymentMethodUsageMode;

/** @var string */
public $description;

/** @var \DateTime */
public $expirationDate;

/** @var PayLinkStatus */
public $payLinkStatus;

/** ******************************
* Open banking search criteria *
********************************/
Expand All @@ -498,13 +519,6 @@ class SearchCriteriaBuilder
*/
public $returnPii;

/**
* This is the PayLink id
*
* @var string
*/
public $payLinkId;

/** END Open Banking search criteria */


Expand Down
45 changes: 32 additions & 13 deletions src/Mapping/GpApiMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace GlobalPayments\Api\Mapping;

use _PHPStan_76800bfb5\Nette\Utils\DateTime;
use GlobalPayments\Api\Entities\AlternativePaymentResponse;
use GlobalPayments\Api\Entities\BatchSummary;
use GlobalPayments\Api\Entities\CardIssuerResponse;
Expand Down Expand Up @@ -703,7 +704,7 @@ public static function mapResponseAPM($response)
if (!empty($response->payment_method->authorization)) {
$authorization = $response->payment_method->authorization;
$apm->authStatus = !empty($authorization->status) ? $authorization->status : null;
$apm->authAmount = !empty($authorization->amount) ? $authorization->amount : null;
$apm->authAmount = !empty($authorization->amount) ? StringUtils::toAmount($authorization->amount) : null;
$apm->authAck = !empty($authorization->ack) ? $authorization->ack : null;
$apm->authCorrelationReference = !empty($authorization->correlation_reference) ?
$authorization->correlation_reference : null;
Expand Down Expand Up @@ -731,37 +732,42 @@ public static function mapResponseAPM($response)
public static function mapPayLinkSummary($response)
{
$summary = new PayLinkSummary();

$summary->id = $response->id ?? null;
$summary->merchantId = $response->merchant_id ?? null;
$summary->merchantName = $response->merchant_name ?? null;
$summary->accountId = $response->account_id ?? null;
$summary->accountName = $response->account_name ?? null;
$summary->id = $response->id ?? null;
$summary->url = $response->url ?? null;
$summary->status = $response->status ?? null;
$summary->type = $response->type ?? null;
$summary->allowedPaymentMethods = $response->allowed_payment_methods ?? null; //@TODO check
$summary->usageMode = $response->usage_mode ?? null;
$summary->usageCount = $response->usage_count ?? null;
$summary->usageLimit = $response->usage_limit ?? null; //@TODO
$summary->reference = $response->reference ?? null;
$summary->name = $response->name ?? null;
$summary->description = $response->description ?? null;
$summary->shippable = $response->shippable ?? null;
$summary->viewedCount = $response->viewed_count ?? null;
$summary->expirationDate = !empty($response->expiration_date) ?
new \DateTime($response->expiration_date) : null;

$summary->shippable = $response->shippable ?? null;
$summary->usageCount = $response->usage_count ?? null;
$summary->images = $response->images ?? null;
$summary->shippingAmount = $response->shipping_amount ?? null;

if (!empty($response->transactions)) {
foreach ($response->transactions as $transaction) {
$summary->transactions[] = self::createTransactionSummary($transaction);
$summary->amount = StringUtils::toAmount($response->transactions->amount) ?? null;
$summary->currency = $response->transactions->currency ?? null;
$summary->allowedPaymentMethods = $response->transactions->allowed_payment_methods ?? null; //@TODO check
if (!empty($response->transactions->transaction_list)) {
foreach ($response->transactions->transaction_list as $transaction) {
$summary->transactions[] = self::createTransactionSummary($transaction);
}
}
}

return $summary;
}


public static function mapPayLinkResponse($response)
{
$payLinkResponse = new PayLinkResponse();
Expand All @@ -775,9 +781,9 @@ public static function mapPayLinkResponse($response)
$payLinkResponse->reference = $response->reference ?? null;
$payLinkResponse->name = $response->name ?? null;
$payLinkResponse->description = $response->description ?? null;
$payLinkResponse->isShippable = $response->shippable ?? null;
$payLinkResponse->viewedCount = $response->viewed_count ?? null;
$payLinkResponse->expirationDate = !empty($response->expiration_date) ? new \DateTime($response->expiration_date) : null;
$payLinkResponse->isShippable = $response->shippable ?? null;

return $payLinkResponse;
}
Expand All @@ -793,9 +799,8 @@ private static function createTransactionSummary($response)
{
$transaction = new TransactionSummary();
$transaction->transactionId = isset($response->id) ? $response->id : null;
// $transaction->transactionDate = $response->time_created;
$transaction->transactionDate = !empty($response->time_created) ?
new \DateTime($response->time_created) : '';
$timeCreated = self::validateStringDate($response->time_created);
$transaction->transactionDate = !empty($timeCreated) ? new \DateTime($timeCreated) : '';
$transaction->transactionStatus = $response->status;
$transaction->transactionType = $response->type;
$transaction->channel = !empty($response->channel) ? $response->channel : null;
Expand All @@ -806,6 +811,20 @@ private static function createTransactionSummary($response)
return $transaction;
}

private static function validateStringDate($date)
{
try {
new \DateTime($date);
} catch (\Exception $e) {
$errors = \DateTime::getLastErrors();
if (isset($errors['error_count']) && $errors['error_count'] > 0) {
return current(explode('.', $date));
}
}

return $date;
}

/**
* Map the result codes directly from the card issuer.
*
Expand Down
Loading

0 comments on commit 937b361

Please sign in to comment.