Class: OffsitePayments::Integrations::Pxpay::Notification

Inherits:
Notification
  • Object
show all
Includes:
ActiveUtils::PostsData, ActiveUtils::RequiresParameters
Defined in:
lib/offsite_payments/integrations/pxpay.rb

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

#amount, #empty!, #gross_cents, #iso_currency, #valid_sender?

Constructor Details

#initialize(query_string, options = {}) ⇒ Notification

Returns a new instance of Notification.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/offsite_payments/integrations/pxpay.rb', line 110

def initialize(query_string, options={})
  # PxPay appends ?result=...&userid=... to whatever return_url was specified, even if that URL ended with a ?query.
  # So switch the first ? if present to a &
  query_string[/\?/] = '&' if query_string[/\?/]
  super

  @encrypted_params = @params
  @params = {}

  requires! @encrypted_params, "result"
  requires! @options, :credential1, :credential2

  decrypt_transaction_result(@encrypted_params["result"])
end

Instance Method Details

#accountObject



159
160
161
# File 'lib/offsite_payments/integrations/pxpay.rb', line 159

def 
  @params['userid']
end

#acknowledge(authcode = nil) ⇒ Object

was the notification a validly formed request?



126
127
128
# File 'lib/offsite_payments/integrations/pxpay.rb', line 126

def acknowledge(authcode = nil)
  @valid == '1'
end

#auth_codeObject



171
172
173
# File 'lib/offsite_payments/integrations/pxpay.rb', line 171

def auth_code
  @params['AuthCode']
end

#cancelled?Boolean

Returns:

  • (Boolean)


140
141
142
# File 'lib/offsite_payments/integrations/pxpay.rb', line 140

def cancelled?
  !success?
end

#card_holder_nameObject



179
180
181
# File 'lib/offsite_payments/integrations/pxpay.rb', line 179

def card_holder_name
  @params['CardHolderName']
end

#card_numberObject



183
184
185
# File 'lib/offsite_payments/integrations/pxpay.rb', line 183

def card_number
  @params['CardNumber']
end

#card_typeObject



175
176
177
# File 'lib/offsite_payments/integrations/pxpay.rb', line 175

def card_type
  @params['CardName']
end

#client_ipObject



191
192
193
# File 'lib/offsite_payments/integrations/pxpay.rb', line 191

def client_ip
  @params['ClientInfo']
end

#complete?Boolean

Returns:

  • (Boolean)


136
137
138
# File 'lib/offsite_payments/integrations/pxpay.rb', line 136

def complete?
  @params['TxnType'] == 'Purchase' && success?
end

#currencyObject



155
156
157
# File 'lib/offsite_payments/integrations/pxpay.rb', line 155

def currency
  @params['CurrencySettlement']
end

#currency_inputObject



167
168
169
# File 'lib/offsite_payments/integrations/pxpay.rb', line 167

def currency_input
  @params['CurrencyInput']
end

#expiry_dateObject



187
188
189
# File 'lib/offsite_payments/integrations/pxpay.rb', line 187

def expiry_date
  @params['DateExpiry']
end

#grossObject



151
152
153
# File 'lib/offsite_payments/integrations/pxpay.rb', line 151

def gross
  @params['AmountSettlement']
end

#item_idObject



163
164
165
# File 'lib/offsite_payments/integrations/pxpay.rb', line 163

def item_id
  @params['MerchantReference']
end

#messageObject



216
217
218
# File 'lib/offsite_payments/integrations/pxpay.rb', line 216

def message
  @params['ResponseText']
end

#optional_dataObject



220
221
222
# File 'lib/offsite_payments/integrations/pxpay.rb', line 220

def optional_data
  [@params['TxnData1'],@fields['TxnData2'],@fields['TxnData3']]
end

#order_idObject



195
196
197
# File 'lib/offsite_payments/integrations/pxpay.rb', line 195

def order_id
  item_id
end

#payer_emailObject



199
200
201
# File 'lib/offsite_payments/integrations/pxpay.rb', line 199

def payer_email
  @params['EmailAddress']
end

#received_atObject

When was this payment was received by the client.



225
226
227
# File 'lib/offsite_payments/integrations/pxpay.rb', line 225

def received_at
  settlement_date
end

#settlement_dateObject



207
208
209
# File 'lib/offsite_payments/integrations/pxpay.rb', line 207

def settlement_date
  @params['DateSettlement']
end

#statusObject



130
131
132
133
134
# File 'lib/offsite_payments/integrations/pxpay.rb', line 130

def status
  return 'Failed' unless success?
  return 'Completed' if complete?
  'Error'
end

#success?Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/offsite_payments/integrations/pxpay.rb', line 147

def success?
  @params['Success'] == '1'
end

#test?Boolean

Was this a test transaction?

Returns:

  • (Boolean)


230
231
232
# File 'lib/offsite_payments/integrations/pxpay.rb', line 230

def test?
  nil
end

#transaction_idObject



203
204
205
# File 'lib/offsite_payments/integrations/pxpay.rb', line 203

def transaction_id
  @params['DpsTxnRef']
end

#txn_macObject

Indication of the uniqueness of a card number



212
213
214
# File 'lib/offsite_payments/integrations/pxpay.rb', line 212

def txn_mac
  @params['TxnMac']
end