Package: django-payments-payu
NOTE: This project is still in development, so use with extreme caution.PayU payments provider for django-payments. Uses the new PayU REST API. Supports normal, express and recurring payments.DocumentationThe full documentation is athttps://django-payments-payu.readthedocs.io.QuickstartInstalldjango-paymentsand set up PayU payment provider backend according todjango-payments documentation:This backend implements payments usingPayU.com.Set up the payment provider:Example:# use sandbox
PAYMENT_VARIANTS = {
    'payu': ('payments_payu.provider.PayuProvider', {
        'pos_id': '123456',
        'second_key': 'iseedeadpeople',
        'client_secret': 'peopleiseedead',
        'sandbox': True,
        'capture': False,
    }),
}Here are valid parameters for the provider:client_secret:PayU OAuth protocol client secretpos_id:PayU POS IDsecond_key:PayU second key (MD5)shop_name:Name of the shop send to the APIsandbox:ifTrue, set the endpoint to sandboxendpoint:endpoint URL, if not set, the will be automatically set based onsandboxsettingsrecurring_payments:enable recurring payments, only valid withexpress_payments=True, see bellow for additional setup, that is neededexpress_payments:use PayU express formwidget_branding:tell express form to show PayU brandingstore_card:(default: False) whether PayU should store the cardNOTE: notifications about the payment status from PayU are requested to be sent todjango-paymentsprocess_paymenturl. The request from PayU can fail for several reasons (i.e. it can be blocked by proxy). Use “Show reports” page in PayU administration to get more information about the requests.Recurring payments:If recurring payments are enabled, the PayU card token needs to be stored in your application for usage in next payments. The next payments can be either initiated by user through (user will be prompted only for payment confirmation by the express form) or by server.
To enable recurring payments, you will need to set additional things:NOTE: Recurring payments are not enabled by default even in Sandbox, you sould consult their helpdesk to enable this.In order to make payments recurring, the card token needs to be stored for thePayment’s user (not just the payment itself). Implement thePayment.set_renew_token()andPayment.get_renew_token().ImplementPayment.get_payment_url().For the server initiated recurring payments you will need to create the new payment and then callpayment.auto_complete_recurring().The method returns either string ‘success’ or url where the user can provide his CVV2 or 3D secure information.The'success'string means, that the payment is waiting for notification from PayU, but no further user action is required.Example of triggering recurring payment:payment = Payment.objects.create(...)
redirect_url = payment.auto_complete_recurring()
if redirect_url != 'success':
    send_mail(
        'Recurring payment - action required',
        'Please renew your CVV2/3DS at %s' % redirect_url,
        'noreply@test.com',
        [user.email],
        fail_silently=False,
    )Running TestsDoes the code actually work?source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ toxCreditsTools used in rendering this package:Cookiecuttercookiecutter-djangopackageHistory1.2.4 (2022-03-17)treat partial refundstests for Django 2.2-4.0 Python 3.7-3.101.2.3 (2022-01-25)better distinct PayU API errors1.2.2 (2021-11-30)solve the duplicate order case that errored already confirmed payment1.2.1 (2021-10-29)set fraud status if PayU anti-froud errorstore PayU error on payment1.2.0 (2021-10-11)user Payment.billing_* correctly - the functions likeget_userorget_user_email,get_user_first_nameandget_user_last_namewere redundant and are not called anymore.Shop name is taken from provider configuration variableshop_name1.1.0 (2021-10-05)redirect to payment.get_failure_url() after API error, log the error1.0.0 (2020-10-21)first major releasemany fixesrecurring payments workingproved by production environment0.3.0 (2020-05-30)fix amount quantizationadd store_card parameterfix base url parameter for express form0.2.0 (2020-04-13)Second releaseFixed testing matrix0.1.0 (2020-04-06)First release on PyPI.Still in development.