Class: ActiveMerchant::Billing::Integrations::Pxpay::Notification

Inherits:
Notification
  • Object
show all
Includes:
PostsData, RequiresParameters
Defined in:
lib/active_merchant/billing/integrations/pxpay/notification.rb

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

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

Constructor Details

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

Returns a new instance of Notification.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 10

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



59
60
61
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 59

def 
  @params['userid']
end

#acknowledge(authcode = nil) ⇒ Object

was the notification a validly formed request?



26
27
28
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 26

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

#auth_codeObject



71
72
73
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 71

def auth_code
  @params['AuthCode']
end

#cancelled?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 40

def cancelled?
  !success?
end

#card_holder_nameObject



79
80
81
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 79

def card_holder_name
  @params['CardHolderName']
end

#card_numberObject



83
84
85
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 83

def card_number
  @params['CardNumber']
end

#card_typeObject



75
76
77
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 75

def card_type
  @params['CardName']
end

#client_ipObject



91
92
93
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 91

def client_ip
  @params['ClientInfo']
end

#complete?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 36

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

#currencyObject



55
56
57
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 55

def currency
  @params['CurrencySettlement']
end

#currency_inputObject



67
68
69
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 67

def currency_input
  @params['CurrencyInput']
end

#expiry_dateObject



87
88
89
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 87

def expiry_date
  @params['DateExpiry']
end

#grossObject



51
52
53
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 51

def gross
  @params['AmountSettlement']
end

#item_idObject



63
64
65
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 63

def item_id
  @params['TxnId']
end

#messageObject



116
117
118
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 116

def message
  @params['ResponseText']
end

#optional_dataObject



120
121
122
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 120

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

#order_idObject



95
96
97
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 95

def order_id
  item_id
end

#payer_emailObject



99
100
101
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 99

def payer_email
  @params['EmailAddress']
end

#received_atObject

When was this payment was received by the client.



125
126
127
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 125

def received_at
  settlement_date
end

#settlement_dateObject



107
108
109
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 107

def settlement_date
  @params['DateSettlement']
end

#statusObject



30
31
32
33
34
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 30

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

#success?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 47

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

#test?Boolean

Was this a test transaction?

Returns:

  • (Boolean)


130
131
132
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 130

def test?
  nil
end

#transaction_idObject



103
104
105
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 103

def transaction_id
  @params['DpsTxnRef']
end

#txn_macObject

Indication of the uniqueness of a card number



112
113
114
# File 'lib/active_merchant/billing/integrations/pxpay/notification.rb', line 112

def txn_mac
  @params['TxnMac']
end