Skip to content
Snippets Groups Projects
Unverified Commit 7b0469e9 authored by Angelo's avatar Angelo
Browse files

[skip-ci] Send user id to request payment form data

parent 7663e2bb
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -52,7 +52,7 @@ def buy_storage
end
 
def payment_form
response = client.payment_form_params(params[:id])
response = client.payment_form_params(params[:id], current_user.id)
render json: response[:data]
end
 
Loading
Loading
Loading
Loading
@@ -25,8 +25,8 @@ def create_subscription(params, email, token)
http_post("subscriptions", customer_headers(email, token), params)
end
 
def payment_form_params(payment_type)
http_get("payment_forms/#{payment_type}", admin_headers)
def payment_form_params(payment_type, user_id = '')
http_get("payment_forms/#{payment_type}", admin_headers, { user_id: user_id })
end
 
def payment_method(id)
Loading
Loading
@@ -51,8 +51,9 @@ def base_url
EE::SUBSCRIPTIONS_URL
end
 
def http_get(path, headers)
response = Gitlab::HTTP.get("#{base_url}/#{path}", headers: headers)
def http_get(path, headers, params = nil)
url = "#{base_url}/#{path}?#{URI.encode_www_form(params)}"
response = Gitlab::HTTP.get(url, headers: headers)
 
parse_response(response)
rescue *Gitlab::HTTP::HTTP_ERRORS => e
Loading
Loading
Loading
Loading
@@ -223,7 +223,7 @@
before do
sign_in(user)
client_response = { success: true, data: { signature: 'x', token: 'y' } }
allow(Gitlab::SubscriptionPortal::Client).to receive(:payment_form_params).with('cc').and_return(client_response)
expect(Gitlab::SubscriptionPortal::Client).to receive(:payment_form_params).with('cc', user.id).and_return(client_response)
end
 
it { is_expected.to have_gitlab_http_status(:ok) }
Loading
Loading
Loading
Loading
@@ -104,6 +104,10 @@
client.payment_form_params('cc')
end
 
before do
expect(Gitlab::HTTP).to receive('get').with("payment_forms/cc?user_id=1", headers: admin_headers)
end
let(:http_method) { :get }
 
it_behaves_like 'when response is successful'
Loading
Loading
@@ -137,4 +141,15 @@
it_behaves_like 'when response code is 500'
it_behaves_like 'when http call raises an exception'
end
private
def admin_headers
json_headers.merge(
{
'X-Admin-Email' => EE::SUBSCRIPTION_PORTAL_ADMIN_EMAIL,
'X-Admin-Token' => EE::SUBSCRIPTION_PORTAL_ADMIN_TOKEN
}
)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment