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)



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

def bill_outstanding_amount(profile_id, options = {})
  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.)



67
68
69
70
# File 'lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb', line 67

def cancel_recurring(profile_id, options = {})
  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)



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

def reactivate_recurring(profile_id, options = {})
  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
# File 'lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb', line 27

def recurring(amount, credit_card, options = {})
  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)



78
79
80
81
# File 'lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb', line 78

def status_recurring(profile_id)
  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)



89
90
91
92
# File 'lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb', line 89

def suspend_recurring(profile_id, options = {})
  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)



51
52
53
54
55
# File 'lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb', line 51

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