일일 보상
일일 보상은 프리미엄 구독을 구매한 사용자에게 제공됩니다. 각각의 프리미엄 구독 가입에는 자체 보상 세트가 있습니다.
일일 보상은 프리미엄 구독을 구매한 사용자에게 제공됩니다. 각각의 프리미엄 구독 가입에는 자체 보상 세트가 있습니다.
모듈 통합 방법:
통합에 필요한 매개변수는 다음과 같습니다.
본 가이드는 모듈을 빠르게 시작하기 위해 필요한 최소 설정 세트에 대한 설명을 제공합니다. 매개변수 전체 목록은 API Reference에서 확인할 수 있습니다. 질문이 있을 경우, 계정 관리자에게 문의합니다.
중요 정보! 하나의 플랜에는 하나의 통화만 지정할 수 있습니다. 개별 프로젝트 통화의 경우 별도의 플랜 세트를 생성해야 합니다.
프리미엄 플랜에 다음과 같은 보상을 추가할 수 있습니다.
중요 정보! 선택한 보상에 따라, 가상 아이템 및/또는 가상 통화 모듈을 추가로 설정할 필요가 있습니다.
보상을 설정하려면 요청을 integration@xsolla.com으로 제출합니다.
상점 UI를 게임에 통합하려면 액세스 토큰이 필요합니다. 액세스 토큰은 게임, 사용자 및 구매 매개변수를 식별하는 문자열입니다.
Xsolla API는 HTTP 기본 인증을 사용합니다. 판매자 ID를 기본 인증 사용자 이름으로 제공하고 API 키를 암호로 제공합니다.
결제 프로세스를 테스트하려면 값을 "mode":"sandbox"로 설정합니다.
토큰 엔드포인트 URL:
https://api.xsolla.com/merchant/merchants/{merchant_id}/token
HTTP POST 요청에서, 상점 UI의 매개변수를 사용할 수 있습니다. 요청 및 응답 페이로드는 JSON 형식으로 되어 있습니다.
요청 예제
아래에는 Xsolla PHP SDK를 사용하여 PHP에서 토큰을 얻는 방법에 대한 샘플 코드가 제공되어 있습니다. 다른 프로그래밍 언어를 사용하고 있는 경우, 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 Reference에서 확인할 수 있습니다.
상점을 열 수 있는 세 가지 방법:
샌드박스 모드로 상점을 열려면 다음 URL을 사용합니다. https://sandbox-secure.xsolla.com/
Pay Station 임베드 스크립트가 장치 유형을 결정하고 라이트박스(데스크톱 화면) 또는 새 창(모바일 및 태블릿 화면)에서 상점 UI를 엽니다. 비동기 스크립트 로딩 기능을 사용하는 것이 좋습니다.
비동기 스크립트 로딩 예제:
<script>
var options = {
access_token: 'ACCESS_TOKEN', //TODO use access token, received on previous step
sandbox: true //TODO please do not forget to remove this setting when going live
};
var s = document.createElement('script');
s.type = "text/javascript";
s.async = true;
s.src = "https://static.xsolla.com/embed/paystation/1.0.7/widget.min.js";
s.addEventListener('load', function (e) {
XPayStationWidget.init(options);
}, false);
var head = document.getElementsByTagName('head')[0];
head.appendChild(s);
</script>
<button data-xpaystation-widget-open>크레딧 구입</button>
매개변수 전체 목록은 API Reference에서 확인할 수 있습니다.
새 창에서 상점 UI를 열려면 다음 링크를 사용합니다. https://secure.xsolla.com/paystation2/?access_token=ACCESS_TOKEN, 여기에서 ACCESS_TOKEN은 이전 단계에서 입수한 토큰입니다.
iframe에서 상점 UI를 열려면 다음 메커니즘을 자신 쪽에 적용해야 합니다.
새 창에서 상점 UI를 열려면 다음 링크를 사용합니다. https://secure.xsolla.com/paystation2/?access_token=ACCESS_TOKEN, 여기에서 ACCESS_TOKEN은 이전 단계에서 입수한 토큰입니다.
Xsolla는 프로젝트에 다음과 같은 웹훅을 전송합니다.
아무런 문제없이 웹훅 알림을 받았음을 확인하려면 사용자 서버가 본문없이 204 HTTP 상태 코드를 반환해야 합니다. 예제를 포함한 웹훅 메커니즘에 대한 내용은 API Reference에 자세히 설명되어 있습니다.
서명 생성 방법:
웹훅을 처리할 때 수신한 서명이 서명 헤더에 설정된 서명과 일치하는 확인합니다.
Xsolla 서버는 사용자가 결제를 완료할 때마다 결제 세부 정보가 포함되어 있는 웹훅을 전송합니다.
요청 예제
$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 Reference에서 확인할 수 있습니다.
Xsolla 서버는 사용자가 결제를 완료할 때마다 구독 세부 정보가 포함되어 있는 웹훅을 전송합니다.
요청 예제
<?php
$request = array(
'notification_type' => 'create_subscription',
'user' => (
'id' => '1234567',
'name' => 'Xsolla User'
),
'subscription' => (
'plan_id' => 'b5dac9c8',
'subscription_id' => '10',
'product_id' => 'Demo Product',
'date_create' => '2014-09-22T19:25:25+04:00',
'date_next_charge' => '2015-01-22T19:25:25+04:00',
'trial' => (
'value' => 90,
'type' => 'day'
)
)
);
$ curl -v 'https://your.hostname/your/uri' \
-X POST \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Signature 13342703ccaca5064ad33ba451d800c5e823db8f' \
-d '{
"notification_type":"create_subscription",
"user":{
"id":"1234567",
"name":"Xsolla User"
},
"subscription":{
"plan_id":"b5dac9c8",
"subscription_id":"10",
"product_id":"Demo Product",
"date_create":"2014-09-22T19:25:25+04:00",
"date_next_charge":"2015-01-22T19:25:25+04:00",
"trial": {
"value": 90,
"type": "day"
}
}
}'
매개변수 전체 목록은 API Reference에서 확인할 수 있습니다.
사용자의 인벤토리가 변경될 때마다(아이템이 추가되거나 제거될 때마다) Xsolla 서버가 웹훅을 프로젝트 서버로 전송합니다.
요청 예제
$request = array(
'virtual_currency_balance' => (
'old_value' => '0',
'new_value' => '200',
'diff' => '200'
),
'user' => (
'name' => 'Xsolla User',
'id' => '1234567',
'email' => 'email@example.com'
),
'operation_type' => 'inGamePurchase',
'notification_type' => 'user_balance_operation',
'items_operation_type' => 'add',
'items' => array(
'sku' => '1468',
'amount' => '2'
),
'id_operation' => '66989'
);
curl -v https://example.com/ \
-X POST \
-H 'Content-Type:application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Signature 13342703ccaca5064ad33ba451d800c5e823db8f' \
-d '
{
"virtual_currency_balance":{
"old_value":"0",
"new_value":"200",
"diff":"200"
},
"user":{
"name":"Xsolla User",
"id":"1234567",
"email":"semail@example.com
},
"operation_type":"inGamePurchase",
"notification_type":"user_balance_operation",
"items_operation_type": "add",
"items": [{
"sku": "1468",
"amount": "2"
}],
"id_operation":"66989"
}'
매개변수 전체 목록은API Reference에서 확인할 수 있습니다.
사용자가 구독 플랜을 변경하거나 구독 기간을 연장하거나 다음 청구일이 변경 될 때마다 Xsolla 서버가 웹훅을 전송합니다.
요청 예제
<?php
$request = array(
'notification_type' => 'update_subscription',
'user' => (
'id' => '1234567',
'name' => 'Xsolla User'
),
'subscription' => (
'plan_id' => 'b5dac9c8',
'subscription_id' => '10',
'product_id' => 'Demo Product',
'date_next_charge' => '2015-01-22T19:25:25+04:00'
)
);
$ curl -v 'https://your.hostname/your/uri' \
-X POST \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Signature 13342703ccaca5064ad33ba451d800c5e823db8f' \
-d '{
"notification_type":"update_subscription",
"user":{
"id":"1234567",
"name":"Xsolla User"
},
"subscription":{
"plan_id":"b5dac9c8",
"subscription_id":"10",
"product_id":"Demo Product",
"date_next_charge":"2015-01-22T19:25:25+04:00"
}
}'
매개변수 전체 목록은 API Reference에서 확인할 수 있습니다.
사용자가 결제를 취소할 경우, Xsolla 서버가 지불 정보와 함께 웹훅 알림을 전송합니다.
요청 예제
$request = array(
'notification_type' => 'refund',
'purchase' => array(
'virtual_currency' => array(
'name' => 'Coins',
'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' => 'Fraud'
),
'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": "Coins",
"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 User",
"country": "US"
},
"transaction":{
"id":1,
"external_id":1,
"dry_run":1,
"agreement":1
},
"refund_details":{
"code":1,
"reason":"Fraud"
},
"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 Reference에서 확인할 수 있습니다.
구독이 취소될 때마다 Xsolla 서버가 웹훅을 전송합니다.
요청 예제
<?php
$request = array(
'notification_type' => 'cancel_subscription',
'user' => (
'id' => '1234567',
'name' => 'Xsolla User'
),
'subscription' => (
'plan_id' => 'b5dac9c8',
'subscription_id' => '10',
'product_id' => 'Demo Product',
'date_create' => '2014-09-22T19:25:25+04:00',
'date_end' => '2015-01-22T19:25:25+04:00',
)
);
$ curl -v 'https://your.hostname/your/uri' \
-X POST \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Signature 13342703ccaca5064ad33ba451d800c5e823db8f' \
-d '{
"notification_type":"cancel_subscription",
"user":{
"id":"1234567",
"name":"Xsolla User"
},
"subscription":{
"plan_id":"b5dac9c8",
"subscription_id":"10",
"product_id":"Demo Product",
"date_create":"2014-09-22T19:25:25+04:00",
"date_end":"2015-01-22T19:25:25+04:00"
}
}'
매개변수 전체 목록은 API Reference에서 확인할 수 있습니다.
웹훅 처리 테스트 방법:
Xsolla 샌드박스는 실제 결제를 제외한 결제 프로세스 관련 모든 기능을 지원하는 독립형 환경입니다. "mode" = "sandbox"를 전송하여 샌드박스에 액세스할 수 있습니다( 토큰 입수 시 가능).
은행 카드 결제 테스트 방법:
중요 정보! 샌드박스 은행 카드 결제는 USD, EUR, RUB, GBP, SGD, HKD 또는 THB로만 이용할 수 있습니다.
테스트를 성공적으로 완료한 후 모듈을 시작하려면 게시자 계정에서 설정을 열고 시작 탭으로 이동한 다음, 켜기를 클릭합니다.
중요 정보! 실제 지불을 받으려면 먼저 다음을 수행해야 합니다.