Fulfill orders from the client #

Below is an example of calling the fulfill orders API from the client using the SDK.

Unreal example #

This Unreal example extends from the Unreal SDK Setup tutorial.
void AUnicornPlayerController::FulfillOrders() {
  Player->OrderApi().FulfillOrders(
      FPragmaProviderData("STEAM"),
      UPragmaOrderApi::FFulfillOrdersDelegate::CreateLambda(
          [](const TPragmaResult<TArray<FPragmaFulfillment>> &Result) {
            if (Result.IsSuccessful()) {
              const auto Fulfillments = Result.Payload<>();
              for (const FPragmaFulfillment &Fulfillment : Fulfillments) {
                UE_LOG(LogTemp, Display,
                       TEXT("Order fulfilled by platform: %s"),
                       *Fulfillment.ProviderId);

                /*
                 * Fulfillment Status Codes:
                 *   1 = Fulfilled
                 *   2 = Failed
                 *   3 = Revoked
                 *   4 = Revoke Failed
                 */
                UE_LOG(LogTemp, Display, TEXT("Status: %d"),
                       Fulfillment.Status);
              }
            } else {
              UE_LOG(LogTemp, Error, TEXT("FulfillOrders request failed"));
            }
          }));
}

Fulfill orders from a trusted partner #

You can have a trusted partner call fulfill orders with a HTTP request.

Trusted backend must send a valid partner token. Tokens can be generated in the portal.
Method: POST
Protocol: https
URL: <backend-url>:10100/v1/rpc
Authorization: <valid-partner-token> // partner token from portal
JSON Payload: 
{
    "requestId": 1,
    "type": "FulfillmentRpc.FulfillOrdersPartnerV1Request",
    "payload": {
        "pragmaPlayerId": "<player-game-uuid-as-string>",
        "providerData": [
            {
                "providerId": "STEAM"
            }
         ]
    }
}

Example cURL request:

curl --location 'https://<backend-url>:10100/v1/rpc' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
    "requestId": 1,
    "type": "FulfillmentRpc.FulfillOrdersPartnerV1Request",
    "payload": {
        "pragmaPlayerId": "00000000-0000-0000-0000-000000000001",
        "providerData": [
            {
                "providerId": "STEAM"
            }
         ]
    }
}'

Example Response:

A successful response will include a fulfillment object for each order processed. Check the status field to determine success.


{
    "requestId":10,
    "type":"FulfillmentRpc.FulfillOrdersPartnerV1Response",
    "payload":{
        "fulfillments":[
            {
                "fulfillmentId":"<uuid-for-fulfillment>",
                "orderId":"<uuid-for-order>",
                "pragmaPlayerId":"00000000-0000-0000-0000-000000000001",
                "skuId":"500_coin_pack", // from Fulfillment Mapping Specs
                "quantity":1.0,
                "providerId":"STEAM",
                "status":"FULFILLMENT_STATUS_FULFILLED",
                "createdTimestampMillis":"1755296097555",
                "lastUpdatedTimestampMillis":"1755296097555",
                "contentVersion":"2"
            }
        ]
    }
}

Configure for local testing #

All Pragma live shards are configured by default to include a SocialBackendPartnerClientConfig.

If you are wanting to test from a local machine, add this configuration to you local-dev.yml. Check out the Generate Partner tokens to generate a token in the social operator portal.

game:
  serviceConfigs:
    SocialBackendPartnerClientConfig:
      bearerToken: <social-partner-token>