2016-12-29 105 views
0

我試圖調試Apple代碼示例以打開付款表。昨天它工作,支付表打開,但今天我認爲我無法通過session.onvalidatemerchant階段。當我調試時,它不會停止在getApplePaySession(event.validationURL)中,而是直接跳到session.onshippingmethodselected(這沒有意義,因爲燈箱尚未打開,對吧?!)。Apple Pay支付表不會打開

我在控制檯中沒有任何錯誤。 「驗證商家」未寫入控制檯。 這是JS代碼蘋果公司提供,我使用它:

const session = new ApplePaySession(1, paymentRequest); 

/** 
* Merchant Validation 
* We call our merchant session endpoint, passing the URL to use 
*/ 
session.onvalidatemerchant = (event) => { 
    console.log("Validate merchant"); 
    const validationURL = event.validationURL; 
    getApplePaySession(event.validationURL).then(function(response) { 
     console.log(response); 
     session.completeMerchantValidation(response); 
    }); 
}; 

/** 
* Shipping Method Selection 
* If the user changes their chosen shipping method we need to recalculate 
* the total price. We can use the shipping method identifier to determine 
* which method was selected. 
*/ 
session.onshippingmethodselected = (event) => { 
    const shippingCost = event.shippingMethod.identifier === 'free' ? '0.00' : '5.00'; 
    const totalCost = event.shippingMethod.identifier === 'free' ? '8.99' : '13.99'; 

    const lineItems = [ 
     { 
      label: 'Shipping', 
      amount: shippingCost, 
     }, 
    ]; 

    const total = { 
     label: 'Apple Pay Example', 
     amount: totalCost, 
    }; 

    session.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS, total, lineItems); 
}; 

回答

0

我解決了這個問題。 Mac和iPhone未配置相同的iCloud用戶。

相關問題