Merge pull request #1902 from Safelite/feature/CSR-2130
CSR-2130 flag applePay for backend
This commit is contained in:
commit
57cae3a32b
4 changed files with 72 additions and 21 deletions
|
|
@ -6,4 +6,5 @@ export const paymentMethods = {
|
||||||
AFTERPAY: "Afterpay",
|
AFTERPAY: "Afterpay",
|
||||||
PAY_NOW: "PayNow",
|
PAY_NOW: "PayNow",
|
||||||
INSURANCE: "Insurance",
|
INSURANCE: "Insurance",
|
||||||
|
APPLE_PAY: "ApplePay",
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ export default {
|
||||||
console.log("Error during payment: " + piaError);
|
console.log("Error during payment: " + piaError);
|
||||||
const paymentPageNavScenario =
|
const paymentPageNavScenario =
|
||||||
store.getters.order.payment.piaType === paymentMethods.CREDIT_CARD ||
|
store.getters.order.payment.piaType === paymentMethods.CREDIT_CARD ||
|
||||||
|
store.getters.order.payment.piaType === paymentMethods.APPLE_PAY ||
|
||||||
store.getters.order.payment.piaType === paymentMethods.AFTERPAY;
|
store.getters.order.payment.piaType === paymentMethods.AFTERPAY;
|
||||||
if (paymentPageNavScenario) {
|
if (paymentPageNavScenario) {
|
||||||
this.$router.navigateWithoutSaving(
|
this.$router.navigateWithoutSaving(
|
||||||
|
|
@ -45,13 +46,42 @@ export default {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const card_expirationMonth = getQuerystringParameter(
|
switch (store.getters.order.payment.piaType) {
|
||||||
queryStrings.CARD_EXPIRATION_MONTH
|
case paymentMethods.CREDIT_CARD:
|
||||||
);
|
case paymentMethods.APPLE_PAY:
|
||||||
if (card_expirationMonth) {
|
case paymentMethods.AFTERPAY:
|
||||||
await this.processCreditCardResponse();
|
await this.processCreditCardResponse();
|
||||||
} else {
|
break;
|
||||||
await this.processPaypalResponse();
|
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 +90,6 @@ export default {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
async processPaypalResponse() {
|
async processPaypalResponse() {
|
||||||
await this.dispatchStoreAction(
|
|
||||||
storeActions.SAVE_PAYMENT_METHOD_CHOICE,
|
|
||||||
paymentMethods.PAYPAL,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
const token = getQuerystringParameter(queryStrings.TOKEN);
|
const token = getQuerystringParameter(queryStrings.TOKEN);
|
||||||
const payerId = getQuerystringParameter(queryStrings.PAYERID);
|
const payerId = getQuerystringParameter(queryStrings.PAYERID);
|
||||||
|
|
||||||
|
|
@ -79,12 +103,6 @@ export default {
|
||||||
await this.saveAndSubmitWorkOrder();
|
await this.saveAndSubmitWorkOrder();
|
||||||
},
|
},
|
||||||
async processCreditCardResponse() {
|
async processCreditCardResponse() {
|
||||||
await this.dispatchStoreAction(
|
|
||||||
storeActions.SAVE_PAYMENT_METHOD_CHOICE,
|
|
||||||
paymentMethods.CREDIT_CARD,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
const subscriptionID = getQuerystringParameter(queryStrings.SUBSCRIPTIONID);
|
const subscriptionID = getQuerystringParameter(queryStrings.SUBSCRIPTIONID);
|
||||||
|
|
||||||
const referralSeqNum = getQuerystringParameter(queryStrings.REFERRAL_SEQ_NUM);
|
const referralSeqNum = getQuerystringParameter(queryStrings.REFERRAL_SEQ_NUM);
|
||||||
|
|
|
||||||
|
|
@ -669,12 +669,15 @@ export default {
|
||||||
if (iframe.contentWindow) {
|
if (iframe.contentWindow) {
|
||||||
if (isApplePayAvailable) {
|
if (isApplePayAvailable) {
|
||||||
iframe.contentWindow.postMessage("hybrid-with-applepay", "*");
|
iframe.contentWindow.postMessage("hybrid-with-applepay", "*");
|
||||||
|
console.log(new Date() + ": Sent applepay");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.paymentType == "cc") {
|
if (this.paymentType == "cc") {
|
||||||
iframe.contentWindow.postMessage("CreditCardChosen", "*");
|
iframe.contentWindow.postMessage("CreditCardChosen", "*");
|
||||||
|
console.log(new Date() + ": Sent creditcard");
|
||||||
} else if (this.paymentType == "ap") {
|
} else if (this.paymentType == "ap") {
|
||||||
iframe.contentWindow.postMessage("afterpay", "*");
|
iframe.contentWindow.postMessage("afterpay", "*");
|
||||||
|
console.log(new Date() + ": Sent afterpay");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -698,10 +701,37 @@ export default {
|
||||||
this.backButtonAction();
|
this.backButtonAction();
|
||||||
}
|
}
|
||||||
if (event.data.indexOf("creditCardSubmit") > -1) {
|
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);
|
this.setUIBlock(true);
|
||||||
}
|
}
|
||||||
if (event.data.indexOf("hybrid") > -1) {
|
if (event.data.indexOf("afterpayPaymentReceived") > -1) {
|
||||||
this.setUIBlock(true);
|
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,8 @@ export const actions = {
|
||||||
order.payment.piaType == paymentMethods.CREDIT_CARD ? true : false,
|
order.payment.piaType == paymentMethods.CREDIT_CARD ? true : false,
|
||||||
isPaypal: order.payment.piaType == paymentMethods.PAYPAL ? true : false,
|
isPaypal: order.payment.piaType == paymentMethods.PAYPAL ? true : false,
|
||||||
isAfterPay: order.payment.piaType == paymentMethods.AFTERPAY ? true : false,
|
isAfterPay: order.payment.piaType == paymentMethods.AFTERPAY ? true : false,
|
||||||
|
isApplePay:
|
||||||
|
order.payment.piaType == paymentMethods.APPLE_PAY ? true : false,
|
||||||
paypalToken: order.payment.paypalToken,
|
paypalToken: order.payment.paypalToken,
|
||||||
nextGenSettledAmount: order.payment.nextGenSettledAmount,
|
nextGenSettledAmount: order.payment.nextGenSettledAmount,
|
||||||
ccToken: {
|
ccToken: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue