如何从Stripe for webhook中检索值

时间:2017-03-09 13:47:12

标签: php json stripe-payments

我使用条带webhook在成功付款后收到一些信息 但它给了我错误

 <?php

    include 'dbConfig.php'; // For Connecting the database to Store the retrieve value in SQL database
    include 'init.php';

    Stripe::setApiKey("sk_test_*****************");


    // retrieve the request's body and parse it as JSON
    $input = file_get_contents("php://input");
    $event = json_decode($input);


if ($event_json->type == "charge.succeeded") {
 print_r($event_json);
 }

它给我这个回应

stdClass Object
(
    [created] => 1326853478
    [livemode] => 
    [id] => evt_00000000000000
    [type] => charge.succeeded
    [object] => event
    [request] => 
    [pending_webhooks] => 1
    [api_version] => 2017-02-14
    [data] => stdClass Object
        (
            [object] => stdClass Object
                (
                    [id] => ch_00000000000000
                    [object] => charge
                    [amount] => 249
                    [amount_refunded] => 0
                    [application] => 
                    [application_fee] => 
                    [balance_transaction] => txn_00000000000000
                    [captured] => 1
                    [created] => 1489056204
                    [currency] => usd
                    [customer] => 
                    [description] => Movie Title
                    [destination] => 
                    [dispute] => 
                    [failure_code] => 
                    [failure_message] => 
                    [fraud_details] => stdClass Object
                        (
                        )

                    [invoice] => 
                    [livemode] => 
                    [metadata] => stdClass Object
                        (
                            [order_id] => 6735
                        )

                    [on_behalf_of] => 
                    [order] => 
                    [outcome] => stdClass Object
                        (
                            [network_status] => approved_by_network
                            [reason] => 
                            [risk_level] => normal
                            [seller_message] => Payment complete.
                            [type] => authorized
                        )

                    [paid] => 1
                    [receipt_email] => 
                    [receipt_number] => 
                    [refunded] => 
                    [refunds] => stdClass Object
                        (
                            [object] => list
                            [data] => Array
                                (
                                )

                            [has_more] => 
                            [total_count] => 0
                            [url] => /v1/charges/ch_19vOjwKGQPjNjAif9fuYkcsj/refunds
                        )

                    [review] => 
                    [shipping] => 
                    [source] => stdClass Object
                        (
                            [id] => card_00000000000000
                            [object] => card
                            [address_city] => ludhiana
                            [address_country] => AL
                            [address_line1] => hn 88 st.no5
                            [address_line1_check] => pass
                            [address_line2] => 
                            [address_state] => skdjflsdf
                            [address_zip] => skfnsd
                            [address_zip_check] => pass
                            [brand] => Visa
                            [country] => US
                            [customer] => 
                            [cvc_check] => pass
                            [dynamic_last4] => 
                            [exp_month] => 1
                            [exp_year] => 2018
                            [funding] => credit
                            [last4] => 4242
                            [metadata] => stdClass Object
                                (
                                )

                            [name] => jagtarnice
                            [tokenization_method] => 
                        )

                    [source_transfer] => 
                    [statement_descriptor] => 
                    [status] => succeeded
                    [transfer_group] => 
                )

        )

)

我希望存储此响应的值 如状态,付款日期和描述

$customer_id = $event_json->data->object->customer;
$customer = Stripe_Customer::retrieve($customer_id);
$charge_id = $event_json->data->object->id;
$charge = Stripe_Charge::retrieve($charge_id);

这件事不起作用

0 个答案:

没有答案