@@ -9,7 +9,6 @@ const { APPLE_PAY } = require('./constants');
9
9
10
10
let checkout ;
11
11
let shippingMethodsData ;
12
- let temporaryBasketId ;
13
12
14
13
function formatCustomerObject ( customerData , billingData ) {
15
14
return {
@@ -110,12 +109,12 @@ function callPaymentFromComponent(data, resolveApplePay, rejectApplePay) {
110
109
} ) ;
111
110
}
112
111
113
- async function selectShippingMethod ( { shipmentUUID, ID } , basketId , reject ) {
112
+ async function selectShippingMethod ( { shipmentUUID, ID } , reject ) {
114
113
const requestBody = {
115
114
paymentMethodType : APPLE_PAY ,
116
115
shipmentUUID,
117
116
methodID : ID ,
118
- basketId ,
117
+ isExpressPdp : true ,
119
118
} ;
120
119
return $ . ajax ( {
121
120
type : 'POST' ,
@@ -130,10 +129,10 @@ async function selectShippingMethod({ shipmentUUID, ID }, basketId, reject) {
130
129
} ) . fail ( ( ) => reject ( ) ) ;
131
130
}
132
131
133
- function getShippingMethod ( shippingContact , basketId , reject ) {
132
+ function getShippingMethod ( shippingContact , reject ) {
134
133
const requestBody = {
135
134
paymentMethodType : APPLE_PAY ,
136
- basketId ,
135
+ isExpressPdp : true ,
137
136
} ;
138
137
if ( shippingContact ) {
139
138
requestBody . address = {
@@ -204,7 +203,7 @@ async function onAuthorized(resolve, reject, event, amountValue, merchantName) {
204
203
} ;
205
204
206
205
await callPaymentFromComponent (
207
- { ...stateData , customer, basketId : temporaryBasketId } ,
206
+ { ...stateData , customer, isExpressPdp : true } ,
208
207
resolveApplePay ,
209
208
reject ,
210
209
) ;
@@ -229,7 +228,6 @@ async function onShippingMethodSelected(
229
228
) ;
230
229
const calculationResponse = await selectShippingMethod (
231
230
matchingShippingMethod ,
232
- temporaryBasketId ,
233
231
reject ,
234
232
) ;
235
233
if ( calculationResponse ?. grandTotalAmount ) {
@@ -252,16 +250,11 @@ async function onShippingMethodSelected(
252
250
253
251
async function onShippingContactSelected ( resolve , reject , event , merchantName ) {
254
252
const { shippingContact } = event ;
255
- shippingMethodsData = await getShippingMethod (
256
- shippingContact ,
257
- temporaryBasketId ,
258
- reject ,
259
- ) ;
253
+ shippingMethodsData = await getShippingMethod ( shippingContact , reject ) ;
260
254
if ( shippingMethodsData ?. shippingMethods ?. length ) {
261
255
const selectedShippingMethod = shippingMethodsData . shippingMethods [ 0 ] ;
262
256
const newCalculation = await selectShippingMethod (
263
257
selectedShippingMethod ,
264
- temporaryBasketId ,
265
258
reject ,
266
259
) ;
267
260
if ( newCalculation ?. grandTotalAmount ) {
@@ -327,8 +320,7 @@ async function init(paymentMethodsResponse) {
327
320
onClick : async ( resolve , reject ) => {
328
321
if ( window . isExpressPdp ) {
329
322
const tempBasketResponse = await createTemporaryBasket ( ) ;
330
- if ( tempBasketResponse ?. basketId ) {
331
- temporaryBasketId = tempBasketResponse . basketId ;
323
+ if ( tempBasketResponse ?. temporaryBasketCreated ) {
332
324
applePayButtonConfig . amount = {
333
325
value : tempBasketResponse . amount . value ,
334
326
currency : tempBasketResponse . amount . currency ,
0 commit comments