Skip to main content

A django integration for ePayco's gateway.

Project description

ePayco Django

A Django integration for ePayco's gateway. ##Requirements

Installation

If you want clone the repository:

$ git clone https://github.com/gustav0/epayco_django.git

Install from package manager

$ pip install epayco-django

Add 'epayco_django' to your INSTALLED_APPS setting.

INSTALLED_APPS = [
    ...
    'epayco_django',
    ...
]

And set this in your settings, you can get this data from your ePayco dashboard under Integration > API keys.

EPAYCO = {
    'PUBLIC_KEY': 'MY_PUBLIC_KEY',
    'PRIVATE_KEY': 'MY_PRIVATE_KEY',
    'P_KEY': 'MY_P_KEY',
    'TEST': True, # you probably want to test it first rigth?

    # Optional (ignore these if you want the default behaviour)
    'IS_SECURE': False, # Enable this if you are in production
    'CONFIRMATION_URL': reverse('epayco_confirmation'),
    'RESPONSE_URL': reverse('epayco_response'),

    # And you can use your own image as a payment button
    'CHECKOUT_BUTTON_URL': 'https://mydomain.com/btns/pay_now_button.png'
}

Now edit the myproject/urls.py module in your project:

from django.conf.urls import url, include
from epayco_django import urls as epayco_urls

# or this if you are using Django 2.0 +
from django.urls import path, include

urlpatterns = [
    ...
    url('^', include(epayco_urls)),

    # or 

    path('', include(epayco_urls)),
    ...
]

Usage

At the moment the usage of the library is very limited, but it can be helpful to receive and act upon payment confirmations.

If this is what you need then you should set the confirmation url under Integrations > My site properties > Gateway options in the ePayco dashboard to:

https://yourdomain.com/epayco/confirmation

It is important to use https, and if you are working locally you can use tools like ngrok.

Payment Confirmation

Now that you set payment confirmations to be reported to your site, we can listen to whatever confirmation is sent, validate it and act on it. Listen to any of the epayco_django.signals you are interested in and you should be able to acomplish what you need. Here is an example:

from django.dispatch import receiver
from epayco_django.signals import valid_confirmation_received

@receiver(valid_confirmation_received)
def activate_membership(sender, user=None, **kwargs):
    ...
    HERE SHOULD BE YOUR MEMBERSHIP ACTIVATION CODE
    ...

Validating responses

We provide a utility that will search for existing payments with the provided reference code, if it finds a payment it will retrieve its information but if it doesn't it will fetch the payment data and activate the payment confirmation process by itself.

...

from epayco_django.utils import validate_response_code

class MyView(TemplateView):
    ...

    def get_context_data(self, request, *args, **kwargs):
        context = super().get_context_data(request, *args, **kwargs)
        ref_code = request.GET.get('ref_code')
        result = validate_response_code(ref_code)
        # You will get a dict like this as a result
        # {'valid_ref': True, 'existed': True, 'flag': False, 'obj': <PaymentConfirmationObject>}

        # INSERT CUSTOM CODE HERE

        return context

Contributing

I'm always grateful for any kind of contribution including but not limited to bug reports, code enhancements, bug fixes, and even functionality suggestions.

You can report any bug you find or suggest new functionality with a new

issue.

If you want to add yourself some functionality to the wrapper:
  1. Fork it ( https://github.com/gustav0/epayco_django)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Adds my new feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

epayco-django-0.0.1.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

epayco_django-0.0.1-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file epayco-django-0.0.1.tar.gz.

File metadata

  • Download URL: epayco-django-0.0.1.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for epayco-django-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3ba61700257cce4281b23940789cee5a2412bb46b9e98bb5320a349d26c80dbe
MD5 e34bab1a7b606387fd8d407f8b38c7db
BLAKE2b-256 f1b6d212416ade0bc34181ce2d705c2406eceed21b18f7e029df7ce2f637dd06

See more details on using hashes here.

File details

Details for the file epayco_django-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: epayco_django-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for epayco_django-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e1379ff362eb1f538c9edfc596c7f0c0036afa6ce6a0b2b31353b1cf020e11f4
MD5 105a1a6746d531ee92f39d10fd4f437f
BLAKE2b-256 ddd27ad301caf5244712e543249e2fb0d649809ecff9c615fb8a81a8ff46d6cd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page