From 33d8cc0fa5ce2d4fd7c06a930ffff8c3a2ab89f9 Mon Sep 17 00:00:00 2001 From: "Liquan (Max) Gu" Date: Thu, 30 Sep 2021 12:29:14 -0400 Subject: [PATCH 1/3] remove basic-card --- demo/js/payment-request.js | 11 +---------- demo/js/script.js | 11 +---------- dist/appr.js | 7 ------- src/index.ts | 13 ------------- 4 files changed, 2 insertions(+), 40 deletions(-) diff --git a/demo/js/payment-request.js b/demo/js/payment-request.js index 1ae2edb..0dccb45 100644 --- a/demo/js/payment-request.js +++ b/demo/js/payment-request.js @@ -68,14 +68,6 @@ function onBuyClicked(event) { event.preventDefault(); let supportedInstruments = [{ - supportedMethods: 'basic-card', - data: { - supportedNetworks: [ - 'visa', 'mastercard', 'amex', 'discover', - 'diners', 'jcb', 'unionpay' - ] - } - }, { supportedMethods: 'https://apple.com/apple-pay', data: { supportedNetworks: [ @@ -186,9 +178,8 @@ function onBuyClicked(event) { console.log('This is Bobpay'); console.log(response); break; - case 'basic-card': default: - console.log('This is basic-card'); + console.log('This is ' + response.methodName); console.log(response); break; } diff --git a/demo/js/script.js b/demo/js/script.js index 5a9630e..f3262a4 100644 --- a/demo/js/script.js +++ b/demo/js/script.js @@ -62,14 +62,6 @@ class priceCalc { } const methods = [{ - supportedMethods: 'basic-card', - data: { - supportedNetworks: [ - 'visa', 'mastercard', 'amex', 'discover', - 'diners', 'jcb', 'unionpay' - ] - } -}, { supportedMethods: 'https://apple.com/apple-pay', data: { supportedNetworks: [ @@ -194,9 +186,8 @@ function onBuyClicked(event) { console.log('This is Bobpay'); console.log(response); break; - case 'basic-card': default: - console.log('This is basic-card'); + console.log('This is ' + response.methodName); console.log(response); break; } diff --git a/dist/appr.js b/dist/appr.js index e0d261f..41e39a4 100644 --- a/dist/appr.js +++ b/dist/appr.js @@ -219,13 +219,6 @@ if (window.ApplePaySession && !ApplePaySession.supportsVersion(3)) { var modifier = _e[_d]; if (modifier.supportedMethods !== selectedMethod) continue; - if (selectedMethod == 'basic-card' && - modifier.data && - modifier.data.supportedTypes) { - if (!selectedType || - modifier.data.supportedTypes.indexOf(selectedType) === -1) - continue; - } if (modifier.additionalDisplayItems) { details.displayItems = details.displayItems.concat(modifier.additionalDisplayItems); this.preservedDisplayItems = modifier.additionalDisplayItems; diff --git a/src/index.ts b/src/index.ts index d41b4cc..fb98283 100644 --- a/src/index.ts +++ b/src/index.ts @@ -147,7 +147,6 @@ if ((window).ApplePaySession && !ApplePaySession.supportsVersion(3)) { private updatePaymentDetails( details: PaymentDetailsUpdate, selectedMethod?: string, - selectedType?: string ): void { if (selectedMethod) { // Get rid of existing preserved display items @@ -167,18 +166,6 @@ if ((window).ApplePaySession && !ApplePaySession.supportsVersion(3)) { if (modifier.supportedMethods !== selectedMethod) continue; - // if supported method is 'basic-card' and - // supported type is specified, check if it matches - // Otherwise ignore. - // (This is technically useless on Safari) - if (selectedMethod == 'basic-card' && - modifier.data && - modifier.data.supportedTypes) { - if (!selectedType || - modifier.data.supportedTypes.indexOf(selectedType) === -1) - continue; - } - if (modifier.additionalDisplayItems) { // Concatenate existing display items and additional ones details.displayItems = From c2e4f9d5baa213f65dfeff93fb110b6fa9135b87 Mon Sep 17 00:00:00 2001 From: "Liquan (Max) Gu" Date: Thu, 30 Sep 2021 12:36:31 -0400 Subject: [PATCH 2/3] remove basic-card from uglified code --- demo/js/appr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/js/appr.js b/demo/js/appr.js index dafed40..c540033 100644 --- a/demo/js/appr.js +++ b/demo/js/appr.js @@ -1 +1 @@ -!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var s=n[i]={i:i,l:!1,exports:{}};return e[i].call(s.exports,s,s.exports,t),s.l=!0,s.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";if(Object.defineProperty(t,"__esModule",{value:!0}),window.ApplePaySession&&!ApplePaySession.supportsVersion(3)){var i="https://apple.com/apple-pay";t.PaymentRequest=function(){function e(e,t,n){this.paymentRequestID="",this.shippingAddress=null,this.shippingOption="",this.shippingType="shipping",this.paymentResolver=null,this.paymentRejector=null,this.onshippingaddresschange=null,this.onshippingoptionchange=null,this.onpaymentmethodselected=null,this.merchantIdentifier="";var s=!1;this.paymentRequest={countryCode:"",currencyCode:"",lineItems:[],merchantCapabilities:null,supportedNetworks:[],total:null,billingContact:null,requiredBillingContactFields:[],requiredShippingContactFields:[],shippingContact:null,shippingMethods:[],shippingType:"shipping"};for(var a=0,o=e;a-1||p.supportedMethods===i){if(this.paymentRequest.supportedNetworks=p.data.supportedNetworks,this.paymentRequest.countryCode=p.data.countryCode,3!==p.data.version)throw"Apple Pay needs to be version 3.";p.data.billingContact?this.paymentRequest.billingContact=p.data.billingContact:delete this.paymentRequest.billingContact,p.data.shippingContact?this.paymentRequest.shippingContact=p.data.shippingContact:delete this.paymentRequest.shippingContact,p.data.merchantCapabilities&&(this.paymentRequest.merchantCapabilities=p.data.merchantCapabilities),this.merchantIdentifier=p.data.merchantIdentifier,s=!0;break}}if(!s)throw"Payment method not specified for Apple Pay.";t&&this.updatePaymentDetails(t),n&&(n.requestShipping&&(this.paymentRequest.requiredBillingContactFields.push("postalAddress"),this.paymentRequest.requiredShippingContactFields.push("postalAddress")),n.requestPayerName&&this.paymentRequest.requiredShippingContactFields.push("name"),n.requestPayerEmail&&this.paymentRequest.requiredShippingContactFields.push("email"),n.requestPayerPhone&&this.paymentRequest.requiredShippingContactFields.push("phone"),"pickup"===n.shippingType?this.paymentRequest.shippingType="servicePickup":this.paymentRequest.shippingType=n.shippingType||"shipping"),this.session=new ApplePaySession(1,this.paymentRequest),this.session.addEventListener("validatemerchant",this.onMerchantValidation.bind(this)),this.session.addEventListener("paymentauthorized",this.onPaymentAuthorized.bind(this)),this.session.addEventListener("paymentmethodselected",this.onPaymentMethodSelected.bind(this)),this.session.addEventListener("shippingcontactselected",this.onShippingAddressChange.bind(this)),this.session.addEventListener("shippingmethodselected",this.onShippingOptionChange.bind(this)),this.session.addEventListener("cancel",this.onPaymentCanceled.bind(this))}return e.prototype.updatePaymentDetails=function(e,t,n){if(t){for(var i=[],s=0,a=e.displayItems;s-1||p.supportedMethods===i){if(this.paymentRequest.supportedNetworks=p.data.supportedNetworks,this.paymentRequest.countryCode=p.data.countryCode,3!==p.data.version)throw"Apple Pay needs to be version 3.";p.data.billingContact?this.paymentRequest.billingContact=p.data.billingContact:delete this.paymentRequest.billingContact,p.data.shippingContact?this.paymentRequest.shippingContact=p.data.shippingContact:delete this.paymentRequest.shippingContact,p.data.merchantCapabilities&&(this.paymentRequest.merchantCapabilities=p.data.merchantCapabilities),this.merchantIdentifier=p.data.merchantIdentifier,s=!0;break}}if(!s)throw"Payment method not specified for Apple Pay.";t&&this.updatePaymentDetails(t),n&&(n.requestShipping&&(this.paymentRequest.requiredBillingContactFields.push("postalAddress"),this.paymentRequest.requiredShippingContactFields.push("postalAddress")),n.requestPayerName&&this.paymentRequest.requiredShippingContactFields.push("name"),n.requestPayerEmail&&this.paymentRequest.requiredShippingContactFields.push("email"),n.requestPayerPhone&&this.paymentRequest.requiredShippingContactFields.push("phone"),"pickup"===n.shippingType?this.paymentRequest.shippingType="servicePickup":this.paymentRequest.shippingType=n.shippingType||"shipping"),this.session=new ApplePaySession(1,this.paymentRequest),this.session.addEventListener("validatemerchant",this.onMerchantValidation.bind(this)),this.session.addEventListener("paymentauthorized",this.onPaymentAuthorized.bind(this)),this.session.addEventListener("paymentmethodselected",this.onPaymentMethodSelected.bind(this)),this.session.addEventListener("shippingcontactselected",this.onShippingAddressChange.bind(this)),this.session.addEventListener("shippingmethodselected",this.onShippingOptionChange.bind(this)),this.session.addEventListener("cancel",this.onPaymentCanceled.bind(this))}return e.prototype.updatePaymentDetails=function(e,t,n){if(t){for(var i=[],s=0,a=e.displayItems;s Date: Thu, 30 Sep 2021 12:46:54 -0400 Subject: [PATCH 3/3] remove type --- dist/appr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/appr.js b/dist/appr.js index 41e39a4..4a07d55 100644 --- a/dist/appr.js +++ b/dist/appr.js @@ -199,7 +199,7 @@ if (window.ApplePaySession && !ApplePaySession.supportsVersion(3)) { this.session.addEventListener('shippingmethodselected', this.onShippingOptionChange.bind(this)); this.session.addEventListener('cancel', this.onPaymentCanceled.bind(this)); } - class_1.prototype.updatePaymentDetails = function (details, selectedMethod, selectedType) { + class_1.prototype.updatePaymentDetails = function (details, selectedMethod) { if (selectedMethod) { var newDisplayItems = []; for (var _i = 0, _a = details.displayItems; _i < _a.length; _i++) {