> ## 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.

# Using Credit Cards for One-Time Transactions

Create, populate, authorize, and capture a Transaction with payment method type: CreditCard:

```

 $tx = new Transaction();
 $tx->setAmount('9.90');
 $tx->setCurrency('USD');
  
 // Merchant transaction id must be unique for each new 
 // transaction you wish Vindicia to process. If you use an id 
 // that has been used before, the authCapture() call will 
 // simply update the corresponding
 // existing transaction with new data
  
 $tx->setMerchantTransactionId('txid-123456');
  
 $tx->setTimestamp('2006-09-11T22:34:32.265Z');
 $tx->setSourceIp('34.67.89.234');
 $tx->setSourcePhoneNumber('650-874-6784');
  
 // Reference an existing account
 $account = new Account();
 $account->setMerchantAccountId('9876-5432');
 $tx->setAccount($account);
  
 // Different shipping address from Account?
 $shippingAddress = new Address();
 $shippingAddress->setName('Jane Doe');
 $shippingAddress->setAddr1('44 Elm St.');
 $shippingAddress->setAddr2('Apt 55');
 $shippingAddress->setAddr3(''); 
 $shippingAddress->setCity('San Mateo');
 $shippingAddress->setDistrict('CA');
 $shippingAddress->setPostalCode('94403');
 $shippingAddress->setCountry('US');
 $shippingAddress->setPhone('650-555-3444');
 $shippingAddress->setFax('650-555-3445');
  
 $tx->setShippingAddress($shippingAddress);
  
 // The line items of the transaction
 $tx_item = new TransactionItem();
 $tx_item->setSku('sku-1234');
 $tx_item->setName('Widget');
 $tx_item->setPrice('3.30');
 $tx_item->setQuantity('3');
 $tx->setTransactionItems(array($tx_item));
  
 $paymentMethod = new PaymentMethod();
 $paymentMethod->setBillingAddress($address);
 $paymentMethod->setType('CreditCard');
  
 $card = new CreditCard();
 $card->setAccount('4444222211113333');
 $card->setExpirationDate('xxxxxx'); // Use YYYYMM format for date
 $paymentMethod->setCreditCard($card);
  
 $tx->setSourcePaymentMethod($paymentMethod);
  
 // Subscribe can send an email notification to the customer 
 // associated with this transaction, if an email template 
 // for this is uploaded to the Subscribe database
  
 $sendEmailNotification=false;
  
 $response = $tx->authCapture($sendEmailNotification);
  
 if($response['returnCode']==200) {
    // The transaction statuses can be found in statusLog attribute
    // of the Transaction object. This is an array of 
    // TransactionStatus objects. The first entry in this array 
    // is the latest status of the transaction
    if($tx->statusLog[0]->status=='Authorized') {
       print "Captured\n";
    }
    else if($tx->statusLog[0]->status=='Cancelled') {
       // The transaction did not go through 
       print "Declined. 
       Reason code received from payment processor: ";
       print $tx->statusLog[0]->status->creditCardStatus->authCode 
       . "\n";
    }
 }
```

With the `CreditCard` payment method, the `Transaction` status after an `authCapture()` call is `Authorized`. The payment processor has authorized the transaction, and Subscribe has marked it for capture with the payment processor. After capture, the status changes to `Captured`. Although this change usually takes less than 24 hours, in most cases you can assume that if `Authorized` is returned as the status, Subscribe will capture the transaction.

* **[Verifying AVS and CVN for One-Time Transactions](../topics/Verifying_AVS_and_CVN_fo_1)**

* **[Calling the auth and capture Methods Separately](../topics/Calling_the_auth_and_cap)**

**Parent topic:**[Working with One-Time Transactions](../topics/ProgGuide_Transactions)


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