Class: Paypal::NVP::Response
Direct Known Subclasses
Constant Summary
- @@attribute_mapping =
{ :ACK => :ack, :ADDRESSSTATUS => :address_status, :BILLINGAGREEMENTACCEPTEDSTATUS => :billing_agreement_accepted_status, :BUILD => :build, :CHECKOUTSTATUS => :checkout_status, :CORRELATIONID => :colleration_id, :COUNTRYCODE => :country_code, :CURRENCYCODE => :currency_code, :DESC => :description, :NOTIFYURL => :notify_url, :TIMESTAMP => :timestamp, :TOKEN => :token, :VERSION => :version, :BILLINGAGREEMENTID => :billing_agreement_id }
Instance Attribute Summary (collapse)
-
- (Object) amount
Returns the value of attribute amount.
-
- (Object) description
Returns the value of attribute description.
-
- (Object) insurance_option_selected
Returns the value of attribute insurance_option_selected.
-
- (Object) items
Returns the value of attribute items.
-
- (Object) payer
Returns the value of attribute payer.
-
- (Object) payment_info
Returns the value of attribute payment_info.
-
- (Object) payment_responses
Returns the value of attribute payment_responses.
-
- (Object) recurring
Returns the value of attribute recurring.
-
- (Object) refund
Returns the value of attribute refund.
-
- (Object) ship_to
Returns the value of attribute ship_to.
-
- (Object) shipping_options_is_default
Returns the value of attribute shipping_options_is_default.
-
- (Object) success_page_redirect_requested
Returns the value of attribute success_page_redirect_requested.
Instance Method Summary (collapse)
-
- (Response) initialize(attributes = {})
constructor
A new instance of Response.
Methods included from Util
#==, formatted_amount, #numeric_attribute?, to_numeric
Constructor Details
- (Response) initialize(attributes = {})
A new instance of Response
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 |
# File 'lib/paypal/nvp/response.rb', line 25 def initialize(attributes = {}) attrs = attributes.dup @@attribute_mapping.each do |key, value| self.send "#{value}=", attrs.delete(key) end @shipping_options_is_default = attrs.delete(:SHIPPINGOPTIONISDEFAULT) == 'true' @success_page_redirect_requested = attrs.delete(:SUCCESSPAGEREDIRECTREQUESTED) == 'true' @insurance_option_selected = attrs.delete(:INSURANCEOPTIONSELECTED) == 'true' @amount = Payment::Common::Amount.new( :total => attrs.delete(:AMT), :item => attrs.delete(:ITEMAMT), :handing => attrs.delete(:HANDLINGAMT), :insurance => attrs.delete(:INSURANCEAMT), :ship_disc => attrs.delete(:SHIPDISCAMT), :shipping => attrs.delete(:SHIPPINGAMT), :tax => attrs.delete(:TAXAMT) ) @ship_to = Payment::Response::ShipTo.new( :owner => attrs.delete(:SHIPADDRESSOWNER), :status => attrs.delete(:SHIPADDRESSSTATUS), :name => attrs.delete(:SHIPTONAME), :zip => attrs.delete(:SHIPTOZIP), :street => attrs.delete(:SHIPTOSTREET), :street2 => attrs.delete(:SHIPTOSTREET2), :city => attrs.delete(:SHIPTOCITY), :state => attrs.delete(:SHIPTOSTATE), :country_code => attrs.delete(:SHIPTOCOUNTRYCODE), :country_name => attrs.delete(:SHIPTOCOUNTRYNAME) ) if attrs[:PAYERID] @payer = Payment::Response::Payer.new( :identifier => attrs.delete(:PAYERID), :status => attrs.delete(:PAYERSTATUS), :first_name => attrs.delete(:FIRSTNAME), :last_name => attrs.delete(:LASTNAME), :email => attrs.delete(:EMAIL) ) end if attrs[:REFUNDTRANSACTIONID] @refund = Payment::Response::Refund.new( :transaction_id => attrs.delete(:REFUNDTRANSACTIONID), :amount => { :total => attrs.delete(:TOTALREFUNDEDAMOUNT), :fee => attrs.delete(:FEEREFUNDAMT), :gross => attrs.delete(:GROSSREFUNDAMT), :net => attrs.delete(:NETREFUNDAMT) } ) end if attrs[:PROFILEID] @recurring = Payment::Recurring.new( :identifier => attrs.delete(:PROFILEID), # NOTE: # CreateRecurringPaymentsProfile returns PROFILESTATUS # GetRecurringPaymentsProfileDetails returns STATUS :description => @description, :status => attrs.delete(:STATUS) || attrs.delete(:PROFILESTATUS), :start_date => attrs.delete(:PROFILESTARTDATE), :name => attrs.delete(:SUBSCRIBERNAME), :reference => attrs.delete(:PROFILEREFERENCE), :auto_bill => attrs.delete(:AUTOBILLOUTAMT), :max_fails => attrs.delete(:MAXFAILEDPAYMENTS), :aggregate_amount => attrs.delete(:AGGREGATEAMT), :aggregate_optional_amount => attrs.delete(:AGGREGATEOPTIONALAMT), :final_payment_date => attrs.delete(:FINALPAYMENTDUEDATE) ) if attrs[:BILLINGPERIOD] @recurring.billing = Payment::Recurring::Billing.new( :amount => @amount, :currency_code => @currency_code, :period => attrs.delete(:BILLINGPERIOD), :frequency => attrs.delete(:BILLINGFREQUENCY), :total_cycles => attrs.delete(:TOTALBILLINGCYCLES), :trial_amount_paid => attrs.delete(:TRIALAMTPAID) ) end if attrs[:REGULARAMT] @recurring.regular_billing = Payment::Recurring::Billing.new( :amount => attrs.delete(:REGULARAMT), :shipping_amount => attrs.delete(:REGULARSHIPPINGAMT), :tax_amount => attrs.delete(:REGULARTAXAMT), :currency_code => attrs.delete(:REGULARCURRENCYCODE), :period => attrs.delete(:REGULARBILLINGPERIOD), :frequency => attrs.delete(:REGULARBILLINGFREQUENCY), :total_cycles => attrs.delete(:REGULARTOTALBILLINGCYCLES), :paid => attrs.delete(:REGULARAMTPAID) ) @recurring.summary = Payment::Recurring::Summary.new( :next_billing_date => attrs.delete(:NEXTBILLINGDATE), :cycles_completed => attrs.delete(:NUMCYCLESCOMPLETED), :cycles_remaining => attrs.delete(:NUMCYCLESREMAINING), :outstanding_balance => attrs.delete(:OUTSTANDINGBALANCE), :failed_count => attrs.delete(:FAILEDPAYMENTCOUNT), :last_payment_date => attrs.delete(:LASTPAYMENTDATE), :last_payment_amount => attrs.delete(:LASTPAYMENTAMT) ) end end # payment_responses payment_responses = [] attrs.keys.each do |_attr_| prefix, index, key = case _attr_.to_s when /^PAYMENTREQUEST/, /^PAYMENTREQUESTINFO/ _attr_.to_s.split('_') when /^L_PAYMENTREQUEST/ _attr_.to_s.split('_')[1..-1] end if prefix payment_responses[index.to_i] ||= {} payment_responses[index.to_i][key.to_sym] = attrs.delete(_attr_) end end @payment_responses = payment_responses.collect do |_attrs_| Payment::Response.new _attrs_ end # payment_info payment_info = [] attrs.keys.each do |_attr_| prefix, index, key = _attr_.to_s.split('_') if prefix == 'PAYMENTINFO' payment_info[index.to_i] ||= {} payment_info[index.to_i][key.to_sym] = attrs.delete(_attr_) end end @payment_info = payment_info.collect do |_attrs_| Payment::Response::Info.new _attrs_ end # payment_info items = [] attrs.keys.each do |_attr_| key, index = _attr_.to_s.scan(/^L_(.+)(\d)$/).flatten if index items[index.to_i] ||= {} items[index.to_i][key.to_sym] = attrs.delete(_attr_) end end @items = items.collect do |_attrs_| Payment::Response::Item.new _attrs_ end # remove duplicated parameters attrs.delete(:SHIPTOCOUNTRY) # NOTE: Same with SHIPTOCOUNTRYCODE # warn ignored attrs attrs.each do |key, value| Paypal.log "Ignored Parameter (#{self.class}): #{key}=#{value}", :warn end end |
Instance Attribute Details
- (Object) amount
Returns the value of attribute amount
23 24 25 |
# File 'lib/paypal/nvp/response.rb', line 23 def amount @amount end |
- (Object) description
Returns the value of attribute description
23 24 25 |
# File 'lib/paypal/nvp/response.rb', line 23 def description @description end |
- (Object) insurance_option_selected
Returns the value of attribute insurance_option_selected
22 23 24 |
# File 'lib/paypal/nvp/response.rb', line 22 def insurance_option_selected @insurance_option_selected end |
- (Object) items
Returns the value of attribute items
23 24 25 |
# File 'lib/paypal/nvp/response.rb', line 23 def items @items end |
- (Object) payer
Returns the value of attribute payer
23 24 25 |
# File 'lib/paypal/nvp/response.rb', line 23 def payer @payer end |
- (Object) payment_info
Returns the value of attribute payment_info
23 24 25 |
# File 'lib/paypal/nvp/response.rb', line 23 def payment_info @payment_info end |
- (Object) payment_responses
Returns the value of attribute payment_responses
23 24 25 |
# File 'lib/paypal/nvp/response.rb', line 23 def payment_responses @payment_responses end |
- (Object) recurring
Returns the value of attribute recurring
23 24 25 |
# File 'lib/paypal/nvp/response.rb', line 23 def recurring @recurring end |
- (Object) refund
Returns the value of attribute refund
23 24 25 |
# File 'lib/paypal/nvp/response.rb', line 23 def refund @refund end |
- (Object) ship_to
Returns the value of attribute ship_to
23 24 25 |
# File 'lib/paypal/nvp/response.rb', line 23 def ship_to @ship_to end |
- (Object) shipping_options_is_default
Returns the value of attribute shipping_options_is_default
22 23 24 |
# File 'lib/paypal/nvp/response.rb', line 22 def @shipping_options_is_default end |
- (Object) success_page_redirect_requested
Returns the value of attribute success_page_redirect_requested
22 23 24 |
# File 'lib/paypal/nvp/response.rb', line 22 def success_page_redirect_requested @success_page_redirect_requested end |