Documentation

PayForPurchase

Selects a payment option for purchase order created via StartPurchase

Request Details

This is the second step in the purchasing process, initiating the purchase transaction with the payment provider (if applicable). For payment provider scenarios, the title should next present the user with the payment provider'sinterface for payment. Once the player has completed the payment with the provider, the title should call ConfirmPurchase tofinalize the process and add the appropriate items to the player inventory.

PayForPurchaseRequest
Request Properties
Currency (required) String

Currency to use to fund the purchase.

OrderId (required) String

Purchase order identifier returned from StartPurchase.

ProviderName (required) String

Payment provider to use to fund the purchase.

ProviderTransactionId String

Payment provider transaction identifier. Required for Facebook Payments.

POST https://{{TitleID}}.playfabapi.com/Client/PayForPurchase
    Content-Type: application/json
    X-Authentication: <user_session_ticket_value>
{
  "OrderId": "8853591446005860822",
  "ProviderName": "PayPal",
  "Currency": "RM"
}
        

Response Details

For web-based payment providers, this operation returns the URL to which the user should be directed inorder to approve the purchase. Items added to the user inventory as a result of this operation will be marked as unconfirmed.

PayForPurchaseResult
Result Properties
CreditApplied (required) uint32

Local credit applied to the transaction (provider specific).

OrderId String

Purchase order identifier.

ProviderData String

Provider used for the transaction.

ProviderToken String

A token generated by the provider to authenticate the request (provider-specific).

PurchaseConfirmationPageURL String

URL to the purchase provider page that details the purchase.

PurchaseCurrency String

Currency for the transaction, may be a virtual currency or real money.

PurchasePrice (required) uint32

Cost of the transaction.

Status TransactionStatus

Status of the transaction.

VCAmount Dict<String, int32>

Virtual currencies granted by the transaction, if any.

VirtualCurrency Dict<String, int32>

Current virtual currency balances for the user.

Sample Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
  "code": 200,
  "status": "OK",
  "data": {
    "OrderId": "8853591446005860822",
    "Status": "Init",
    "PurchaseCurrency": "RM",
    "PurchasePrice": 199,
    "CreditApplied": 0
  }
}

Authentication

SessionTicket

Possible Error Codes

Name Code
FailedByPaymentProvider 1015
InsufficientFunds 1059
InvalidPaymentProvider 1063
InvalidPurchaseTransactionStatus 1081
PurchaseDoesNotExist 1080
PurchaseInitializationFailure 1064