Performing Refunds
The PayButton makes it easy to implement refunds.
Your transaction is based on a set of
MPTransactionParameters
and provided to [MposUi createTransactionViewControllerWithTransactionParameters:]
.To perform a full or partial refund, you must create
new
MPTransactionParameters
with
the transactionIdentifier
of the previous charge transaction.
For partial refunds, you must specify the amount that should be refunded.How to perform refunds:
- (IBAction)refund:(id)sender { MPUMposUi *ui = [MPUMposUi initializeWithProviderMode:/*...*/]; ui.configuration.summaryFeatures = MPUMposUiConfigurationSummaryFeatureSendReceiptViaEmail; MPTransactionParameters *parameters = [MPTransactionParameters refundForTransactionIdentifier:@"<transactionIdentifier>" optionals: ^(id<MPTransactionParametersRefundOptionals> _Nonnull optionals) { optionals.subject = @"Refund for Bouquet of Flowers"; optionals.customIdentifier = @"yourReferenceForTheTransaction"; // For partial refunds, specify the amount to be refunded // and the currency from the original transaction // [optionals setAmount:[NSDecimalNumber decimalNumberWithString:@"1.00"] currency:MPCurrencyEUR]; }]; UIViewController *viewController = [ui createTransactionViewControllerWithTransactionParameters:parameters completed:^(UIViewController *ui, MPUTransactionResult result, MPTransaction* transaction) { [self dismissViewControllerAnimated:YES completion:NULL]; UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Result" message:@"" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK",nil]; if (result == MPUTransactionResultApproved) { alert.title = @"Refund was made!"; } else { alert.title = @"Refund was declined/aborted!"; } [alert show]; }]; UINavigationController *modalNav = [[UINavigationController alloc] initWithRootViewController:viewController]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { modalNav.modalPresentationStyle = UIModalPresentationFullScreen; } else { // Show as Form on iPad modalNav.modalPresentationStyle = UIModalPresentationFormSheet; } [self presentViewController:modalNav animated:YES completion:NULL]; }
As a result, you will receive one of the following:
- The original transaction that now contains information about the refund in thetransaction.refundDetails.
- An error indicating why refunding the charge failed.
To check if a transaction can be refunded in general,
see
transaction.refundDetails.status
.Performing Refunds
The PayButton makes it easy to implement refunds.
Your transaction is based on a set of
TransactionParameters
and is used in
conjunction with MposUi.createTransactionIntent()
.To perform a full or partial refund, you must create
new
TransactionParameters
with
the transactionIdentifier
of the previous charge transaction.
For partial refunds, you need to specify the amount that should be refunded.How to perform refunds:
TransactionParameters parameters = new TransactionParameters.Builder() .refund("<transactionIdentifer>") // For partial refunds, specify the amount to be refunded // and the currency from the original transaction //.amountAndCurrency(new BigDecimal("1.00"), io.mpos.transactions.Currency.EUR) .build(); Intent intent = ui.createTransactionIntent(transactionParameters); startActivityForResult(intent, MposUi.REQUEST_CODE_PAYMENT);
As a result, you will receive one of the following via the
onActivityResult()
:- The original transaction that now contains information about the refund in thetransaction.refundDetails.
- An error indicating why refunding the charge failed.
To check if a transaction can be refunded in general, see
transaction.refundDetails.status
.