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

Add support for Apple Pay in Popup #112

Open
wants to merge 1 commit into
base: release/5.8.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 22 additions & 12 deletions assets/js/paystack.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
jQuery( function( $ ) {

$('head').append('<style>.merchant-logo img, img.merchant-logo { max-height: 30px !important; width: auto; }</style>');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be removed? I guess this is overriding a global style applied by Paystack?

let paystack_submit = false;

$( '#wc-paystack-form' ).hide();
Expand All @@ -13,6 +14,7 @@ jQuery( function( $ ) {
jQuery( '#paystack_form form#order_review' ).submit( function() {
return wcPaystackFormHandler();
} );


function wcPaystackCustomFields() {

Expand Down Expand Up @@ -189,11 +191,11 @@ jQuery( function( $ ) {
} );
};

let paymentData = {
const paymentData = {
key: wc_paystack_params.key,
email: wc_paystack_params.email,
amount: amount,
ref: wc_paystack_params.txnref,
reference: wc_paystack_params.txnref,
currency: wc_paystack_params.currency,
subaccount: subaccount_code,
bearer: charges_account,
Expand All @@ -203,20 +205,28 @@ jQuery( function( $ ) {
},
onSuccess: paystack_callback,
onCancel: () => {
$( '#wc-paystack-form' ).show();
$( this.el ).unblock();
$('#wc-paystack-form').show();
$(this.el).unblock();
}
};

if ( Array.isArray( wcPaymentChannels() ) && wcPaymentChannels().length ) {
paymentData[ 'channels' ] = wcPaymentChannels();
if ( !$.isEmptyObject( wcPaystackCustomFilters() ) ) {
paymentData[ 'metadata' ][ 'custom_filters' ] = wcPaystackCustomFilters();
if (Array.isArray(wcPaymentChannels()) && wcPaymentChannels().length) {
paymentData.channels = wcPaymentChannels();
if (!$.isEmptyObject(wcPaystackCustomFilters())) {
paymentData.metadata.custom_filters = wcPaystackCustomFilters();
}
}

const paystack = new PaystackPop();
paystack.newTransaction( paymentData );

try {
const paystack = new PaystackPop();
paystack.checkout(paymentData).then(function(transaction) {
console.log('Transaction:', transaction);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove logging to the console.

}).catch(function(error) {
console.error('Paystack checkout error:', error);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove logging to the console.

});
} catch (error) {
console.error('Paystack checkout error:', error);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove logging to the console.

}
}

} );
2 changes: 1 addition & 1 deletion assets/js/paystack.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.