Skip to content

Commit

Permalink
OctopusDeploy release: 4.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
securesubmit-buildmaster committed Jul 14, 2022
1 parent 0346d01 commit b92712f
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 7 deletions.
7 changes: 7 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: 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

## v4.0.3 (06/28/2022)
#### Enhancements:
- Add autoloader standalone
- Add end-to-end example for GP-API with HF and 3DS2
- Refacto on the folder structure in examples
Expand All @@ -25,6 +31,7 @@
- GP-ECOM/GP-API: Structure refacto
- Upgrade to min PHP 7.1
- GP-API: Add example with Google Pay
- GP-API: Add Dynamic Descriptor for authorize and charge

## v3.1.1 (05/17/2022)
#### Enhancements:
Expand Down
3 changes: 3 additions & 0 deletions examples/gp-ecom/hpp/get-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use GlobalPayments\Api\Entities\Enums\HppVersion;
use GlobalPayments\Api\Entities\Exceptions\ApiException;
use GlobalPayments\Api\Services\HostedService;
use GlobalPayments\Api\Entities\Enums\PhoneNumberType;

// configure client, request and HPP settings
$config = new GpEcomConfig();
Expand Down Expand Up @@ -74,6 +75,8 @@
->withHostedPaymentData($hostedPaymentData)
->withAddress($billingAddress, AddressType::BILLING)
->withAddress($shippingAddress, AddressType::SHIPPING)
->withPhoneNumber('44', '124 445 556', PhoneNumberType::WORK)
->withPhoneNumber('44', '124 444 333', PhoneNumberType::HOME)
->withRemittanceReference(RemittanceReferenceType::TEXT, 'Nike Bounce Shoes')
->serialize();
//with this, we can pass our json to the client side
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.3</releaseNumber>
<releaseNumber>4.0.4</releaseNumber>
</xml>
4 changes: 2 additions & 2 deletions src/Entities/Enums/ServiceEndpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ class ServiceEndpoints extends Enum
const PROPAY_PRODUCTION_CANADIAN = "https://www.propaycanada.ca/API/PropayAPI.aspx";
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 = 'https://beta.globalpay-ecommerce.com/openbanking';
const OPEN_BANKING_TEST = 'https://api.sandbox.globalpay-ecommerce.com/openbanking';
const OPEN_BANKING_PRODUCTION = 'https://api.globalpay-ecommerce.com/openbanking';
}
16 changes: 16 additions & 0 deletions src/Entities/ThreeDSecure.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,20 @@ public function setVersion($version)
*/
public $liabilityShift;

/**
* Reference Number assigned by the ACS.
*
* @var string
*/
public $acsReferenceNumber;

/**
* The reference created by the 3DSecure provider to identify the specific authentication attempt.
*
* @var string
*/
public $providerServerTransRef;

public function __construct()
{
$this->paymentDataType = '3DSecure';
Expand Down Expand Up @@ -414,6 +428,8 @@ public function merge(ThreeDSecure $secureEcom)
$this->exemptStatus = $this->mergeValue($this->exemptStatus, $secureEcom->exemptStatus);
$this->exemptReason = $this->mergeValue($this->exemptStatus, $secureEcom->exemptReason);
$this->liabilityShift = $this->mergeValue($this->liabilityShift, $secureEcom->liabilityShift);
$this->acsReferenceNumber = $this->mergeValue($this->acsReferenceNumber, $secureEcom->acsReferenceNumber);
$this->providerServerTransRef = $this->mergeValue($this->providerServerTransRef, $secureEcom->providerServerTransRef);
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/Gateways/GpEcomConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use GlobalPayments\Api\Entities\Enums\Secure3dVersion;
use GlobalPayments\Api\Builders\Secure3dBuilder;
use GlobalPayments\Api\Entities\Exceptions\ApiException;
use GlobalPayments\Api\Utils\StringUtils;

class GpEcomConnector extends XmlGateway implements IPaymentGateway, IRecurringService, ISecure3dProvider
{
Expand Down Expand Up @@ -377,6 +378,18 @@ public function serializeRequest(AuthorizationBuilder $builder)
);
}

if (!empty($builder->homePhone)) {
$this->setSerializeData('HPP_CUSTOMER_PHONENUMBER_HOME',
StringUtils::validateToNumber($builder->homePhone->countryCode) . '|' .
StringUtils::validateToNumber($builder->homePhone->number));
}

if (!empty($builder->workPhone)) {
$this->setSerializeData('HPP_CUSTOMER_PHONENUMBER_WORK',
StringUtils::validateToNumber($builder->workPhone->countryCode) . '|' .
StringUtils::validateToNumber($builder->workPhone->number));
}

$this->setSerializeData('VAR_REF', $builder->clientTransactionId);
$this->setSerializeData('HPP_LANG', $this->hostedPaymentConfig->language);
$this->setSerializeData('MERCHANT_RESPONSE_URL', $this->hostedPaymentConfig->responseUrl);
Expand Down
6 changes: 4 additions & 2 deletions src/Mapping/GpApiMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ public static function mapResponseSecure3D($response)
{
$transaction = new Transaction();
$threeDSecure = new ThreeDSecure();
$threeDSecure->serverTransactionId = !empty($response->id) ? $response->id :
(!empty($response->three_ds->server_trans_ref) ? $response->three_ds->server_trans_ref : null);
$threeDSecure->serverTransactionId = $response->id;

if (!empty($response->three_ds->message_version)) {
$messageVersion = $response->three_ds->message_version;
switch (substr($messageVersion, 0, 2)) {
Expand Down Expand Up @@ -499,6 +499,8 @@ public static function mapResponseSecure3D($response)
$threeDSecure->eci = !empty($response->three_ds->eci) ? $response->three_ds->eci : null;
$threeDSecure->acsInfoIndicator = !empty($response->three_ds->acs_info_indicator) ?
$response->three_ds->acs_info_indicator : null;
$threeDSecure->acsReferenceNumber = $response->three_ds->acs_reference_number ?? null;
$threeDSecure->providerServerTransRef = $response->three_ds->server_trans_ref ?? null;
$threeDSecure->challengeMandated = !empty($response->three_ds->challenge_status) ?
($response->three_ds->challenge_status == 'MANDATED') : false;
$threeDSecure->payerAuthenticationRequest = !empty($response->three_ds->method_data->encoded_method_data) ?
Expand Down
114 changes: 112 additions & 2 deletions test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,15 +632,125 @@ public function testIncrementalAuth()
$this->assertEquals(TransactionStatus::PREAUTHORIZED, $transaction->responseMessage);
$this->assertEquals(60, $transaction->authorizedAmount);



$capture = $transaction->capture()->execute();

$this->assertNotNull($capture);
$this->assertEquals('SUCCESS', $capture->responseCode);
$this->assertEquals(TransactionStatus::CAPTURED, $capture->responseMessage);
}

public function testIncrementalAuth_WithoutCurrencyAndLodgingData()
{
$card = $this->initCreditCardData();

$transaction = $card->authorize(50)
->withCurrency($this->currency)
->execute();

$this->assertNotNull($transaction);
$this->assertEquals('SUCCESS', $transaction->responseCode);
$this->assertEquals(TransactionStatus::PREAUTHORIZED, $transaction->responseMessage);

$transaction = $transaction->additionalAuth(10)
->execute();

$this->assertNotNull($transaction);
$this->assertEquals('SUCCESS', $transaction->responseCode);
$this->assertEquals(TransactionStatus::PREAUTHORIZED, $transaction->responseMessage);
$this->assertEquals(60, $transaction->authorizedAmount);
}

public function testIncrementalAuth_ZeroAmount()
{
$card = $this->initCreditCardData();

$transaction = $card->authorize(50)
->withCurrency($this->currency)
->execute();

$this->assertNotNull($transaction);
$this->assertEquals('SUCCESS', $transaction->responseCode);
$this->assertEquals(TransactionStatus::PREAUTHORIZED, $transaction->responseMessage);

$transaction = $transaction->additionalAuth(0)
->execute();

$this->assertNotNull($transaction);
$this->assertEquals('SUCCESS', $transaction->responseCode);
$this->assertEquals(TransactionStatus::PREAUTHORIZED, $transaction->responseMessage);
$this->assertEquals(50, $transaction->authorizedAmount);
}

public function testIncrementalAuth_ChargeTransaction()
{
$card = $this->initCreditCardData();

$charge = $card->charge(50)
->withCurrency($this->currency)
->execute();

$this->assertNotNull($charge);
$this->assertEquals('SUCCESS', $charge->responseCode);
$this->assertEquals(TransactionStatus::CAPTURED, $charge->responseMessage);

$exceptionCaught = false;
try {
$charge->additionalAuth(10)
->execute();
} catch (GatewayException $e) {
$exceptionCaught = true;
$this->assertEquals('40290', $e->responseCode);
$this->assertContains('Status Code: INVALID_ACTION - Cannot PROCESS Incremental Authorization over a transaction that does not have a status of PREAUTHORIZED.', $e->getMessage());
} finally {
$this->assertTrue($exceptionCaught);
}
}

public function testIncrementalAuth_WithoutAmount()
{
$card = $this->initCreditCardData();

$transaction = $card->authorize(50)
->withCurrency($this->currency)
->execute();

$this->assertNotNull($transaction);
$this->assertEquals('SUCCESS', $transaction->responseCode);
$this->assertEquals(TransactionStatus::PREAUTHORIZED, $transaction->responseMessage);

$exceptionCaught = false;
try {
$transaction->additionalAuth()
->withCurrency($this->currency)
->execute();
} catch (GatewayException $e) {
$exceptionCaught = true;
$this->assertEquals('40005', $e->responseCode);
$this->assertContains('Status Code: MANDATORY_DATA_MISSING - Request expects the following fields [amount]', $e->getMessage());
} finally {
$this->assertTrue($exceptionCaught);
}
}

public function testIncrementalAuth_TransactionNotFound()
{
$transaction = new Transaction();
$transaction->transactionId = GenerationUtils::getGuid();

$exceptionCaught = false;
try {
$transaction->additionalAuth()
->withCurrency($this->currency)
->execute();
} catch (GatewayException $e) {
$exceptionCaught = true;
$this->assertEquals('40008', $e->responseCode);
$this->assertContains(sprintf('Status Code: RESOURCE_NOT_FOUND - Transaction %s not found at this location.', $transaction->transactionId), $e->getMessage());
} finally {
$this->assertTrue($exceptionCaught);
}
}

private function initCreditCardData()
{
$card = new CreditCardData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -743,14 +743,18 @@ public function testFrictionlessFullCycle_v2_WithMobileSdk()
->withOrderTransactionType(OrderTransactionType::GOODS_SERVICE_PURCHASE)
->withMobileData($mobileData)
->execute();

$this->assertNotNull($initAuth);
$this->assertEquals(Secure3dStatus::SUCCESS_AUTHENTICATED, $initAuth->status);
$this->assertNotNull($initAuth->issuerAcsUrl);
$this->assertNotNull($initAuth->payerAuthenticationRequest);
$this->assertNotNull($initAuth->acsTransactionId);
$this->assertNotNull($initAuth->providerServerTransRef);
$this->assertNotNull($initAuth->acsReferenceNumber);
$this->assertEquals("05", $initAuth->eci);
$this->assertEquals("2.2.0", $initAuth->messageVersion);


$secureEcom = Secure3dService::getAuthenticationData()
->withServerTransactionId($secureEcom->serverTransactionId)
->execute();
Expand Down
33 changes: 33 additions & 0 deletions test/Integration/Gateways/GpEcomConnector/OpenBankingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public function testFasterPaymentsCharge()
$this->assertNotNull($response);
$this->assertEquals(1, $response->totalRecordCount);
$this->assertEquals($trn->bankPaymentResponse->id, $response->result[0]->transactionId);
$this->assertNull($response->result[0]->bankPaymentResponse->iban);
$this->assertNull($response->result[0]->bankPaymentResponse->sortCode);
$this->assertNull($response->result[0]->bankPaymentResponse->accountNumber);
$this->assertNull($response->result[0]->bankPaymentResponse->accountName);
}

public function testSEPACharge()
Expand All @@ -73,6 +77,17 @@ public function testSEPACharge()
$this->assertOpenBankingResponse($trn);

// fwrite(STDERR, print_r($trn->bankPaymentResponse->redirectUrl, TRUE));
sleep(2);
$response = ReportingService::bankPaymentDetail($trn->bankPaymentResponse->id)
->execute();

$this->assertNotNull($response);
$this->assertEquals(1, $response->totalRecordCount);
$this->assertEquals($trn->bankPaymentResponse->id, $response->result[0]->transactionId);
$this->assertNull($response->result[0]->bankPaymentResponse->iban);
$this->assertNull($response->result[0]->bankPaymentResponse->sortCode);
$this->assertNull($response->result[0]->bankPaymentResponse->accountNumber);
$this->assertNull($response->result[0]->bankPaymentResponse->accountName);
}

public function testBankPaymentList()
Expand Down Expand Up @@ -417,6 +432,24 @@ public function testSEPACharge_InvalidCurrency()
}
}

public function testSEPACharge_CADCurrency()
{
$bankPayment = $this->sepaConfig();

$exceptionCaught = false;
try {
$bankPayment->charge($this->amount)
->withCurrency("CAD")
->withRemittanceReference(RemittanceReferenceType::TEXT, 'Nike Bounce Shoes')
->execute();
} catch (GatewayException $e) {
$exceptionCaught = true;
$this->assertEquals('Status Code: 400 - payment.scheme cannot be null ', $e->getMessage());
} finally {
$this->assertTrue($exceptionCaught);
}
}

private function fasterPaymentsConfig()
{
$bankPayment = new BankPayment();
Expand Down

0 comments on commit b92712f

Please sign in to comment.