Skip to content

Commit 73ab7fd

Browse files
Merge pull request #1274 from travis-ci/add_card_fingerprint_am
[BSFY-216] Save card fingerprint from Stripe
2 parents d456c3f + 376bd8b commit 73ab7fd

File tree

7 files changed

+11
-10
lines changed

7 files changed

+11
-10
lines changed

lib/travis/api/v3/billing_client.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def update_creditcard(subscription_id, creditcard_token)
124124
handle_subscription_response(response)
125125
end
126126

127-
def update_v2_creditcard(subscription_id, creditcard_token)
128-
response = connection.patch("/v2/subscriptions/#{subscription_id}/creditcard", token: creditcard_token)
127+
def update_v2_creditcard(subscription_id, creditcard_token, creditcard_fingerprint)
128+
response = connection.patch("/v2/subscriptions/#{subscription_id}/creditcard", token: creditcard_token, fingerprint: creditcard_fingerprint)
129129
handle_v2_subscription_response(response)
130130
end
131131

lib/travis/api/v3/queries/v2_subscription.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def update_address(user_id)
1010

1111
def update_creditcard(user_id)
1212
client = BillingClient.new(user_id)
13-
client.update_v2_creditcard(params['subscription.id'], params['token'])
13+
client.update_v2_creditcard(params['subscription.id'], params['token'], params['fingerprint'])
1414
end
1515

1616
def changetofree(user_id)

lib/travis/api/v3/queries/v2_subscriptions.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Travis::API::V3
22
class Queries::V2Subscriptions < Query
33
params :plan, :coupon, :organization_id, :client_secret, :v1_subscription_id
44
params :first_name, :last_name, :company, :address, :address2, :city, :country, :state, :vat_id, :zip_code, :billing_email, :has_local_registration, prefix: :billing_info
5-
params :token, prefix: :credit_card_info
5+
params :token, :fingerprint, prefix: :credit_card_info
66

77
def all(user_id)
88
client = BillingClient.new(user_id)

lib/travis/api/v3/services/v2_subscription/update_creditcard.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Travis::API::V3
22
class Services::V2Subscription::UpdateCreditcard < Service
3-
params :token
3+
params :token, :fingerprint
44

55
def run!
66
raise LoginRequired unless access_control.full_access_or_logged_in?

lib/travis/api/v3/services/v2_subscriptions/create.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Services::V2Subscriptions::Create < Service
33
result_type :v2_subscription
44
params :plan, :coupon, :organization_id, :client_secret, :v1_subscription_id
55
params :first_name, :last_name, :company, :address, :address2, :city, :country, :state, :vat_id, :zip_code, :billing_email, :has_local_registration, prefix: :billing_info
6-
params :token, prefix: :credit_card_info
6+
params :token, :fingerprint, prefix: :credit_card_info
77

88
def run!
99
raise LoginRequired unless access_control.full_access_or_logged_in?

spec/v3/billing_client_spec.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,12 @@
175175

176176
describe '#update_v2_creditcard' do
177177
let(:creditcard_token) { 'token' }
178-
subject { billing.update_v2_creditcard(subscription_id, creditcard_token) }
178+
let(:creditcard_fingerprint) { 'fingerprint' }
179+
subject { billing.update_v2_creditcard(subscription_id, creditcard_token, creditcard_fingerprint) }
179180

180181
it 'requests the update' do
181182
stubbed_request = stub_billing_request(:patch, "/v2/subscriptions/#{subscription_id}/creditcard", auth_key: auth_key, user_id: user_id)
182-
.with(body: JSON.dump(token: creditcard_token))
183+
.with(body: JSON.dump(token: creditcard_token, fingerprint: creditcard_fingerprint))
183184
.to_return(status: 204)
184185

185186
expect { subject }.to_not raise_error

spec/v3/services/v2_subscription/update_creditcard_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
let(:token) { Travis::Api::App::AccessToken.create(user: user, app_id: 1) }
2121
let(:headers) {{ 'HTTP_AUTHORIZATION' => "token #{token}",
2222
'CONTENT_TYPE' => 'application/json' }}
23-
let(:creditcard_token) { { 'token' => 'token_from_stripe' } }
23+
let(:creditcard_token) { { 'token' => 'token_from_stripe', 'fingerprint' => 'fingerprint_from_stripe' } }
2424
let(:subscription_id) { rand(999) }
2525

2626
let!(:stubbed_request) do
2727
stub_billing_request(:patch, "/v2/subscriptions/#{subscription_id}/creditcard", auth_key: billing_auth_key, user_id: user.id)
28-
.with(body: { 'token' => 'token_from_stripe' })
28+
.with(body: { 'token' => 'token_from_stripe', 'fingerprint' => 'fingerprint_from_stripe' })
2929
.to_return(status: 204)
3030
end
3131

0 commit comments

Comments
 (0)