Skip to content

Commit

Permalink
Merge pull request #10 from OnTap/release0522
Browse files Browse the repository at this point in the history
Version 1.3.0
  • Loading branch information
ellenchristine authored Jul 11, 2022
2 parents dd013a8 + 115d879 commit 416ead9
Show file tree
Hide file tree
Showing 11 changed files with 379 additions and 63 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.3.0] - 2022-06-17
### Changed
- New Hosted Checkout integration is introduced

### Fixed
- The version of the plugin is displayed incorrectly in the Admin Panel


## [1.2.1] - 2021-12-01
### Fixed
- Fixed an error "invalid request" for Order if Customer clicks Browser Back button from Order Success Page
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The module has been tested with the WooCommerce versions:
- 5.5.2
- 6.0.0
- 6.2.1
- 6.4.0

The module has been tested with the WordPress versions:

Expand Down Expand Up @@ -43,7 +44,7 @@ WooCommerce Mastercard Payment Gateway Service module supports following list of
- AVS
- 3DSv1
- 3DSv2
- Tokenisation
- Tokenization

## Documentation

Expand All @@ -54,7 +55,7 @@ The official documentation for this module is available on: [http://ontap.wiki/w
You can obtain the module by downloading a release from: https://github.com/Mastercard-Gateway/gateway-woocommerce-module/releases
## Installation of Module
To use WooCommerce MPGS for WordPress, you need to install both the MasterCard Payment Gateway Services module and the WooCommerce module.
### Steps to install WooCommerce for Wordpress:
### Steps to install WooCommerce for WordPress:
Follow the below steps:
1. Connect to Backoffice of your shop with the available admin credentials.
2. Go to **Plugins > Add New** on your WordPress site.
Expand All @@ -63,9 +64,9 @@ Follow the below steps:
4. Click **Install Now** and **Activate**.
![](images/2.png)
5. Once the installation is complete, we need to configure the WooCommerce as per the steps in https://docs.woocommerce.com/document/woocommerce-setup-wizard/
### Steps to install MasterCard Payment Gateway Services for Wordpress
### Steps to install MasterCard Payment Gateway Services for WordPress
Follow the below steps:
1. There are two ways to install the plugin into Wordpress, either:
1. There are two ways to install the plugin into WordPress, either:
1.1 Download the gateway-woocommerce-module plugin zip file from https://github.com/Mastercard-Gateway/gateway-woocommerce-module/releases and extract to the /wp-content/plugins/ directory,
**or**
1.2. Connect to Backoffice of your shop with the available admin credentials and install the plugin through the WordPress plugins screen directly.
Expand All @@ -88,16 +89,16 @@ Once you have installed the MasterCard Payment Gateway Services module, you can
3. Locate "MasterCard Payment Gateway Services" and then click the "Manage" button.
![](images/7.png)
3. The gateway configuration fields will be displayed. Configure according to your requirements and then click on the "Save Changes" button.
- **Enable/Disable** - Tick the checkbox to make this Payment option available in the frontend. Un-tick it to Disable it so it will not display in the frontend.
- **Enable/Disable** - Tick the checkbox to make this Payment option available in the frontend. Un-tick it to Disable it, so it will not display in the frontend.
- **Title** - Short payment method name displayed to the payer on the checkout page. Example, "Credit Card / Debit Card".
- **Description** - Description of this Payment Method displayed when a payer selects this payment method. Example, "Pay with your card via Mastercard".
- **Gateway** - The payment gateway region, use Custom Gateway Host if one has been provided to you. Four options are available: Europe, Asia Pacific. North America, and Custom URL.
- **Custom Gateway Host** - This option is available when the 'Gateway' option is set to 'Custom Gateway Host' . Your Account Manager will tell you if this is needed or not.
- **Custom Gateway Host** - This option is available when the "Gateway" option is set to "Custom Gateway Host" . Your Account Manager will tell you if this is needed or not.
- **Transaction Mode** - In "Purchase" mode, the customer is charged immediately. In Authorize mode, the transaction is only authorized, and the capturing of funds is a manual process performed by you using the Woocommerce admin panel. The Manual capture process is explained in the next section.
- **Integration Model** - In "Hosted Checkout", the payer will type their details into the gateway's payment page. In "Hosted Session", the payer will remain on the woocommerce payment page.
- **Checkout Interaction** - This option is available when the 'Payment Model' option is set to 'Hosted Checkout' and allows to choose redirection behavior to the payment gateway. Either in the "Lightbox" or "Redirect Payment Page".
- **3D-Secure** - This option is available when the 'Payment Model' option is set to 'Hosted Session'. Tick the checkbox of "Use 3D-Secure" to Enable it. Be sure to Enable 3D-Secure in your Mastercard account. Un-tick it to Disable it. Hosted Checkout will present 3D-Secure authentication when configured by your payment service provider.
- **Saved Cards** - This option is available when the 'Payment Model' option is set to 'Hosted Session'. Tick the checkbox of "Enable Payment via Saved Cards" to Enable it. If enabled, payer will be able to pay with a previously saved card during checkout. Card details are saved on payment gateway, not on your store. Un-tick it to Disable it.
- **Integration Model** - In "Hosted Checkout" and "Legacy Hosted Checkout", the payer will type their details into the gateway"s payment page. In "Hosted Session", the payer will remain on the woocommerce payment page.
- **Checkout Interaction** - This option is available when the "Payment Model" option is set to "Hosted Checkout" or "Legacy Hosted Checkout" and allows to set redirection behavior to the payment gateway. Either "Embedded" or "Redirect to Payment Page" for contemporary version Hosted Checkout or Either "Lightbox" or "Redirect to Payment Page" for Legacy Hosted Checkout.
- **3D-Secure** - This option is available when the "Payment Model" option is set to "Hosted Session". Tick the checkbox of "Use 3D-Secure" to Enable it. Be sure to Enable 3D-Secure in your Mastercard account. Un-tick it to Disable it. Hosted Checkout will present 3D-Secure authentication when configured by your payment service provider.
- **Saved Cards** - This option is available when the "Payment Model" option is set to "Hosted Session". Tick the checkbox of "Enable Payment via Saved Cards" to Enable it. If enabled, payer will be able to pay with a previously saved card during checkout. Card details are saved on payment gateway, not on your store. Un-tick it to Disable it.
- **Debug Logging** - When ticked, the file ./wp-content/mastercard.log will include additional logging including all communication with the gateway. Debug logging is only available in test sandbox mode.
- **Test Sandbox** - Tick the checkbox of "Enable Sandbox Mode" to Enable it. If enabled, it places the payment gateway in test mode using test API credentials (real payments will not be taken). Un-tick it to Disable it. If disabled, it will take the real payments.
- **Merchant ID** - Insert your account Merchant ID. Gateway Merchant Administrator: Admin > Integration Settings.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.2.1",
"version": "1.3.0",
"type": "woocommerce-plugin",
"require": {
"php-http/curl-client": "^1.7",
Expand Down
14 changes: 12 additions & 2 deletions includes/assets/js/mastercard-admin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2021 Mastercard
* Copyright (c) 2019-2022 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,7 @@ jQuery(function ($) {
password = $('#woocommerce_mpgs_gateway_password').parents('tr').eq(0),
threedsecure = $('#woocommerce_mpgs_gateway_threedsecure').parents('tr').eq(0),
gateway_url = $('#woocommerce_mpgs_gateway_custom_gateway_url').parents('tr').eq(0),
hc_interaction = $('#woocommerce_mpgs_gateway_hc_interaction').parents('tr').eq(0),
hc_type = $('#woocommerce_mpgs_gateway_hc_type').parents('tr').eq(0),
saved_cards = $('#woocommerce_mpgs_gateway_saved_cards').parents('tr').eq(0);

Expand All @@ -42,14 +43,23 @@ jQuery(function ($) {
}).change();

$('#woocommerce_mpgs_gateway_method').on('change', function () {
if ($(this).val() === 'hostedcheckout') {
if ($(this).val() === 'newhostedcheckout') {
// Hosted Checkout
threedsecure.hide();
hc_interaction.show();
hc_type.hide();
saved_cards.hide();
} else if ($(this).val() === 'hostedcheckout') {
// Legacy Hosted Checkout
// @todo Remove after removal of Legacy Hosted Checkout
threedsecure.hide();
hc_interaction.hide();
hc_type.show();
saved_cards.hide();
} else {
// Hosted Session
threedsecure.show();
hc_interaction.hide();
hc_type.hide();
saved_cards.show();
}
Expand Down
26 changes: 25 additions & 1 deletion includes/class-checkout-builder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2019-2021 Mastercard
* Copyright (c) 2019-2022 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -152,6 +152,30 @@ public function getOrder() {
* @return array
*/
public function getInteraction( $capture = true, $returnUrl = null ) {
return array(
'merchant' => array(
'name' => esc_html( get_bloginfo( 'name', 'display' ) )
),
'returnUrl' => $returnUrl,
'displayControl' => array(
'customerEmail' => 'HIDE',
'billingAddress' => 'HIDE',
'paymentTerms' => 'HIDE',
'shipping' => 'HIDE',
),
'operation' => $capture ? 'PURCHASE' : 'AUTHORIZE',
);
}

/**
* @param bool $capture
* @param string|null $returnUrl
*
* @return array
* @deprecated
*
*/
public function getLegacyInteraction( $capture = true, $returnUrl = null ) {
return array(
'operation' => $capture ? 'PURCHASE' : 'AUTHORIZE',
'merchant' => array(
Expand Down
68 changes: 64 additions & 4 deletions includes/class-gateway-service.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2019-2021 Mastercard
* Copyright (c) 2019-2022 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -413,6 +413,61 @@ public function check3dsEnrollment( $data, $order, $session = null, $source_of_f
return $response;
}


/**
* Initiate Checkout
* Request to create a session identifier for the checkout interaction.
* The session identifier, when included in the Checkout.configure() function,
* allows you to return the payer to the merchant's website after completing the payment attempt.
* https://mtf.gateway.mastercard.com/api/rest/version/63/merchant/{merchantId}/session
*
* @param array $order
* @param array $interaction
* @param array $customer
* @param array $billing
* @param array $shipping
*
* @return array
* @throws Exception
* @throws Mastercard_GatewayResponseException
*/
public function initiateCheckout(
$order = array(),
$interaction = array(),
$customer = array(),
$billing = array(),
$shipping = array()
) {
$txnId = uniqid( sprintf( '%s-', $order['id'] ) );
$uri = $this->apiUrl . 'session';

$requestData = array(
'apiOperation' => 'INITIATE_CHECKOUT',
'partnerSolutionId' => $this->getSolutionId(),
'order' => array_merge( $order, array(
'notificationUrl' => $this->webhookUrl,
'reference' => $order['id']
) ),
'billing' => $billing,
'shipping' => $shipping,
'interaction' => $interaction,
'customer' => $customer,
'transaction' => [
'reference' => $txnId,
'source' => 'INTERNET',
]
);

$request = $this->messageFactory->createRequest( 'POST', $uri, array(), json_encode( $requestData ) );

$response = $this->client->sendRequest( $request );
$response = json_decode( $response->getBody(), true );

$this->validateCheckoutSessionResponse( $response );

return $response;
}

/**
* Create Checkout Session
* Request to create a session identifier for the checkout interaction.
Expand All @@ -429,6 +484,8 @@ public function check3dsEnrollment( $data, $order, $session = null, $source_of_f
* @return array
* @throws Exception
* @throws Mastercard_GatewayResponseException
*
* @todo Remove with Legacy Hosted Checkout
*/
public function createCheckoutSession(
$order = array(),
Expand All @@ -452,7 +509,8 @@ public function createCheckoutSession(
'interaction' => $interaction,
'customer' => $customer,
'transaction' => [
'reference' => $txnId
'reference' => $txnId,
'source' => 'INTERNET',
]
);

Expand Down Expand Up @@ -598,7 +656,8 @@ public function authorize(
'customer' => $customer,
'session' => $session,
'transaction' => [
'reference' => $txnId
'reference' => $txnId,
'source' => 'INTERNET',
]
);

Expand Down Expand Up @@ -664,7 +723,8 @@ public function pay(
'customer' => $customer,
'session' => $session,
'transaction' => [
'reference' => $txnId
'reference' => $txnId,
'source' => 'INTERNET',
]
);

Expand Down
Loading

0 comments on commit 416ead9

Please sign in to comment.