Class: ActiveMerchant::Billing::PayflowNvpUkGateway
- Defined in:
- lib/active_merchant/billing/gateways/payflow_nvp_uk.rb
Constant Summary collapse
- TEST_URL =
'https://pilot-payflowpro.paypal.com'
- LIVE_URL =
'https://payflowpro.paypal.com'
- TRANSACTIONS =
{ :purchase => "S", :authorization => "A", :capture => "D", :void => "V", :credit => "C", :recurring => "R" }
- PERIODS =
{ :daily => "EDAY", :weekly => "WEEK", :biweekly => "BIWK", :semimonthly => "SMMO", :quadweekly => "FRWK", :monthly => "MONT", :quarterly => "QTER", :semiyearly => "SMYR", :yearly => "YEAR" }
- RECURRING_ACTIONS =
{ :create => "A", :modify => "M", :deactivate => "C", :reactivate => "R", :inquiry => "I" }
Constants inherited from Gateway
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
-
#authorize(money, creditcard, options = {}) ⇒ Object
Performs an authorization transaction.
-
#cancel_recurring(profile_id) ⇒ Object
Cancel a recurring profile.
-
#capture(money, authorization, options = {}) ⇒ Object
Captures authorized funds.
-
#credit(money, authorization_or_card, options = {}) ⇒ Object
Process a refund to a customer.
-
#gateway_url ⇒ Object
Return the url of the gateway.
-
#initialize(options = {}) ⇒ PayflowNvpUkGateway
constructor
Creates a new PayflowNvpUkGateway.
-
#purchase(money, creditcard, options = {}) ⇒ Object
A purchase transaction authorizes and captures in a single hit.
-
#recurring(money, creditcard, options = {}) ⇒ Object
Create or modify a recurring profile.
-
#recurring_inquiry(profile_id, options = {}) ⇒ Object
Inquire about the status of a previously created recurring profile.
-
#test? ⇒ Boolean
Is the gateway in test mode?.
-
#void(authorization, options = {}) ⇒ Object
Voids an authorization or delayed capture.
Methods inherited from Gateway
#card_brand, card_brand, inherited, supports?
Methods included from Utils
Methods included from CreditCardFormatting
Methods included from RequiresParameters
Methods included from PostsData
Constructor Details
#initialize(options = {}) ⇒ PayflowNvpUkGateway
Creates a new PayflowNvpUkGateway
The gateway requires that a valid login and password be passed in the options
hash.
Parameters
-
options
-
:login
- Your Payflow login -
:password
- Your Payflow password -
:vendor
- Your vendor ID. If not present then the login is used
-
75 76 77 78 79 80 81 |
# File 'lib/active_merchant/billing/gateways/payflow_nvp_uk.rb', line 75 def initialize( = {}) requires!(, :login, :password) @options = @options[:partner] = partner if @options[:partner].blank? @options[:vendor] = [:login] if @options[:vendor].blank? super end |
Instance Method Details
#authorize(money, creditcard, options = {}) ⇒ Object
Performs an authorization transaction. This is required due to Visa and Mastercard restrictions, in that a customer’s card cannot be charged until the goods have been dispatched. An authorization allows an amout to be reserved on a customer’s card, bringing down the available balance or credit, but they are not actually charged until a subsequent capture step actually captures the funds.
Parameters
-
money
- The amount to be charged as an integer value in cents. -
creditcard
- The CreditCard object to be used as a funding source for the transaction. -
options
- A hash of optional parameters-
:order_id
- A unique reference for this order (maximum of 127 characters). -
:email
- The customer’s email address -
:customer
- A unique reference for the customer (maximum of 12 characters). -
:ip
- The customer’s IP address -
:currency
- The currency of the transaction. If present must be one of { AUD, CAD, EUR, JPY, GBP or USD }. If omitted the default currency is used. -
:billing_address
- The customer’s billing address as a hash of address information.-
:address1
- The billing address street -
:city
- The billing address city -
:state
- The billing address state -
:country
- The 2 digit ISO billing address country code -
:zip
- The billing address zip code
-
-
:shipping_address
- The customer’s shipping address as a hash of address information.-
:address1
- The shipping address street -
:city
- The shipping address city -
:state
- The shipping address state code -
:country
- The 2 digit ISO shipping address country code -
:zip
- The shipping address zip code
-
-
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/active_merchant/billing/gateways/payflow_nvp_uk.rb', line 122 def (money, creditcard, = {}) post = {} add_invoice(post, ) add_creditcard(post, creditcard) add_currency(post, money, ) add_address(post, [:billing_address] || [:address]) add_address(post, [:shipping_address], "shipto") add_customer_data(post, ) commit(TRANSACTIONS[:authorize], money, post) end |
#cancel_recurring(profile_id) ⇒ Object
Cancel a recurring profile.
Parameters
-
profile_id
- the id of the recurring profile to cancel
266 267 268 269 270 271 272 273 |
# File 'lib/active_merchant/billing/gateways/payflow_nvp_uk.rb', line 266 def cancel_recurring(profile_id) post = {} post[:action] = RECURRING_ACTIONS[:deactivate] post[:origprofileid] = profile_id.to_s commit(TRANSACTIONS[:recurring], nil, post) end |
#capture(money, authorization, options = {}) ⇒ Object
Captures authorized funds.
Parameters
-
money
- The amount to be authorized as an integer value in cents. Payflow does support changing the captured amount, so whatever is passed here will be captured. -
authorization
- The authorization reference string returned by the original transaction’s Response#authorization. -
options
- not currently used.
178 179 180 181 182 183 |
# File 'lib/active_merchant/billing/gateways/payflow_nvp_uk.rb', line 178 def capture(money, , = {}) post = {} post[:origid] = commit(TRANSACTIONS[:capture], money, post) end |
#credit(money, authorization_or_card, options = {}) ⇒ Object
Process a refund to a customer.
Parameters
-
money
- The amount to be credited as an integer value in cents. -
authorization_or_card
- The CreditCard you want to refund to OR the PayPal PNRef of a previous transaction. It depends on the settings in your PayPal account as to whether non referenced credits are permitted. The default is that they are not. -
options
- not currently used
204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/active_merchant/billing/gateways/payflow_nvp_uk.rb', line 204 def credit(money, , = {}) post = {} if .is_a?(String) # perform a referenced credit post[:origid] = else # perform an unreferenced credit add_creditcard(post, creditcard) end commit(TRANSACTIONS[:credit], money, post) end |
#gateway_url ⇒ Object
Return the url of the gateway
84 85 86 |
# File 'lib/active_merchant/billing/gateways/payflow_nvp_uk.rb', line 84 def gateway_url return test? ? TEST_URL : LIVE_URL end |
#purchase(money, creditcard, options = {}) ⇒ Object
A purchase transaction authorizes and captures in a single hit. We can only do this for transactions where you provide immediate fulfillment of products or services.
Parameters
-
money
- The amount to be charged as an integer value in cents. -
creditcard
- The CreditCard object to be used as a funding source for the transaction. -
options
- A hash of optional parameters-
:order_id
- A unique reference for this order (maximum of 127 characters). -
:email
- The customer’s email address -
:customer
- A unique reference for the customer (maximum of 12 characters). -
:ip
- The customer’s IP address -
:currency
- The currency of the transaction. If present must be one of { AUD, CAD, EUR, JPY, GBP or USD }. If ommitted the default currency is used. -
:billing_address
- The customer’s billing address as a hash of address information.-
:address1
- The billing address street -
:city
- The billing address city -
:state
- The billing address state -
:country
- The 2 digit ISO billing address country code -
:zip
- The billing address zip code
-
-
:shipping_address
- The customer’s shipping address as a hash of address information.-
:address1
- The shipping address street -
:city
- The shipping address city -
:state
- The shipping address state code -
:country
- The 2 digit ISO shipping address country code -
:zip
- The shipping address zip code
-
-
159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/active_merchant/billing/gateways/payflow_nvp_uk.rb', line 159 def purchase(money, creditcard, = {}) post = {} add_invoice(post, ) add_creditcard(post, creditcard) add_currency(post, money, ) add_address(post, [:billing_address] || [:address]) add_address(post, [:shipping_address], "shipto") add_customer_data(post, ) commit(TRANSACTIONS[:purchase], money, post) end |
#recurring(money, creditcard, options = {}) ⇒ Object
Create or modify a recurring profile.
Parameters
-
money
- The amount that the recurring profile is to be set up for as an integer value in cents. -
creditcard
- The CreditCard object to be used as a funding source for the recurring profile. -
options
- A hash of parameters (some optional).-
:profile_id
- If present then we are modifying an existing profile, and this :profile_id identifies the profile we want to amend. If not present then we are creating a new recurring payments profile. -
:starting_at
- Takes a Date, Time or string in MMDDYYYY format. The date must be in the future. -
:name
- The name of the customer to be billed. If omitted the name from the creditcard is used. -
:periodicity
- The frequency that the recurring payments will occur at. Can be one of: [:daily, :weekly, :biweekly (every 2 weeks), :semimonthly (twice every month), :quadweekly (once every 4 weeks), :monthly (every month on the same date as the first payment), :quarterly (every 3 months on the same date as the first payment), :semiyearly (every 6 months on the same date as the first payment), :yearly. -
:payments
- Integer value describing the number of payments to be made. If set to 0 then profile will continue until terminated -
<tt>:comment<tt> - Optional description of the goods or service being purchased
-
:max_failed_payments
- The number of payments that are allowed to fail before PayPal suspends the profile. Defaults to 0 which means PayPal will never suspend the profile until the term is completed. PayPal will keep attempting to process failed payments. -
:currency
- The currency of the transaction. If present must be one of { AUD, CAD, EUR, JPY, GBP or USD }. If omitted the default currency is used. -
:description
- The description of the profile. Required for the profile to be created successfully.
-
234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/active_merchant/billing/gateways/payflow_nvp_uk.rb', line 234 def recurring(money, creditcard, = {}) post = {} add_creditcard(post, creditcard) add_currency(post, money, ) add_address(post, [:billing_address] || [:address]) add_address(post, [:shipping_address], "shipto") add_customer_data(post, ) add_recurring_info(post, creditcard, ) commit(TRANSACTIONS[:recurring], money, post) end |
#recurring_inquiry(profile_id, options = {}) ⇒ Object
Inquire about the status of a previously created recurring profile.
Parameters
-
profile_id
- the id of the recurring profile we want to get the details of. -
options
- not currently used
252 253 254 255 256 257 258 259 |
# File 'lib/active_merchant/billing/gateways/payflow_nvp_uk.rb', line 252 def recurring_inquiry(profile_id, = {}) post = {} post[:action] = RECURRING_ACTIONS[:inquiry] post[:origprofileid] = profile_id.to_s commit(TRANSACTIONS[:recurring], nil, post) end |
#test? ⇒ Boolean
Is the gateway in test mode?
89 90 91 |
# File 'lib/active_merchant/billing/gateways/payflow_nvp_uk.rb', line 89 def test? @options[:test] || super end |
#void(authorization, options = {}) ⇒ Object
Voids an authorization or delayed capture
Parameters
-
authorization
- The authorization reference string returned by the original transaction’s Response#authorization. -
options
- Not currently used.
191 192 193 194 195 196 |
# File 'lib/active_merchant/billing/gateways/payflow_nvp_uk.rb', line 191 def void(, = {}) post = {} post[:origid] = commit(TRANSACTIONS[:void], nil, post) end |