WebAPI/WebPaymentProvider: Difference between revisions

Completion
(Completion)
Line 14: Line 14:


== API ==
== API ==
The <code>navigator.mozPay()</code> implementation injects a global <code>mozPaymentProvider</code> object within the payment provider's web page context.


  interface mozPaymentProvider
  interface mozPaymentProvider
Line 85: Line 87:


== Completion ==
== Completion ==
 
In order to allow the payment provider to control the behavior of the payment window, the mozPaymentProvider API exposes paymentSuccess and paymentFailed. These functions should be called by the payment provider to finish the payment flow. Both functions would close the payment flow window and trigger the [https://developer.mozilla.org/en-US/docs/DOM/DOMRequest.onsuccess onsuccess] or [https://developer.mozilla.org/en-US/docs/DOM/DOMRequest.onerror onerror] events over the [https://developer.mozilla.org/en-US/docs/DOM/DOMRequest DOMRequest] returned by the <code>navigator.mozPay</code> call. The <code>aResult</code> and <code>aErrorMsg</code> strings passed by the payment provider would be available for the application as [https://developer.mozilla.org/en-US/docs/DOM/DOMRequest.result DOMRequest.result] and [https://developer.mozilla.org/en-US/docs/DOM/DOMRequest.error DOMRequest.error] values respectively.
The <code>navigator.mozPay()</code> implementation injects a global <code>mozPaymentProvider</code> object within the payment provider's web page context. The payment provider can use this to control behavior of the payment window. It looks something like this:
<code>
window.mozPaymentProvider = {
  paymentSuccess: function(aResult) {},
  paymentFailed: function(aErrorMsg) {}
};
</code>
 
where <code>aResult</code> and <code>aErrorMsg</code> are simple strings.  
 
These functions should be called by the payment provider to finish the payment flow. Both functions would close the payment flow window and trigger the [https://developer.mozilla.org/en-US/docs/DOM/DOMRequest.onsuccess onsuccess] or [https://developer.mozilla.org/en-US/docs/DOM/DOMRequest.onerror onerror] events over the [https://developer.mozilla.org/en-US/docs/DOM/DOMRequest DOMRequest] returned by the <code>navigator.mozPay</code> call. The <code>aResult</code> and <code>aErrorMsg</code> strings passed by the payment provider would be available for the application as [https://developer.mozilla.org/en-US/docs/DOM/DOMRequest.result DOMRequest.result] and [https://developer.mozilla.org/en-US/docs/DOM/DOMRequest.error DOMRequest.error] values respectively.


* The success callback in the app is to say “the payment is done processing.” It does not guarantee a positive or negative outcome.
* The success callback in the app is to say “the payment is done processing.” It does not guarantee a positive or negative outcome.
Confirmed users
483

edits