Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TR-68: BNPL integration #41

Open
wants to merge 47 commits into
base: release/next-release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c52fc55
TR-71: add bnpl affirm
apetrovici Nov 9, 2022
29097d6
Merge branch 'release/next-release' into feature/tr-68-bnpl
apetrovici Nov 9, 2022
d0d9b58
change format
apetrovici Nov 9, 2022
4efbbef
TR-68: update bnpl request
apetrovici Nov 23, 2022
b094004
TR-68: update notification endpoints
apetrovici Dec 2, 2022
19db60f
TR-68: update request customer data
apetrovici Dec 2, 2022
122ff59
Merge branch 'globalpayments:main' into feature/tr-68-bnpl-duplicate
apetrovici Dec 2, 2022
3157970
update
apetrovici Dec 2, 2022
ede4f55
Test change
CatalinMatea Dec 5, 2022
7356ae6
Revert test change
CatalinMatea Dec 5, 2022
53b1e08
TR-68: add Clearpay/Klarna, toggle refactor
CatalinMatea Dec 5, 2022
ff41ba5
TR-68: add view transaction info feature for bnpl
CatalinMatea Dec 7, 2022
58d7f16
TR-68: remove extra lines
CatalinMatea Dec 7, 2022
ff15a1f
TR-68: add nonce and is admin verifications for view transaction info
CatalinMatea Dec 8, 2022
00da4c0
TR-68: update bnpl request
apetrovici Dec 16, 2022
a32b500
composer update
apetrovici Dec 20, 2022
4fd45b0
TR-68: update bnpl availability
apetrovici Jan 10, 2023
c9af814
TR-68: add status endpoint, validate post requests
CatalinMatea Jan 10, 2023
0ca2668
TR-68: add status endpoint, validate post requests
CatalinMatea Jan 10, 2023
9a36bbf
TR-68: bug fix settings save
apetrovici Jan 12, 2023
8e8b784
TR-68: change match to switch
CatalinMatea Jan 12, 2023
f2851c1
TR-68: bug fix virtual products required zipcode
apetrovici Jan 12, 2023
9b95eca
TR-68: update post request validation
CatalinMatea Jan 13, 2023
f6d62b9
Merge branch 'feature/tr-68-bnpl-duplicate' of https://github.com/ape…
CatalinMatea Jan 13, 2023
715357e
Merge branch 'release/next-release' into feature/tr-68-bnpl-duplicate
apetrovici Jan 18, 2023
93d276c
TR-68: bug fix toggle place order button
apetrovici Jan 18, 2023
b864049
TR-68: bug fix include script once
apetrovici Jan 18, 2023
7458f46
TR-68: filter fix
apetrovici Jan 19, 2023
9609fcf
TR-68: handle GP JS lib error update
apetrovici Jan 20, 2023
c80d175
TR-68: bug fix pay order 3ds
apetrovici Jan 20, 2023
dbcf2a4
TR-68: bnpl method availability update
apetrovici Jan 20, 2023
6fddd8e
TR-68: refactor get transaction details
apetrovici Jan 23, 2023
d6f3020
TR-68: refactor notification urls
apetrovici Jan 23, 2023
8ea554b
TR-68: refactor initiate
apetrovici Jan 23, 2023
53750a5
TR-68: refactor initiate
apetrovici Jan 25, 2023
5432fb3
TR-68: sdk version update
apetrovici Jan 25, 2023
2db7627
TR-68: refactor user message
apetrovici Jan 25, 2023
08af807
TR-68: bug fix capture
apetrovici Jan 26, 2023
7478719
TR-68: remove comment
apetrovici Jan 26, 2023
7fcbf12
TR-68: update user message on return url
apetrovici Jan 26, 2023
d417435
TR-68: bug fix back button
apetrovici Feb 1, 2023
0def18a
TR-68: bug fix back button
apetrovici Feb 1, 2023
171dddb
TR-68: bug fix back button
apetrovici Feb 2, 2023
2943a3c
TR-68: update country availability
apetrovici Feb 3, 2023
e29d958
TR-68: add shipping item
apetrovici Feb 9, 2023
af92476
Merge branch 'release/next-release' into feature/tr-68-bnpl-duplicate
apetrovici Feb 9, 2023
6f4d225
TR-68: update initiate request
apetrovici Feb 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion assets/admin/css/globalpayments-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
margin:0;
}

.woocommerce-globalpayments-checkout-error {
.woocommerce-globalpayments-checkout-error,
.wc-globalpayments-transaction-info-error {
background-color:#e2401c;
margin-left:0;
margin-bottom:10px;
Expand All @@ -21,3 +22,25 @@
min-height:32px;
width:auto;
}

.wc-transaction-info table {
border-collapse: collapse;
width: 100%;
}

.wc-transaction-info td {
text-align: left;
padding: 8px;
}

.wc-transaction-info tr:nth-child(odd) {
background-color: #f2f2f2;
}

.wc-transaction-info td:first-child {
float: left;
}

.wc-transaction-info td:last-child {
float: right;
}
68 changes: 63 additions & 5 deletions assets/admin/js/globalpayments-admin.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* global globalpayments_admin_params */

( function(
(function (
$,
globalpayments_admin_params
globalpayments_admin_params,
globalpayments_admin_txn_params
) {
function GlobalPaymentsAdmin( globalpayments_admin_params ) {
function GlobalPaymentsAdmin( globalpayments_admin_params, globalpayments_admin_txn_params ) {
this.id = globalpayments_admin_params.gateway_id;
this.toggleCredentialsSettings();
this.toggleValidations();
Expand All @@ -21,10 +22,12 @@
$( document ).on( 'change', this.getLiveModeSelector(), this.toggleCredentialsSettings.bind( this ) );
$( document ).on( 'change', this.getEnabledGatewaySelector(), this.toggleValidations.bind( this ) );
$( document ).on( 'change', $( '.accepted_cards.required' ), this.validate_cc_types.bind( this ) );

// Admin Pay for Order
$( '#customer_user' ).on( 'change', this.updatePaymentMethods );
$( '.wc-globalpayments-pay-order' ).on( 'click', this.payForOrder );
// Admin View Transaction Details
$( '.wc-globalpayments-transaction-info' ).on( 'click', this.viewTransactionStatus );
$( document.body ).on('wc_backbone_modal_loaded', this.modalLoaded.bind( this ) );
},

Expand Down Expand Up @@ -61,6 +64,57 @@
});
},

/**
* Enable modal template.
*
* @param e
*/
viewTransactionStatus: function ( e ) {
e.preventDefault();
const transactionInfo = GlobalPaymentsAdmin.transactionInfo = $(this);
if ( transactionInfo.data( 'transaction-info' ) ) {
$( this ).WCBackboneModal({
template: 'wc-globalpayments-transaction-info-modal',
variable: {
transaction_info: $( this ).data( 'transaction-info' )
}
});
} else {
$( '.wc-globalpayments-transaction-info' ).prop( 'disabled', true );

$.ajax({
url: globalpayments_admin_txn_params.transaction_info_url,
method: 'POST',
data: {
_wpnonce: globalpayments_admin_txn_params._wpnonce,
transactionId: globalpayments_admin_txn_params.transaction_id
}
}).done( function ( response ) {
if ( response.error ) {
$( this ).WCBackboneModal({
template: 'wc-globalpayments-transaction-info-modal',
variable: {
error_message: response.message
}
});
} else {
transactionInfo.data( 'transaction-info', response );

$( this ).WCBackboneModal({
template: 'wc-globalpayments-transaction-info-modal',
variable: {
transaction_info: response
}
});
}
}).fail( function (xhr, textStatus, errorThrown) {
window.alert(errorThrown);
}).always( function () {
$( '.wc-globalpayments-transaction-info' ).prop( 'disabled', false );
})
}
},

/**
* Render modal content.
*
Expand All @@ -73,6 +127,9 @@
$( document.body ).trigger( 'globalpayments_pay_order_modal_loaded' );
$( document.body ).trigger( 'wc-credit-card-form-init' );
break;
case 'wc-globalpayments-transaction-info-modal':
$( document.body ).trigger( 'globalpayments_transaction_info_modal_loaded' );
break;
}
},

Expand Down Expand Up @@ -177,7 +234,7 @@
return '#woocommerce_' + this.id + '_enabled';
}
};
new GlobalPaymentsAdmin( globalpayments_admin_params );
new GlobalPaymentsAdmin( globalpayments_admin_params, globalpayments_admin_txn_params );
}(
/**
* Global `jQuery` reference
Expand All @@ -191,4 +248,5 @@
* @type {any}
*/
(window).globalpayments_admin_params || {},
(window).globalpayments_admin_txn_params || {}
));
15 changes: 10 additions & 5 deletions assets/admin/js/globalpayments-enforce-single-gateway.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
( function( $ ) {
( function(
$,
single_toggle_gateways
) {
$( function() {
var digitalWallet = [ 'globalpayments_googlepay', 'globalpayments_applepay' ];
// Toggle GlobalPayments gateway on/off.
$( '[data-gateway_id^="globalpayments_"]' ).on( 'click', '.wc-payment-gateway-method-toggle-enabled', function() {
var toggle = true;

if ( digitalWallet.includes( $( this ).closest( 'tr' ).data( 'gateway_id' ) ) ) {
if ( ! single_toggle_gateways.includes( $( this ).closest( 'tr' ).data( 'gateway_id' ) ) ) {
return;
}

Expand All @@ -18,7 +20,7 @@
var clicked = $( this ).closest( 'tr' ).data( 'gateway_id' );
$( '[data-gateway_id^="globalpayments_"]' ).each( function() {
if ( ! $( this ).find( 'span.woocommerce-input-toggle--disabled' ).length > 0 ) {
if ( ! digitalWallet.includes( $( this ).data( 'gateway_id' ) ) && ! digitalWallet.includes( clicked ) ) {
if ( single_toggle_gateways.includes( $( this ).data( 'gateway_id' ) ) && single_toggle_gateways.includes( clicked ) ) {
var gateway_title = $( this ).closest( 'tr' ).find( 'a.wc-payment-gateway-method-title' ).text();
window.alert( 'You can enable only one GlobalPayments gateway at a time. ' +
'Please disable ' + gateway_title + ' first!' );
Expand All @@ -32,4 +34,7 @@
});
});

})( jQuery );
})(
(window).jQuery,
(window).globalpayments_enforce_single_gateway_params || []
);
16 changes: 9 additions & 7 deletions assets/frontend/js/globalpayments-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@
toggleSubmitButtons: function () {
var selectedPaymentGatewayId = $( '.payment_methods input.input-radio:checked' ).val();
var isGPGateway = selectedPaymentGatewayId.search( 'globalpayments' ) >= 0;
var submitButtonTarget = $( this.getSubmitButtonTargetSelector( selectedPaymentGatewayId ) );
var placeOrderButton = $( this.getPlaceOrderButtonSelector() );

$( '.globalpayments.card-submit' ).hide();

// another payment method was selected
if ( ! isGPGateway ) {
$( this.getPlaceOrderButtonSelector() ).removeClass( 'woocommerce-globalpayments-hidden' ).show();
// another payment method was selected or target button doesn't exists
if ( ! isGPGateway || ! submitButtonTarget.length ) {
placeOrderButton.removeClass( 'woocommerce-globalpayments-hidden' ).show();
return;
}

Expand All @@ -112,13 +114,13 @@
var newSavedCardSelected = 'new' === $( this.getStoredPaymentMethodsRadioSelector( selectedPaymentGatewayId ) + ':checked' ).val();
// selected payment method is card or digital wallet
if ( ! savedCardsAvailable || savedCardsAvailable && newSavedCardSelected ) {
$( this.getSubmitButtonTargetSelector( selectedPaymentGatewayId ) ).show();
$( this.getPlaceOrderButtonSelector() ).addClass( 'woocommerce-globalpayments-hidden' ).hide();
submitButtonTarget.show();
placeOrderButton.addClass( 'woocommerce-globalpayments-hidden' ).hide();
} else {
// selected payment method is stored card
$( this.getSubmitButtonTargetSelector( selectedPaymentGatewayId ) ).hide();
submitButtonTarget.hide();
// show platform `Place Order` button
$( this.getPlaceOrderButtonSelector() ).removeClass( 'woocommerce-globalpayments-hidden' ).show();
placeOrderButton.removeClass( 'woocommerce-globalpayments-hidden' ).show();
}
},

Expand Down
12 changes: 8 additions & 4 deletions assets/frontend/js/globalpayments-secure-payment-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@
$( document ).ready( this.renderPaymentFields.bind( this ) );
$( document ).ready( function () {
$( helper.getPlaceOrderButtonSelector() ).on( 'click', function ( $e ) {
$e.preventDefault();
$e.stopImmediatePropagation();
self.threeDSecure();
var selectedPaymentGatewayId = $( '.payment_methods input.input-radio:checked' ).val();
if ( 'globalpayments_gpapi' === selectedPaymentGatewayId ) {
$e.preventDefault();
$e.stopImmediatePropagation();
self.threeDSecure();
}
return;
} );
} );
Expand Down Expand Up @@ -224,6 +227,8 @@
}

GlobalPayments.configure( gatewayConfig );
GlobalPayments.on( 'error', this.handleErrors.bind( this ) );

this.cardForm = GlobalPayments.ui.form(
{
fields: this.getFieldConfiguration(),
Expand All @@ -234,7 +239,6 @@
this.cardForm.on( 'token-success', this.handleResponse.bind( this ) );
this.cardForm.on( 'token-error', this.handleErrors.bind( this ) );
this.cardForm.on( 'error', this.handleErrors.bind( this ) );
GlobalPayments.on( 'error', this.handleErrors.bind( this ) );

// match the visibility of our payment form
this.cardForm.ready( function () {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
},
"require": {
"globalpayments/php-sdk": "6.0.0",
"globalpayments/php-sdk": "6.0.5",
"psr/log": "^1.1"
},
"require-dev": {
Expand Down
Loading