def test_can_load_external_module(self, mock_post): mock_post.return_value = MockRequst( { "status": False, "message": "Invalid key" }, status_code=400) instance = load_lib('django_paystack.mock_implement')() response = instance.verify_payment("12345", amount=27000) self.assertEqual(response, "hello")
def verify_payment(request, order): amount = request.GET.get("amount") txrf = request.GET.get("trxref") PaystackAPI = load_lib() paystack_instance = PaystackAPI() response = paystack_instance.verify_payment(txrf, amount=int(amount)) if response[0]: payment_verified.send(sender=PaystackAPI, ref=txrf, amount=int(amount) / 100, order=order) return redirect( reverse("paystack:successful_verification", args=[order])) return redirect(reverse("paystack:failed_verification", args=[order]))
def webhook_view(request): # ensure that all parameters are in the bytes representation PaystackAPI = load_lib() paystack_instance = PaystackAPI() signature = request.META["HTTP_X_PAYSTACK_SIGNATURE"] paystack_instance.webhook_api.verify(signature, request.body, full_auth=True) # digest = utils.generate_digest(request.body) # if digest == signature: # payload = json.loads(request.body) # signals.event_signal.send( # sender=request, event=payload['event'], data=payload['data']) return JsonResponse({"status": "Success"})
def setUp(self): from paystack.utils import load_lib self.instance = load_lib('django_paystack.mock_implement')()