WebAPI/WebPayment: Difference between revisions

no edit summary
No edit summary
Line 314: Line 314:
See the [[WebAPI/WebPaymentProvider|WebPaymentProvider]] spec for details on how to implement a payment provider for <code>navigator.mozPay()</code>.
See the [[WebAPI/WebPaymentProvider|WebPaymentProvider]] spec for details on how to implement a payment provider for <code>navigator.mozPay()</code>.


== BlueVia Payment Provider ==
== Testing ==
=== Testing against the BlueVia Payment Provider ===
=== Test app ===
The <code>navigator.mozPay</code> API is currently in mozilla-central and there is a first alpha version of the BlueVia Payment Provider, so testing is currently possible. Currently (31th August), there are several requirements though.
https://github.com/ferjm/Payment-tests
=== Testing against the Mock Payment Provider ===
The <code>navigator.mozPay</code> API is currently in mozilla-central and there is a dummy mock payment provider available for testing.  


* <code>navigator.mozPay</code> requires a list of allowed Payment Providers given in the form of user preferences. So first of all, you need to add this Payment Providers information to your Gaia profile <code>prefs.js</code> file. The following preferences provides access to BlueVia Payment Providers (with two different flows) and a Mock Payment Provider.
<code>navigator.mozPay</code> requires a list of allowed Payment Providers given in the form of user preferences. So first of all, you need to add the Mock Payment Provider information to your Gaia profile as a user preference:
- Create a file named <code>custom-prefs.js</code> in the Gaia root directory.
- Add the following user preferences:
  <code>
  <code>
  pref("dom.payment.provider.0.name", "blueviasimple");
  user_pref("dom.payment.provider.0.name", "mockpayprovider");
pref("dom.payment.provider.0.description", "Telefónica BlueVia simple flow");
  user_pref("dom.payment.provider.0.description", "Mock Payment Provider");
pref("dom.payment.provider.0.type", "tu.com/payments/v1/simplepay");
  user_pref("dom.payment.provider.0.type", "mock/payments/inapp/v1");
pref("dom.payment.provider.0.uri", "https://id.tda-qa-01.hi.inet/en/payments/v1/simplepay?req=");
  user_pref("dom.payment.provider.0.uri", "https://mockpayprovider.phpfogapp.com/?req=");
  pref("dom.payment.provider.0.requestMethod", "GET");
  user_pref("dom.payment.provider.0.requestMethod", "GET");
pref("dom.payment.provider.1.name", "bluevia");
pref("dom.payment.provider.1.description", "Telefónica BlueVia flow");
pref("dom.payment.provider.1.type", "tu.com/payments/v1/pay");
pref("dom.payment.provider.1.uri", "https://id.tda-qa-01.hi.inet/en/payments/v1/pay?req=");
pref("dom.payment.provider.1.requestMethod", "GET");
pref("dom.payment.provider.2.name", "mockpayprovider");
pref("dom.payment.provider.2.description", "Mock Payment Provider");
  pref("dom.payment.provider.2.type", "mock/payments/inapp/v1");
  pref("dom.payment.provider.2.uri", "https://mockpayprovider.phpfogapp.com/?req=");
  pref("dom.payment.provider.2.requestMethod", "GET");
  </code>
  </code>
Note that you may need to change the payment provider index (0 in the above preferences) according to already existing payment provider preferences.
- Run <code>make install-gaia</code>
After adding the Mock Payment Provider information as a user preference you should be able to start testing.
An example of a valid payment request against the Mock Payment Provider would be:


<code>
{
  "iss": "123456789",
  "aud": "Mock Payment Provider",
  "typ": "mock\/payments\/inapp\/v1",
  "exp": 1345259882,
  "iat": 1345256282,
  "request": {
    "name": "Piece of Cake",
    "description": "Virtual chocolate cake to fill your virtual tummy",
    "price":[ { "country":"US", "amount":"5.50", "currency":"USD" }, { "country":"BR", "amount":"8.50", "currency":"BRL" } ]
  }
}
</code>
Which results in the following JWT:
<code>eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIxMjM0NTY3ODkiLCJhdWQiOiJNb2NrIFBheW1lbnQgUHJvdmlkZXIiLCJ0eXAiOiJtb2NrXC9wYXltZW50c1wvaW5hcHBcL3YxIiwiZXhwIjoxMzQ1MjU5ODgyLCJpYXQiOjEzNDUyNTYyODIsInJlcXVlc3QiOnsibmFtZSI6IlBpZWNlIG9mIENha2UiLCJkZXNjcmlwdGlvbiI6IlZpcnR1YWwgY2hvY29sYXRlIGNha2UgdG8gZmlsbCB5b3VyIHZpcnR1YWwgdHVtbXkiLCJwcmljZSI6W3siY291bnRyeSI6IlVTIiwiYW1vdW50IjoiNS41MCIsImN1cnJlbmN5IjoiVVNEIn0seyJjb3VudHJ5IjoiQlIiLCJhbW91bnQiOiI4LjUwIiwiY3VycmVuY3kiOiJCUkwifV19fQ.EaXnlL7LUlmYXUTty5ZkUQ7VZeCBa_edi2YXKPnjSl4</code>
=== Testing against the BlueVia Payment Provider ===
* Since the BlueVia Payment Provider is behind a Telefónica VPN, the first requirement is to get access to it. Unfortunately not everyone can get access to it and BlueVia should provide access to its dev servers under direct request.
* Since the BlueVia Payment Provider is behind a Telefónica VPN, the first requirement is to get access to it. Unfortunately not everyone can get access to it and BlueVia should provide access to its dev servers under direct request.


Line 350: Line 370:
*** Launch B2G-desktop again. You should be able to navigate to https://webvpn.tid.es from the Gaia system app, that means that the certificates has been properly stored.
*** Launch B2G-desktop again. You should be able to navigate to https://webvpn.tid.es from the Gaia system app, that means that the certificates has been properly stored.


If everything went well, you should be able to start testing.
If everything went well, you should be able to start testing agains BlueVia.


=== Error codes ===
=== Error codes ===
Confirmed users
483

edits