カテゴリー:
Stripe
閲覧数:254 配信日:2019-02-14 11:17
Cardオブジェクト
Stripeオブジェクトと継承関係がない
・他とは異なり、このオブジェクトだけは「Stripeオブジェクト」と継承関係がない
→ 他とは異なり、createメソッドがない
→ 他とは異なり、deleteメソッドがない
階層
・Customerオブジェクトのsourcesプロパティ内にあるdataプロパティ内にリスト構造化されて配置される仕様
Link
・Stripe API Reference
・stripe-php/Card.php
既存Customerオブジェクトに"source"パラメータとして、トークンID(tok_xxxx)を追加
\Stripe\Stripe::setApiKey("sk_test_xxxx");
$customer = \Stripe\Customer::retrieve("cus_EiZRT8YsFHonSq");
$customer->sources->create(["source" => "tok_mastercard"]);
(新規作成直後の)既存Customerオブジェクトに"source"パラメータとして、ソースID(src_xxxx)を追加
\Stripe\Stripe::setApiKey("sk_test_xxxx");
$customer1 = \Stripe\Customer::create([
"description" => "Customer 「Stripe.js and Elements」→ ソースID(src_xxxx)指定。4.既存Customerオブジェクトに'source'パラメータとして、ソースID(src_xxxx)を追加",
'email' => '20190316@example.com',
]);
$customer = \Stripe\Customer::retrieve($customer1->id);
$sourceObj = $customer->sources->create(["source" => $sourceId]);
新規Customerオブジェクト作成時に'source'パラメータとして、ソースID(src_xxxx)を指定
\Stripe\Stripe::setApiKey("sk_xxxx");
$customer = \Stripe\Customer::create([
"description" => "Customer 「Stripe.js and Elements」→ ソースID(src_xxxx)指定。3.新規Customerオブジェクト作成時に'source'パラメータとして、ソースID(src_xxxx)を指定",
'email' => '20190316@example.com',
'source' => $sourceId,
]);
\Stripe\Chargeオブジェクト
create()メソッド
\Stripe\Stripe::setApiKey("sk_test_●●");
\Stripe\Charge::create([
"amount" => 2000,
"currency" => "jpy",
"source" => "tok_visa", // obtained with Stripe.js
"description" => "Charge for jenny.rosen@example.com"
]);
\Stripe\Productオブジェクト
製品やサービス
・その配下に料金や通貨などが異なる Plan を複数紐付けることができる
一つの Product へ対して出来ること
・複数の料金プランを持つことができる
・毎月、毎年など異なる請求間隔プランを持つことができる。月額500円のプラン。年額5,000円のプラン
・複数の通貨プランを持つことができる。日本円の料金プラン。USドルの料金プラン。ユーロの料金プラン
create()メソッド
・次のコードは、'type'が'good'タイプのProductを作成する方法を示している
\Stripe\Stripe::setApiKey("sk_test_●●");
\Stripe\Product::create([
"name" => 'T-shirt',
"type" => "good",
"description" => "Comfortable cotton t-shirt",
"attributes" => ["size", "gender"]
]);
・次のコードは、'type'が'service'タイプのProductを作成する方法を示している
\Stripe\Stripe::setApiKey("'sk_test_●●");
$product = \Stripe\Product::create([
'name' => 'My SaaS Platform',
'type' => 'service',
]);
・Managing Plans