Class: Paypal::Express::Request
- Inherits:
-
NVP::Request
- Object
- Base
- NVP::Request
- Paypal::Express::Request
- Defined in:
- lib/paypal/express/request.rb
Constant Summary
Constants inherited from NVP::Request
Instance Attribute Summary
Attributes inherited from NVP::Request
Instance Method Summary collapse
-
#agree!(token, options = {}) ⇒ Object
Reference Transaction Specific.
- #agreement(reference_id) ⇒ Object
- #cancel!(profile_id, options = {}) ⇒ Object
- #capture!(authorization_id, amount, currency_code, complete_type = 'Complete') ⇒ Object
- #charge!(reference_id, amount, options = {}) ⇒ Object
- #checkout!(token, payer_id, payment_requests) ⇒ Object
- #details(token) ⇒ Object
- #reactivate!(profile_id, options = {}) ⇒ Object
-
#refund!(transaction_id, options = {}) ⇒ Object
Refund Specific.
- #renew!(profile_id, action, options = {}) ⇒ Object
- #revoke!(reference_id) ⇒ Object
-
#setup(payment_requests, return_url, cancel_url, options = {}) ⇒ Object
Common.
-
#subscribe!(token, recurring_profile) ⇒ Object
Recurring Payment Specific.
- #subscription(profile_id) ⇒ Object
- #suspend!(profile_id, options = {}) ⇒ Object
- #transaction_details(transaction_id) ⇒ Object
- #void!(authorization_id, params = {}) ⇒ Object
Methods inherited from NVP::Request
#common_params, endpoint, #initialize, #request
Methods inherited from Base
Methods included from Util
#==, formatted_amount, #numeric_attribute?, to_numeric
Constructor Details
This class inherits a constructor from Paypal::NVP::Request
Instance Method Details
#agree!(token, options = {}) ⇒ Object
Reference Transaction Specific
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/paypal/express/request.rb', line 136 def agree!(token, = {}) params = { :TOKEN => token, :version => Paypal.api_version } if [:max_amount] params[:MAXAMT] = Util.formatted_amount [:max_amount] end response = self.request :CreateBillingAgreement, params Response.new response end |
#agreement(reference_id) ⇒ Object
148 149 150 151 152 153 154 155 |
# File 'lib/paypal/express/request.rb', line 148 def agreement(reference_id) params = { :REFERENCEID => reference_id, :version => Paypal.api_version } response = self.request :BillAgreementUpdate, params Response.new response end |
#cancel!(profile_id, options = {}) ⇒ Object
125 126 127 |
# File 'lib/paypal/express/request.rb', line 125 def cancel!(profile_id, = {}) renew!(profile_id, :Cancel, ) end |
#capture!(authorization_id, amount, currency_code, complete_type = 'Complete') ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/paypal/express/request.rb', line 65 def capture!(, amount, currency_code, complete_type = 'Complete') params = { :AUTHORIZATIONID => , :COMPLETETYPE => complete_type, :AMT => amount, :CURRENCYCODE => currency_code } response = self.request :DoCapture, params Response.new response end |
#charge!(reference_id, amount, options = {}) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/paypal/express/request.rb', line 157 def charge!(reference_id, amount, = {}) params = { :REFERENCEID => reference_id, :AMT => Util.formatted_amount(amount), :version => Paypal.api_version, :PAYMENTACTION => [:payment_action] || :Sale } if [:currency_code] params[:CURRENCYCODE] = [:currency_code] end response = self.request :DoReferenceTransaction, params Response.new response end |
#checkout!(token, payer_id, payment_requests) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/paypal/express/request.rb', line 52 def checkout!(token, payer_id, payment_requests) params = { :TOKEN => token, :PAYERID => payer_id, :version => Paypal.api_version } Array(payment_requests).each_with_index do |payment_request, index| params.merge! payment_request.to_params(index) end response = self.request :DoExpressCheckoutPayment, params Response.new response end |
#details(token) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/paypal/express/request.rb', line 39 def details(token) response = self.request :GetExpressCheckoutDetails, { :TOKEN => token, :version => Paypal.api_version } Response.new response end |
#reactivate!(profile_id, options = {}) ⇒ Object
129 130 131 |
# File 'lib/paypal/express/request.rb', line 129 def reactivate!(profile_id, = {}) renew!(profile_id, :Reactivate, ) end |
#refund!(transaction_id, options = {}) ⇒ Object
Refund Specific
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/paypal/express/request.rb', line 184 def refund!(transaction_id, = {}) params = { :TRANSACTIONID => transaction_id, :REFUNDTYPE => :Full, :version => Paypal.api_version } if [:invoice_id] params[:INVOICEID] = [:invoice_id] end if [:type] params[:REFUNDTYPE] = [:type] params[:AMT] = [:amount] params[:CURRENCYCODE] = [:currency_code] end if [:note] params[:NOTE] = [:note] end response = self.request :RefundTransaction, params Response.new response end |
#renew!(profile_id, action, options = {}) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/paypal/express/request.rb', line 108 def renew!(profile_id, action, = {}) params = { :PROFILEID => profile_id, :ACTION => action, :version => Paypal.api_version } if [:note] params[:NOTE] = [:note] end response = self.request :ManageRecurringPaymentsProfileStatus, params Response.new response end |
#revoke!(reference_id) ⇒ Object
171 172 173 174 175 176 177 178 179 |
# File 'lib/paypal/express/request.rb', line 171 def revoke!(reference_id) params = { :REFERENCEID => reference_id, :BillingAgreementStatus => :Canceled, :version => Paypal.api_version } response = self.request :BillAgreementUpdate, params Response.new response end |
#setup(payment_requests, return_url, cancel_url, options = {}) ⇒ Object
Common
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/paypal/express/request.rb', line 7 def setup(payment_requests, return_url, cancel_url, = {}) params = { :RETURNURL => return_url, :CANCELURL => cancel_url, :version => Paypal.api_version } if [:no_shipping] params[:REQCONFIRMSHIPPING] = 0 params[:NOSHIPPING] = 1 end params[:ALLOWNOTE] = 0 if [:allow_note] == false { :solution_type => :SOLUTIONTYPE, :landing_page => :LANDINGPAGE, :email => :EMAIL, :brand => :BRANDNAME, :locale => :LOCALECODE, :logo => :LOGOIMG, :cart_border_color => :CARTBORDERCOLOR, :payflow_color => :PAYFLOWCOLOR }.each do |option_key, param_key| params[param_key] = [option_key] if [option_key] end Array(payment_requests).each_with_index do |payment_request, index| params.merge! payment_request.to_params(index) end response = self.request :SetExpressCheckout, params Response.new response, end |
#subscribe!(token, recurring_profile) ⇒ Object
Recurring Payment Specific
89 90 91 92 93 94 95 96 97 |
# File 'lib/paypal/express/request.rb', line 89 def subscribe!(token, recurring_profile) params = { :TOKEN => token, :version => Paypal.api_version } params.merge! recurring_profile.to_params response = self.request :CreateRecurringPaymentsProfile, params Response.new response end |
#subscription(profile_id) ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/paypal/express/request.rb', line 99 def subscription(profile_id) params = { :PROFILEID => profile_id, :version => Paypal.api_version } response = self.request :GetRecurringPaymentsProfileDetails, params Response.new response end |
#suspend!(profile_id, options = {}) ⇒ Object
121 122 123 |
# File 'lib/paypal/express/request.rb', line 121 def suspend!(profile_id, = {}) renew!(profile_id, :Suspend, ) end |