Confirmed users
483
edits
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>. | ||
== | == Testing == | ||
=== Testing against the | === Test app === | ||
The <code>navigator.mozPay</code> API is currently in mozilla-central and there is a | 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 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> | ||
user_pref("dom.payment.provider.0.name", "mockpayprovider"); | |||
user_pref("dom.payment.provider.0.description", "Mock Payment Provider"); | |||
user_pref("dom.payment.provider.0.type", "mock/payments/inapp/v1"); | |||
user_pref("dom.payment.provider.0.uri", "https://mockpayprovider.phpfogapp.com/?req="); | |||
user_pref("dom.payment.provider.0.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 === | ||