Skip to content

Commit

Permalink
Integrated Blik
Browse files Browse the repository at this point in the history
  • Loading branch information
Silviana Ghita committed Sep 4, 2023
1 parent 7bfb3e3 commit 680e719
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
3 changes: 2 additions & 1 deletion mangopay/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
19 changes: 19 additions & 0 deletions mangopay/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
39 changes: 38 additions & 1 deletion tests/test_payins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

0 comments on commit 680e719

Please sign in to comment.