Overview
  • Namespace
  • Class
  • Tree

Namespaces

  • OpenDNS
    • MES
      • Recurring
      • Reporting
      • Trident

Classes

  • Capture
  • CardTransaction
  • Credit
  • DeleteStoredCard
  • PreAuthorization
  • ReAuthorization
  • Refund
  • Request
  • Sale
  • StoreCard
  • Verification
  • Void
  1 <?php
  2 namespace OpenDNS\MES\Trident;
  3 
  4 /**
  5  *  Abstract for endpoints that accept a credit card and all its details
  6  */
  7 abstract class CardTransaction extends Request
  8 {
  9     /**
 10      * Sets the amount of the transaction
 11      *
 12      * @param float|string $amount
 13      * @return self The current class instance for chaining
 14      */
 15     public function setAmount($amount)
 16     {
 17         return $this->setField('transaction_amount', $amount);
 18     }
 19 
 20     /**
 21      * Sets the credit card expiration date.
 22      *
 23      * Accepts strings because that's most commonly how they're
 24      * implemented in web forms. You can also pass a \DateTime instance as a single argument
 25      *
 26      * @param int|string|\DateTime $month Either the expiration month or a datetime representing the whole expiration date
 27      * @param int|string|null $year Expiration year (2 or 4 digits) or omit if using a \DateTime
 28      * @return self The current class instance for chaining
 29      */
 30     public function setCardExpiration($month, $year = null)
 31     {
 32         $expDate = null;
 33 
 34         if ($month instanceof \DateTime) {
 35             $expDate = $month->format('md');
 36         } else if ($month && $year) {
 37             $expDate = str_pad($month, 2, '0', STR_PAD_LEFT)
 38                 . substr(str_pad($year, 2, '0', STR_PAD_LEFT), -2);
 39         }
 40 
 41         return $this->setField('card_exp_date', $expDate);
 42     }
 43 
 44     /**
 45      * Sets a card ID from a previous 'Store Card' operation to charge.
 46      *
 47      * This is mutually exclusive of setting the card number. Setting a Card ID
 48      * will unset any previously set card number.
 49      *
 50      * @param string $cardId 32-character card ID
 51      * @return self The current class instance for chaining
 52      */
 53     public function setCardId($cardId)
 54     {
 55         return $this->removeField('card_number')
 56                     ->setField('card_id', $cardId);
 57     }
 58 
 59     /**
 60      * Sets the credit card number to charge.
 61      *
 62      * This is mutually exclusive of setting the card id. Setting a card number
 63      * will unset any previously set card id.
 64      *
 65      * @param string $cardNumber 15 or 16 digit credit card number
 66      * @return self The current class instance for chaining
 67      */
 68     public function setCardNumber($cardNumber)
 69     {
 70         $cardNumber = preg_replace('/[^0-9]/', '', $cardNumber);
 71 
 72         return $this->removeField('card_id')
 73                     ->setField('card_number', $cardNumber);
 74     }
 75 
 76     /**
 77      * Sets a reference number that's of significance to the client.
 78      *
 79      * This might be an order number or some other value that you the
 80      * merchant would like to be able to refer to. It can't contain '&' or '='
 81      * for some reason
 82      *
 83      * @param int|string $referenceNumber A number of some interest to you.
 84      * @return self The current class instance for chaining
 85      */
 86     public function setClientReferenceNumber($referenceNumber)
 87     {
 88         return $this->setField('client_reference_number', $referenceNumber);
 89     }
 90 
 91     /**
 92      * Sets the card's CVV2 value for extra verification.
 93      *
 94      * Requires that CVV2 support be enabled on your account by MeS.
 95      *
 96      * @param int|string $cvv2 A 3 or 4 digit card verification number
 97      * @return self The current class instance for chaining
 98      */
 99     public function setCvv2($cvv2)
100     {
101         return $this->setField('cvv2', $cvv2);
102     }
103 
104     /**
105      * Sets the invoice number for the transaction.
106      *
107      * Limited to 0-9, a-z, A-Z, and spaces.
108      *
109      * @param int|string $invoiceNumber
110      * @return self The current class instance for chaining
111      */
112     public function setInvoiceNumber($invoiceNumber)
113     {
114         return $this->setField('invoice_number', $invoiceNumber);
115     }
116 
117     /**
118      * Sets the cardholder's street address for verification
119      *
120      * Just the first line ('123 Fake Street', for example)
121      *
122      * @param string $streetAddress
123      * @return self The current class instance for chaining
124      */
125     public function setStreetAddress($streetAddress)
126     {
127         return $this->setField('cardholder_street_address', $streetAddress);
128     }
129 
130     /**
131      * Sets the cardholder's ZIP code (or postal code) for verification
132      *
133      * Can be either 5 or 9 digits long.
134      *
135      * @param int $streetAddress
136      * @return self The current class instance for chaining
137      */
138     public function setZipCode($zipCode)
139     {
140         return $this->setField('cardholder_zip', $zipCode);
141     }
142 
143 }
144 
API documentation generated by ApiGen