Skip to content

Commit

Permalink
Resolved installment issue when card is saved in shortcode setup
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishgurung committed Nov 18, 2024
1 parent de1c335 commit 91bf48b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 29 deletions.
38 changes: 13 additions & 25 deletions assets/javascripts/omise-payment-form-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,15 @@
}

function omiseInstallmentFormHandler() {
function getSelectedCardId() {
const $selected_card_id = $("input[name='card_id']:checked");
if ($selected_card_id.length > 0) {
return $selected_card_id.val();
}

return "";
if (!$('#payment_method_omise_installment').is(':checked')) {
return true;
}

if ($('#payment_method_omise_installment').is(':checked')) {
if (getSelectedCardId() !== "") {
//submit the form right away if the card_id is not blank
return true;
}

if (0 === $('input.omise_token').length && 0 === $('input.omise_source').length) {
requestCardToken();
return false;
}
return true;
if (0 === $('input.omise_token').length && 0 === $('input.omise_source').length) {
requestCardToken();
return false;
}

return true;
}

Expand Down Expand Up @@ -272,13 +260,13 @@

function setupOmiseForm() {
var selectedPaymentMethod = $('input[name="payment_method"]:checked').val();
if (selectedPaymentMethod === 'omise') {
initializeSecureCardForm();
} else if (selectedPaymentMethod === 'omise_installment') {
initializeInstallmentForm();
} else {
OmiseCard.destroy();
}
if (selectedPaymentMethod === 'omise') {
initializeSecureCardForm();
} else if (selectedPaymentMethod === 'omise_installment') {
initializeInstallmentForm();
} else {
OmiseCard.destroy();
}
}

$(function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'e2436da6ade36f0dc6835eb771337040');
<?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '34ae2a7f9367048bb27a58ad9955227b');
2 changes: 1 addition & 1 deletion includes/blocks/assets/js/build/omise_installment.js

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

2 changes: 1 addition & 1 deletion includes/blocks/assets/js/omise-installment.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Label = ( props ) => {
}

const {select, subscribe} = window.wp.data;
const cartStoreKey = window.wc.wcBlocksData.CART_STORE_KEY;
const cartStoreKey = window.wc.wcBlocksData ? window.wc.wcBlocksData.CART_STORE_KEY : '';

const InstallmentPaymentMethod = (props) => {
const {eventRegistration, emitResponse} = props;
Expand Down
1 change: 0 additions & 1 deletion includes/gateway/class-omise-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ protected function payment_failed( $reason ) {
$this->order()->update_status( 'failed' );
}

wc_add_notice( sprintf( wp_kses( $message, array( 'br' => array() ) ), __( $reason, 'omise' ) ), 'error' );
throw new \Exception(sprintf( wp_kses( $message, array( 'br' => array() ) ), __( $reason, 'omise' ) ));
}

Expand Down

0 comments on commit 91bf48b

Please sign in to comment.