def create(self): author = self.mangopay_user.get_user() payin = self.mangopay_pay_in.get_pay_in() payin_refund = PayInRefund( author=author, payin=payin, ) payin_refund.save() self.mangopay_id = payin_refund.get_pk() self.status = payin_refund.status self.result_code = payin_refund.result_code self.execution_date = get_execution_date_as_datetime(payin_refund) self.save() return self
def test_RecurringPayment(self): user = self.get_john(True) wallet = self.get_johns_wallet(True) card = BaseTestLive.get_johns_card_3dsecure(True) recurring = RecurringPayInRegistration() recurring.author = user recurring.card = card recurring.user = user recurring.credited_wallet = wallet recurring.first_transaction_fees = Money(1, "EUR") recurring.first_transaction_debited_funds = Money(12, "EUR") 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" recurring.billing = Billing(first_name="John", last_name="Doe", address=address) recurring.shipping = Shipping(first_name="John", last_name="Doe", address=address) recurring.end_date = 1768656033 recurring.migration = True recurring.next_transaction_fees = Money(1, "EUR") recurring.next_transaction_debited_funds = Money(12, "EUR") result = recurring.save() self.assertIsNotNone(result) created_recurring = RecurringPayInRegistration.get(result.get('id')) self.assertIsNotNone(created_recurring) print(created_recurring.id) cit = RecurringPayInCIT() cit.recurring_payin_registration_id = created_recurring.id cit.tag = "custom meta" cit.statement_descriptor = "lorem" cit.secure_mode_return_url = "http://www.my-site.com/returnurl" cit.ip_address = "2001:0620:0000:0000:0211:24FF:FE80:C12C" browser = BrowserInfo() browser.accept_header = "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8" browser.java_enabled = True browser.language = "FR-FR" browser.color_depth = 4 browser.screen_width = 400 browser.screen_height = 1800 browser.javascript_enabled = True browser.timezone_offset = "+60" browser.user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" cit.browser_info = browser cit.debited_funds = Money(12, "EUR") cit.fees = Money(1, "EUR") created_cit = cit.save() self.assertIsNotNone(created_cit) cit_id = created_cit.get('id') got_cit = RecurringPayInCIT.get(cit_id) self.assertIsNotNone(got_cit) self.assertIsInstance(got_cit, RecurringPayInCIT) mit = RecurringPayInMIT() mit.recurring_payin_registration_id = created_recurring.id mit.statement_descriptor = "lorem" mit.tag = "custom meta" mit.debited_funds = Money(10, "EUR") mit.fees = Money(1, "EUR") created_mit = mit.save() self.assertIsNotNone(created_mit) got_cit = RecurringPayInCIT.get(cit_id) self.assertIsNotNone(got_cit) #self.assertIsInstance(got_cit, RecurringPayInCIT) params = {"author": user, "payin": got_cit} payin_refund = PayInRefund(**params) self.assertIsNotNone(payin_refund) self.assertIsNone(payin_refund.get_pk()) payin_refund.save() self.assertIsInstance(payin_refund, PayInRefund) self.assertEqual(payin_refund.status, 'SUCCEEDED') mit_id = created_mit.get('id') got_mit = RecurringPayInMIT.get(mit_id) self.assertIsNotNone(got_mit) self.assertIsInstance(got_mit, RecurringPayInMIT) params = {"author": user, "payin": got_mit} payin_refund_mit = PayInRefund(**params) self.assertIsNotNone(payin_refund_mit) self.assertIsNone(payin_refund_mit.get_pk()) payin_refund_mit.save() self.assertIsInstance(payin_refund_mit, PayInRefund) self.assertEqual(payin_refund_mit.status, 'SUCCEEDED')