1

最初の4つの値を正常に取得できますが、$item_nameわかりません。プランの取得に使用している構文の何が問題になっていますか:name: "LITE" value

これは私のphpです-最初の4つは問題なく返されますが、$item_nameは無効を返します。

    $customer = $event_json->data->object->customer;
    $amount = $event_json->data->object->total;
    $period_end = $event_json->data->object->period_end;
    $paid = $event_json->data->object->paid;
    $item_name = $event_json->data->object->lines->data->plan->name;

これがStripeから送信されているものです

{
  "id": "evt_1CTCF3tibBeC2y",
  "created": 1359565368,
  "livemode": false,
  "type": "invoice.payment_succeeded",
  "data": {
    "object": {
      "period_end": 1359565367,
      "charge": "ch_1CTCMvOgHE1Q9K",
      "discount": null,
      "period_start": 1359565367,
      "livemode": false,
      "customer": "cus_1CTCYQNoghibwb",
      "amount_due": 7500,
      "lines": {
        "count": 1,
        "object": "list",
        "url": "/v1/invoices/in_1CTCCBbENUpsE6/lines",
        "data": [
          {
            "type": "subscription",
            "livemode": false,
            "period": {
              "end": 1391101367,
              "start": 1359565367
            },
            "object": "line_item",
            "proration": false,
            "plan": {
              "trial_period_days": null,
              "livemode": false,
              "interval": "year",
              "object": "plan",
              "name": "LITE",
              "amount": 7500,
              "currency": "usd",
              "id": "LITE",
              "interval_count": 1
            },
4

1 に答える 1

6

データは配列です:

$item_name = $event_json->data->object->lines->data[0]->plan->name;

右?

于 2013-02-01T04:10:32.097 に答える