Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
Correctly pass and handle recurring flag for one click payments
Browse files Browse the repository at this point in the history
  • Loading branch information
osahyoun committed Oct 18, 2016
1 parent d14ab63 commit 1c32436
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
5 changes: 2 additions & 3 deletions app/services/action_builder.rb
Expand Up @@ -82,12 +82,11 @@ def update_donor_status
end

def is_donation?
return false if @extra_attrs.blank?
@extra_attrs[:donation] ? true : false
@extra_attrs && @extra_attrs[:donation]
end

def is_recurring_donation?
@params[:is_subscription] ? true : false
@params && @params[:is_subscription]
end

def form_data
Expand Down
4 changes: 2 additions & 2 deletions app/services/manage_action.rb
Expand Up @@ -12,15 +12,15 @@ def initialize(params, extra_params: {}, skip_queue: false, skip_counter: false)
@params = params
@skip_queue = skip_queue
@skip_counter = skip_counter
@extra_params = extra_params
@extra_attrs = extra_params
end

def create
if !page.allow_duplicate_actions? && previous_action.present?
return previous_action
end

build_action(@extra_params)
build_action(@extra_attrs)
end

private
Expand Down
4 changes: 2 additions & 2 deletions circle.yml
Expand Up @@ -32,13 +32,13 @@ database:

deployment:
production:
branch: "feature/one-click-donations"
branch: "master"
commands:
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
- docker push soutech/champaign_web
- ./deploy.sh $CIRCLE_SHA1 'champaign' 'env-production' 'champaign-assets-production' 'logs3.papertrailapp.com:44107' 'actions.sumofus.org'
staging:
branch: "feature/one-click-donations"
branch: "development"
commands:
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
- docker push soutech/champaign_web
Expand Down
1 change: 1 addition & 0 deletions lib/payment_processor/braintree/one_click.rb
Expand Up @@ -53,6 +53,7 @@ def create_action(extra = {})
.merge(page_id: params[:page_id])
.merge(action_express_donation: 1,
store_in_vault: true,
is_recurring: payment_options.recurring?,
express_account: payment_options.express_account?,
card_num: payment_options.payment_method.last_4,
card_expiration_date: payment_options.payment_method.expiration_date),
Expand Down
8 changes: 8 additions & 0 deletions spec/requests/api/braintree/braintree_spec.rb
Expand Up @@ -68,6 +68,10 @@
end
end

it 'sets donor status to "recurring_donor"' do
expect(member.reload.donor_status).to eq('recurring_donor')
end

describe 'local record' do
it 'creates action' do
action = page.actions.first
Expand Down Expand Up @@ -144,6 +148,10 @@
transaction = payment_method.transactions.first.attributes.symbolize_keys
expect(transaction).to include(expected_attributes)
end

it 'sets donor status to "donor"' do
expect(member.reload.donor_status).to eq('donor')
end
end

it 'creates transaction on braintree' do
Expand Down

0 comments on commit 1c32436

Please sign in to comment.