title: confused on how to create the Stripe ephemeral key in the APIClient.swift class
body: <p>So for the last 2 days I've been stumped on how to implement this Stripe API, it's by far been the hardest thing to wrap my head around with. So I decided to integrate the Stripe functionality  using Firebase and Cloud Functions and I've been seeing that it's server-less which is great.</p>
  <p>I've been trying to follow <a href="https://www.iosapptemplates.com/blog/ios-development/stripe-firebase-swift" rel="nofollow noreferrer">this article on iOS Stripe API integration</a> and <a href="https://medium.com/firebase-developers/go-serverless-manage-payments-in-your-apps-with-cloud-functions-for-firebase-3528cfad770" rel="nofollow noreferrer">this article showing how to create the cloud functions involving Stripe</a> and I so far have been able to create a Stripe customer upon new user creation. After that, I'm pretty much lost on how to do what I want to do next, which is create ephemeral keys.</p>
  <p>I have this function I snagged from another SO post:</p>
  <pre><code>exports.createEphemeralKeys = functions.https.onRequest((req, res) =&gt; {
  var api_version = req.body.api_version;
  var customerId = req.body.customerId;
  
  if (!api_version) {
   res.status(400).end();
   return;
   }
  
   stripe.ephemeralKeys.create(
    { customer: customerId },
    { stripe_version: api_version }, 
  
   function(err, key) {
     return res.send(key);
   });   
  });
  </code></pre>
  <p>And this is the method in the <code>MyAPIClient.swift</code> file:</p>
  <pre><code> func createCustomerKey(withAPIVersion apiVersion: String, completion: @escaping STPJSONResponseCompletionBlock) {
      let url = self.baseURL.appendingPathComponent(&quot;ephemeral_keys&quot;)
      var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false)!
      urlComponents.queryItems = [URLQueryItem(name: &quot;api_version&quot;, value: apiVersion)]
      var request = URLRequest(url: urlComponents.url!)
      request.httpMethod = &quot;POST&quot;
      let task = URLSession.shared.dataTask(with: request, completionHandler: { (data, response, error) in
          guard let response = response as? HTTPURLResponse,
              response.statusCode == 200,
              let data = data,
              let json = ((try? JSONSerialization.jsonObject(with: data, options: []) as? [String : Any]) as [String : Any]??) else {
              completion(nil, error)
              return
          }
          completion(json, nil)
      })
      task.resume()
  }
  </code></pre>
  <p>Now this is where I get confused, since integrating Stripe with Firebase is server-less, what are we supposed to input in the <code>baseURL</code>? Currently the <code>baseURL</code> variable is empty, but I'm also getting thrown errors that <code>.appendingPathComponent</code> is not available as well. Forgive me if this is a dumb question, but I'd much rather look like a complete idiot and eventually figure out how to successfully integrate this API, than not ask anything at all. Thanks in advance.</p>