Payments with myPOS iOS SDK
This guide explains how to accept payments and process refunds in your iOS app using the myPOS SDK. Follow the steps below for a smooth payment experience.
Make a Payment
To initiate a payment, create an instance of PaymentViewController with:
- A list of
CartItemobjects - A unique Order ID
- A Delegate to handle the result
let controller = PaymentViewController(cartItems: selectedCartItems, orderId: ICUtils.randomOrderId, delegate: self) self.present(controller, animated: true, completion: nil)
Implement the PaymentDelegate
Make sure your class implements these methods:
func didMakePayment(transactionRef: String) func paymentFailed(error: MobilePaymentSDKError)
Refund a Payment
Refunds require:
- The Transaction Reference
- The Order ID used for the payment
- The Amount you want to refund
Also, provide:
- A completed block (on success)
- A failed block (on error)
MobilePaymentSDK.refundTransaction(transaction.reference, orderId: transaction.orderId, amount: amount, completed: { (transactionRef) in showAlertWithText("Refund completed successfully") }, failed: { (error) in showAlertWithText("Refund failed. Error: \(error.message)") })
Important:
Always make sure you are using the correct Transaction Reference ID for the refund