Payment Method¶
Payment-method is a lightweight plugin which used to help determine the type of credit card being used and set, or update, the payment method field for order submission on the Checkout: Payment Information page in Miva Merchant.
Installation¶
-
Add the following to your
OPAY.js
file:import paymentMethod from 'extensions/payment-method';
-
Add the following logic to your
OPAY.js
file. paymentMethod takes two arguments, input & call back function.paymentMethod(input, function (paymentDetected) { if (!paymentDetected) { return; }
Example Usage¶
This example the paymentMethod function is returning if the payment is not detected.
.js¶
import paymentMethod from 'extensions/payment-method';
const detectPaymentMethod = function (input) {
if (isNaN(input.value)) {
input.classList.add('has-error');
}
paymentMethod(input, function (paymentDetected) {
if (!paymentDetected) {
return;
}
input.classList.remove('has-error');
if (paymentMethodDisplays.length) {
for (const paymentMethodDisplay of paymentMethodDisplays) {
paymentMethodDisplay.innerText = paymentDetected.display;
}
}
if (paymentMethods.length) {
for (const payMethod of paymentMethods) {
payMethod.value = window.supportedPaymentMethods.findPaymentMethod(paymentDetected.name);
}
}
});
};