зеркало из https://github.com/mozilla/payments.git
Merge pull request #111 from andymckay/api
some first steps on how to integrate
This commit is contained in:
Коммит
9e8ed782e6
|
@ -0,0 +1,31 @@
|
|||
.. _client-label:
|
||||
|
||||
Client API
|
||||
====================
|
||||
|
||||
The selling site will need to include the `payments-client library <https://github.com/mozilla/payments-client>`_.
|
||||
The client is available on `npm <https://www.npmjs.com/package/mozilla-payments-client>`_::
|
||||
|
||||
npm install mozilla-payments-client
|
||||
|
||||
Then add in:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
var client = new window.PaymentsClient({
|
||||
accessToken: firefox_accounts_access_token,
|
||||
product: {
|
||||
id: 'product-id-from-payments-config',
|
||||
image: 'http://url.to.product.image'
|
||||
},
|
||||
});
|
||||
|
||||
Parameters:
|
||||
|
||||
* `httpsOnly`: if `true`, the payments-ui will check to see if requests are using HTTPS. Should be set to `true` for production. Intended for development where HTTPS might not be available. Defaults to `true`.
|
||||
* `accessToken`: an access token returned by Firefox Accounts.
|
||||
* `product.id`: the id of the product from :ref:`payments config <configuration-label>`
|
||||
* `product.image`: URL of an image to be shown in the purchase flow
|
||||
* `paymentHost`: (optional) the server used to process payments [*]_
|
||||
|
||||
.. [*] This will default to the production server when it exists. Currently its going to default to a local Docker development instance: `http://pay.dev:8000`
|
|
@ -0,0 +1,43 @@
|
|||
.. _configuration-label:
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
Product configuration occurs in the `payments-config repository <https://github.com/mozilla/payments-config/>`_.
|
||||
|
||||
Configuration is stored in a `python file <https://github.com/mozilla/payments-config/blob/master/payments_config/products.py>`_, JSON, translations and other formats are generated from that.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
'mozilla-concrete': {
|
||||
'email': 'support@concrete.mozilla.org',
|
||||
'name': _('Mozilla Concrete'),
|
||||
'url': 'http://pay.dev.mozaws.net/',
|
||||
'terms': 'http://pay.dev.mozaws.net/terms/',
|
||||
'products': [
|
||||
{
|
||||
'id': 'brick',
|
||||
'description': _('Brick'),
|
||||
'amount': '10.00',
|
||||
},
|
||||
{
|
||||
'id': 'mortar',
|
||||
'description': _('Mortar'),
|
||||
'amount': '5.00',
|
||||
'img': ('https://raw.githubusercontent.com/mozilla'
|
||||
'/payments-config/master/payments_config'
|
||||
'/assets/mortar.png'),
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
* ``email``: a support address for the selling site
|
||||
* ``name``: a general name for the selling site, shown to buyers
|
||||
* ``url``: a URL to the selling site
|
||||
* ``terms``: a URL to the selling site terms
|
||||
* ``products``: an array of products for sale
|
||||
* ``products.id``: a unique id for the product, not shown to buyers
|
||||
* ``products.description``: a description shown to buyers of the product
|
||||
* ``products.img``: optional image URL to an image to show to buyers
|
|
@ -4,5 +4,7 @@ APIs
|
|||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
configuration
|
||||
client
|
||||
payments
|
||||
storage
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Payment API
|
||||
Backend API
|
||||
-----------
|
||||
|
||||
The payments-ui interacts with payments-service,
|
||||
|
|
|
@ -27,7 +27,11 @@ TODO
|
|||
Product setup and configuration
|
||||
===============================
|
||||
|
||||
TODO
|
||||
To implement, you'll need to:
|
||||
|
||||
* :ref:`Complete product configuration <configuration-label>`
|
||||
* :ref:`Add client to your project <client-label>`
|
||||
* Call the appropriate APIs to start a purchase
|
||||
|
||||
Testing
|
||||
=======
|
||||
|
|
Загрузка…
Ссылка в новой задаче