1 <?php
2 namespace OpenDNS\MES\Recurring;
3
4 /**
5 * Abstract with setters for recurring billing profiles
6 */
7 abstract class RecurringDetailRequest extends Request
8 {
9
10 /**
11 * Sets Amount to charge each billing cycle
12 *
13 * @param int $recurringAmount
14 *
15 * @return self The current class instance for chaining
16 */
17 public function setRecurringAmount($recurringAmount)
18 {
19 return $this->setField('recur_amount', $recurringAmount);
20 }
21
22 /**
23 * Sets starting date of the recurring payments
24 * @param DateTime $startDate
25 *
26 * @return self The current class instance for chaining
27 */
28 public function setRecurringStartDate(\DateTime $startDate)
29 {
30 return $this->setField('recur_start_date', $startDate->format('m/d/y'));
31 }
32
33 /**
34 * Sets number of payments to process over the lifespan of the profile, or 0 for infinite
35 *
36 * @param int $payments
37 *
38 * @return self The current class instance for chaining
39 */
40 public function setNumberofPayments($payments)
41 {
42 return $this->setField('recur_num_pmt', $payments);
43 }
44
45 /**
46 * Sets a reference number that's of significance to the client.
47 *
48 * This might be an order number or some other value that you the
49 * merchant would like to be able to refer to. It can't contain '&' or '='
50 * for some reason
51 *
52 * @param int|string $referenceNumber A number of some interest to you.
53 * @return self The current class instance for chaining
54 */
55 public function setClientReferenceNumber($referenceNumber)
56 {
57 return $this->setField('client_reference_number', $referenceNumber);
58 }
59
60 /**
61 * Sets a card ID from a previous 'Store Card' operation to charge.
62 *
63 * This is mutually exclusive of setting the card number. Setting a Card ID
64 * will unset any previously set card number.
65 *
66 * @param string $cardId 32-character card ID
67 * @return self The current class instance for chaining
68 */
69 public function setCardId($cardId)
70 {
71 return $this->removeField('card_number')
72 ->setField('card_id', $cardId);
73 }
74
75 /**
76 * Sets the credit card number to charge.
77 *
78 * This is mutually exclusive of setting the card id. Setting a card number
79 * will unset any previously set card id.
80 *
81 * @param string $cardNumber 15 or 16 digit credit card number
82 * @return self The current class instance for chaining
83 */
84 public function setCardNumber($cardNumber)
85 {
86 return $this->removeField('card_id')
87 ->setField('card_number', $cardNumber);
88 }
89
90 /**
91 * Sets the credit card expiration date.
92 *
93 * Accepts strings because that's most commonly how they're
94 * implemented in web forms. You can also pass a \DateTime instance as a single argument
95 *
96 * @param int|string|\DateTime $month Either the expiration month or a datetime representing the whole expiration date
97 * @param int|string|null $year Expiration year (2 or 4 digits) or omit if using a \DateTime
98 * @return self The current class instance for chaining
99 */
100 public function setCardExpiration($month, $year)
101 {
102 $month = str_pad($month, 2, '0', STR_PAD_LEFT);
103
104 $year = substr(str_pad($year, 2, '0', STR_PAD_LEFT), -2);
105
106 return $this->setField('card_exp_date', $month . $year);
107 }
108
109 /**
110 * Sets the cardholder's street address for verification
111 *
112 * Just the first line ('123 Fake Street', for example)
113 *
114 * @param string $streetAddress
115 * @return self The current class instance for chaining
116 */
117 public function setStreetAddress($streetAddress)
118 {
119 return $this->setField('cardholder_street_address', $streetAddress);
120 }
121
122 /**
123 * Sets the cardholder's ZIP code (or postal code) for verification
124 *
125 * Can be either 5 or 9 digits long.
126 *
127 * @param int $zipCode
128 * @return self The current class instance for chaining
129 */
130 public function setZipCode($zipCode)
131 {
132 return $this->setField('cardholder_zip', $zipCode);
133 }
134
135 /**
136 * Sets the amount of tax to charge on the transaction
137 *
138 * @param int $taxAmount
139 * @return self The current class instance for chaining
140 */
141 public function setTaxAmount($taxAmount)
142 {
143 return $this->setField('tax_amount', $taxAmount);
144 }
145
146 }
147