Skip to content

Commit

Permalink
OctopusDeploy release: 6.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
securesubmit-buildmaster committed Mar 7, 2023
1 parent 9269134 commit e6ff4e5
Show file tree
Hide file tree
Showing 7 changed files with 346 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

## Latest Version
#### Bug Fixes:
- Portico/Heartland: fix 'withStartDate()' reporting method

#### Enhancements:
- Portico/Heartland: improvements to GooglePay and ApplePay token handling
- Portico/Heartland: simple GooglePay example added

## v6.1.5 (02/28/2023)
#### Bug Fixes:
- TSYS/Merchantware: correction to service endpoints

## v6.1.4 (02/21/2023)
Expand Down
30 changes: 30 additions & 0 deletions examples/portico/google-pay/charge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

require_once ('../../../autoload_standalone.php');

use GlobalPayments\Api\Entities\Enums\PaymentDataSourceType;
use GlobalPayments\Api\PaymentMethods\CreditCardData;
use GlobalPayments\Api\ServiceConfigs\Gateways\PorticoConfig;
use GlobalPayments\Api\ServicesContainer;

$config = new PorticoConfig();
$config->secretApiKey = 'skapi_cert_MVq4BQC5n3AAgd4M1Cvph2ud3CGaIclCgC7H_KxZaQ'; // 777703754644
ServicesContainer::configureService($config);

$card = new CreditCardData();
$card->token = $_POST['paymentReference'];
$card->paymentSource = PaymentDataSourceType::GOOGLEPAYWEB;

try {
$response = $card->charge(15)
->withCurrency('USD')
->withAllowDuplicates(true)
->execute();

echo "<h1>Success!</h1>" . PHP_EOL;

echo "<b>Your transaction Id is: </b>" . $response->transactionId;
} catch (Exception $e) {
echo 'Failure: ' . $e->getMessage();
exit;
}
290 changes: 290 additions & 0 deletions examples/portico/google-pay/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>End-to-End Payment Example</title>
<style>
.container {
width: 300px;
margin: 0 auto;
}

input,
select {
font-size: 14px;
height: 34px;
max-width: 267px;
margin-bottom: 5px;
padding: 6px 12px;
width: 267px;
}
</style>
</head>

<body>
<div class="container">
<div class="row col-xs-12">
<h1>End-to-End Example</h1>
</div>

<form class="paymentForm form-horizontal" id="paymentForm" method="POST" action="charge.php">

<!-- The Payment Form -->
<div id="container"></div>

<input id="paymentReference" type="hidden" name="paymentReference">
</form>
</div>


<script async src="https://pay.google.com/gp/p/js/pay.js" onload="onGooglePayLoaded()"></script>

<!-- latest GooglePay -->
<script>
const myConfig = {
gateway: 'globalpayments',
gatewayMerchantId: '777703754644',
environment: 'TEST',
// googleMerchantId : null, // need this for production
// googleMerchantName : null, // and this
}

/**
* Define the version of the Google Pay API referenced when creating your
* configuration
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest|apiVersion in PaymentDataRequest}
*/
const baseRequest = {
apiVersion: 2,
apiVersionMinor: 0
};

/**
* Card networks supported by your site and your gateway
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}
* @todo confirm card networks supported by your site and gateway
*/
const allowedCardNetworks = ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"];

/**
* Card authentication methods supported by your site and your gateway
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}
* @todo confirm your processor supports Android device tokens for your
* supported card networks
*/
const allowedCardAuthMethods = ["PAN_ONLY", "CRYPTOGRAM_3DS"];

/**
* Identify your gateway and your site's gateway merchant identifier
*
* The Google Pay API response will return an encrypted payment method capable
* of being charged by a supported gateway after payer authorization
*
* @todo check with your gateway on the parameters to pass
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#gateway|PaymentMethodTokenizationSpecification}
*/
const tokenizationSpecification = {
type: 'PAYMENT_GATEWAY',
parameters: {
'gateway': myConfig.gateway,
'gatewayMerchantId': myConfig.gatewayMerchantId
}
};

/**
* Describe your site's support for the CARD payment method and its required
* fields
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}
*/
const baseCardPaymentMethod = {
type: 'CARD',
parameters: {
allowedAuthMethods: allowedCardAuthMethods,
allowedCardNetworks: allowedCardNetworks
}
};

/**
* Describe your site's support for the CARD payment method including optional
* fields
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}
*/
const cardPaymentMethod = Object.assign(
{},
baseCardPaymentMethod,
{
tokenizationSpecification: tokenizationSpecification
}
);

/**
* An initialized google.payments.api.PaymentsClient object or null if not yet set
*
* @see {@link getGooglePaymentsClient}
*/
let paymentsClient = null;

/**
* Configure your site's support for payment methods supported by the Google Pay
* API.
*
* Each member of allowedPaymentMethods should contain only the required fields,
* allowing reuse of this base request when determining a viewer's ability
* to pay and later requesting a supported payment method
*
* @returns {object} Google Pay API version, payment methods supported by the site
*/
function getGoogleIsReadyToPayRequest() {
return Object.assign(
{},
baseRequest,
{
allowedPaymentMethods: [baseCardPaymentMethod]
}
);
}

/**
* Configure support for the Google Pay API
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest|PaymentDataRequest}
* @returns {object} PaymentDataRequest fields
*/
function getGooglePaymentDataRequest() {
const paymentDataRequest = Object.assign({}, baseRequest);
paymentDataRequest.allowedPaymentMethods = [cardPaymentMethod];
paymentDataRequest.transactionInfo = getGoogleTransactionInfo();
paymentDataRequest.merchantInfo = {
// @todo a merchant ID is available for a production environment after approval by Google
// See {@link https://developers.google.com/pay/api/web/guides/test-and-deploy/integration-checklist|Integration checklist}
merchantId: myConfig.googleMerchantId,
merchantName: myConfig.googleMerchantName
};
return paymentDataRequest;
}

/**
* Return an active PaymentsClient or initialize
*
* @see {@link https://developers.google.com/pay/api/web/reference/client#PaymentsClient|PaymentsClient constructor}
* @returns {google.payments.api.PaymentsClient} Google Pay API client
*/
function getGooglePaymentsClient() {
if (paymentsClient === null) {
paymentsClient = new google.payments.api.PaymentsClient({ environment: myConfig.environment });
}
return paymentsClient;
}

/**
* Initialize Google PaymentsClient after Google-hosted JavaScript has loaded
*
* Display a Google Pay payment button after confirmation of the viewer's
* ability to pay.
*/
function onGooglePayLoaded() {
const paymentsClient = getGooglePaymentsClient();
paymentsClient.isReadyToPay(getGoogleIsReadyToPayRequest())
.then(function (response) {
if (response.result) {
addGooglePayButton();
// @todo prefetch payment data to improve performance after confirming site functionality
// prefetchGooglePaymentData();
}
})
.catch(function (err) {
// show error in developer console for debugging
console.error(err);
});
}

/**
* Add a Google Pay purchase button alongside an existing checkout button
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#ButtonOptions|Button options}
* @see {@link https://developers.google.com/pay/api/web/guides/brand-guidelines|Google Pay brand guidelines}
*/
function addGooglePayButton() {
const paymentsClient = getGooglePaymentsClient();
const button =
paymentsClient.createButton({ onClick: onGooglePaymentButtonClicked });
document.getElementById('container').appendChild(button);
}

/**
* Provide Google Pay API with a payment amount, currency, and amount status
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#TransactionInfo|TransactionInfo}
* @returns {object} transaction info, suitable for use as transactionInfo property of PaymentDataRequest
*/
function getGoogleTransactionInfo() {
return {
countryCode: 'US',
currencyCode: 'USD',
totalPriceStatus: 'FINAL',
// set to cart total
totalPrice: '1.00'
};
}

/**
* Prefetch payment data to improve performance
*
* @see {@link https://developers.google.com/pay/api/web/reference/client#prefetchPaymentData|prefetchPaymentData()}
*/
function prefetchGooglePaymentData() {
const paymentDataRequest = getGooglePaymentDataRequest();
// transactionInfo must be set but does not affect cache
paymentDataRequest.transactionInfo = {
totalPriceStatus: 'NOT_CURRENTLY_KNOWN',
currencyCode: 'USD'
};
const paymentsClient = getGooglePaymentsClient();
paymentsClient.prefetchPaymentData(paymentDataRequest);
}

/**
* Show Google Pay payment sheet when Google Pay payment button is clicked
*/
function onGooglePaymentButtonClicked() {
const paymentDataRequest = getGooglePaymentDataRequest();
paymentDataRequest.transactionInfo = getGoogleTransactionInfo();

const paymentsClient = getGooglePaymentsClient();
paymentsClient.loadPaymentData(paymentDataRequest)
.then(function (paymentData) {
// handle the response
processPayment(paymentData);
})
.catch(function (err) {
// show error in developer console for debugging
console.error(err);
});
}

/**
* Process payment data returned by the Google Pay API
*
* @param {object} paymentData response from Google Pay API after user approves payment
* @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentData|PaymentData object reference}
*/
function processPayment(paymentData) {
// show returned data in developer console for debugging
console.log(paymentData);
// @todo pass payment token to your gateway to process payment
paymentToken = paymentData.paymentMethodData.tokenizationData.token;

document.getElementById("paymentReference").value = paymentToken;
document.getElementById("paymentForm").submit();
}
</script>
</body>

</html>
2 changes: 1 addition & 1 deletion metadata.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<xml>
<releaseNumber>6.1.5</releaseNumber>
<releaseNumber>6.1.6</releaseNumber>
</xml>
11 changes: 11 additions & 0 deletions src/Builders/TransactionReportBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ public function withEndDate($value)
return $this;
}

/**
*
* @param mixed $value
* @return $this
*/
public function withStartDate($value)
{
$this->searchBuilder->startDate = $value;
return $this;
}

/**
* Sets the payment type.
*
Expand Down
5 changes: 3 additions & 2 deletions src/Gateways/PorticoConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2359,8 +2359,9 @@ private function hydrateWalletData(DOMDocument $xml, BaseBuilder $builder, $bloc
$walletData->appendChild($xml->createElement('PaymentSource', $builder->paymentMethod->paymentSource));
}
if (!empty($builder->paymentMethod->token)) {
$token = $this->toFormatToken($builder->paymentMethod->token);
$walletData->appendChild($xml->createElement('DigitalPaymentToken', $token));
$token = $builder->paymentMethod->token;
$dpt = $walletData->appendChild($xml->createElement('DigitalPaymentToken'));
$dpt->appendChild($xml->createCDATASection($token));
$block1->removeChild($cardData);
}

Expand Down
Loading

0 comments on commit e6ff4e5

Please sign in to comment.