def test_format_stripe_object_invoice(self):
        """Makes sure that it returns something useful for rending in
        an email."""

        httpretty.register_uri(
            httpretty.GET, "https://api.stripe.com/v1/events/ev_id_fake",
            body=self.fixture('events/invoice_created.json'))

        event = stripe.Event.retrieve("ev_id_fake")
        data = format_stripe_object(event.data.object)

        assert data['currency'] == 'usd'
    def test_format_stripe_object_customer(self):
        """Makes sure that it returns something useful for rending in
        an email."""

        httpretty.register_uri(
            httpretty.GET, "https://api.stripe.com/v1/customers/cus_id_fake",
            body=self.fixture('customer.json'))

        customer = stripe.Customer.retrieve("cus_id_fake")
        data = format_stripe_object(customer)

        assert data['description'] == 'test'
Exemple #3
0
def parse_receipt(event):
    "Parse the details of an event for a receipt"
    recepient = find_email_address(event.data.object)

    # A CleanParseException tells the webhook to respond
    # succesfully with a message back to the stripe dashboard
    if not recepient:
        raise CleanParseException(
            "Can't find customer email address for receipt")

    # Format the data for the email
    data = format_stripe_object(event.data.object)

    send_receipt(event.type, recepient, data)
Exemple #4
0
def parse_notification(event):
    "Parse the details of an event for a notification"
    # Format the data for the email
    data = format_stripe_object(event.data.object)

    send_notification(event.type, data)