from tbk.webpay.commerce import Commerce
commerce = Commerce(testing=True)
from tbk.webpay.logging import configure_logger
from tbk.webpay.logging.official import WebpayOfficialHandler
LOG_BASE_PATH = '/tmp/'
configure_logger(WebpayOfficialHandler(LOG_BASE_PATH))
from tbk.webpay.payment import Payment
payment = Payment(
request_ip = request.META.get('REMOTE_ADDR', None), # customer request ip
commerce=commerce,
success_url='http://127.0.0.1:8080/payment/webpay/success/',
confirmation_url='http://127.0.0.1:8080/payment/webpay/callback/', # callback url with IP
failure_url='http://127.0.0.1:8080/payment/webpay/fail/',
session_id='%s' % str(order.id),
amount=10, # could be int, str or Decimal
order_id=order.id,
)
url = payment.redirect_url
from tbk.webpay.commerce import Commerce
from tbk.webpay.confirmation import Confirmation
commerce = Commerce(testing=True)
confirmation = Confirmation(
commerce=commerce,
request_ip=request.META.get('REMOTE_ADDR', None),
data=request.POST
)
if confirmation.is_success() :
return http.HttpResponse(commerce.acknowledge)
return http.HttpResponse(commerce.reject)