Make a payment

 Create an instance of PaymentViewController with a list of CartItem object, a unique order id and a delegate to handle various outcomes of the operation:

 

let controller = PaymentViewController(cartItems: selectedCartItems, 
                                       orderId: ICUtils.randomOrderId, 
                                       delegate: self)
self.present(controller, animated: true, completion: nil)
PaymentViewController *controller = [[PaymentViewController alloc] initWithCartItems:_selectedCartItems 
                                                                             orderId:[ICUtils randomOrderId] 
                                                                            delegate:self];

[self presentViewController:controller animated:YES completion:nil];

The delegate must implement PaymentDelegate’s methods:

func didMakePayment(transactionRef: String)
func paymentFailed(error: MobilePaymentSDKError)
- (void)didMakePaymentWithTransactionRef:(NSString *)transactionRef;
- (void)paymentFailedWithError:(MobilePaymentSDKError *)error;

 

Refund


Refunding a payment requires that you have the transaction reference and order id of the payment. The amount should also be specified. A completion block with the transaction reference and a failed block with a MobilePaymentSDKError object should be provided.

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)")
})
[MobilePaymentSDK refundTransaction:_transaction.reference
                            orderId:_transaction.orderId
                             amount:_amount
                          completed:^(NSString * _Nonnull transactionRef) {
                              [self showAlertWithText:@"Refund completed successfully"];
                          } failed:^(MobilePaymentSDKError * _Nonnull error) {
                              [self showAlertWithText:[@"Refund failed. Error: "                                 
                                                       stringByAppendingString:error.message]];
                          }];

Note: Please make sure that you are using the correct Transaction Reference ID for the transaction that you want to be refunded.