-
Notifications
You must be signed in to change notification settings - Fork 4
/
BraspagCreditCardModel.php
175 lines (140 loc) · 4.1 KB
/
BraspagCreditCardModel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
/**
* BraspagCreditCardModel
* Credit Card Entity used to make authorizations, captures and justclick saves
*
* @author Robson Morais ([email protected])
* @link http://www.isharelife.com.br/
* @version $ID$
* @package opensource
* @copyright Copyright © 2010-2012 iShareLife
* @license Apache License, Version 2.0
*
*/
class BraspagCreditCardModel extends BraspagPaymentModel{
//Payment plans
const PAYMENT_PLAN_FULL = 0;
const PAYMENT_PLAN_FINANCED_STORE = 1;
const PAYMENT_PLAN_FINANCED_CARD = 2;
//Transaction types
const TRANSACTION_TYPE_INVALID = 0;
const TRANSACTION_TYPE_AUTHORIZE = 1;
const TRANSACTION_TYPE_AUTOCAPTURE = 2;
const TRANSACTION_TYPE_PREAUTH_AUTENTICATION = 3;
const TRANSACTION_TYPE_AUTOCAPTURE_AUTENTICATION = 4;
//Payment methods
const METHOD_CIELO_VISA = 500;
const METHOD_CIELO_MASTERCARD = 501;
const METHOD_CIELO_AMEX = 502;
const METHOD_CIELO_DINNERS = 503;
const METHOD_CIELO_ELO = 504;
const METHOD_REDECARD_VISA = 509;
const METHOD_REDECARD_MASTERCARD = 510;
const METHOD_REDECARD_DINNERS = 511;
const METHOD_HOMOLOGATION = 997;
public $method;
public $numberOfPayments;
public $paymentPlan;
public $transactionType;
public $cardHolder;
public $cardNumber;
public $cardSecurityCode;
public $cardExpirationDate;
public $creditCardToken;
public $justClickAlias;
public $saveCreditCard = 0;
public function __construct(){
$this->setType(parent::TYPE_CREDITCARD);
}
public function getCreditCardToken(){
return $this->creditCardToken;
}
public function getJustClickAlias(){
return $this->justClickAlias;
}
public function getSaveCreditCard(){
return $this->saveCreditCard;
}
public function setCreditCardToken($creditCardToken){
$this->creditCardToken = $creditCardToken;
}
public function setJustClickAlias($justClickAlias){
$this->justClickAlias = $justClickAlias;
}
public function setSaveCreditCard($saveCreditCard){
$this->saveCreditCard = $saveCreditCard;
}
public function getMethod(){
return $this->method;
}
public function setMethod($method){
$this->method = $method;
return $this;
}
public function getNumberOfPayments(){
return $this->numberOfPayments;
}
public function getPaymentPlan(){
return $this->paymentPlan;
}
public function getTransactionType(){
return $this->transactionType;
}
public function getCardHolder(){
return $this->cardHolder;
}
public function getCardNumber(){
return $this->cardNumber;
}
public function getCardSecurityCode(){
return $this->cardSecurityCode;
}
public function getCardExpirationDate(){
return $this->cardExpirationDate;
}
public function setNumberOfPayments($numberOfPayments){
$this->numberOfPayments = $numberOfPayments;
}
public function setPaymentPlan($paymentPlan){
$this->paymentPlan = $paymentPlan;
}
public function setTransactionType($transactionType){
$this->transactionType = $transactionType;
}
public function setCardHolder($cardHolder){
$this->cardHolder = $cardHolder;
}
public function setCardNumber($cardNumber){
$this->cardNumber = $cardNumber;
}
public function setCardSecurityCode($cardSecurityCode){
$this->cardSecurityCode = $cardSecurityCode;
}
public function setCardExpirationDate($mm, $yyyy){
$this->cardExpirationDate = $mm.'/'.$yyyy;
}
public function clearCreditCardToken(){
unset($this->creditCardToken);
}
public function getPaymentData(){
$data = new BraspagCreditCardDataRequest();
$data->Amount = $this->amount;
$data->Currency = $this->currency;
$data->PaymentMethod = $this->method;
$data->NumberOfPayments = $this->numberOfPayments;
$data->PaymentPlan = $this->paymentPlan;
$data->TransactionType = $this->transactionType;
$data->CardHolder = $this->cardHolder;
$data->CardNumber = $this->cardNumber;
$data->CardSecurityCode = $this->cardSecurityCode;
$data->CardExpirationDate = $this->cardExpirationDate;
$data->SaveCreditCard = $this->saveCreditCard;
if(!empty($this->creditCardToken)){
$data->CreditCardToken = $this->creditCardToken;
$data->JustClickAlias = $this->justClickAlias;
}else{
$data->clearCreditCardJustClick();
}
return $data;
}
}