def test_charge_list_create(self): charge_list = openpay.Charge.all() DUMMY_CHARGE['order_id'] = generate_order_id() charge = charge_list.create(**DUMMY_CHARGE) self.assertTrue(isinstance(charge, openpay.Charge)) self.assertEqual(DUMMY_CHARGE['amount'], charge.amount)
def setUp(self): super(TransferTest, self).setUp() self.customer = openpay.Customer.create(name="John", last_name="Doe", description="Test User", email="*****@*****.**") self.bank_account = self.customer.bank_accounts.create( clabe="032180000118359719", alias="Cuenta principal", holder_name="John Doe") self.card = self.customer.cards.create(card_number="4111111111111111", holder_name="Juan Perez", expiration_year="20", expiration_month="12", cvv2="110", address={ "city": "Querétaro", "country_code": "MX", "postal_code": "76900", "line1": "Av 5 de Febrero", "line2": "Roble 207", "line3": "col carrillo", "state": "Queretaro" }) self.charge = self.customer.charges.create( source_id=self.card.id, method="card", amount=100, description="Test Charge", order_id=generate_order_id()) self.second_customer = openpay.Customer.all().data[3]
def setUp(self): super(TransferTest, self).setUp() self.customer = openpay.Customer.create( name="John", last_name="Doe", description="Test User", email="*****@*****.**") self.bank_account = self.customer.bank_accounts.create( clabe="032180000118359719", alias="Cuenta principal", holder_name="John Doe") self.card = self.customer.cards.create( card_number="4111111111111111", holder_name="Juan Perez", expiration_year="20", expiration_month="12", cvv2="110", address={ "city": "Querétaro", "country_code": "MX", "postal_code": "76900", "line1": "Av 5 de Febrero", "line2": "Roble 207", "line3": "col carrillo", "state": "Queretaro" } ) self.charge = self.customer.charges.create( source_id=self.card.id, method="card", amount=100, description="Test Charge", order_id=generate_order_id()) self.second_customer = openpay.Customer.all().data[3]
def test_fee_create(self): fee = openpay.Fee.create(customer_id=self.customer.id, amount=5, description="Test Fee", order_id=generate_order_id()) self.assertTrue(isinstance(fee, openpay.Fee)) self.assertTrue(hasattr(fee, 'id'))
def test_create_payout_with_card(self): payout = self.customer.payouts.create(method="card", destination_id=self.card.id, amount=25, description="Payout with card", order_id=generate_order_id()) self.assertTrue(hasattr(payout, 'id')) self.assertTrue(isinstance(payout, openpay.Payout))
def test_transfer_create(self): transfer = self.customer.transfers.create( customer_id=self.second_customer.id, amount=10, description="Test transfer", order_id=generate_order_id()) self.assertTrue(isinstance(transfer, openpay.Transfer)) self.assertTrue(hasattr(transfer, 'id'))
def test_transfer_retrieve(self): transfer = self.customer.transfers.create( customer_id=self.second_customer.id, amount=10, description="Test transfer", order_id=generate_order_id()) transfer_list = self.customer.transfers.all() test_transfer = transfer_list.data[0] transfer = self.customer.transfers.retrieve(test_transfer.id) self.assertTrue(isinstance(transfer, openpay.Transfer))
def test_refresh(self): DUMMY_CHARGE['order_id'] = generate_order_id() charge = openpay.Charge.create(**DUMMY_CHARGE) charge2 = openpay.Charge.retrieve_as_merchant(charge.id) self.assertEqual(charge2.creation_date, charge.creation_date) charge2.junk = 'junk' charge2.refresh() self.assertRaises(AttributeError, lambda: charge2.junk)
def test_create_payout_with_bank_account(self): payout = self.customer.payouts.create( method='bank_account', destination_id=self.bank_account.id, amount="10", description="First payout", order_id=generate_order_id()) self.assertTrue(hasattr(payout, 'id')) self.assertTrue(isinstance(payout, openpay.Payout))
def test_list_charges(self): customer = openpay.Customer.create(name="Miguel Lopez", email="*****@*****.**", description="foo bar") customer.charges.create(amount=100, method="card", description="Customer test charge", order_id=generate_order_id(), card=DUMMY_CARD) self.assertEqual(1, len(customer.charges.all().data))
def test_list_charges(self): customer = openpay.Customer.create( name="Miguel Lopez", email="*****@*****.**", description="foo bar") customer.charges.create( amount=100, method="card", description="Customer test charge", order_id=generate_order_id(), card=DUMMY_CARD) self.assertEqual(1, len(customer.charges.all().data))
def test_run(self): DUMMY_CHARGE['order_id'] = generate_order_id() charge = openpay.Charge.create(**DUMMY_CHARGE) # self.assertFalse(hasattr(charge, 'refund')) charge.refund(merchant=True) self.assertTrue(hasattr(charge, 'refund'))
def test_fee_create(self): fee = openpay.Fee.create( customer_id=self.customer.id, amount=5, description="Test Fee", order_id=generate_order_id()) self.assertTrue(isinstance(fee, openpay.Fee)) self.assertTrue(hasattr(fee, 'id'))