Usage
Rendering the Payment Form
Once you have generated an ecommerce entity on your backend and passed the ID to your iOS app, render the payment form
using render(ecommerceID:).
The form will consume the full width of its container. It is recommended to give it a minimum height of 500 points. The view automatically adjusts its height based on the content being displayed.
Required Parameters
- Name
ecommerceID- Type
- String
- Description
A valid UUID identifying the ecommerce payment instance, generated via the Felloh API.
The Render Method
FellohPayment(
configuration: FellohPaymentConfiguration(
publicKey: "pk_live_YOUR_PUBLIC_KEY",
environment: .sandbox
),
ecommerceID: ecommerceID,
onSuccess: { transaction in
print("Success: \(transaction.id)")
}
)
.frame(height: 500)
The Render Method (UIKit)
let paymentView = FellohPaymentView(
configuration: config
)
view.addSubview(paymentView)
// Render the payment form
try paymentView.render(
ecommerceID: "your-ecommerce-id"
)
Custom Pay Button
You can hide the built-in pay button and trigger payment from your own UI by setting design.payButton to false
and calling the pay() method on the payment view.
This is useful when you want to match your app's design language or add custom validation before submitting payment.
Custom Pay Button
let config = FellohPaymentConfiguration(
publicKey: "pk_live_YOUR_PUBLIC_KEY",
design: FellohDesignOptions(payButton: false)
)
let paymentView = FellohPaymentView(
configuration: config
)
try paymentView.render(
ecommerceID: "your-ecommerce-id"
)
// Trigger from your own button
@IBAction func payTapped(_ sender: Any) {
paymentView.pay()
}
Events — Delegate (UIKit)
Conform to FellohPaymentDelegate to receive payment form events. All methods have default empty implementations,
so you only need to implement the ones you care about.
| Method | Fires when |
|---|---|
fellohPaymentDidRender(_:) | The payment form finishes loading |
fellohPayment(_:didSucceedWith:) | Payment completes successfully |
fellohPayment(_:didDeclineWith:) | Payment is declined |
fellohPayment(_:isProcessing:) | Payment is submitted and processing |
Each event callback receives a FellohTransaction object containing the transaction id.
Delegate Events
class CheckoutVC: UIViewController,
FellohPaymentDelegate {
func fellohPaymentDidRender(
_ paymentView: FellohPaymentView
) {
print("Form rendered")
}
func fellohPayment(
_ paymentView: FellohPaymentView,
didSucceedWith transaction: FellohTransaction
) {
print("Success: \(transaction.id)")
// Navigate to confirmation screen
}
func fellohPayment(
_ paymentView: FellohPaymentView,
didDeclineWith transaction: FellohTransaction
) {
print("Declined: \(transaction.id)")
// Show error to user
}
func fellohPayment(
_ paymentView: FellohPaymentView,
isProcessing transaction: FellohTransaction
) {
print("Processing: \(transaction.id)")
// Show loading indicator
}
}
Events — Closures
As an alternative to the delegate pattern, you can set closure properties directly on FellohPaymentView.
Both delegate and closure callbacks fire for each event — you can use either or both.
- Name
onRender- Type
- (() -> Void)?
- Description
Called when the payment form finishes loading.
- Name
onSuccess- Type
- ((FellohTransaction) -> Void)?
- Description
Called when payment completes successfully.
- Name
onDecline- Type
- ((FellohTransaction) -> Void)?
- Description
Called when payment is declined.
- Name
onProcessing- Type
- ((FellohTransaction) -> Void)?
- Description
Called when payment is submitted and processing.
Closure Events
let paymentView = FellohPaymentView(
configuration: config
)
paymentView.onRender = {
print("Rendered")
}
paymentView.onSuccess = { transaction in
print("Success: \(transaction.id)")
}
paymentView.onDecline = { transaction in
print("Declined: \(transaction.id)")
}
paymentView.onProcessing = { transaction in
print("Processing: \(transaction.id)")
}
Payment Status
You can check the current state of the payment form at any time via the status property on FellohPaymentView.
| Status | Description |
|---|---|
.preload | The form has not yet loaded |
.rendered | The form is loaded and ready for input |
.processing | Payment has been submitted and is processing |
.success | Payment completed successfully |
.declined | Payment was declined |
Checking Status
switch paymentView.status {
case .preload:
print("Loading...")
case .rendered:
print("Ready for payment")
case .processing:
print("Processing payment...")
case .success:
print("Payment complete!")
case .declined:
print("Payment declined")
}
Error Handling
The render(ecommerceID:) method throws if the ecommerce ID is not a valid UUID or if the payment URL cannot be constructed.
| Error | Description |
|---|---|
FellohError.invalidEcommerceID | The provided ID is not a valid UUID |
FellohError.invalidURL | Failed to construct the payment URL |
Error Handling
do {
try paymentView.render(
ecommerceID: "your-ecommerce-id"
)
} catch FellohError.invalidEcommerceID(let id) {
print("Invalid ecommerce ID: \(id)")
} catch FellohError.invalidURL {
print("Failed to build payment URL")
} catch {
print("Unexpected error: \(error)")
}
