Documentation for TheChefzPayments
Table of Contents
Installation
To install TheChefzPayments, follow these steps:
- Ensure you have CocoaPods installed by running the command
pod --version
in your terminal. If not installed, refer to the CocoaPods website for installation instructions. - Add
TheChefzPayments
to your project’sPodfile
:pod 'TheChefzPayments'
- Run
pod install
in your project’s root directory. - Open your project’s
.xcworkspace
file to start usingTheChefzPayments
.
Usage
Follow these steps to use TheChefzPayments
in your project:
- Import the framework in your source file:
import TheChefzPayments
- Create an instance of
TheChefzPaymentsManager
:let paymentsManager = TheChefzPaymentsManager()
- Configure the manager with your payment provider keys:
paymentsManager.configure(with: "yourPublicKey", and: "yourPrivateKey")
- Use the manager’s methods to process payments and handle payment callbacks.
API Reference
TheChefzPayments provides the following methods:
- configure(with:and:)
Configures the payment manager with your payment provider keys.Parameters:
publicKey
(String): Your payment provider public key.privateKey
(String): Your payment provider private key.
- processPayment(with:)
Processes a payment with the provided payment details.Parameters:
paymentDetails
(PaymentDetails): Contains payment information like amount, currency, and customer details.
- handlePaymentCallback(from:)
Handles the payment callback received from the payment provider.Parameters:
url
(URL): The URL received in the app delegate’sopenURL
method.
Examples
Example 1: Configuring TheChefzPaymentsManager
// Import the framework
import TheChefzPayments
// Create an instance of TheChefzPaymentsManager
let paymentsManager = TheChefzPaymentsManager()
// Configure the manager with your payment provider keys
paymentsManager.configure(with: "yourPublicKey", and: "yourPrivateKey")
Example 2: Processing a Payment
// Create a PaymentDetails object
let paymentDetails = PaymentDetails(amount: 50.0, currency: "USD", customerName: "John Doe", customerEmail: "john.doe@example.com")
// Process payment using the manager
paymentsManager.processPayment(with: paymentDetails)
Example 3: Handling Payment Callback
// In your app delegate's openURL method, call handlePaymentCallback
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
paymentsManager.handlePaymentCallback(from: url)
return true
}
Support
If you need any assistance or have any questions, please contact our support team at support@example.com.