Skip to content

Commit

Permalink
Integrated Satispay
Browse files Browse the repository at this point in the history
  • Loading branch information
Silviana Ghita committed Sep 4, 2023
1 parent ed4578e commit 7bfb3e3
Show file tree
Hide file tree
Showing 3 changed files with 60 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 @@ -288,7 +288,8 @@
("APPLEPAY", "applepay", "Applepay"),
("GOOGLEPAY", "googlepay", "Googlepay"),
("MBWAY", "mbway", "Mbway"),
("MULTIBANCO", "multibanco", "Multibanco")
("MULTIBANCO", "multibanco", "Multibanco"),
("SATISPAY", "satispay","Satispay"),
)

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 @@ -479,6 +479,7 @@ def cast(cls, result):
("GOOGLEPAY", "DIRECT"): GooglepayPayIn,
("MBWAY", "DIRECT"): MbwayPayIn,
("MULTIBANCO", "DIRECT"): MultibancoPayIn,
("SATISPAY", "DIRECT"): SatispayPayIn,
}

return types.get((payment_type, execution_type), cls)
Expand Down Expand Up @@ -777,6 +778,24 @@ class Meta:
SelectQuery.identifier: '/payins'
}

class SatispayPayIn(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)
return_url = CharField(api_name='ReturnURL', required=True)
redirect_url = CharField(api_name='RedirectURL')
country = CharField(api_name='Country', required=True)
statement_descriptor = CharField(api_name='StatementDescriptor')

class Meta:
verbose_name = 'satispay_payin'
verbose_name_plural = 'satispay_payins'
url = {
InsertQuery.identifier: '/payins/payment-methods/satispay',
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
40 changes: 39 additions & 1 deletion tests/test_payins.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from mangopay.resources import DirectDebitDirectPayIn, Mandate, ApplepayPayIn, GooglepayPayIn, \
RecurringPayInRegistration, \
RecurringPayInCIT, PayInRefund, RecurringPayInMIT, CardPreAuthorizedDepositPayIn, MbwayPayIn, MultibancoPayIn
RecurringPayInCIT, PayInRefund, RecurringPayInMIT, CardPreAuthorizedDepositPayIn, MbwayPayIn, MultibancoPayIn, SatispayPayIn
from mangopay.utils import (Money, ShippingAddress, Shipping, Billing, Address, SecurityInfo, ApplepayPaymentData,
GooglepayPaymentData, DebitedBankAccount, BrowserInfo)

Expand Down Expand Up @@ -1194,3 +1194,41 @@ def test_PayIns_MultibancoDirect_Create(self):
self.assertEqual("WEB", result.execution_type)
self.assertEqual("MULTIBANCO", result.payment_type)
self.assertEqual("PAYIN", result.type)

def test_PayIns_SatispayDirect_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 = SatispayPayIn()
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 = 'http://www.my-site.com/returnURL?transactionId=wt_71a08458-b0cc-468d-98f7-1302591fc238'
pay_in.tag = 'Satispay tag'
pay_in.country = 'IT'

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

0 comments on commit 7bfb3e3

Please sign in to comment.