CSR-2130 flag applePay for backend
CSR-2130 flag applePay for backend
This commit is contained in:
parent
acbbd6de2b
commit
6fec862fbf
4 changed files with 70 additions and 21 deletions
|
|
@ -6,4 +6,5 @@ export const paymentMethods = {
|
|||
AFTERPAY: "Afterpay",
|
||||
PAY_NOW: "PayNow",
|
||||
INSURANCE: "Insurance",
|
||||
APPLE_PAY: "ApplePay",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ export default {
|
|||
console.log("Error during payment: " + piaError);
|
||||
const paymentPageNavScenario =
|
||||
store.getters.order.payment.piaType === paymentMethods.CREDIT_CARD ||
|
||||
store.getters.order.payment.piaType === paymentMethods.APPLE_PAY ||
|
||||
store.getters.order.payment.piaType === paymentMethods.AFTERPAY;
|
||||
if (paymentPageNavScenario) {
|
||||
this.$router.navigateWithoutSaving(
|
||||
|
|
@ -45,13 +46,41 @@ export default {
|
|||
);
|
||||
}
|
||||
} else {
|
||||
const card_expirationMonth = getQuerystringParameter(
|
||||
queryStrings.CARD_EXPIRATION_MONTH
|
||||
);
|
||||
if (card_expirationMonth) {
|
||||
await this.processCreditCardResponse();
|
||||
} else {
|
||||
await this.processPaypalResponse();
|
||||
switch (store.getters.order.payment.piaType) {
|
||||
case paymentMethods.CREDIT_CARD:
|
||||
case paymentMethods.APPLE_PAY:
|
||||
case paymentMethods.AFTERPAY:
|
||||
await this.processCreditCardResponse();
|
||||
break;
|
||||
case paymentMethods.PAYPAL:
|
||||
await this.processPaypalResponse();
|
||||
break;
|
||||
default: {
|
||||
// If we're here, the payment-method did not get properly set in
|
||||
// payment.vue method handleIFrameContentWindowMessage, we will look and see if
|
||||
// if we can default it to credit card. The payment method type is most likely still
|
||||
// set to PayNow originally set in payment-method.vue
|
||||
const lastFour = getQuerystringParameter(queryStrings.LAST_FOUR);
|
||||
if (lastFour) {
|
||||
console.log(new Date() + ": Payment method credit card selected by default");
|
||||
this.dispatchStoreAction(
|
||||
storeActions.SAVE_PAYMENT_METHOD_CHOICE,
|
||||
paymentMethods.CREDIT_CARD,
|
||||
false
|
||||
);
|
||||
await this.processCreditCardResponse();
|
||||
}
|
||||
else {
|
||||
var msg = "Unknown Pia type: " + store.getters.order.payment.piaType;
|
||||
console.log(msg);
|
||||
this.$router.navigateWithoutSaving(
|
||||
this.navigationScenarios.PIA_ERROR,
|
||||
this.$route,
|
||||
{},
|
||||
{ [routerParams.DISPLAY_PIA_ALERT]: true }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -60,12 +89,6 @@ export default {
|
|||
return true;
|
||||
},
|
||||
async processPaypalResponse() {
|
||||
await this.dispatchStoreAction(
|
||||
storeActions.SAVE_PAYMENT_METHOD_CHOICE,
|
||||
paymentMethods.PAYPAL,
|
||||
false
|
||||
);
|
||||
|
||||
const token = getQuerystringParameter(queryStrings.TOKEN);
|
||||
const payerId = getQuerystringParameter(queryStrings.PAYERID);
|
||||
|
||||
|
|
@ -79,12 +102,6 @@ export default {
|
|||
await this.saveAndSubmitWorkOrder();
|
||||
},
|
||||
async processCreditCardResponse() {
|
||||
await this.dispatchStoreAction(
|
||||
storeActions.SAVE_PAYMENT_METHOD_CHOICE,
|
||||
paymentMethods.CREDIT_CARD,
|
||||
false
|
||||
);
|
||||
|
||||
const subscriptionID = getQuerystringParameter(queryStrings.SUBSCRIPTIONID);
|
||||
|
||||
const referralSeqNum = getQuerystringParameter(queryStrings.REFERRAL_SEQ_NUM);
|
||||
|
|
|
|||
|
|
@ -669,12 +669,15 @@ export default {
|
|||
if (iframe.contentWindow) {
|
||||
if (isApplePayAvailable) {
|
||||
iframe.contentWindow.postMessage("hybrid-with-applepay", "*");
|
||||
console.log(new Date() + ": Sent applepay");
|
||||
}
|
||||
|
||||
if (this.paymentType == "cc") {
|
||||
iframe.contentWindow.postMessage("CreditCardChosen", "*");
|
||||
console.log(new Date() + ": Sent creditcard");
|
||||
} else if (this.paymentType == "ap") {
|
||||
iframe.contentWindow.postMessage("afterpay", "*");
|
||||
console.log(new Date() + ": Sent afterpay");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -698,10 +701,37 @@ export default {
|
|||
this.backButtonAction();
|
||||
}
|
||||
if (event.data.indexOf("creditCardSubmit") > -1) {
|
||||
console.log(new Date() + ": Payment method credit card selected");
|
||||
this.dispatchStoreAction(
|
||||
storeActions.SAVE_PAYMENT_METHOD_CHOICE,
|
||||
paymentMethods.CREDIT_CARD,
|
||||
false
|
||||
);
|
||||
this.setUIBlock(true);
|
||||
}
|
||||
if (event.data.indexOf("hybrid") > -1) {
|
||||
this.setUIBlock(true);
|
||||
if (event.data.indexOf("afterpayPaymentReceived") > -1) {
|
||||
console.log(new Date() + ": Payment method afterpay selected");
|
||||
this.dispatchStoreAction(
|
||||
storeActions.SAVE_PAYMENT_METHOD_CHOICE,
|
||||
paymentMethods.AFTERPAY,
|
||||
false
|
||||
);
|
||||
}
|
||||
if (event.data.indexOf("applepayOpened") > -1) {
|
||||
console.log(new Date() + ": Payment method applepay selected");
|
||||
this.dispatchStoreAction(
|
||||
storeActions.SAVE_PAYMENT_METHOD_CHOICE,
|
||||
paymentMethods.APPLE_PAY,
|
||||
false
|
||||
);
|
||||
}
|
||||
if (event.data.indexOf("showLoaderForPaypal") > -1) {
|
||||
console.log(new Date() + ": Payment method paypal selected");
|
||||
this.dispatchStoreAction(
|
||||
storeActions.SAVE_PAYMENT_METHOD_CHOICE,
|
||||
paymentMethods.PAYPAL,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1778,6 +1778,7 @@ export const actions = {
|
|||
order.payment.piaType == paymentMethods.CREDIT_CARD ? true : false,
|
||||
isPaypal: order.payment.piaType == paymentMethods.PAYPAL ? true : false,
|
||||
isAfterPay: order.payment.piaType == paymentMethods.AFTERPAY ? true : false,
|
||||
isApplePay: order.payment.piaType == paymentMethods.APPLE_PAY ? true : false,
|
||||
paypalToken: order.payment.paypalToken,
|
||||
nextGenSettledAmount: order.payment.nextGenSettledAmount,
|
||||
ccToken: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue