dqy0707 2017-03-09 13:47
浏览 59

如何从Stripe for webhook中检索值

I am using webhook of stripe to receive some information after successful payment but it give me error

 <?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);
 }

its give me this response

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] => 
                )

        )

)

and i want to store value from this response like status, paymentdate and description

$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);

This thing is not works

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题