ストア
store > get_cart
この機能は以下の内容を返します。
・進行中の注文がない場合、ショッピングカートにある商品一覧。
・進行中の注文がある場合、その注文の商品一覧。
・合計(未払い額、使用済み/使用可能クレジット、進行中の注文で支払われた金額、など)
リクエストの構築
リクエストURLとGET変数
リクエスト固有のGET変数
| 変数 | 値 | 説明 |
|---|---|---|
| go | store | APIセクション |
| do | get_cart | APIアクション |
| iq | User ID | ユーザーID |
リクエストURLは以下のようになります。必須情報(key, timestamp, salt, signature)を追加することを忘れないでください。
POST変数
このリクエストにはPOST変数は必要ありません。
応答例
リクエストが成功した場合は、以下の内容のレスポンスを受け取ります。
・data:ショッピングカートまたは進行中の注文データを含む配列。
配列には以下が含まれます。
- order_contains_subscription(int 0|1):カート/注文にサブスクリプション商品が含まれているかどうか。
- order_contains_subscription_trial(int 0|1):カート/注文に無料試用版付きのサブスクリプション商品が含まれているかどうか。
試用版:
- order_trial_requires_rp(int 0|1):試用版に定期支払いが必要かどうか。("order_contains_subscription_trial=1"の場合のみ適用)
外部支払処理で定期支払いをサポートしていない場合は、カートから商品を削除する必要があります。
それ以外の場合は、注文の処理後に定期支払いプロファイルを作成する必要があります。 - order_has_credit_product(int 0|1):カート/注文にクレジット商品が含まれているかどうか。
含まれている場合、クレジットは支払に使用されません。
- order_id(int):注文ID(進行中の注文の場合)
- order_min_purchase_check(int 0|1):カートが最小購入要件を満たしているかどうか。
- order_num_products(int):カート内の商品の数量、注文数
- buyer_credit(decimal):利用可能なユーザークレジット
- buyer_credit_formatted(string):利用可能なユーザークレジットのフォーマット値
- order_amount_due(decimal):支払う必要のある額、未払い額(進行中の注文の場合)
- order_amount_paid(decimal):支払いが終わった額(進行中の注文の場合)
- order_credit_used(decimal):カート/注文で商品を部分的な(または全額)支払に使用できるクレジットの額
- order_credit_used_formatted(string):"order_credit_used"値のフォーマット値
- order_subtotal(decimal):クレジットを適用する前のカート/注文の合計
- order_subtotal_formatted(string):"order_subtotal"値のフォーマット値
注:支払いが終わった額(order_amount_paid) + 支払う必要のある額、未払い額(order_amount_due) + クレジット適用額(order_credit_used) = カート/注文の合計(order_subtotal)
- order_total(decimal):カート/注文の合計
- order_total_formatted(string):"order_total"値のフォーマット値
- product_list(array):カートまたは進行中の注文からの商品リスト
product_list
商品リストの配列には以下が含まれます。
- id(int):商品ID。カートから商品を削除する為に使用するIDです。
- id_clip(int):動画商品の場合は動画ID(番号>0)になります。
- id_channel(int):チャンネル商品の場合はチャンネルID(番号>0)になります。
- id_type(int):商品タイプのID
- type_name(string):商品タイプの名前
CREDIT(クレジット), 有効期限付アクセスパス(ENDDATE), 期間アクセスパス(PERIOD), サブスクリプション(SUBSCRIPTION), 無料試用版付きサブスクリプション(SUBSCRIPTIONTRIAL), サブスクリプション更新(SUBSCRIPTIONRENEWAL), 寄付(DONATION), サービス(SERVICE), 寄稿者メンバーシップ(MEMBERSHIPPERIODAUTHORING), 投稿者メンバーシップ(MEMBERSHIPPERIODCONTRIBUTING) - ctype(int):商品のコンテンツタイプ(-1=その他、0=サイト、1=チャンネル、2=動画、3=メンバーシップ)
- sku(string):商品のSKU
- price(decimal):商品単価
- price_formatted(string):商品単価のフォーマット値
- price_after_trial(decimal):無料試用期間の終了後の商品単価("type_name=SUBSCRIPTIONTRIAL"の場合に適用)
- price_after_trial_formatted(string):"price_after_trial"値のフォーマット値
- quantity(int):数量
- price_by_qty(decimal):"price"値と"Quantity"値の乗算値
- price_by_qty_formatted(string):"price_by_qty"値のフォーマット値
- title(string):商品の名前
- description(string):商品の説明文
- img_thumbnail, img_social, img_poster(string):各コンテンツまたは商品の画像
- period_unit(string):時間単位(DAY, WEEK, MONTH, YEAR)("type_name=PERIOD"の場合)
- period_amount(int):期間アクセスパスの単位数("type_name=PERIOD"の場合)
- subs_period_unit(string):請求の時間単位(DAY, WEEK, MONTH, YEAR)("type_name=SUBSCRIPTION","type_name=SUBSCRIPTIONTRIAL","type_name=SUBSCRIPTIONRENEWAL"の場合)
- subs_period_amount(int):請求期間の単位数、頻度("type_name=SUBSCRIPTION","type_name=SUBSCRIPTIONTRIAL","type_name=SUBSCRIPTIONRENEWAL"の場合)
例)
・"period_unit=DAY,period_amount=3"の場合→3日間有効なアクセスパス
・"subs_period_unit=MONTH,subs_period_amount=3"の場合→3週間に一度更新されるサブスクリプション
試用版:
- trial_period_unit(string):無料試用版の時間単位 (DAY, WEEK, MONTH, YEAR)("type_name=SUBSCRIPTIONTRIAL"の場合)
- trial_period_amount(int):無料試用版の単位数("type_name=SUBSCRIPTIONTRIAL"の場合)
含まれている場合、クレジットは支払に使用されません。 - trial_requires_rp(int):無料試用期間を有効にするために定期支払いが必要かどうか。
{
"data": {
"buyer_credit": "1.00",
"buyer_credit_formatted": "1.00\u20ac",
"order_amount_due": 9.5,
"order_amount_paid": 0,
"order_contains_subscription": 0,
"order_contains_subscription_trial": 0,
"order_trial_requires_rp": 0,
"order_credit_used": 0,
"order_credit_used_formatted": "0.00\u20ac",
"order_has_credit_product": 1,
"order_id": -1,
"order_min_purchase_check": 1,
"order_num_products": 2,
"order_subtotal": 9.5,
"order_subtotal_formatted": "9.50\u20ac",
"order_total": 9.5,
"order_total_formatted": "9.50\u20ac",
"product_list": [{
"id": "1",
"id_clip": null,
"id_channel": null,
"id_type": "1",
"ctype": "0",
"sku": "CREDIT",
"price": "1.00",
"price_formatted": "1.00\u20ac",
"quantity": "5",
"price_by_qty": 5,
"price_by_qty_formatted": "5.00\u20ac",
"title": "Credit Recharge",
"description": "アカウントにクレジットを追加して、いつでもINTER-STREAMコンテンツアクセスの購入に使用できます。
クレジットでの購入は非常に速くて簡単で、注文に関する手続きを経由する事なくクイック購入オプションの使用が可能となります。
注:定期支払い(自動支払い)が定期購読で有効な場合、定期購読の更新にクレジットを使用することはできません。",
"img_thumbnail": "http:\/\/www.interstreamdomain.com\/public\/common\/images\/_default_store_product_credit_thumb.jpg",
"img_social": "http:\/\/www.interstreamdomain.com\/public\/common\/images\/_default_store_product_credit_social.jpg",
"img_poster": "http:\/\/www.interstreamdomain.com\/public\/common\/images\/_default_store_product_credit_poster.jpg",
"type_name": "CREDIT",
"period_unit": "",
"period_amount": 0,
"subs_period_unit": "",
"subs_period_amount": 0
}, {
"id": "8",
"id_clip": "1",
"id_channel": null,
"id_type": "3",
"ctype": "2",
"sku": "CLIPACCPER_1",
"price": "4.50",
"price_formatted": "4.50\u20ac",
"quantity": 1,
"price_by_qty": 4.5,
"price_by_qty_formatted": "4.50\u20ac",
"title": "プレミアム動画:動画アクセスパス(1週間)",
"description": "動画の視聴が可能なアクセスパス(1週間)",
"img_thumbnail": "http:\/\/www.interstreamdomain.com\/uploads\/images\/clip_1_1467909401_thumb.jpg",
"img_social": "http:\/\/www.interstreamdomain.com\/uploads\/images\/clip_1_1467909401_social.jpg",
"img_poster": "http:\/\/www.interstreamdomain.com\/uploads\/images\/clip_1_1467909401_poster.jpg",
"type_name": "PERIOD",
"period_unit": "WEEK",
"period_amount": "1",
"subs_period_unit": "",
"subs_period_amount": 0
}]
}
}
リクエストにハッシュが指定されていない場合など、リクエストが失敗した場合のレスポンス
{
"error" : "REQUEST_ERROR",
"error_long" : "Missing signature"
}
このリクエストは以下のエラーを返す可能性があります。
・REQUEST_ERROR | Invalid User ID
ユーザーIDが1未満かもしくは数値ではありません。
その他のエラー内容に関しては一般的なエラーメッセージを確認してください。
PHPサンプルコード
GETおよびPOSTデータを準備します。
// GET変数 $GET_VARS = array( "go" => "store", "do" => "get_cart", "iq" => "2" ); // POST変数 $POST_VARS = array();
salt, timestamp, signatureを生成してリクエストを送信します。
// APIベースURLと認証情報の収集
$API_URL = "https://www.interstreamdomain.tv/api.php";
$API_KEY_ID = "1b323a1cb879fd4e66530fbad07a32ee";
$API_SHARED_SECRET = "MWIzMjNhMWNiODc5ZmQ0ZTY2NTMwZmJhZDA3YTMyZWViOTQ3MDJiOGM2ZTU2NjE3"; // 公開しないでください
// salt, timestamp, signatureの生成
$salt = md5(mt_rand());
$timestamp = time();
$signature = base64_encode(hash_hmac('sha256', $salt.$timestamp, $API_SHARED_SECRET, true));
// key, salt, timestamp, signatureをGET変数に追加
$GET_VARS["timestamp"] = $timestamp; // UTCタイムスタンプ
$GET_VARS["salt"] = $salt;
$GET_VARS["key"] = $API_KEY_ID ; // APIキーID:これは公開されており、アプリケーションを識別するためにAPIによって使用されます
$GET_VARS["signature"] = $signature;
// リクエストURLを作成します。HTTPクエリを作成するためにPHPの組み込み関数を使用しない場合は、値をURLエンコードすることを忘れないでください。
$REQUEST_URL = $API_URL."?".http_build_query($GET_VARS);
// ".../api.php?go=api_subject&do=api_action&etc..."のようにURLを構築
// 新しいcURLリソースを作成して適切なオプションを設定
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $REQUEST_URL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $POST_VARS);
// PHPホストに有効なSSL証明書がない場合は、SSL証明書の検証を無効にする必要があります。これは危険であり、有効な証明書がインストールされるまで一時的に行われるべきです。
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Turns off verification of the SSL certificate.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Turns off verification of the SSL certificate.
// APIにリクエストを送信
$response = curl_exec($ch);
// レスポンス処理
if (!$response) {
echo 'API call failed';
}
else
{
print_r(json_decode($response,true));
}