Payments with myPOS iOS SDK
Once the SDK is successfully initialized, your iOS app is ready to accept card-present payments using a connected myPOS terminal. You can initiate checkout, refunds, and even reprint the last receipt directly from your application.
This section walks you through how to structure and send payment-related requests using the SDK.
Checkout Request
To accept a payment, use the MPCheckoutRequest object. Provide the amount, currency, and an optional item title.
MPCheckoutRequest *checkoutRequest = [MPCheckoutRequest requestWithTotal:[NSDecimalNumber decimalNumberWithString:@"1.00"] title:@"Some item" currency:MPCurrencyEUR];
Note: Use NSDecimalNumber explicitly to ensure precision. Avoid using NSNumber to create NSDecimalNumber instances.
Refund Request
To process a refund, use MPRefundRequest similarly to a checkout request:
MPRefundRequest *refundRequest = [MPRefundRequest requestWithTotal:[NSDecimalNumber decimalNumberWithString:@"1.00"] title:@"Some item" currency:MPCurrencyEUR];
Add Optional Transaction Reference
You can attach a custom transaction reference for better tracking.
[request setTransactionReference:@"my_transaction_reference"];
This applies to both MPCheckoutRequest and MPRefundRequest.
Executing Transactions
Initiate Checkout Send the checkout request to the myPOS terminal using:
[myPOSService checkoutWithRequest:checkoutRequest fromViewController:self completion:^(NSError * _Nullable error) { }];
Initiate Refund
Trigger a refund back to the customer’s card account:
[myPOSService requestRefund:refundRequest fromViewController:self completion:^(NSError * _Nullable error) { }];
Reprint Last Receipt
If needed, you can reprint the slip from the last transaction:
[myPOSService reprintLastReceiptWithCompletion:^(NSError * _Nullable error) { }];
Tip: Always validate NSError in the completion blocks to gracefully handle errors such as user cancellations, terminal issues, or connectivity problems.