From 680e7199dc7428529f1dd6df0b6bf717c8eba316 Mon Sep 17 00:00:00 2001 From: Silviana Ghita Date: Mon, 4 Sep 2023 16:32:01 +0300 Subject: [PATCH] Integrated Blik --- mangopay/constants.py | 3 ++- mangopay/resources.py | 19 +++++++++++++++++++ tests/test_payins.py | 39 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/mangopay/constants.py b/mangopay/constants.py index c6a1e27..271876a 100644 --- a/mangopay/constants.py +++ b/mangopay/constants.py @@ -289,7 +289,8 @@ ("GOOGLEPAY", "googlepay", "Googlepay"), ("MBWAY", "mbway", "Mbway"), ("MULTIBANCO", "multibanco", "Multibanco"), - ("SATISPAY", "satispay","Satispay"), + ("SATISPAY", "satispay", "Satispay"), + ("BLIK", "blik", "Blik") ) CARD_STATUS_CHOICES = Choices( diff --git a/mangopay/resources.py b/mangopay/resources.py index 22d7988..977a36d 100644 --- a/mangopay/resources.py +++ b/mangopay/resources.py @@ -480,6 +480,7 @@ def cast(cls, result): ("MBWAY", "DIRECT"): MbwayPayIn, ("MULTIBANCO", "DIRECT"): MultibancoPayIn, ("SATISPAY", "DIRECT"): SatispayPayIn, + ("BLIK", "DIRECT"): BlikPayIn, } return types.get((payment_type, execution_type), cls) @@ -796,6 +797,24 @@ class Meta: SelectQuery.identifier: '/payins' } +class BlikPayIn(PayIn): + creation_date = DateTimeField(api_name='CreationDate') + author = ForeignKeyField(User, api_name='AuthorId', required=True) + debited_funds = MoneyField(api_name='DebitedFunds', required=True) + fees = MoneyField(api_name='Fees', required=True) + statement_descriptor = CharField(api_name='StatementDescriptor') + return_url = CharField(api_name='ReturnURL', required=True) + redirect_url = CharField(api_name='RedirectURL') + + class Meta: + verbose_name = 'blik_payin' + verbose_name_plural = 'blik_payins' + url = { + InsertQuery.identifier: '/payins/payment-methods/blik', + SelectQuery.identifier: '/payins' + } + + class CardWebPayIn(PayIn): author = ForeignKeyField(User, api_name='AuthorId', required=True) credited_wallet = ForeignKeyField(Wallet, api_name='CreditedWalletId', required=True) diff --git a/tests/test_payins.py b/tests/test_payins.py index 5368a50..6e5985a 100644 --- a/tests/test_payins.py +++ b/tests/test_payins.py @@ -9,7 +9,8 @@ from mangopay.resources import DirectDebitDirectPayIn, Mandate, ApplepayPayIn, GooglepayPayIn, \ RecurringPayInRegistration, \ - RecurringPayInCIT, PayInRefund, RecurringPayInMIT, CardPreAuthorizedDepositPayIn, MbwayPayIn, MultibancoPayIn, SatispayPayIn + RecurringPayInCIT, PayInRefund, RecurringPayInMIT, CardPreAuthorizedDepositPayIn, MbwayPayIn, MultibancoPayIn, SatispayPayIn, \ + BlikPayIn from mangopay.utils import (Money, ShippingAddress, Shipping, Billing, Address, SecurityInfo, ApplepayPaymentData, GooglepayPaymentData, DebitedBankAccount, BrowserInfo) @@ -1232,3 +1233,39 @@ def test_PayIns_SatispayDirect_Create(self): self.assertEqual("SATISPAY", result.payment_type) self.assertEqual("PAYIN", result.type) + def test_PayIns_BlikDirect_Create(self): + user = BaseTestLive.get_john(True) + + # create wallet + credited_wallet = Wallet() + credited_wallet.owners = (user,) + credited_wallet.currency = 'PLN' + credited_wallet.description = 'WALLET IN PLN' + credited_wallet = Wallet(**credited_wallet.save()) + + pay_in = BlikPayIn() + pay_in.author = user + pay_in.credited_wallet = credited_wallet + pay_in.fees = Money() + pay_in.fees.amount = 300 + pay_in.fees.currency = 'PLN' + pay_in.debited_funds = Money() + pay_in.debited_funds.amount = 1000 + pay_in.debited_funds.currency = 'PLN' + pay_in.statement_descriptor = 'test' + pay_in.return_url = 'https://example.com?transactionId=wt_57b8f69d-cbcc-4202-9a4f-9a3f3668240b' + pay_in.redirect_url = 'https://r3.girogate.de/ti/dumbdummy?tx=140079495229&rs=oHkl4WvsgwtWpMptWpqWlFa90j0EzzO9&cs=e43baf1ae4a556dfb823fd304acc408580c193e04c1a9bcb26699b4185393b05' + pay_in.tag = 'Blik tag' + + result = BlikPayIn(**pay_in.save()) + fetched = BlikPayIn().get(result.id) + + self.assertIsNotNone(result) + self.assertIsNotNone(fetched) + self.assertEqual(result.id, fetched.id) + + self.assertEqual("CREATED", result.status) + self.assertEqual("REGULAR", result.nature) + self.assertEqual("WEB", result.execution_type) + self.assertEqual("BLIK", result.payment_type) + self.assertEqual("PAYIN", result.type) \ No newline at end of file