Skip to content

Commit

Permalink
Merge pull request #368 from Mangopay/feature/bancontact-payin
Browse files Browse the repository at this point in the history
implemented bancontact payin
  • Loading branch information
iulian03 authored Aug 13, 2024
2 parents ec4405e + e51b353 commit db29f12
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 4 deletions.
3 changes: 2 additions & 1 deletion mangopay/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@
("SATISPAY", "satispay", "Satispay"),
("BLIK", "blik", "Blik"),
("IDEAL", "ideal", "Ideal"),
("GIROPAY", "giropay", "Giropay")
("GIROPAY", "giropay", "Giropay"),
("BCMC", "bancontact", "Bancontact")
)

CARD_STATUS_CHOICES = Choices(
Expand Down
23 changes: 23 additions & 0 deletions mangopay/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ def cast(cls, result):
("KLARNA", "WEB"): KlarnaPayIn,
("IDEAL", "WEB"): IdealPayIn,
("GIROPAY", "WEB"): GiropayPayIn,
("BANCONTACT", "WEB"): BancontactPayIn
}

return types.get((payment_type, execution_type), cls)
Expand Down Expand Up @@ -1143,6 +1144,28 @@ class Meta:
}


class BancontactPayIn(PayIn):
author = ForeignKeyField(User, api_name='AuthorId', required=True)
credited_wallet = ForeignKeyField(Wallet, api_name='CreditedWalletId', required=True)
debited_funds = MoneyField(api_name='DebitedFunds', required=True)
fees = MoneyField(api_name='Fees', required=True)
return_url = CharField(api_name='ReturnURL', required=True)
statement_descriptor = CharField(api_name='StatementDescriptor')
creation_date = DateTimeField(api_name='CreationDate')
redirect_url = CharField(api_name='RedirectURL')
recurring = BooleanField(api_name='Recurring')
culture = CharField(api_name='Culture')
deep_link_url = CharField(api_name='DeepLinkURL')

class Meta:
verbose_name = 'gancontact_payin'
verbose_name_plural = 'bancontact_payins'
url = {
InsertQuery.identifier: '/payins/payment-methods/bancontact',
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
43 changes: 40 additions & 3 deletions tests/test_payins.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from mangopay.resources import DirectDebitDirectPayIn, Mandate, ApplepayPayIn, GooglepayPayIn, \
RecurringPayInRegistration, \
RecurringPayInCIT, PayInRefund, RecurringPayInMIT, CardPreAuthorizedDepositPayIn, MbwayPayIn, PayPalWebPayIn, \
GooglePayDirectPayIn, MultibancoPayIn, SatispayPayIn, BlikPayIn, KlarnaPayIn, IdealPayIn, GiropayPayIn, CardRegistration
GooglePayDirectPayIn, MultibancoPayIn, SatispayPayIn, BlikPayIn, KlarnaPayIn, IdealPayIn, GiropayPayIn, \
CardRegistration, BancontactPayIn
from mangopay.utils import (Money, ShippingAddress, Shipping, Billing, Address, SecurityInfo, ApplepayPaymentData,
GooglepayPaymentData, DebitedBankAccount, LineItem, CardInfo)
from tests import settings
Expand Down Expand Up @@ -1520,7 +1521,6 @@ def test_PayIns_IdealWeb_Create(self):
self.assertEqual("IDEAL", result.payment_type)
self.assertEqual("PAYIN", result.type)


def test_PayIns_GiropayWeb_Create(self):
user = BaseTestLive.get_john(True)

Expand Down Expand Up @@ -1557,6 +1557,44 @@ def test_PayIns_GiropayWeb_Create(self):
self.assertEqual("GIROPAY", result.payment_type)
self.assertEqual("PAYIN", result.type)

def test_PayIns_BancontactWeb_Create(self):
user = BaseTestLive.get_john(True)

# create wallet
credited_wallet = Wallet()
credited_wallet.owners = (user,)
credited_wallet.currency = 'EUR'
credited_wallet.description = 'WALLET IN EUR'
credited_wallet = Wallet(**credited_wallet.save())

pay_in = BancontactPayIn()
pay_in.author = user
pay_in.credited_wallet = credited_wallet
pay_in.fees = Money()
pay_in.fees.amount = 200
pay_in.fees.currency = 'EUR'
pay_in.debited_funds = Money()
pay_in.debited_funds.amount = 2000
pay_in.debited_funds.currency = 'EUR'
pay_in.statement_descriptor = 'test'
pay_in.return_url = 'https://mangopay.com/'
pay_in.tag = 'Bancontact PayIn'
pay_in.recurring = True
pay_in.culture = 'FR'

result = BancontactPayIn(**pay_in.save())
fetched = BancontactPayIn().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("BCMC", result.payment_type)
self.assertEqual("PAYIN", result.type)

def test_PayIns_Legacy_IdealWeb_Create(self):
user = BaseTestLive.get_john(True)

Expand All @@ -1580,7 +1618,6 @@ def test_PayIns_Legacy_IdealWeb_Create(self):
payin.bic = 'RBRBNL21'
result = CardWebPayIn(**payin.save())


self.assertIsNotNone(result)
self.assertIsNotNone(result.bank_name)

Expand Down

0 comments on commit db29f12

Please sign in to comment.