Class: BraspagRails::Transacao::Credito

Inherits:
Object
  • Object
show all
Extended by:
Savon::Model
Defined in:
lib/braspag_rails/transacoes/credito.rb

Class Method Summary collapse

Class Method Details

.autorizar(value, holder, number, code, date, method, number_payments, plan, tax = 0) ⇒ Object

value = valor da autorização (em centavos) holder = Nome do cartão number = Numero do cartão code = Codigo de segurança date = Data de validate do cartão method = Meio de Pagamento (BraspagRails::MEIOS_DE_PAGAMENTO) number_payments = número de pagamentos

plan = Plano de Pagamento (BraspagRails::PLANOS_DE_PAGAMENTO) tax = Taxa do Serviço (em centavos)



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
# File 'lib/braspag_rails/transacoes/credito.rb', line 24

def self.autorizar(value,holder,number,code,date,method,number_payments,plan,tax=0)
  resp = authorize_transaction(message: {
                                 request: {
                                   RequestId: SecureRandom.uuid,
                                   Version: "1.0",
                                   OrderData: {
                                     MerchantId: BraspagRails.config['merchant_id'],
                                     OrderId: Random.rand(10000),
                                   },
                                   PaymentDataCollection: [
                                     PaymentDataRequest: {
                                       :'@xsi:type' => 'tns:CreditCardDataRequest',
                                       PaymentMethod: method,
                                       Amount: value,
                                       Currency: BraspagRails.config['currency'],
                                       Country: BraspagRails.config['country'],
                                       NumberOfPayments: number_payments,
                                       PaymentPlan: plan,
                                       TransactionType: 1,
                                       CardHolder: holder,
                                       CardNumber: number,
                                       CardSecurityCode: code,
                                       CardExpirationDate: date,
                                       ServiceTaxAmount: tax
                                     }
                                   ],
                                   CustomerData: {
                                     CustomerName: BraspagRails.config['customer_name']
                                   }
                                 }
                              })
  resp
end

.autorizar_capturar(value, holder, number, code, date, method, number_payments, plan, tax = 0) ⇒ Object

value = valor da autorização (em centavos) holder = Nome do cartão number = Numero do cartão code = Codigo de segurança date = Data de validate do cartão method = Meio de Pagamento (BraspagRails::MEIOS_DE_PAGAMENTO) number_payments = número de pagamentos

plan = Plano de Pagamento (BraspagRails::PLANOS_DE_PAGAMENTO) taxa = Taxa do Serviço (em centavos)



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
# File 'lib/braspag_rails/transacoes/credito.rb', line 88

def self.autorizar_capturar(value,holder,number,code,date,method,number_payments,plan,tax=0)
  resp = authorize_transaction(message: {
                                 request: {
                                   RequestId: SecureRandom.uuid,
                                   Version: "1.0",
                                   OrderData: {
                                     MerchantId: BraspagRails.config['merchant_id'],
                                     OrderId: Random.rand(10000),
                                   },
                                   PaymentDataCollection: [
                                     PaymentDataRequest: {
                                       :'@xsi:type' => 'tns:CreditCardDataRequest',
                                       PaymentMethod: method,
                                       Amount: value,
                                       Currency: BraspagRails.config['currency'],
                                       Country: BraspagRails.config['country'],
                                       NumberOfPayments: number_payments,
                                       PaymentPlan: plan,
                                       TransactionType: 2,
                                       CardHolder: holder,
                                       CardNumber: number,
                                       CardSecurityCode: code,
                                       CardExpirationDate: date,
                                       ServiceTaxAmount: tax
                                     }
                                   ],
                                   CustomerData: {
                                     CustomerName: BraspagRails.config['customer_name']
                                   }
                                 }
                              })
  resp
end

.cancelar(braspagid, value, tax = 0) ⇒ Object

braspagid = Código do braspag value = valor da autorização (em centavos) tax = Taxa do Serviço (em centavos)



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/braspag_rails/transacoes/credito.rb', line 125

def self.cancelar(braspagid,value,tax=0)
  resp = void_credit_card_transaction(message: {
                                 request: {
                                   RequestId: SecureRandom.uuid,
                                   Version: "1.0",
                                   MerchantId: BraspagRails.config['merchant_id'],
                                   TransactionDataCollection: [
                                     TransactionDataRequest: {
                                       BraspagTransactionId: braspagid,
                                       Amount: value,
                                       ServiceTaxAmount: tax
                                     }
                                   ]
                                 }
                              })
  resp
end

.capturar(braspagid, value, tax = 0) ⇒ Object

braspagid = Código do braspag value = valor da autorização (em centavos) tax = Taxa do Serviço (em centavos)



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/braspag_rails/transacoes/credito.rb', line 61

def self.capturar(braspagid,value,tax=0)
  resp = capture_credit_card_transaction(message: {
                                 request: {
                                   RequestId: SecureRandom.uuid,
                                   Version: "1.0",
                                   MerchantId: BraspagRails.config['merchant_id'],
                                   TransactionDataCollection: [
                                     TransactionDataRequest: {
                                       BraspagTransactionId: braspagid,
                                       Amount: value,
                                       ServiceTaxAmount: tax
                                     }
                                   ]
                                 }
                              })
  resp
end

.estornar(braspagid, value, tax = 0) ⇒ Object

braspagid = Código do braspag value = valor da autorização (em centavos) tax = Taxa do Serviço (em centavos)



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/braspag_rails/transacoes/credito.rb', line 146

def self.estornar(braspagid,value,tax=0)
  resp = void_credit_card_transaction(message: {
                                 request: {
                                   RequestId: SecureRandom.uuid,
                                   Version: "1.0",
                                   MerchantId: BraspagRails.config['merchant_id'],
                                   TransactionDataCollection: [
                                     TransactionDataRequest: {
                                       BraspagTransactionId: braspagid,
                                       Amount: value,
                                       ServiceTaxAmount: tax
                                     }
                                   ]
                                 }
                              })
  resp
end