[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"Translation issue"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples/Code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Google Pay 即時示範模式
本頁面提供的 Google Pay 即時示範模式可讓您在 JavaScript 或 JSFiddle 中編輯。
基本示例
以下是 Google Pay 按鈕的基本示例,可讓您瞭解按鈕的實際運作方式。如要瞭解如何建立按鈕,請參閱鄰近的程式碼。
以下說明如何調整 Google Pay 按鈕的大小。呼叫 buttonSizeMode
屬性設為 fill
的 createButton
,然後為 #container div
設定大小。
授權付款示例
以下示例說明如何先「授權付款」,再處理付款。
採取先授權付款再進行處理這種做法,是因為如果授權失敗,使用者還有機會可以選擇其他付款方式。
處理付款授權要求的操作說明如下:
-
在
PaymentOptions
中註冊 onPaymentAuthorized()
回呼。
- 使用
PAYMENT_AUTHORIZATION
回呼意圖呼叫 loadPaymentData()
函式。
- 實作
onPaymentAuthorized()
回呼處理常式。
按一下在 JSFiddle 中編輯連結即可編輯並親自試用。
動態價格更新示例
「動態價格更新」功能可讓您動態調整總價,以反映運送地址和運送選項的變更。
請按照下列步驟設定動態價格更新功能:
- 在
PaymentOptions
中註冊 onPaymentAuthorized
和 onPaymentDataChanged
回呼。
- 使用回呼意圖呼叫
loadPaymentData()
函式。詳情請參閱相對應的示例。
- 實作
onPaymentAuthorized
和 onPaymentDataChanged
。
按一下在 JSFiddle 中編輯連結即可編輯並親自試用。
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"Translation issue"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples/Code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-02-08 UTC.