Class: TransactionOperations
- Inherits:
-
Object
- Object
- TransactionOperations
- Defined in:
- lib/Test/transaction_operations.rb
Instance Method Summary collapse
-
#initialize(metropaGatewayObj) ⇒ TransactionOperations
constructor
A new instance of TransactionOperations.
- #PerformAdjustment(customerId) ⇒ Object
- #PerformPreAuthorization(customerId) ⇒ Object
- #PerformRebill(customerId) ⇒ Object
- #PerformRefund(customerId) ⇒ Object
- #PerformSale(customerId) ⇒ Object
- #PerformUpdateTransaction(customerId) ⇒ Object
- #SearchTransactions(cutomerId) ⇒ Object
Constructor Details
#initialize(metropaGatewayObj) ⇒ TransactionOperations
Returns a new instance of TransactionOperations.
17 18 19 20 |
# File 'lib/Test/transaction_operations.rb', line 17 def initialize(metropaGatewayObj) @CroemincGateway = metropaGatewayObj @preAuth_TransactionId="" end |
Instance Method Details
#PerformAdjustment(customerId) ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/Test/transaction_operations.rb', line 176 def PerformAdjustment(customerId) tranxRequest = Transaction.new tranxRequest.TransactionId = @preAuth_TransactionId tranxRequest.Amount = 1.00 tranxMgr = TransactionManager.new(@CroemincGateway) responseTranxModel = tranxMgr.Adjustment(tranxRequest) puts 'RESULT - Adjustment:' responseDetails = responseTranxModel.getResponseDetails if(responseDetails.getIsSuccess == true) puts 'Transaction Processed Successfullly. Transaction Id: ' + responseDetails.getTransactionId else puts responseDetails.getResponseSummary end end |
#PerformPreAuthorization(customerId) ⇒ Object
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 |
# File 'lib/Test/transaction_operations.rb', line 89 def PerformPreAuthorization(customerId) tranxRequest = Transaction.new customer = Customer.new #card Info creditCards = [] card = CreditCard.new card.Token = "A2478342-617A-4EE5-BC1B-ECD3D132D9CF" creditCards << card #Account Info accounts = [] account = CustomerEntity.new account.Id = "9680" accounts << account #customer Info customer.CustomerId = customerId customer.CreditCards = creditCards #customer.CustomerEntities = accounts #Transaction Info tranxRequest.CustomerData = customer tranxRequest.Amount = 1.00 tranxRequest.OrderTrackingNumber = "777AAAAA" tranxMgr = TransactionManager.new(@CroemincGateway) responseTranxModel = tranxMgr.PreAuthorization(tranxRequest) puts 'RESULT - PreAuthorization:' responseDetails = responseTranxModel.getResponseDetails if(responseDetails.getIsSuccess == true) puts 'Transaction Processed Successfullly. Transaction Id: ' + responseDetails.getTransactionId @preAuth_TransactionId = responseDetails.getTransactionId else puts responseDetails.getResponseSummary end end |
#PerformRebill(customerId) ⇒ Object
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 |
# File 'lib/Test/transaction_operations.rb', line 133 def PerformRebill(customerId) tranxRequest = Transaction.new customer = Customer.new #card Info creditCards = [] card = CreditCard.new card.Token = "A2478342-617A-4EE5-BC1B-ECD3D132D9CF" creditCards << card #Account Info accounts = [] account = CustomerEntity.new account.Id = "9680" accounts << account #customer Info customer.CustomerId = customerId customer.CreditCards = creditCards customer.CustomerEntities = accounts #Transaction Info tranxRequest.CustomerData = customer tranxRequest.Amount = 1.00 tranxRequest.OrderTrackingNumber = "777AAAAA" tranxMgr = TransactionManager.new(@CroemincGateway) responseTranxModel = tranxMgr.Rebill(tranxRequest) puts 'RESULT - Rebill:' responseDetails = responseTranxModel.getResponseDetails if(responseDetails.getIsSuccess == true) puts 'Transaction Processed Successfullly. Transaction Id: ' + responseDetails.getTransactionId else puts responseDetails.getResponseSummary end end |
#PerformRefund(customerId) ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/Test/transaction_operations.rb', line 196 def PerformRefund(customerId) tranxRequest = Transaction.new tranxRequest.TransactionId = @preAuth_TransactionId tranxRequest.Amount = 1.00 tranxMgr = TransactionManager.new(@CroemincGateway) responseTranxModel = tranxMgr.Refund(tranxRequest) puts 'RESULT - Refund:' responseDetails = responseTranxModel.getResponseDetails if(responseDetails.getIsSuccess == true) puts 'Transaction Processed Successfullly. Transaction Id: ' + responseDetails.getTransactionId else puts responseDetails.getResponseSummary end end |
#PerformSale(customerId) ⇒ Object
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 |
# File 'lib/Test/transaction_operations.rb', line 22 def PerformSale(customerId) tranxRequest = Transaction.new customer = Customer.new #card Info creditCards = [] card = CreditCard.new card.Token = "A2478342-617A-4EE5-BC1B-ECD3D132D9CF" creditCards << card #Account Info accounts = [] account = CustomerEntity.new account.Id = "10752" accounts << account #customer Info customer.CustomerId = customerId customer.CreditCards = creditCards #customer.CustomerEntities = accounts #Transaction Info tranxRequest.CustomerData = customer tranxRequest.Amount = 1.00 tranxRequest.OrderTrackingNumber = "777AAAAA" tranxMgr = TransactionManager.new(@CroemincGateway) responseTranxModel = tranxMgr.Sale(tranxRequest) puts 'RESULT - Perform Sale:' responseDetails = responseTranxModel.getResponseDetails if(responseDetails && responseDetails.getIsSuccess == true) puts 'Transaction Processed Successfullly. Transaction Id: ' + responseDetails.getTransactionId #example accessing inner models if(responseTranxModel.getCustomerData) customerCards = responseTranxModel.getCustomerData.getCreditCards puts customerCards[0].getCardHolder end else puts responseDetails.getResponseSummary end if(responseDetails.getValidationErrors) vErrors = responseDetails.getValidationErrors if(vErrors.getErrorDetails) vErrors.getErrorDetails.each do |ed| puts "Error Summary:" puts ed.getErrorSummary puts "Error Description: " puts ed.getErrorDescription end end end end |
#PerformUpdateTransaction(customerId) ⇒ Object
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/Test/transaction_operations.rb', line 236 def PerformUpdateTransaction(customerId) tranxRequest = Transaction.new tranxRequest.ThirdPartyDescription = "Account Payment ABC123" tranxRequest.ThirdPartyStatus = "POSTED" tranxRequest.TransactionId = "102747859" tranxMgr = TransactionManager.new(@CroemincGateway) responseTranxModel = tranxMgr.UpdateTransaction(tranxRequest) puts 'RESULT - Update Transaction:' responseDetails = responseTranxModel.getResponseDetails if(responseDetails.getIsSuccess == true) puts 'Transaction Updated Successfullly. Transaction Id: ' + responseDetails.getTransactionId else puts responseDetails.getResponseSummary end end |
#SearchTransactions(cutomerId) ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/Test/transaction_operations.rb', line 216 def SearchTransactions(cutomerId) searchRequest = TransactionSearchRequest.new searchRequest.Amount = AmountRangeFilter.new.Between(0.00, 2.00) searchRequest.CardHolderName = TextFilter.new.StartsWith("ZEE") #searchRequest.TransactionId = "102747816" searchRequest.CustomerId = cutomerId tranxMgr = TransactionManager.new(@CroemincGateway) transactions = tranxMgr.SearchTransaction(searchRequest) transactions.each do |tranx| puts tranx.getTransactionId + " - " + tranx.getAmount.to_s + " - " + tranx.getCreditCardDetail.to_json end end |