aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/web/api/paymentrequest/index.html
blob: 033ce47312f96c812df0ba53962e541f44dae960 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
title: PaymentRequest
slug: Web/API/PaymentRequest
translation_of: Web/API/PaymentRequest
---
<div>{{securecontext_header}}{{APIRef("Payment Request API")}}</div>

<p><strong><code>PaymentRequest</code></strong> 介面是 <a href="/zh-TW/docs/Web/API/Payment_Request_API">Payment Request API</a> 的主要切入點,它能讓網頁或 app 接受終端用戶的付款。</p>

<h2 id="建構子">建構子</h2>

<dl>
 <dt>{{domxref('PaymentRequest.PaymentRequest()','PaymentRequest()')}} {{securecontext_inline}}</dt>
 <dd>建立新的 <code>PaymentRequest</code> 物件。</dd>
</dl>

<h2 id="屬性">屬性</h2>

<dl>
 <dt>{{domxref('PaymentRequest.id')}} {{readonlyinline}}{{securecontext_inline}}</dt>
 <dd>個別 <code>PaymentRequest</code> 的唯一標識符(unique identifier),可透過 <code>details.id</code> 設定之。若尚未指定,預設為 UUID。</dd>
 <dt>{{domxref('PaymentRequest.shippingAddress')}} {{readonlyinline}} {{securecontext_inline}}</dt>
 <dd>若透過付款設定(payment options)請求的話,回傳用戶指定的運送地址,以便計算運輸事宜。只有在呼叫的建構子 <code>requestShipping</code> flag 為 true 時,此屬性才能作動。另外,部份瀏覽器會出於隱私上的理由而只節錄部分地址,除非用戶表示交易手續即將完成(例如按下「付款」鈕)。</dd>
 <dt>{{domxref('PaymentRequest.shippingOption')}} {{readonlyinline}} {{securecontext_inline}}</dt>
 <dd>回傳的運送選項的標識符。只有在呼叫的建構子 <code>requestShipping</code> flag 為 true 時,此屬性才能作動。</dd>
 <dt>{{domxref('PaymentRequest.shippingType')}} {{readonlyinline}} {{securecontext_inline}}</dt>
 <dd>回傳用於完成交易的運送類型。可以是 <code>shipping</code>, <code>delivery</code>, <code>pickup</code>, 或在建構子未提供的情形下:<code>null</code></dd>
</dl>

<h3 id="事件處理器">事件處理器</h3>

<dl>
 <dt>{{domxref('PaymentRequest.onshippingaddresschange')}} {{securecontext_inline}}</dt>
 <dd>用戶修改運送地址時觸發之。</dd>
 <dt>{{domxref('PaymentRequest.onshippingoptionchange')}} {{securecontext_inline}}</dt>
 <dd>用戶修改運送選項時觸發之。</dd>
 <dt>{{domxref('PaymentRequest.onpaymentmethodchange')}} {{securecontext_inline}}</dt>
 <dd>針對付款方法(如 Apple Pay),用戶修改支付方式時觸發之,比方說從信用卡改為簽帳卡。</dd>
 <dt>{{domxref('PaymentRequest.onmerchantvalidation')}} {{securecontext_inline}}</dt>
 <dd>針對付款方法(如 Apple Pay),本事件會呼叫 {{event("merchantvalidation")}} 事件,在用戶代理要求驗證付款商家或供應商是否合法時觸發之。</dd>
</dl>

<h2 id="方法">方法</h2>

<dl>
 <dt>{{domxref('PaymentRequest.canMakePayment()')}} {{securecontext_inline}}</dt>
 <dd>在呼叫 <code>show()</code> 前告訴 <code>PaymentRequest</code> 物件能不能付款。</dd>
</dl>

<dl>
 <dt>{{domxref('PaymentRequest.show()')}} {{securecontext_inline}}</dt>
 <dd>讓用戶代理開始付款請求的用戶交互。</dd>
 <dt>{{domxref('PaymentRequest.abort()')}} {{securecontext_inline}}</dt>
 <dd>讓用戶代理結束付款請求並刪除可能顯示的任何用戶界面。</dd>
</dl>

<h2 id="規範">規範</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">規範</th>
   <th scope="col">狀態</th>
   <th scope="col">註解</th>
  </tr>
  <tr>
   <td>{{SpecName('Payment','#paymentrequest-interface','PaymentRequest')}}</td>
   <td>{{Spec2('Payment')}}</td>
   <td>初始定義。</td>
  </tr>
 </tbody>
</table>

<h2 id="瀏覽器相容性">瀏覽器相容性</h2>

<div>


<p>{{Compat("api.PaymentRequest")}}</p>
</div>