条纹webhook:能够从“源”中检索数据,但仅此而已

时间:2019-03-27 16:18:28

标签: php json stripe-payments webhooks endpoint

正如标题所述,我能够从“源”(我想那是$ token)中获取数据,但没有别的。

<?php

require_once('stripe/init.php');

\Stripe\Stripe::setApiKey("sk_test_xxxxxxxxxxxxxxxxxxxxxxxxx");

$input = @file_get_contents("php://input");

$event_json = json_decode($input);

$name = $event_json->data->object->name;
$cvc_check = $event_json->data->object->cvc_check;

?>

=

我可以获得$ name(这是电子邮件地址)和$ cvc_check,但是如果我对状态做同样的事情,那这里什么也没有:

=

  $status = $event_json->data->object->status;

=

有人可以告诉/引导我正确的方向吗?为什么我无法在“来源”之外得到任何东西?

{
  "object": {
"id": "ch_1EIdL8IcP22cq9aQpA",
"object": "charge",
"amount": 500,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1EIdL8IcP22cq9",

"source": {
  "id": "card_1EIdL3IcP22cq",
  "object": "card",
  "address_city": null,
  "address_country": null,
  "address_line1": null,
  "address_line1_check": null,
  "address_line2": null,
  "address_state": null,
  "address_zip": null,
  "address_zip_check": null,
  "brand": "Visa",
  "country": "US",
  "customer": "cus_EmBix3cJ",
  "cvc_check": "pass",
  "dynamic_last4": null,
  "exp_month": 2,
  "exp_year": 2022,
  "fingerprint": "zrzwvqXQTWp",
  "funding": "credit",
  "last4": "4242",
  "metadata": {
  },
  "name": "someemailaddress@yahoo.com",
  "tokenization_method": null
},
"source_transfer": null,
"statement_descriptor": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}
}

=

条形测试响应:

=

object(stdClass)#1 (9) {
["created"]=>
int(1326853478)
["livemode"]=>
bool(false)
["id"]=>
string(31) "charge.succeeded_00000000000000"
["type"]=>
string(16) "charge.succeeded"
["object"]=>
string(5) "event"
["request"]=>
NULL
["pending_webhooks"]=>
int(1)
["api_version"]=>
string(10) "2018-10-31"
["data"]=>
object(stdClass)#14 (1) {
["object"]=>
object(stdClass)#2 (41) {
  ["id"]=>
  string(17) "ch_00000000000000"
  ["object"]=>
  string(6) "charge"
  ["amount"]=>
  int(500)
  ["amount_refunded"]=>
  int(0)
  ["application"]=>
  NULL
  ["application_fee"]=>
  NULL
  ["application_fee_amount"]=>
  NULL
  ["balance_transaction"]=>
  string(18) "txn_00000000000000"
  ["billing_details"]=>
  object(stdClass)#4 (4) {
    ["address"]=>
    object(stdClass)#3 (6) {
      ["city"]=>
      NULL
      ["country"]=>
      NULL
      ["line1"]=>
      NULL
      ["line2"]=>
      NULL
      ["postal_code"]=>
      NULL
      ["state"]=>
      NULL
    }
    ["email"]=>
    NULL
    ["name"]=>
    string(25) "someemail@yahoo.com"
    ["phone"]=>
    NULL
  }
  ["captured"]=>
  bool(false)
  ["created"]=>
  int(1553691107)
  ["currency"]=>
  string(3) "usd"
  ["customer"]=>
  string(18) "cus_00000000000000"
  ["description"]=>
  NULL
  ["destination"]=>
  NULL
  ["dispute"]=>
  NULL
  ["failure_code"]=>
  string(13) "card_declined"
  ["failure_message"]=>
  string(23) "Your card was declined."
  ["fraud_details"]=>
  object(stdClass)#5 (1) {
    ["stripe_report"]=>
    string(10) "fraudulent"
  }
  ["invoice"]=>
  NULL
  ["livemode"]=>
  bool(false)
  ["metadata"]=>
  object(stdClass)#6 (0) {
  }
  ["on_behalf_of"]=>
  NULL
  ["order"]=>
  NULL
  ["outcome"]=>
  object(stdClass)#7 (6) {
    ["network_status"]=>
    string(19) "not_sent_to_network"
    ["reason"]=>
    string(18) "merchant_blacklist"
    ["risk_level"]=>
    string(7) "highest"
    ["risk_score"]=>
    int(98)
    ["seller_message"]=>
    string(28) "Stripe blocked this payment."
    ["type"]=>
    string(7) "blocked"
  }
  ["paid"]=>
  bool(true)
  ["payment_intent"]=>
  NULL
  ["payment_method_details"]=>
  object(stdClass)#10 (2) {
    ["card"]=>
    object(stdClass)#8 (10) {
      ["brand"]=>
      string(4) "visa"
      ["checks"]=>
      object(stdClass)#9 (3) {
        ["address_line1_check"]=>
        NULL
        ["address_postal_code_check"]=>
        NULL
        ["cvc_check"]=>
        string(11) "unavailable"
      }
      ["country"]=>
      string(2) "US"
      ["exp_month"]=>
      int(1)
      ["exp_year"]=>
      int(2022)
      ["fingerprint"]=>
      string(16) "Gawa768Trrk4fEmb"
      ["funding"]=>
      string(6) "credit"
      ["last4"]=>
      string(4) "0019"
      ["three_d_secure"]=>
      NULL
      ["wallet"]=>
      NULL
    }
    ["type"]=>
    string(4) "card"
  }
  ["receipt_email"]=>
  NULL
  ["receipt_number"]=>
  NULL
  ["receipt_url"]=>
  string(118) "https://pay.stripe.com/receipts/acct_1DU4J1IcP22cq9aQ/ch_1EIbENIcP22cq9aQk7r9xN3u/rcpt_Em9Xy3Ambv1b8QZISOsIHdbxCn"
  ["refunded"]=>
  bool(false)
  ["refunds"]=>
  object(stdClass)#11 (5) {
    ["object"]=>
    string(4) "list"
    ["data"]=>
    array(0) {
    }
    ["has_more"]=>
    bool(false)
    ["total_count"]=>
    int(0)
    ["url"]=>
    string(47) "/v1/charges/ch_1EIbENIcP22cq9aQk7r9xN3u/refunds"
  }
  ["review"]=>
  NULL
  ["shipping"]=>
  NULL
  ["source"]=>
  object(stdClass)#12 (23) {
    ["id"]=>
    string(19) "card_00000000000000"
    ["object"]=>
    string(4) "card"
    ["address_city"]=>
    NULL
    ["address_country"]=>
    NULL
    ["address_line1"]=>
    NULL
    ["address_line1_check"]=>
    NULL
    ["address_line2"]=>
    NULL
    ["address_state"]=>
    NULL
    ["address_zip"]=>
    NULL
    ["address_zip_check"]=>
    NULL
    ["brand"]=>
    string(4) "Visa"
    ["country"]=>
    string(2) "US"
    ["customer"]=>
    string(18) "cus_00000000000000"
    ["cvc_check"]=>
    string(11) "unavailable"
    ["dynamic_last4"]=>
    NULL
    ["exp_month"]=>
    int(1)
    ["exp_year"]=>
    int(2022)
    ["fingerprint"]=>
    string(16) "Gawa768Trrk4fEmb"
    ["funding"]=>
    string(6) "credit"
    ["last4"]=>
    string(4) "0019"
    ["metadata"]=>
    object(stdClass)#13 (0) {
    }
    ["name"]=>
    string(25) "someemail@yahoo.com"
    ["tokenization_method"]=>
    NULL
  }
  ["source_transfer"]=>
  NULL
  ["statement_descriptor"]=>
  NULL
  ["status"]=>
  string(6) "failed"
  ["transfer_data"]=>
  NULL
  ["transfer_group"]=>
  NULL
 }
 }
 }

=

我想从["status"]=> string(6) "failed"(代码的最后一部分)中获取数据。

0 个答案:

没有答案