Skip to content

Commit

Permalink
change cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrumie committed Nov 2, 2021
1 parent ae5ed7a commit 062f9f0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions api/extenal/paystack.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ def pay(self, payload):
user = payload.get("user")
tx_ref = payload.get("tx_ref")
amount = payload.get("amount")
# For paystack, amount must be an integer, convert the amount to an integer
amount = int(round(amount))
redirect_url = payload.get("redirect_url")
currency = payload.get('currency')
api_key = payload.get('api_key')
payload = {
"user_id": user.id,
"reference": tx_ref,
"amount": str(amount),
"amount": amount,
"currency": currency,
"meta": {
"user_id": user.id
Expand All @@ -34,13 +36,13 @@ def pay(self, payload):
}
}
self.method = 'post'
self.api = 'payments'
self.api = 'initialize'
self.headers['Authorization'] = f'Bearer {api_key}'
self.data = payload
response = dict()
response = super(PayStackPayment, self).send()
link = response['data']['authorization_url']
reference = response['data']['authorization_url']
reference = response['data']['reference']
res = {
"link": link,
"message": response['message'],
Expand All @@ -54,7 +56,7 @@ def verify(self, payload):
transaction_id = payload.get("transaction_id")
method = payload.get("method")
self.method = 'get'
self.api = f'transaction/verify/:{transaction_id}'
self.api = f'verify/:{transaction_id}'
self.headers['Authorization'] = f'Bearer {api_key}'
response = dict()
try:
Expand Down
2 changes: 2 additions & 0 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class Meta:


class ApiKeySerializer(serializers.ModelSerializer):
user = serializers.PrimaryKeyRelatedField(read_only=True)

class Meta:
model = UserApiKey
fields = '__all__'
Expand Down
2 changes: 1 addition & 1 deletion api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def post(self, request, *args, **kwargs):
description=description)
response = Response(res, status=status.HTTP_200_OK)
response.set_cookie(
'platform', ["FLUTTERWAVE", "rave_payment"])
'platform', [platform[0], platform[1]])
return response
except KeyboardInterrupt:
return Response({'message': 'An error occured'},
Expand Down
2 changes: 1 addition & 1 deletion multipay/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
]

UI_DOMAIN = os.getenv('UI_DOMAIN', 'http://localhost:8000/')
UI_ROUTE = 'payment/confirm'
UI_ROUTE = 'api/payment/confirm'


# Internationalization
Expand Down

0 comments on commit 062f9f0

Please sign in to comment.