Stripe Q18。PHP使用する場合、オブジェクト形式で配列形式でもアクセスできる

StripeQA

目次一覧

 状態:-  閲覧数:671  投稿日:2019-03-11  更新日:2019-03-21  
質問履歴18-1 / A.18-1
質問履歴18-2 / A.18-2 / 質問履歴18-3
質問しなかったQ

質問履歴18-1 / A.18-1

 閲覧数:307 投稿日:2019-03-11 更新日:2019-03-12 

質問履歴18-1


Tell me why I can also access as an array as an object
・2019/3/7

Create a Stripe Product object.
\Stripe\Stripe::setApiKey("sk_test_××××××");

$product = \Stripe\Product::create([
   'name' => 'My SaaS Platform',
   'type' => 'service',
]);


Get the id of the Product object
echo $product->id;
· I can understand the above code
echo $product['id'];
· I can not understand the above code

・What is the reason why the returned value should be an object but can be accessed in an array?

A.18-1


implements ArrayAccess
・「ArrayAccessインターフェースをimplementsしているオブジェクト」だから、配列形式でもアクセスできる
・Product extends ApiResource which extends StripeObject which implements ArrayAccess.

質問履歴18-2 / A.18-2 / 質問履歴18-3

 閲覧数:300 投稿日:2019-03-12 更新日:2019-03-12 

質問履歴18-2


Is there a way to check whether the object (such as the return value from the API) is implements ArrayAccess?
・2019/3/11
・Is there a way to judge whether it is implements ArrayAccess by return value object without reading the document of API?

\Stripe\Stripe::setApiKey("sk_test_××××××");

$product = \Stripe\Product::create([
   'name' => 'My SaaS Platform',
   'type' => 'service',
]);


Access by object
echo $product->id;

Access by array
echo $product['id'];

A.18-2


2案
is_subclass_of
instanceof

\Stripe\Stripe::setApiKey("sk_test_××××");

$product = \Stripe\Product::create([
   'name' => 'My SaaS Platform 2019年3月6日',
   'type' => 'good',
]);

if (is_subclass_of($product, 'ArrayAccess')) {
 echo "yes, \$product is a implements ArrayAccess\n";
} else {
 echo "no, \$product is not implements ArrayAccess\n";
}

var_dump($product instanceof ArrayAccess);


質問履歴18-3


「あるオブジェクト」が、「指定インターフェース」を「implementsしているかどうか」の条件判定について


質問しなかったQ

 閲覧数:282 投稿日:2019-03-12 更新日:2019-03-12 

質問しなかったQ


「あるオブジェクト」が、「指定インターフェース」を「implementsしているかどうか」の条件判定について
・2019/3/12
「あるオブジェクト」が、「指定インターフェース」を「implementsしているかどうか」条件判定したい
・具体的には、ArrayAccess インターフェイスを「implementsしているかどうか」条件判定したい

Q
・どうやって条件判定するのですか?
・調べたら2つ見つかったのですが、違いは何ですか?
subclass_of
ReflectionClass::isSubclassOf



Stripe Q17。カード情報を「card object」「source object」へ保存する違いについて

Stripe Q19。「PaymentIntents」と「Sourceオブジェクト」と「Sources API」の関係について

コメント投稿(ログインが必要)



類似度ページランキング
順位 ページタイトル抜粋
1 Stripe Q18。PHP使用する場合、オブジェクト形式で配列形式でもアクセスできる 84
2 Stripe オブジェクト 46
3 Stripe プレフィックスがある「オブジェクトの値」など 42
4 Stripe Q12。IBAN要素を使用すると、日本でも顧客の銀行口座の詳細を取得できますか? 40
5 Stripe Q11。テストAPIで、実際のカード番号を入力したらどうなりますか? 38
6 Stripe Q14。Customerオブジェクトをcreateする際の"source"パラメータについて 38
7 Stripe Q28。Sourceオブジェクトのusageプロパティのデフォルト値について 36
8 Stripe Q21。新規顧客作成時に新規ソースオブジェクトを添付したいのですが、No such token: src_xxxxとなります 36
9 Stripe Q57。トークン化について 35
10 Stripe Q44。Standard アカウント連結後の返り値で、保存すべき値について 34
11 Stripe Q68.WebhookはPUT送信しているのですか? 34
12 Stripeの「ProductオブジェクトとPlanオブジェクトの関係」は、データベースにおける正規化のようなもの 34
13 Stripe Q60. Checkout\SessionオブジェクトとPaymentIntentオブジェクトの関係性は1対1ですか? 33
14 Stripe。Stripeアカウントを持っていない人でもクレジットカード決済が出来る 33
15 Stripe Q74.「お客様のビジネスの詳細」とは何ですか? 32
16 Stripe Q33。CustomerオブジェクトのcreateSourceメソッドのAPIドキュメントについて 32
17 Stripe Q49。 Connect 「Standardアカウント」で、自身の子アカウントでも商品販売する場合、被る不利益はありますか? 32
18 Stripe Q19。「PaymentIntents」と「Sourceオブジェクト」と「Sources API」の関係について 32
19 Stripe Q234。Connect カスタムアカウント手数料 32
20 Stripe Q56. 作成したCheckout\Sessionオブジェクトが破棄されるタイミングは? 32
2024/7/27 16:21 更新
週間人気ページランキング / 7-20 → 7-26
順位 ページタイトル抜粋 アクセス数
1 決済系サービス比較 | 決済(Webサービスビジネス) 3
1 Twitch | ゲーム実況配信サービス(課金販売できるプラットフォーム) 3
2 支払い 2
2 Stripe Q47。Charge::create の 'receipt_email' について | QA(Stripe) 2
2 Stripe webhook 配信の問題 / 実際に受け取った警告メールの受信例 2
2 Stripe Q37。PaymentIntentで支払いを行った後、成功画面を表示させるためにはどうすれば良いですか? | QA(Stripe) 2
3 普通送金とは? / 処理の流れ 1
3 ファンティア | クリエイター支援プラットフォーム(課金販売できるプラットフォーム) 1
3 Stripe Payments > SOURCES / ソース | documentation(Stripe) 1
3 Stripe Q16。PaymentIntentの支払いで郵便番号入力を求められる。Radar rules の ZIP code を無効にしているのに | QA(Stripe) 1
3 PaymentIntentで支払を実装する場合の選択肢 /「Payment Intents API」使用によるカードの支払確認方法は2種類 / PaymentMethodオブジェクトは歴史的経緯により3種類ある 1
3 決済用語 1
3 Stripe Q43。payouts スケジュールについて | QA(Stripe) 1
3 「払い戻し」と「チャージバック」の違い | 違い 1
3 EMVレベル1 / EMVレベル2 / EMVCo とは? 1
3 Stripe Q74.「お客様のビジネスの詳細」とは何ですか? | Stripe 1
3 Stripe Q21。新規顧客作成時に新規ソースオブジェクトを添付したいのですが、No such token: src_xxxxとなります | QA(Stripe) 1
3 Stripe オブジェクト | その他エントリー(Stripe) 1
3 LINE LIVE | ライブ配信サービス(課金販売できるプラットフォーム) 1
3 日本で、Connect Standardアカウント を導入している(と思われる)事例 | その他エントリー(Stripe) 1
2024/7/27 1:02 更新