def pay_pagseguro(self): # import pdb;pdb.set_trace() pg = PagSeguro(email="*****@*****.**", token="4194D1DFC27E4E1FAAC0E1B20690B5B5") pg.sender = { "name": self.user.full_name, "email": self.user.email, } pg.reference_prefix = None pg.reference = self.id for item in self.itens.all(): pg.add_item(id=item.option.id, description=item.option.title, amount=item.option.new_price, quantity=item.quantity, weight=0) # pg.redirect_url = "http://meusite.com/obrigado" response = pg.checkout() self.code_pagseguro = response.code self.save() return response.payment_url
def test_add_items_util(items): pagseguro = PagSeguro(token=TOKEN, email=EMAIL) pagseguro.add_item(**items[0]) pagseguro.add_item(**items[1]) assert len(pagseguro.items) == 2
def test_add_items_util(self): pagseguro = PagSeguro(email=self.email, token=self.token) pagseguro.add_item(**self.items[0]) pagseguro.add_item(**self.items[1]) self.assertEqual(len(pagseguro.items), 2)