def test_related_wallet(self):
        user = NaturalUser(**{
            'first_name': 'Mark',
            'last_name': 'Zuckerberg',
            'email': '*****@*****.**',
            'ip_address': '127.0.0.1',
            'tag': 'custom_information',
            'nationality': 'FR',
            'birthday': date.today(),
            'country_of_residence': 'FR'
        })
        user.save(handler)

        wallet = Wallet(**{
            'tag': 'user',
            'name': 'Mark Zuckerberg wallet',
            'description': 'Wallet of Mark Zuckerberg',
            'owners': [user]
        })

        wallet.save(handler=handler)

        user = NaturalUser.get(user.get_pk(), handler=handler)

        self.assertEqual(user.wallets, [wallet])
    def natural_user_wallet(self):
        natural_user_wallet_params = {
            'tag': 'My custom tag',
            'owners': [self.natural_user],
            'description': 'Wallet of Victor Hugo',
            'currency': 'EUR'
        }

        natural_user_wallet = Wallet(**natural_user_wallet_params)
        natural_user_wallet.save()

        return natural_user_wallet
    def legal_user_wallet(self):
        legal_user_wallet_params = {
            'tag': 'My custom tag',
            'owners': [self.legal_user],
            'description': 'Wallet of Victor Hugo',
            'currency': 'EUR'
        }

        legal_user_wallet = Wallet(**legal_user_wallet_params)
        legal_user_wallet.save()

        return legal_user_wallet
Exemple #4
0
    def test_ApplePay_Payin(self):
        user = self.get_john(True)
        debited_wallet = self.get_johns_wallet()

        # 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())
        card = BaseTestLive.get_johns_card(True)

        pay_in = ApplepayPayIn()
        pay_in.author = user
        pay_in.credited_user = user
        pay_in.credited_wallet = credited_wallet
        pay_in.fees = Money()
        pay_in.fees.amount = 1
        pay_in.fees.currency = "EUR"
        pay_in.debited_funds = Money()
        pay_in.debited_funds.amount = 199
        pay_in.debited_funds.currency = "EUR"
        payment_data = ApplepayPaymentData()
        payment_data.transaction_id = '061EB32181A2D9CA42AD16031B476EEBAA62A9A095AD660E2759FBA52B51A61'
        payment_data.network = 'VISA'
        payment_data.token_data = "{\"version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MxMTA1MDdaMCoGCSqGSIb3DQEJNDEdMBswDQYJYIZIAWUDBAIBBQChCgYIKoZIzj0EAwIwLwYJKoZIhvcNAQkEMSIEIIvfGVQYBeOilcB7GNI8m8+FBVZ28QfA6BIXaggBja2PMAoGCCqGSM49BAMCBEYwRAIgU01yYfjlx9bvGeC5CU2RS5KBEG+15HH9tz\\/sg3qmQ14CID4F4ZJwAz+tXAUcAIzoMpYSnM8YBlnGJSTSp+LhspenAAAAAAAA\",\"header\":{\"ephemeralPublicKey\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE0rs3wRpirXjPbFDQfPRdfEzRIZDWm0qn7Y0HB0PNzV1DDKfpYrnhRb4GEhBF\\/oEXBOe452PxbCnN1qAlqcSUWw==\",\"publicKeyHash\":\"saPRAqS7TZ4bAYwzBj8ezDDC55ZolyH1FL+Xc8fd93o=\",\"transactionId\":\"b061eb32181a2d9ca42ad16031b476eebaa62a9a095ad660e2759fba52b51a61\"}}"
        pay_in.payment_data = payment_data
        pay_in.statement_descriptor = 'Python'
        pay_in.payment_type = constants.PAYIN_PAYMENT_TYPE.applepay
        pay_in.execution_type = constants.EXECUTION_TYPE_CHOICES.direct
        result = pay_in.save()
        self.assertIsNotNone(result)
    def test_GooglePay_payIn(self):
        user = self.get_john(True)
        debited_wallet = self.get_johns_wallet()

        # 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())
        card = BaseTestLive.get_johns_card(True)

        pay_in = GooglepayPayIn()
        pay_in.author = user
        pay_in.credited_user = user
        pay_in.credited_wallet = credited_wallet
        pay_in.fees = Money()
        pay_in.fees.amount = 1
        pay_in.fees.currency = "EUR"
        pay_in.debited_funds = Money()
        pay_in.debited_funds.amount = 199
        pay_in.debited_funds.currency = "EUR"
        payment_data = GooglepayPaymentData()
        # can't be tested
        payment_data.transaction_id = "placeholder"
        payment_data.network = 'VISA'
        payment_data.token_data = "placeholder"
        pay_in.payment_data = payment_data
        pay_in.statement_descriptor = 'Python'
        pay_in.payment_type = constants.PAYIN_PAYMENT_TYPE.googlepay
        pay_in.execution_type = constants.EXECUTION_TYPE_CHOICES.direct
        result = pay_in.save()
        self.assertIsNotNone(result)
    def test_create_wallet(self):
        params = {
            'first_name': 'Mark',
            'last_name': 'Zuckerberg',
            'email': '*****@*****.**',
            'ip_address': '127.0.0.1',
            'tag': 'custom_information',
            'nationality': 'FR',
            'birthday': date.today(),
            'country_of_residence': 'FR'
        }

        user = NaturalUser(**params)
        user.save(handler)

        wallet_params = {
            'tag': 'user',
            'name': 'Mark Zuckerberg wallet',
            'description': 'Wallet of Mark Zuckerberg',
            'owners': [user]
        }

        wallet = Wallet(**wallet_params)
        wallet.save(handler=handler)
        print "wallet %r" % wallet.__dict__
        params = dict(wallet_params, **{
            'currency': 'EUR',
            'balance': (0, 'EUR')
        })

        from mangopay.signals import request_started

        def print_infos(signal, **kw):
            print("Before send data : %r" % kw)
        request_started.connect(print_infos)

        for k, v in params.items():
            self.assertEqual(getattr(wallet, k), v)

        w = Wallet.get(wallet.get_pk(), handler)

        for k, v in wallet_params.items():
            self.assertEqual(getattr(w, k), v)

        self.assertEqual(w.get_pk(), wallet.get_pk())

        self.assertEqual(w.users, [user])
    def test_PayIns_DirectDebitDirect_Create(self):
        # create wallet
        wallet = Wallet()
        wallet.owners = (BaseTestLive.get_john(), )
        wallet.currency = 'EUR'
        wallet.description = 'WALLET IN EUR'
        wallet = Wallet(**wallet.save())

        mandate = Mandate()
        mandate.bank_account_id = BaseTestLive.get_johns_account().id
        mandate.return_url = 'http://test.test'
        mandate.culture = 'FR'
        mandate = Mandate(**mandate.save())

        #       ! IMPORTANT NOTE !
        #       In order to make this test pass, at this place you have to set a breakpoint,
        #       navigate to URL the mandate.RedirectURL property points to and click "CONFIRM" button.

        post = DirectDebitDirectPayIn()
        post.author = BaseTestLive.get_john()
        post.credited_wallet = wallet
        post.debited_funds = Money('1000', 'EUR')
        post.fees = Money('0', 'EUR')
        post.mandate = mandate

        result = post.save()

        self.assertIsNotNone(result)
        self.assertFalse(
            'FAILED' == result['status'],
            'In order to make this test pass, after creating mandate and before creating the payin you have\
                          to navigate to URL the mandate.redirect_url property points to and click CONFIRM button.'
        )
        self.assertTrue(result['id'])
        self.assertEqual(wallet.id, result['credited_wallet_id'])
        self.assertEqual('DIRECT_DEBIT', result['payment_type'])
        self.assertEqual('DIRECT', result['execution_type'])
        self.assertEqual(BaseTestLive.get_john().id, result['author_id'])
        self.assertEqual('CREATED', result['status'])
        self.assertEqual('PAYIN', result['type'])
        self.assertIsNotNone(result['mandate_id'])
        self.assertEqual(mandate.id, result['mandate_id'])
    def test_PayIns_CardDirect_CreateWithAvs(self):
        user = BaseTestLive.get_john(True)
        debited_wallet = BaseTestLive.get_johns_wallet(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())
        card = BaseTestLive.get_johns_card(True)

        pay_in = DirectPayIn()
        pay_in.author = user
        pay_in.debited_wallet = debited_wallet
        pay_in.credited_wallet = credited_wallet
        pay_in.card = card
        pay_in.fees = Money()
        pay_in.fees.amount = 100
        pay_in.fees.currency = "EUR"
        pay_in.debited_funds = Money()
        pay_in.debited_funds.amount = 1000
        pay_in.debited_funds.currency = "EUR"
        pay_in.secure_mode_return_url = "http://www.example.com/"
        address = Address()
        address.address_line_1 = "Big Street"
        address.address_line_2 = "no 2 ap 6"
        address.country = "FR"
        address.city = "Lyon"
        address.postal_code = "68400"
        pay_in.billing = Billing(first_name="John",
                                 last_name="Doe",
                                 address=address)

        result = pay_in.save()

        self.assertIsNotNone(result)
        security_info = result['security_info']
        self.assertIsNotNone(security_info)
        self.assertIsInstance(security_info, SecurityInfo)
        self.assertEqual(security_info.avs_result, "NO_CHECK")
 def create_new_wallet():
     wallet = Wallet()
     wallet.owners = (BaseTestLive._john, )
     wallet.currency = 'EUR'
     wallet.description = 'WALLET IN EUR'
     return Wallet(**wallet.save())
Exemple #10
0
    def test_create_wallet(self):
        self.mock_natural_user()

        self.register_mock([{
            'method':
            responses.POST,
            'url':
            settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID +
            '/wallets',
            'body': {
                "Owners": ["1169419"],
                "Description": "Wallet of Victor Hugo",
                "Balance": {
                    "Currency": "EUR",
                    "Amount": 0
                },
                "Currency": "EUR",
                "Id": "1169421",
                "Tag": "your custom tag",
                "CreationDate": 1383323329
            },
            'status':
            200
        }, {
            'method':
            responses.GET,
            'url':
            settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID +
            '/wallets/1169421',
            'body': {
                "Owners": ["1169419"],
                "Description": "Wallet of Victor Hugo",
                "Balance": {
                    "Currency": "EUR",
                    "Amount": 0
                },
                "Currency": "EUR",
                "Id": "1169421",
                "Tag": "My custom tag",
                "CreationDate": 1383323329
            },
            'status':
            200
        }, {
            'method':
            responses.PUT,
            'url':
            settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID +
            '/wallets/1169421',
            'body': {
                "Owners": ["1169419"],
                "Description": "Wallet of Victor Hugo",
                "Balance": {
                    "Currency": "EUR",
                    "Amount": 0
                },
                "Currency": "EUR",
                "Id": "1169421",
                "Tag": "My custom tag",
                "CreationDate": 1383323329
            },
            'status':
            200
        }, {
            'method':
            responses.GET,
            'url':
            settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID +
            '/users/1169419/wallets',
            'body': [{
                "Owners": ["1169419"],
                "Description": "Wallet of Victor Hugo",
                "Balance": {
                    "Currency": "EUR",
                    "Amount": 0
                },
                "Currency": "EUR",
                "Id": "1169421",
                "Tag": "your custom tag",
                "CreationDate": 1383323329
            }],
            'status':
            200
        }])

        wallet_params = {
            'tag': 'My custom tag',
            'owners': [self.natural_user],
            'description': 'Wallet of Victor Hugo',
            'currency': 'EUR'
        }

        wallet = Wallet(**wallet_params)
        wallet.save()

        w = Wallet.get(wallet.get_pk())

        for k, v in wallet_params.items():
            if isinstance(v, list):
                self.assertEqual([self.natural_user], v)  # TODO: Fix this
            else:
                self.assertEqual(getattr(w, k), v)

        self.assertEqual(w.get_pk(), wallet.get_pk())

        previous_pk = wallet.get_pk()

        wallet.description = "Wallet of Victor Claver"
        wallet.save()

        self.assertEqual(previous_pk, wallet.get_pk())

        self.assertEqual(len(self.natural_user.wallets), 1)
        self.assertEqual(self.natural_user.wallets, [wallet])
Exemple #11
0
    def test_related_wallet(self):
        self.mock_natural_user()

        self.register_mock([{
            'method':
            responses.POST,
            'url':
            settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID +
            '/wallets',
            'body': {
                "Owners": ["1167492"],
                "Description": "A very cool wallet",
                "Balance": {
                    "Currency": "EUR",
                    "Amount": 0
                },
                "Currency": "EUR",
                "Id": "1169421",
                "Tag": "your custom tag",
                "CreationDate": 1383323329
            },
            'status':
            200
        }, {
            'method':
            responses.GET,
            'url':
            settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID +
            '/users/natural/1169419',
            'body': {
                "FirstName": "Victor",
                "LastName": "Claver",
                "Address": {
                    "AddressLine1": "AddressLine1",
                    "AddressLine2": "AddressLine2",
                    "City": "City",
                    "Region": "Region",
                    "PostalCode": "11222",
                    "Country": "FR"
                },
                "Birthday": int(time.mktime(date.today().timetuple())),
                "Nationality": "FR",
                "CountryOfResidence": "FR",
                "Occupation": "Writer",
                "IncomeRange": 6,
                "PersonType": "NATURAL",
                "Email": "*****@*****.**",
                "Id": "1169419",
                "Tag": "custom tag",
                "CreationDate": 1383321421,
                "KYCLevel": "LIGHT"
            },
            'status':
            200
        }, {
            'method':
            responses.GET,
            'url':
            settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID +
            '/users/1169419/wallets',
            'body': [{
                "Owners": ["1167492"],
                "Description": "A very cool wallet",
                "Balance": {
                    "Currency": "EUR",
                    "Amount": 0
                },
                "Currency": "EUR",
                "Id": "1169421",
                "Tag": "your custom tag",
                "CreationDate": 1383323329
            }],
            'status':
            200
        }])

        wallet_params = {
            'tag': 'My custom tag',
            'owners': [self.natural_user],
            'description': 'Wallet of Victor Hugo',
            'currency': 'EUR'
        }
        wallet = Wallet(**wallet_params)
        wallet.save()

        user = NaturalUser.get(self.natural_user.get_pk())

        self.assertEqual(user.wallets, [wallet])
    def test_create_transfers(self):
        self.mock_natural_user()
        self.mock_legal_user()
        self.mock_user_wallet()
        self.mock_card()

        self.register_mock([{
            'method':
            responses.GET,
            'url':
            settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID +
            '/users/1167495',
            'body': {
                "FirstName": "Victor",
                "LastName": "Hugo",
                "Address": {
                    "AddressLine1": "AddressLine1",
                    "AddressLine2": "AddressLine2",
                    "City": "City",
                    "Region": "Region",
                    "PostalCode": "11222",
                    "Country": "FR"
                },
                "Birthday": int(time.mktime(date.today().timetuple())),
                "Nationality": "FR",
                "CountryOfResidence": "FR",
                "Occupation": "Writer",
                "IncomeRange": 6,
                "ProofOfIdentity": None,
                "ProofOfAddress": None,
                "PersonType": "NATURAL",
                "Email": "*****@*****.**",
                "Id": "1167495",
                "Tag": "custom tag",
                "CreationDate": 1383321421,
                "KYCLevel": "LIGHT"
            },
            'status':
            200
        }, {
            'method':
            responses.POST,
            'url':
            settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID +
            '/payins/card/direct',
            'body': {
                "Id": "6784288",
                "Tag": None,
                "CreationDate": 1432046586,
                "AuthorId": "6784285",
                "CreditedUserId": "6784283",
                "DebitedFunds": {
                    "Currency": "EUR",
                    "Amount": 10000
                },
                "CreditedFunds": {
                    "Currency": "EUR",
                    "Amount": 9900
                },
                "Fees": {
                    "Currency": "EUR",
                    "Amount": 100
                },
                "Status": "SUCCEEDED",
                "ResultCode": "000000",
                "ResultMessage": "Success",
                "ExecutionDate": 1432046588,
                "Type": "PAYIN",
                "Nature": "REGULAR",
                "CreditedWalletId": "6784284",
                "DebitedWalletId": None,
                "PaymentType": "CARD",
                "ExecutionType": "DIRECT",
                "SecureMode": "DEFAULT",
                "CardId": "6784287",
                "SecureModeReturnURL": None,
                "SecureModeRedirectURL": None,
                "SecureModeNeeded": False
            },
            'status':
            200
        }, {
            'method':
            responses.POST,
            'url':
            settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID +
            '/transfers',
            'body': {
                "Id": "1169434",
                "Tag": "custom tag",
                "CreationDate": 1431648000,
                "AuthorId": "1167495",
                "CreditedUserId": "1167502",
                "DebitedFunds": {
                    "Currency": "EUR",
                    "Amount": 1000
                },
                "CreditedFunds": {
                    "Currency": "EUR",
                    "Amount": 900
                },
                "Fees": {
                    "Currency": "EUR",
                    "Amount": 100
                },
                "Status": "SUCCEEDED",
                "ResultCode": "000000",
                "ResultMessage": "Success",
                "ExecutionDate": int(time.mktime(date.today().timetuple())),
                "Type": "TRANSFER",
                "Nature": "REGULAR",
                "DebitedWalletId": "1167496",
                "CreditedWalletId": "1167504"
            },
            'status':
            200
        }, {
            'method':
            responses.GET,
            'url':
            settings.MANGOPAY_API_SANDBOX_URL + settings.MANGOPAY_CLIENT_ID +
            '/transfers/1169434',
            'body': {
                "Id": "1169434",
                "Tag": "DefaultTag",
                "CreationDate": 1383556653,
                "AuthorId": "1167495",
                "CreditedUserId": "1167502",
                "DebitedFunds": {
                    "Currency": "EUR",
                    "Amount": 1000
                },
                "CreditedFunds": {
                    "Currency": "EUR",
                    "Amount": 900
                },
                "Fees": {
                    "Currency": "EUR",
                    "Amount": 100
                },
                "Status": "SUCCEEDED",
                "ResultCode": "000000",
                "ResultMessage": "Success",
                "ExecutionDate": 1383556653,
                "Type": "TRANSFER",
                "Nature": "REGULAR",
                "DebitedWalletId": "1167496",
                "CreditedWalletId": "1167504"
            },
            'status':
            200
        }])

        wallet_params = {
            'tag': 'My custom tag',
            'owners': [self.card.user],
            'description': 'Wallet of Victor Hugo',
            'currency': 'EUR'
        }
        wallet = Wallet(**wallet_params)
        wallet.save()

        direct_payin_params = {
            "author": self.card.user,
            "debited_funds": Money(amount=10000, currency='EUR'),
            "fees": Money(amount=100, currency='EUR'),
            "credited_wallet": wallet,
            "card": self.card,
            "secure_mode": "DEFAULT",
            "secure_mode_return_url": "http://www.ulule.com/"
        }
        direct_payin = DirectPayIn(**direct_payin_params)
        direct_payin.save()

        params = {
            "author": self.card.user,
            "credited_user": self.legal_user,
            "debited_funds": Money(amount=1000, currency='EUR'),
            "fees": Money(amount=100, currency='EUR'),
            "debited_wallet": wallet,
            "credited_wallet": self.legal_user_wallet,
            "tag": "custom tag"
        }
        transfer = Transfer(**params)

        self.assertIsNone(transfer.get_pk())
        transfer.save()
        self.assertIsInstance(transfer, Transfer)

        self.assertEqual(transfer.status, 'SUCCEEDED')

        self.assertEqual(direct_payin.debited_funds.amount, 10000)
        direct_payin_params.pop('debited_funds')

        self.assertEqual(direct_payin.fees.amount, 100)
        direct_payin_params.pop('fees')

        for key, value in params.items():
            self.assertEqual(getattr(transfer, key), value)

        self.assertIsNotNone(transfer.get_pk())

        # test_retrieve_transfers
        retrieved_transfer = Transfer.get(transfer.get_pk())

        self.assertIsNotNone(retrieved_transfer.get_pk())
        self.assertIsInstance(retrieved_transfer, Transfer)

        self.assertEqual(getattr(retrieved_transfer, 'id'), transfer.get_pk())