Example #1
0
    def marketplaceCreditCreate(self,
                                marketplace_subseller_payments: list,
                                amount: int,
                                order: Order,
                                customer: Customer,
                                credit: Credit,
                                currency: str = "BRL",
                                device: Device = None,
                                **kwargs):

        data = {
            "seller_id": self._client.seller_id,
            "amount": amount,
            "currency": currency,
            "order": order.as_dict(),
            "customer": customer.as_dict(),
            "credit": credit.as_dict()
        }

        if marketplace_subseller_payments is not None:

            data[
                "marketplace_subseller_payments"] = marketplace_subseller_payments

        if device is not None:
            data["device"] = device.as_dict()

        data["credit"].pop("authenticated")
        data["customer"]["billing_address"] = data["customer"].pop("address")
        data["customer"].pop("observation")
        phone = data["customer"].pop("phone_number")
        cellphone = data["customer"].pop("celphone_number")
        data["customer"].pop("seller_id")
        data["customer"].pop("birth_date")
        data["customer"].setdefault(
            "name",
            f'{data["customer"]["first_name"]} {data["customer"]["last_name"]}'
        )

        data["shippings"] = [{
            "first_name": data["customer"]["first_name"],
            "name":
            f'{data["customer"]["first_name"]} {data["customer"]["last_name"]}',
            "email": data["customer"]["email"],
            "phone_number": cellphone,
            "shipping_amount": 0,
            "address": data["customer"]["billing_address"]
        }]

        response = self._post(self._format_url(), json=data)

        if "callback" in kwargs.keys():

            kwargs["callback"](data, response, self._format_url())

        return CreditPaymentResponse(**response)
Example #2
0
 def setUp(self) -> None:
     super(PaymentCreditIntegrationTest, self).setUp()
     self.client = getnet.Client(
         os.environ.get("GETNET_SELLER_ID"),
         os.environ.get("GETNET_CLIENT_ID"),
         os.environ.get("GETNET_CLIENT_SECRET"),
         getnet.api.HOMOLOG,
     )
     self.service = Service(self.client)
     self.order = Order("6d2e4380-d8a3-4ccb-9138-c289182818a3", 0,
                        "physical_goods")
     self.customer = Customer(**customer_sample.copy())
Example #3
0
    def create(
        self,
        amount: int,
        currency: str,
        order: Order,
        boleto: Boleto,
        customer: Customer,
    ) -> BoletoPaymentResponse:
        data = {
            "seller_id": self._client.seller_id,
            "amount": amount,
            "currency": currency,
            "order": order.as_dict(),
            "boleto": boleto.as_dict(),
            "customer": customer.as_dict(),
        }

        response = self._post(self._format_url(), json=data)
        return BoletoPaymentResponse(_base_uri=self._client.base_url,
                                     **response)
Example #4
0
    def marketplaceBoletoCreate(
        self, amount: int, currency: str, order: Order, boleto: Boleto,
        customer: Customer,
        marketplace_subseller_payments: MarketplaceSubseller
    ) -> BoletoPaymentResponse:
        data = {
            "seller_id": self._client.seller_id,
            "amount": amount,
            "currency": currency,
            "order": order.as_dict(),
            "boleto": boleto.as_dict(),
            "customer": customer.as_dict(),
        }

        if marketplace_subseller_payments is not None:

            data[
                "marketplace_subseller_payments"] = marketplace_subseller_payments

        data["customer"]["billing_address"] = data["customer"].pop("address")
        data["customer"]["billing_address"].pop("country")
        data["customer"].pop("observation")
        phone = data["customer"].pop("phone_number")
        cellphone = data["customer"].pop("celphone_number")
        data["customer"].pop("seller_id")
        data["customer"].pop("customer_id")
        data["customer"].pop("email")
        data["customer"].pop("birth_date")
        data["customer"].setdefault(
            "name",
            f'{data["customer"]["first_name"]} {data["customer"]["last_name"]}'
        )

        data["customer"].pop("last_name")

        data["boleto"].pop("our_number")

        response = self._post(self._format_url(), json=data)
        return BoletoPaymentResponse(_base_uri=self._client.base_url,
                                     **response)
Example #5
0
    def create(
        self,
        amount: int,
        currency: str,
        order: Order,
        credit: Credit,
        customer: Customer,
        device: Device = None,
    ) -> CreditPaymentResponse:
        data = {
            "seller_id": self._client.seller_id,
            "amount": amount,
            "currency": currency,
            "order": order.as_dict(),
            "customer": customer.as_dict(),
            "credit": credit.as_dict(),
        }

        if device is not None:
            data["device"] = device.as_dict()

        response = self._post(self._format_url(), json=data)
        return CreditPaymentResponse(**response)