Redirect user to ThePay - create payment

fromthepay.paymentimportPaymentpayment=Payment(config)payment.setValue(321)payment.setMethodId(13)# ID of payment method from abovepayment.setCustomerEmail('test@test.te)payment.setDescription('Order 123 payment')payment.setReturnUrl('https://example.com/payment')# where to redirect user after paymentpayment.setMerchantData(123)# Any custom data - not visible to userpayment.getCreateUrl()# Redirect user to this URL to begin payment

Check incomming payment

This code should be run on returnUrl from above code

return_payment=ReturnPayment(config)return_payment.parseData(self.request.GET)# Pass all GET received data in form of dict()ifnotreturn_payment.checkSignature():returnFalse# Invalid payment signaturereturn_payment.getMerchantData()# -> 123, previously saved custom datareturn_payment.getValue()# -> 321return_payment.getStatus()# Order status, see next paragraph