edalzell / statamic-charge

One-time or subscription billing
13 stars 3 forks source link

Use billing email if receipt's email is empty #83

Closed billmn closed 4 years ago

billmn commented 4 years ago

I have seen this in Stripe Webhook's Log after a subscription completed successfully:

Error:

Type error: Argument 1 passed to Statamic\Addons\Charge\Actions\SendEmailAction::execute() must be of the type string, null given, called in /Code/statamic/site/addons/Charge/Traits/HandlesWebhook.php on line 69

API Body

"charges": {
    "data": [
        {
            ...
            "object": "charge",
            "billing_details": {
                "address": {
                    "city": null,
                    "country": null,
                    "line1": null,
                    "line2": null,
                    "postal_code": "123456",
                    "state": null
                },
                "email": "test@email.local",
                "name": null,
                "phone": null
            },
            "paid": true,
            "receipt_email": null,
            "receipt_number": null,
            ...
        }
    ]
}

This PR allow to use the Billing email as default address if receipt email is empty