Skip to content

Commit c626bfb

Browse files
committed
feat: Add support for Playstation IAPs
1 parent 4b4e55a commit c626bfb

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ public class LootLockerEndPoints
211211
public static EndPointClass redeemAppleAppStorePurchase = new EndPointClass("store/apple/redeem", LootLockerHTTPMethod.POST);
212212
public static EndPointClass redeemGooglePlayStorePurchase = new EndPointClass("store/google/redeem", LootLockerHTTPMethod.POST);
213213
public static EndPointClass redeemEpicStorePurchase = new EndPointClass("store/epic/redeem", LootLockerHTTPMethod.POST);
214+
public static EndPointClass redeemPlayStationStorePurchase = new EndPointClass("store/playstation/redeem", LootLockerHTTPMethod.POST);
214215

215216
public static EndPointClass beginSteamPurchaseRedemption = new EndPointClass("store/steam/redeem/begin", LootLockerHTTPMethod.POST);
216217
public static EndPointClass querySteamPurchaseRedemptionStatus = new EndPointClass("store/steam/redeem/query", LootLockerHTTPMethod.POST);

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6120,6 +6120,101 @@ public static void RedeemEpicStorePurchaseForClass(string accountId, string bear
61206120
LootLockerServerRequest.CallAPI(forPlayerWithUlid, LootLockerEndPoints.redeemEpicStorePurchase.endPoint, LootLockerEndPoints.redeemEpicStorePurchase.httpMethod, body, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
61216121
}
61226122

6123+
/// <summary>
6124+
/// Redeem a purchase that was made successfully towards the Playstation Store for the current player
6125+
/// </summary>
6126+
/// <param name="transaction_id">The transaction id from the PlayStation Store of the purchase to redeem </param>
6127+
/// <param name="auth_code">The authorization code from the PlayStation Store of the purchase to redeem </param>
6128+
/// <param name="entitlement_label">The entitlement label configured in the NP service for the entitlement that this redemption relates to </param>
6129+
/// <param name="onComplete">onComplete Action for handling the response</param>
6130+
/// <param name="service_label">Optional: The NP service label. </param>
6131+
/// <param name="service_name">Optional: The abreviation of the service name of the ASM service ID service that was used when configuring the serviceIds. Possible Values: pssdc, cce. Default Value: pssdc </param>
6132+
/// <param name="environment">Optional: The id of the environment you wish to make the request against. Allowed values: 1, 8, 256 </param>
6133+
/// <param name="use_count">Optional: The use count for this redemption </param>
6134+
/// <param name="forPlayerWithUlid">Optional : Execute the request for the specified player. If not supplied, the default player will be used.</param>
6135+
public static void RedeemPlaystationStorePurchaseForPlayer(string transaction_id, string auth_code, string entitlement_label, Action<LootLockerResponse> onComplete, string service_label = "", string service_name = "", int environment = -1, int use_count = -1, string forPlayerWithUlid = null)
6136+
{
6137+
if (!CheckInitialized(false, forPlayerWithUlid))
6138+
{
6139+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerResponse>(forPlayerWithUlid));
6140+
return;
6141+
}
6142+
Dictionary<string, object> bodyDict = new Dictionary<string, object>
6143+
{
6144+
{ "transaction_id", transaction_id },
6145+
{ "auth_code", auth_code },
6146+
{ "entitlement_label", entitlement_label }
6147+
};
6148+
if (!string.IsNullOrEmpty(service_label))
6149+
{
6150+
bodyDict.Add("service_label", service_label);
6151+
}
6152+
if (!string.IsNullOrEmpty(service_name))
6153+
{
6154+
bodyDict.Add("service_name", service_name);
6155+
}
6156+
if (environment != -1)
6157+
{
6158+
bodyDict.Add("environment", environment);
6159+
}
6160+
if (use_count != -1)
6161+
{
6162+
bodyDict.Add("use_count", use_count);
6163+
}
6164+
var body = LootLockerJson.SerializeObject(bodyDict);
6165+
6166+
LootLockerServerRequest.CallAPI(forPlayerWithUlid, LootLockerEndPoints.redeemPlayStationStorePurchase.endPoint, LootLockerEndPoints.redeemPlayStationStorePurchase.httpMethod, body, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
6167+
}
6168+
6169+
/// <summary>
6170+
/// Redeem a purchase that was made successfully towards the Playstation Store for a class that the current player owns
6171+
/// </summary>
6172+
/// <param name="transaction_id">The transaction id from the PlayStation Store of the purchase to redeem </param>
6173+
/// <param name="auth_code">The authorization code from the PlayStation Store of the purchase to redeem </param>
6174+
/// <param name="entitlement_label">The entitlement label configured in the NP service for the entitlement that this redemption relates to </param>
6175+
/// <param name="classId">The id of the class to redeem this purchase for</param>
6176+
/// <param name="onComplete">onComplete Action for handling the response</param>
6177+
/// <param name="service_label">Optional: The NP service label. </param>
6178+
/// <param name="service_name">Optional: The abreviation of the service name of the ASM service ID service that was used when configuring the serviceIds. Possible Values: pssdc, cce. Default Value: pssdc </param>
6179+
/// <param name="environment">Optional: The id of the environment you wish to make the request against. Allowed values: 1, 8, 256 </param>
6180+
/// <param name="use_count">Optional: The use count for this redemption </param>
6181+
/// <param name="forPlayerWithUlid">Optional : Execute the request for the specified player. If not supplied, the default player will be used.</param>
6182+
public static void RedeemPlaystationStorePurchaseForClass(string transaction_id, string auth_code, string entitlement_label, int classId, Action<LootLockerResponse> onComplete, string service_label = "", string service_name = "", int environment = -1, int use_count = -1, string forPlayerWithUlid = null)
6183+
{
6184+
if (!CheckInitialized(false, forPlayerWithUlid))
6185+
{
6186+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerResponse>(forPlayerWithUlid));
6187+
return;
6188+
}
6189+
6190+
Dictionary<string, object> bodyDict = new Dictionary<string, object>
6191+
{
6192+
{ "transaction_id", transaction_id },
6193+
{ "auth_code", auth_code },
6194+
{ "entitlement_label", entitlement_label },
6195+
{ "character_id", classId }
6196+
};
6197+
if (!string.IsNullOrEmpty(service_label))
6198+
{
6199+
bodyDict.Add("service_label", service_label);
6200+
}
6201+
if (!string.IsNullOrEmpty(service_name))
6202+
{
6203+
bodyDict.Add("service_name", service_name);
6204+
}
6205+
if (environment != -1)
6206+
{
6207+
bodyDict.Add("environment", environment);
6208+
}
6209+
if (use_count != -1)
6210+
{
6211+
bodyDict.Add("use_count", use_count);
6212+
}
6213+
var body = LootLockerJson.SerializeObject(bodyDict);
6214+
6215+
LootLockerServerRequest.CallAPI(forPlayerWithUlid, LootLockerEndPoints.redeemPlayStationStorePurchase.endPoint, LootLockerEndPoints.redeemPlayStationStorePurchase.httpMethod, body, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
6216+
}
6217+
61236218
/// <summary>
61246219
/// Begin a Steam purchase with the given settings that when finalized will redeem the specified catalog item
61256220
///

0 commit comments

Comments
 (0)