> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slm.m1amdocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Token Transactions in Real Time

To track your customers’ token transactions in Subscribe, execute standard `Transaction` objects. For example, if your customer makes a one-time purchase for which the price is a token type instead of currency, construct a real-time `Transaction` object.

**Note:**

* The `Transaction` object’s `sourcePaymentMethod` attribute must refer to a `PaymentMethod` object called `Token`.

* The transaction items in the `Transaction` object must all be for amounts that are in tokens.

* Token transactions must have a `_VT` setting for `currency`, which is Vindicia’s internal code for token-based payment.

* You `cannot` mix items priced in currency and tokens. Apply only a token type to the Transaction object.

Create and process a real-time Transaction:

```

 //Create a new Transaction object
 $tx = new Transaction();
  
 // Reference an existing account to which tokens are to be granted
 $account = new Account();
 $account->setMerchantAccountId('9876-5432');
 $tx->setAccount($account);
  
 // One of the line items of the transaction must be the 
 // product that grants tokens
 $tx_item = new TransactionItem();
 $tx_item->setSku('sku112'); 
 $tx_item->setName('Product priced in token);
 $tx_item->setPrice(2); // this is the number of tokens 
 $tx_item->setQuantity(1);
 $tx->setTransactionItems(array($tx_item));
  
 // The source payment method used for the transaction must be 
 // a token payment method
 $srcPm = new PaymentMethod ();
 $srcPm->setType('Token');
  
 // because the product we want to purchase uses tokens of a
 // certain type, create Token objects of that type to specify 
 // in the payment method
 $tok = new Token();
 $tok->setMerchantTokenId("US_FREQ_BOOK_BUYER_PT");
  
 $srcPm->setToken($tok);
  
 // set the payment method in the transaction
  
 $tx->setSrcPaymentMethod($srcPm);
  
 // set currency of the Transaction to be tokens
  
 $tx->setCurrency('_VT');
  
 // set other transaction attributes here
  
 …
  
 $sendEmailNotification=false;
 $response = $tx->authCapture($sendEmailNotification); 
 // SOAP call
  
 if($response['returnCode']==200) {
 if($tx->statusLog[0]->status=='Authorized') {
 print "Purchase complete";
 }
 }
```

**Parent topic:**[Decrementing Token Balances](../topics/Decrementing_Token_Balan)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.