Module: ActiveMerchant::Billing::PaypalRecurringApi

Included in:
PaypalExpressGateway, PaypalGateway
Defined in:
lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb

Overview

This module is included in both PaypalGateway and PaypalExpressGateway

Constant Summary collapse

PAYPAL_NAMESPACE =
ActiveMerchant::Billing::PaypalCommonAPI::PAYPAL_NAMESPACE
API_VERSION =
ActiveMerchant::Billing::PaypalCommonAPI::API_VERSION
EBAY_NAMESPACE =
ActiveMerchant::Billing::PaypalCommonAPI::EBAY_NAMESPACE

Instance Method Summary collapse

Instance Method Details

#bill_outstanding_amount(profile_id, options = {}) ⇒ Object

Bills outstanding amount to a recurring payment profile.

Parameters

  • profile_id – A string containing the profile_id of the

recurring payment already in place for a given credit card. (REQUIRED)



123
124
125
126
127
128
# File 'lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb', line 123

def bill_outstanding_amount(profile_id, options = {})
  ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE

  raise_error_if_blank('profile_id', profile_id)
  commit 'BillOutstandingAmount', build_bill_outstanding_amount(profile_id, options)
end

#cancel_recurring(profile_id, options = {}) ⇒ Object

Cancel a recurring payment.

This transaction cancels an existing recurring billing profile. Your account must have recurring billing enabled and the subscription must have already been created previously by calling recurring()

Parameters

  • profile_id – A string containing the profile_id of the

recurring payment already in place for a given credit card. (REQUIRED)

  • options – A hash with extra info (‘note’ for ex.)



71
72
73
74
75
76
# File 'lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb', line 71

def cancel_recurring(profile_id, options = {})
  ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE

  raise_error_if_blank('profile_id', profile_id)
  commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(profile_id, 'Cancel', options)
end

#reactivate_recurring(profile_id, options = {}) ⇒ Object

Reactivates a suspended recurring payment profile.

Parameters

  • profile_id – A string containing the profile_id of the

recurring payment already in place for a given credit card. (REQUIRED)



110
111
112
113
114
115
# File 'lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb', line 110

def reactivate_recurring(profile_id, options = {})
  ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE

  raise_error_if_blank('profile_id', profile_id)
commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(profile_id, 'Reactivate', options)
end

#recurring(amount, credit_card, options = {}) ⇒ Object

Create a recurring payment.

This transaction creates a recurring payment profile

Parameters

  • amount – The amount to be charged to the customer at each interval as an Integer value in cents.

  • credit_card – The CreditCard details for the transaction.

  • options – A hash of parameters.

Options

  • :period – [Day, Week, SemiMonth, Month, Year] default: Month

  • :frequency – a number

  • :cycles – Limit to certain # of cycles (OPTIONAL)

  • :start_date – When does the charging starts (REQUIRED)

  • :description – The description to appear in the profile (REQUIRED)



27
28
29
30
31
32
33
34
# File 'lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb', line 27

def recurring(amount, credit_card, options = {})
  ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE

  options[:credit_card] = credit_card
  options[:amount] = amount
  requires!(options, :description, :start_date, :period, :frequency, :amount)
  commit 'CreateRecurringPaymentsProfile', build_create_profile_request(options)
end

#status_recurring(profile_id) ⇒ Object

Get Subscription Status of a recurring payment profile.

Parameters

  • profile_id – A string containing the profile_id of the

recurring payment already in place for a given credit card. (REQUIRED)



84
85
86
87
88
89
# File 'lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb', line 84

def status_recurring(profile_id)
  ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE

  raise_error_if_blank('profile_id', profile_id)
  commit 'GetRecurringPaymentsProfileDetails', build_get_profile_details_request(profile_id)
end

#suspend_recurring(profile_id, options = {}) ⇒ Object

Suspends a recurring payment profile.

Parameters

  • profile_id – A string containing the profile_id of the

recurring payment already in place for a given credit card. (REQUIRED)



97
98
99
100
101
102
# File 'lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb', line 97

def suspend_recurring(profile_id, options = {})
  ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE

  raise_error_if_blank('profile_id', profile_id)
  commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(profile_id, 'Suspend', options)
end

#update_recurring(options = {}) ⇒ Object

Update a recurring payment’s details.

This transaction updates an existing Recurring Billing Profile and the subscription must have already been created previously by calling recurring(). The ability to change certain details about a recurring payment is dependent on transaction history and the type of plan you’re subscribed with paypal. Web Payment Pro seems to have the ability to update the most field.

Parameters

  • options – A hash of parameters.

Options

  • :profile_id – A string containing the :profile_id

of the recurring payment already in place for a given credit card. (REQUIRED)



53
54
55
56
57
58
59
# File 'lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb', line 53

def update_recurring(options={})
  ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE

  requires!(options, :profile_id)
  opts = options.dup
  commit 'UpdateRecurringPaymentsProfile', build_change_profile_request(opts.delete(:profile_id), opts)
end