Subtract Currency
Subtracts the player's currency.
URL Confirmation
This API uses the service-api.playnanoo.com domain.
API Information
- URL:
https://service-api.playnanoo.com/currency/v20250301/subtract - Method:
PUT - Authentication Required: Yes
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| currency_code | string | Required | Currency code |
| currency_amount | double | Required | Currency quantity to subtract |
Response Data
| Field | Type | Description |
|---|---|---|
| currency_amount | number | Owned currency quantity after subtraction |
Code Example
void UMyGame::SubtractCurrency(const FString& CurrencyCode, double Amount)
{
// Create request body with player information
TSharedPtr<FJsonObject> Body = FPlayNANOOHelper::CreateRequestBody();
Body->SetStringField(TEXT("currency_code"), CurrencyCode);
Body->SetNumberField(TEXT("currency_amount"), Amount);
// Convert to JSON string
FString JsonBody = FPlayNANOOHelper::ToJsonString(Body);
// HTTP request
TSharedRef<IHttpRequest> Request = FHttpModule::Get().CreateRequest();
Request->SetURL(TEXT("https://service-api.playnanoo.com/currency/v20250301/subtract"));
Request->SetVerb(TEXT("PUT"));
FPlayNANOOHelper::SetCommonHeaders(Request, true); // Include auth token
Request->SetContentAsString(JsonBody);
Request->OnProcessRequestComplete().BindLambda(
[](FHttpRequestPtr Req, FHttpResponsePtr Res, bool bSuccess)
{
if (bSuccess && Res.IsValid())
{
TSharedPtr<FJsonObject> JsonObject;
TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Res->GetContentAsString());
if (FJsonSerializer::Deserialize(Reader, JsonObject))
{
double RemainingAmount = JsonObject->GetNumberField(TEXT("currency_amount"));
UE_LOG(LogTemp, Log, TEXT("Currency amount after subtraction: %f"), RemainingAmount);
}
}
});
Request->ProcessRequest();
}
Insufficient Currency
An error occurs if there is not enough currency to subtract. Make sure you have sufficient currency before subtracting.