0

i've a peace of code that catch an Exception. I get the error body with $e->getMessage() and the result is the following string. Now i want to access to customer_email how can i do this?

i receive this responde from Stripe API Request

stdClass Object
(
    [error] => stdClass Object
        (
            [charge] => ch_1F1UTrAMXDCOYAqpNzJLKFff
            [code] => card_declined
            [message] => Your card was declined.
            [payment_intent] => stdClass Object
                (
                    [id] => pi_1F1IwGAMXDCOYAqpSwoFHsN1
                    [amount_capturable] => 0
                    [metadata] => stdClass Object
                        (
                            [customer_name] => C B
                            [customer_email] => [email protected]
                            [order_id] => 363
                        )
                    [payment_method_options] => stdClass Object
                        (
                            [card] => stdClass Object
                                (
                                    [request_three_d_secure] => automatic
                                )
                        )
                    [payment_method_types] => Array
                        (
                            [0] => card
                        )
                    [receipt_email] => 
                    [review] => 
                )
            [source] => stdClass Object
                (
                    [id] => src_1F1UTnAMXDCOYAqpYOtW3GyR
                    [object] => source
                    [card] => stdClass Object
                        (
                            [exp_month] => 12
                            [exp_year] => 2020
                            [last4] => 9987
                            [country] => US
                        )
                    [client_secret] => src_client_secret_FWXYzYw3vPwPe4CzyveJdVMP
                    [created] => 1564389915
                    [flow] => none
                    [metadata] => stdClass Object
                        (
                        )
                        )
                [type] => card_error
            )

    )
7
  • Possible duplicate of How to access a property of an object (stdClass Object) member/element of an array? Commented Jul 29, 2019 at 9:34
  • That looks like a var_dump of an exception object or something … are you getting all that as the message of the exception? That would be rather weird. As if someone had “wrapped” one exception in text form into another. Commented Jul 29, 2019 at 9:35
  • are you getting all that as the message of the exception? yes i receive that from $e->getmessage() Commented Jul 29, 2019 at 9:43
  • ->error->payment_intent->metadata->customer_email looks like the trail of it Commented Jul 29, 2019 at 9:46
  • i receive Trying to get property 'error' of non-object Trying to get property 'payment_intent' of non-object Trying to get property 'metadata' of non-object Trying to get property 'customer_email' of non-object Commented Jul 29, 2019 at 9:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.