Xsolla Smart TV
Xsolla Smart TV支持使用Pay Station在Smart TV应用商店中进行支付。选中商品后,价格将在Smart TV应用侧进行计算。然后购买数据将被发送到PayStation付款接口。
支持的功能包括:
- 使用QR码或短链接打开支付UI
- 在Pay Station桌面版或Pay Station移动版中进行支付
- 使用保存的付款帐户进行支付
Xsolla Smart TV支持使用Pay Station在Smart TV应用商店中进行支付。选中商品后,价格将在Smart TV应用侧进行计算。然后购买数据将被发送到PayStation付款接口。
支持的功能包括:
若要集成模块,请执行以下操作:
您需要提供以下参数来进行集成:
需要令牌才能集成到商店。 令牌是一个包含游戏/用户数据和支付设置的字符串。 Xsolla API使用基本HTTP身份验证。请指定您的商户ID作为用户名,API秘钥作为密码。
要启用沙盒模式,请设置"mode" = "sandbox"。
获取令牌的URL:
https://api.xsolla.com/merchant/merchants/{merchant_id}/token
可通过包含要向付款UI传递的参数来更改HTTP POST请求。请求和响应均为JSON格式。
以下是使用PHP和Xsolla PHP SDK获取令牌的示例。如果使用的是其他语言,请参阅基于CURL的示例(单击CURL)。
<?php
use Xsolla\SDK\API\XsollaClient;
use Xsolla\SDK\API\PaymentUI\TokenRequest;
$tokenRequest = new TokenRequest($projectId, $userId);
$tokenRequest->setUserEmail('email@example.com')
->setExternalPaymentId('12345')
->setSandboxMode(true)
->setUserName('USER_NAME')
->setCustomParameters(array('key1' => 'value1', 'key2' => 'value2'));
$xsollaClient = XsollaClient::factory(array(
'merchant_id' => MERCHANT_ID,
'api_key' => API_KEY
));
$token = $xsollaClient->createPaymentUITokenFromRequest($tokenRequest);
curl -v https://api.xsolla.com/merchant/merchants/{merchant_id}/token \
-X POST \
-u your_merchant_id:merchant_api_key \
-H 'Content-Type:application/json' \
-H 'Accept: application/json' \
-d '
{
"user":{
"id":{
"value":"1234567"
},
"email":{
"value":"email@example.com"
}
},
"settings":{
"project_id":14004,
"mode":"sandbox"
}
}'
您可以在API参考中找到参数的完整列表。
Xsolla将向您的项目发送以下webhook:
通过发送不带消息正文的HTTP代码204来确认收到webhook。您可在API参考中查看关于webhook处理的更多信息和示例。
要创建电子签名,我们将:
处理webhook时,请确保收到的签名与签名标头中设置的签名相符。
Xsolla服务器会向项目的webhook URL发送请求以验证用户在游戏中是否存在。
请求范例
$request = array(
'notification_type' => 'user_validation',
'user' => array(
'ip' => '127.0.0.1',
'phone' => '18777976552',
'email'=> 'email@example.com',
'id'=> '1234567',
'country' => 'US'
)
)
curl -v https://example.com/ \
-X POST \
-H 'Content-Type:application/json' \
-H 'Accept: application/json' \
-H 'Authorization:Signature 13342703ccaca5064ad33ba451d800c5e823db8f' \
-d '
{
"notification_type":"user_validation",
"user":{
"ip":"127.0.0.1",
"phone":"18777976552",
"email":"email@example.com",
"id":"1234567",
"country":"US"
}
}'
您可以在API参考中找到参数的完整列表。
用户完成支付后,Xsolla服务器将发送一个包含支付详情的webhook。
请求范例
$request = array(
'notification_type' => 'payment',
'purchase' => array(
'virtual_items' => array(
'items' => array(
0 => array(
'sku' => 'test_item1',
'amount' => 1,
),
1 => array(
'sku' => 'test_item2',
'amount' => 1,
),
2 => array(
'sku' => 'test_item3',
'amount' => 1,
),
)
),
'total' => array(
'currency' => 'USD',
'amount' => 9.99
)
),
'user' => array(
'ip' => '127.0.0.1',
'phone' => '18777976552',
'email' => 'email@example.com',
'id' => '1234567',
'country' => 'US'
),
'transaction' => array(
'id' => 87654321,
'payment_date' => '2014-09-23T19:25:25+04:00',
'payment_method' => 1380,
'dry_run' => 1
),
'payment_details' => array(
'payment' => array(
'currency' => 'USD',
'amount' => 9.99
),
'vat' => array(
'currency' => 'USD',
'amount' => 0
),
'payout_currency_rate' => 1,
'payout' => array(
'currency' => 'USD',
'amount' => 9.49
),
'xsolla_fee' => array(
'currency' => 'USD',
'amount' => 0.19
),
'payment_method_fee' => array(
'currency' => 'USD',
'amount' => 0.31
)
)
)
curl -v https://example.com/ \
-X POST \
-H 'Content-Type:application/json' \
-H 'Accept: application/json' \
-H 'Authorization:Signature 13342703ccaca5064ad33ba451d800c5e823db8f' \
-d '
{
"notification_type":"payment",
"purchase":{
"virtual_items":{
"items":[
{
"sku":"test_item1",
"amount": 1
},
{
"sku":"test_item2",
"amount": 1
},
{
"sku":"test_item3",
"amount": 2
},
]
},
"total":{
"currency":"USD",
"amount": 9.99
}
},
"user":{
"ip":"127.0.0.1",
"phone":"18777976552",
"email":"email@example.com",
"id":"1234567",
"country":"US"
},
"transaction":{
"id":87654321,
"payment_date":"2014-09-23T19:25:25+04:00",
"payment_method":1380,
"dry_run": 1
},
"payment_details":{
"payment":{
"currency":"USD",
"amount": 9.99
},
"vat":{
"currency":"USD",
"amount": 0
},
"payout_currency_rate":1,
"payout":{
"currency":"USD",
"amount": 9.49
},
"xsolla_fee":{
"currency":"USD",
"amount": 0.19
},
"payment_method_fee":{
"currency":"USD",
"amount": 0.31
}
}
}'
您可以在API参考中找到参数的完整列表。
用户取消付款后,Xsolla服务器将发送一个包含支付详情的webhook。
请求范例
$request = array(
'notification_type' => 'refund',
'purchase' => array(
'virtual_currency' => array(
'name' => '金币',
'quantity' => 100,
'currency' => 'USD',
'amount' => 9.99
),
'total' => array(
'currency' => 'USD',
'amount' => 9.99
)
),
'user' => array(
'ip' => '127.0.0.1',
'phone' => '18777976552',
'email' => 'email@example.com',
'id' => '1234567',
'country' => 'US'
),
'transaction' => array(
'id' => 87654321,
'payment_date' => '2014-09-23T19:25:25+04:00',
'payment_method' => 1380,
'dry_run' => 1
),
'refund_details' => (
'code' => 1,
'reason' => '欺诈'
),
'payment_details' => array(
'payment' => array(
'currency' => 'USD',
'amount' => 9.99
),
'vat' => array(
'currency' => 'USD',
'amount' => 0
),
'payout_currency_rate' => 1,
'payout' => array(
'currency' => 'USD',
'amount' => 9.49
),
'xsolla_fee' => array(
'currency' => 'USD',
'amount' => 0.19
),
'payment_method_fee' => array(
'currency' => 'USD',
'amount' => 0.31
)
)
);
curl -v https://example.com/ \
-X POST \
-H 'Content-Type:application/json' \
-H 'Accept: application/json' \
-H 'Authorization:Signature 13342703ccaca5064ad33ba451d800c5e823db8f' \
-d '
{
"notification_type":"refund",
"purchase":{
"virtual_currency":{
"name":"金币",
"quantity":10,
"currency":"USD",
"amount":100
},
"subscription":{
"plan_id":"b5dac9c8",
"subscription_id":"10",
"date_create":"2014-09-22T19:25:25+04:00",
"currency":"USD",
"amount": 9.99
},
"checkout":{
"currency":"USD",
"amount":50
},
"virtual_items":{
"items":[
{
"sku":"test_item1",
"amount":1
}
],
"currency":"USD",
"amount":50
},
"total":{
"currency":"USD",
"amount":200
}
},
"user":{
"ip":"127.0.0.1",
"phone":"18777976552",
"email":"email@example.com",
"id":"1234567",
"name":"Xsolla 用户",
"country":"US"
},
"transaction":{
"id":1,
"external_id":1,
"dry_run":1,
"agreement":1
},
"refund_details":{
"code":1,
"reason":"欺诈"
},
"payment_details":{
"xsolla_fee":{
"currency":"USD",
"amount":"10"
},
"payout":{
"currency":"USD",
"amount":"200"
},
"payment_method_fee":{
"currency":"USD",
"amount":"20"
},
"payment":{
"currency":"USD",
"amount":"230"
}
}
}'
您可以在API参考中找到参数的完整列表。
若要测试webhook处理器,请执行以下操作:
Xsolla Sandbox是一个独立环境,支持除真实付款外实时环境的所有功能。您可以通过在获得令牌时发送"mode" = "sandbox"来访问沙盒。
若要测试银行卡支付,请执行以下操作:
重要事项!沙盒模式下银行卡支付只能使用美元、欧元、卢布或英镑。
若要在测试成功后启动模块,请在发布商帐户中打开其设置,转到启动选项卡,然后单击开。
重要事项!您需要完成以下操作后才能接受真实付款: