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

StripeQA

目次一覧

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

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

 閲覧数:292 投稿日: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

 閲覧数:284 投稿日: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

 閲覧数:268 投稿日: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/4/19 12:23 更新
週間人気ページランキング / 4-12 → 4-18
順位 ページタイトル抜粋 アクセス数
1 YouTube | 動画サービス(課金販売できるプラットフォーム) 7
2 Saving Payment Methods / 支払い方法を保存する 3
2 支払い 3
2 「払い戻し」と「チャージバック」の違い | 違い 3
2 EMVレベル1 / EMVレベル2 / EMVCo とは? 3
3 Stripeで"No such token: src"と表示されたら、最初にAPIキーを確認する | Stripe エラー(Stripe) 2
3 pixivFANBOX | クリエイター支援プラットフォーム(課金販売できるプラットフォーム) 2
3 プリペイドカード | カード 2
3 EMVCo | クレジットカード仕様(仕様) 2
3 ログイン 2
3 Stripe Q73.CheckoutのSessionオブジェクトをcreateする際、'payment_intent_data'内の'metadata'として渡したデータを、webhookで受け取る件について | QA(Stripe) 2
3 Stripe Q55.Checkout\Session::createする際の、'client_reference_id'パラメータと'payment_intent_data.metadata'パラメータの違いについて | QA(Stripe) 2
4 「Gumroad」は、決済サービス「PayPal」を利用したオンラインコンテンツ販売サービス | デジタルコンテンツ販売可能なサービス(課金販売できるプラットフォーム) 1
4 Stripe Q16。PaymentIntentの支払いで郵便番号入力を求められる。Radar rules の ZIP code を無効にしているのに | QA(Stripe) 1
4 Connect決済に際して「選択できる入金経路の種類」比較一覧表 / 「Direct Charges」と「Destination Charges」比較具体例 /「Direct Charges」処理方法に関する比較一覧表 1
4 LINE LIVE | ライブ配信サービス(課金販売できるプラットフォーム) 1
4 IBAN | 海外送金(送金) 1
4 「支払」と「送金」の違い | 違い 1
4 Stripe Q13。決済成功時に、「請求に紐づけられたメールアドレス」に対して、メール送信したいのですが、 | QA(Stripe) 1
4 Stripe Payments > Quickstart / クイックスタート | documentation(Stripe) 1
2024/4/19 1:01 更新