<aside> <img src="notion://custom_emoji/b483512c-e260-41d3-b5ff-36d0dc5fa090/169e981a-0297-8019-be6b-007aa264a5c0" alt="notion://custom_emoji/b483512c-e260-41d3-b5ff-36d0dc5fa090/169e981a-0297-8019-be6b-007aa264a5c0" width="40px" />

Welcome to the the third ****workshop, Integrating Third Party Libraries! We’re excited to help you continue your journey in becoming an experienced iOS developer! 🥳

In this stage of developing the AggieEats App, we will learn how to use Stripe to create a successful payments functionality in your AggieEats app. This will allow us pay for the food we order!

If you haven’t already, make sure you have Xcode 16 or higher on your Mac (instructions on how to download Xcode are in the developer-resources channel on our discord).

To get started, download the starter code from our GitHub Repository down below and open the AggieEats.xcodeproj file with Xcode.\

Our starter code explanation and workshop setup instructions are provided in the Notion Page linked here.

Starter Code and Setup

</aside>

GitHub - Swift-Coding-Club-UCD/BuildingYourFirstiOSApp

Table of Contents


Table of Contents

Overview of The Stripe Payment System

Server Programming

Adding The Publishable Key to the Aggie Eats App

Adding the startOrder Functionality

Calling the startOrder function from “Confirm Order” button:

Creating the PaymentGatewayController

Implementing the pay() function in OrderCompletion.swift

Testing your App!

Overview of The Stripe Payment System


<aside> <img src="notion://custom_emoji/b483512c-e260-41d3-b5ff-36d0dc5fa090/169e981a-0297-8019-be6b-007aa264a5c0" alt="notion://custom_emoji/b483512c-e260-41d3-b5ff-36d0dc5fa090/169e981a-0297-8019-be6b-007aa264a5c0" width="40px" />

In the contemporary tech world, a key skill is understanding the how different layers of a system work. As an app developer, you need to know how different technologies communicate with each other over the Internet.

In our app design, there are three objects that make sure the payment is complete.

Stripe is a payment processing platform that allows businesses to accept payments online.

</aside>

<aside> <img src="notion://custom_emoji/b483512c-e260-41d3-b5ff-36d0dc5fa090/169e981a-0297-8019-be6b-007aa264a5c0" alt="notion://custom_emoji/b483512c-e260-41d3-b5ff-36d0dc5fa090/169e981a-0297-8019-be6b-007aa264a5c0" width="40px" />

Payment Flow Summary

To understand the communication between the above three objects while processing successful payments, we can look at the diagram below:

</aside>

AggieEatsAppWorking.png

<aside> <img src="notion://custom_emoji/b483512c-e260-41d3-b5ff-36d0dc5fa090/169e981a-0297-8019-be6b-007aa264a5c0" alt="notion://custom_emoji/b483512c-e260-41d3-b5ff-36d0dc5fa090/169e981a-0297-8019-be6b-007aa264a5c0" width="40px" />

1️⃣ The app sends a request to the backend with the dollar amount of the Aggie Eats order.

2️⃣ The backend calls Stripe to create a PaymentIntent.

3️⃣ Stripe returns a clientSecret to the backend.

4️⃣ The backend sends this clientSecret to the app to establish a connection between the app and Stripe.

5️⃣ The app collects the user’s payment details (credit card info) and submits the payment to Stripe using the clientSecret.

6️⃣ Stripe processes the payment and returns a status:

Server Programming