PaymentManager: phương thức enableDelegations()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Phương thức enableDelegations() của giao diện PaymentManager ủy thác trách nhiệm cung cấp các phần khác nhau của thông tin thanh toán cần thiết cho ứng dụng thanh toán thay vì thu thập từ trình duyệt (ví dụ: qua tự động điền).
Cú pháp
enableDelegations(delegations)
Tham số
delegationsOptional-
Một mảng chứa một hoặc nhiều giá trị liệt kê chỉ định thông tin thanh toán bạn muốn ủy thác cho ứng dụng thanh toán. Các giá trị có thể là:
payerEmail-
Ứng dụng thanh toán sẽ cung cấp email của người thanh toán khi cần.
payerName-
Ứng dụng thanh toán sẽ cung cấp tên của người thanh toán khi cần.
payerPhone-
Ứng dụng thanh toán sẽ cung cấp số điện thoại của người thanh toán khi cần.
shippingAddress-
Ứng dụng thanh toán sẽ cung cấp địa chỉ vận chuyển khi cần.
Giá trị trả về
Một Promise giải quyết với giá trị undefined.
Ví dụ
navigator.serviceWorker.register("serviceworker.js").then((registration) => {
registration.paymentManager.userHint = "Card number should be 16 digits";
registration.paymentManager
.enableDelegations(["shippingAddress", "payerName"])
.then(() => {
// …
});
// …
});
Thông số kỹ thuật
| Specification |
|---|
| Web-based Payment Handler API> # dom-paymentmanager-enabledelegations> |