Skip to content

htukiain/paytrail-rest-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

paytrail-rest-api

Python PayTrail REST api implementation

Example:

views.py:

from django.template import RequestContext
from django.shortcuts import render
from paytrail_rest_api.paytrail import PaytrailRest, PaytrailRestUrlset, PaytrailRestPaymentS1

  def index(request):

    paytrail_urlset = PaytrailRestUrlset(success_url='http://localhost:8000/success',
                                         failure_url='http://localhost:8000/failure',
                                         notification_url='http://localhost:8000/notification'
    )
    payment = PaytrailRestPaymentS1(order_number='1', urlset=paytrail_urlset, price='10.00')
    paytrail_api = PaytrailRest(merchant_id='13466', merchant_secret='6pKF4jkv97zmqBJ3ZL8gUw5DfT2NMQ')
    result = paytrail_api.process_payment(payment)

    context = {
        'result': result
    }

    return render(request, "paytrail_rest_api/index.html", context)  
  
  def success(request):
    print('++success++')
    boldmessage =  "I am bold font from the context"}
    paytrail_api = PaytrailRest(merchant_id='13466', merchant_secret='6pKF4jkv97zmqBJ3ZL8gUw5DfT2NMQ')
    res = paytrail_api.confirm_payment(order_number=request.GET['ORDER_NUMBER'],
                                 time_stamp=request.GET['TIMESTAMP'],
                                 paid=request.GET['PAID'],
                                 method=request.GET['METHOD'],
                                 auth_code=request.GET['RETURN_AUTHCODE']
    )
    context_dict['valid'] = res
        context = {
        'valid': res,
        'boldmessage': boldmessage,

    }

    return render(request, "paytrail_rest_api/success.html", context)

index.html:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<a href="{{ result.get_url }}">Test paytrail</a>
</body>
</html>

success.html:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<p>Success page</p>
{{ valid }}
</body>
</html>

About

Python PayTrail REST api implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%