Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/rossp/django-pinpayments

Django library to simplify payment processing with pin
https://github.com/rossp/django-pinpayments

Last synced: about 1 month ago
JSON representation

Django library to simplify payment processing with pin

Lists

README

        

> ## Maintainer Wanted
>
> I no longer have any side projects that use `django-pinpayments` and I don't have the time or headspace to maintain an important project. If you're interested in helping maintain this project, add new features, etc then please get in touch [via the relevant issue](https://github.com/rossp/django-pinpayments/issues/27).

# django-pinpayments

`django-pinpayments` provides helper functions for [Pin Payments](https://pinpayments.com) - a relatively new Australian payment processor that doesn't require merchant accounts and that doesn't require purchasers to have an account. Some may call it the "Australian version of Stripe".

`django-pinpayments` provides template tags to render the [*Pin.js payment form*](https://pinpayments.com/developers/integration-guides/payment-forms), which uses the Card API for processing. This means you can collect credit card details on your website, submit them via javascript to Pin (without them landing on your server), then process the payment on your server using the single-use card token that Pin return.

The provided Card tokens can also be used to create [Customer tokens](https://pinpayments.com/developers/integration-guides/payment-forms), to use for delayed or recurring billing.

`django-pinpayments` is designed to be a simple base for your own billing projects. It doesn't make too many assumptions, and leaves many things open for your design input.

### Not Included

* Any link to your existing models or business logic
* Views for users to review/update their stored credit cards, or review previous transactions

### Todo

* Tests
* More documentation
* Signals on success or failure

### Pre-requisites

* Django (Only tested on 3.0)
* [python-requests](http://docs.python-requests.org/en/latest/)
* [Mock](http://www.voidspace.org.uk/python/mock/)

### Settings

* `PIN_ENVIRONMENTS` - a dictionary of dictionaries containing Pin API keys & secrets
* `PIN_DEFAULT_ENVIRONMENT` - a pointer to the environment to be used at runtime, if no specific environment is requested.

**Warning:** Make sure your settings do not end up in public source repositories, as they can be used to process payments in your name.

#### `PIN_ENVIRONMENTS`

Each environment must have the 'key' and 'secret' values.

I highly recommend at least test & production, however you can also configure other key pairs if you have eg a separate Pin account for part of your website. Perhaps you have membership sales processed by one account, and merchandise by another.

This setting, with at least one environment, is **required** for django-pinpayments to function. There is no default.

```python
PIN_ENVIRONMENTS = {
'test': {
'key': 'pk_qokBvPpEHIVmNETSoSdDVYP',
'secret': 'MBjZMurpDtjDANDNFQObZmBhMg',
'host': 'test-api.pinpayments.com',
},
'live': {
'key': 'pk_yGCGLonMHJMFscFyNaLZdkEV',
'secret': 'tOAQeMsMaBrxejJHIqHJVIObUS',
'host': 'api.pinpayments.com',
},
'live_project2': {
'key': 'pk_ByNNmfJfsMywEIEa-aCteTR',
'secret': 'CPslpGmoakWdPuxjtrfibZVLaS',
'host': 'api.pinpayments.com',
},
}
```

API keys and secrets are available from your [Pin Account page](https://dashboard.pinpayments.com/account). Hosts should not include *https* or a trailing slash; these will be added automatically.

#### `PIN_DEFAULT_ENVIRONMENT`

At runtime, the `{% pin_headers %}` template tag can define which environment to use. If you don't specify an environment in the template tag, this setting determines which account to use.

**Default:** `PIN_DEFAULT_ENVIRONMENT = 'test'`

### Template Tags

Two template tags are included. One includes the Pin.js library and associated JavaScript, and the other renders a form that doesn't submit to your server. Both are required.

Both tags are in `pin_payment_tags`, so you should include `{% load pin_payment_tags %}` somewhere near the top of your template.

#### `pin_headers` - Render `pin.js` and helper functions

This tag should be called inside the `head` tag of your HTML page. It will render multiple `` tags: one to load `pin.js`, the other to define a function that will run on submit of the form to load the card token from the Pin API.

```html
{% load pin_payment_tags %}
<html>
<head>
<title>My Payment Page</title>
<script src='/path/to/jquery.js'>
{% pin_header "test" %}