source 'https://github.com/CocoaPods/Specs.git' source 'https://github.com/visa/mpos.sdk.ios.pods.git' use_frameworks! target :"<your-app-target>" do pod 'payworks', '2.61.0' pod 'payworks/offline', '2.61.0' pod 'payworks.paybutton', '2.61.0' end
MPTransactionProvider *transactionProvider = [MPMpos transactionProviderForMode:MPProviderModeTEST merchantIdentifier:@"MERCHANT_IDENTIFIER" merchantSecretKey:@"MERCHANT_SECRET_KEY"]; MPTransactionParameters *transactionParameters = [MPTransactionParameters chargeWithAmount:[NSDecimalNumber decimalNumberWithString:@"10"] currency:MPCurrencyEUR optionals:^(id _Nonnull optionals) { [optionals setSubject:@"my first transaction"]; [optionals setCustomIdentifier:@"yourReferenceForTheTransaction"]; }]; /* When using the Bluetooth Miura, use the following parameters: MPAccessoryParameters *accessoryParameters = [MPAccessoryParameters externalAccessoryParametersWithFamily:MPAccessoryFamilyMiuraMPI protocol:@"com.miura.shuttle" optionals:nil]; */ /* When using Verifone readers via WiFi or Ethernet, use the following parameters: MPAccessoryParameters *accessoryParameters = [MPAccessoryParameters tcpAccessoryParametersWithFamily:MPAccessoryFamilyVerifoneVIPA remote:@"192.168.254.123" port:16107 optionals:nil]; */
[transactionProvider.offlineModule startTransactionWithParameters:transactionParameters accessoryParameters:accessoryParameters processParameters:nil registered:^(MPTransactionProcess * transactionProcess, MPTransaction * transaction) { NSLog(@"Transaction identifier is %@. Store it in your backed so that you can always query its status", transaction.identifier); } statusChanged:^(MPTransactionProcess * transactionProcess, MPTransaction *transaction, MPTransactionProcessDetails * details) { NSLog(@"Status changed %@", details.information); } actionRequired:^(MPTransactionProcess * transactionProcess, MPTransaction * transaction, MPTransactionAction action, MPTransactionActionSupport *support) { NSLog(@"Action is required!"); switch (action) { case MPTransactionActionCustomerSignature: // in a live app, this image comes from your signature screen [transactionProcess continueWithCustomerSignature:[UIImage new] verified:YES]; break; case MPTransactionActionCustomerIdentification: // always return false here [transactionProcess continueWithCustomerIdentityVerified:NO]; break; case MPTransactionActionApplicationSelection: { // This happens only for readers that don't support application selection on their screen MPTransactionActionApplicationSelectionSupportWrapper *sw = [MPTransactionActionApplicationSelectionSupportWrapper wrapAround:support]; [transactionProcess continueWithSelectedApplication:sw.applications.firstObject]; } break; case MPTransactionActionCreditDebitSelection: [transactionProcess continueCreditDebitSelectionWithDebit]; break; case MPTransactionActionNone: //NOOP break; } } completed:^(MPTransactionProcess * transactionProcess, MPTransaction *transaction, MPTransactionProcessDetails * details) { if (details.state == MPTransactionProcessDetailsStateAccepted) { // Make sure to store the transactionIdentifier for later reconciliation NSLog(@"transactionIdentifer for reconciliation: %@", transaction.identifier); // print the merchant receipt MPReceipt *merchantReceipt = transaction.merchantReceipt; // print a signature line if required if (merchantReceipt.printSignatureLine) { NSLog(@"\n\n\n------ PLEASE SIGN HERE ------"); } // ask the merchant, whether the shopper wants to have a receipt MPReceipt *customerReceipt = transaction.customerReceipt; // and close the checkout UI } else { // Allow your merchant to try another transaction // Make clear to merchant NOT to hand out the goods } }];
MPTransactionParameters *refundTransactionParameters = [MPTransactionParameters refundForCustomIdentifier:@"transactionIdentifier" optionals:nil]; [transactionProvider.offlineModule amendTransactionWithParameters:refundTransactionParameters statusChanged:^(MPTransactionProcess *transactionProcess, MPTransaction *transaction, MPTransactionProcessDetails *details) { //intermediary update } completed:^(MPTransactionProcess *transactionProcess, MPTransaction *transaction, MPTransactionProcessDetails *details) { if (transaction.status == MPTransactionStatusAccepted) { //logic for successful offline transaction refund } }];
[transactionProvider.offlineModule submitOfflineTransactionsBatchWithCompleted:^(MPOfflineBatchUploadProcess *uploadProcess, MPSubmitBatchResponse * response) { if (response.error == nil) { // The Offline Transactions have been submitted successfully // for later Deferred Authorization. // You can find the submitted transactions by NSArray *submittedTransactions = response.transactions; // You can mark them as submitted in your POS as submitted, but not yet APPROVED/DECLINED } else { // error indicates that there was a problem refunding the transaction // check response.error.type // and response.error.info for more information // there could be submitted transaction present even if there are errors // as the error may have occured during submission process( Eg: Internet connectivity issues) // response.transactions; // Make your merchants aware that they need to attempt to submit // the Offline Transactions again, until successful } }];
[transactionProvider.offlineModule lookupTransactionWithTransactionIdentifier:@"transactionIdentifier" completed:^(MPTransaction *transaction, NSError *error) { if (error == nil) { //apply logic for the found transaction } else { //handle error } }];
boolean includeReceipts = false; int offset = 0; int page = 10; [transactionProvider.offlineModule queryTransactionsWithRange:NSMakeRange(100, 0) includeReceipts:YES completed:^(NSArray *transactions, NSError *error) { if (error == nil) { //apply logic for the found transaction } else { //handle error } }];
[transactionProvider.transactionModule lookupTransactionWithTransactionIdentifier:@"transactionIdentifierOfAcceptedTransaction" completed:^(MPTransaction * _Nullable transaction, NSError * _Nullable error) { if (error == nil) { if (transaction.status == MPTransactionStatusApproved) { // Merchant will receive the money. No further actions are required. NSLog(@"Final state: APPROVED"); } else if (transaction.status == MPTransactionStatusDeclined) { // Merchant will NOT receive money. NSLog(@"Final state: DECLINED"); } else if (transaction.status == MPTransactionStatusPending) { // Transaction is still queued for Deferred Authorization, try again later NSLog(@"Still waiting for Deferred Authorization"); } else { // handle error and try again } } else { // handle error and try again } }];
TransactionProvider transactionProvider = Mpos.createTransactionProvider(MyActivity.this, ProviderMode.TEST, "MERCHANT_IDENTIFIER", "MERCHANT_SECRET_KEY"); TransactionParameters transactionParameters = new TransactionParameters.Builder() .charge(new BigDecimal("10"), Currency.EUR) .subject("my first transaction") .customIdentifier("yourReferenceForTheTransaction") .build(); /* When using the Bluetooth Miura, use the following parameters: AccessoryParameters accessoryParameters = new AccessoryParameters.Builder(AccessoryFamily.MIURA_MPI) .bluetooth() .build(); */ /* When using Verifone readers via WiFi or Ethernet, use the following parameters: AccessoryParameters accessoryParameters = new AccessoryParameters.Builder(AccessoryFamily.VERIFONE_VIPA) .tcp("192.168.254.123", 16107) .build(); */
[transactionProvider.offlineModule startTransactionWithParameters:transactionParameters accessoryParameters:accessoryParameters processParameters:nil registered:^(MPTransactionProcess * transactionProcess, MPTransaction * transaction) { NSLog(@"Transaction identifier is %@. Store it in your backed so that you can always query its status", transaction.identifier); } statusChanged:^(MPTransactionProcess * transactionProcess, MPTransaction *transaction, MPTransactionProcessDetails * details) { NSLog(@"Status changed %@", details.information); } actionRequired:^(MPTransactionProcess * transactionProcess, MPTransaction * transaction, MPTransactionAction action, MPTransactionActionSupport *support) { NSLog(@"Action is required!"); switch (action) { case MPTransactionActionCustomerSignature: // in a live app, this image comes from your signature screen [transactionProcess continueWithCustomerSignature:[UIImage new] verified:YES]; break; case MPTransactionActionCustomerIdentification: // always return false here [transactionProcess continueWithCustomerIdentityVerified:NO]; break; case MPTransactionActionApplicationSelection: { // This happens only for readers that don't support application selection on their screen MPTransactionActionApplicationSelectionSupportWrapper *sw = [MPTransactionActionApplicationSelectionSupportWrapper wrapAround:support]; [transactionProcess continueWithSelectedApplication:sw.applications.firstObject]; } break; case MPTransactionActionCreditDebitSelection: [transactionProcess continueCreditDebitSelectionWithDebit]; break; case MPTransactionActionNone: //NOOP break; } } completed:^(MPTransactionProcess * transactionProcess, MPTransaction *transaction, MPTransactionProcessDetails * details) { if (details.state == MPTransactionProcessDetailsStateAccepted) { // Make sure to store the transactionIdentifier for later reconciliation NSLog(@"transactionIdentifer for reconciliation: %@", transaction.identifier); // print the merchant receipt MPReceipt *merchantReceipt = transaction.merchantReceipt; // print a signature line if required if (merchantReceipt.printSignatureLine) { NSLog(@"\n\n\n------ PLEASE SIGN HERE ------"); } // ask the merchant, whether the shopper wants to have a receipt MPReceipt *customerReceipt = transaction.customerReceipt; // and close the checkout UI } else { // Allow your merchant to try another transaction // Make clear to merchant NOT to hand out the goods } }];
TransactionParameters refundTransactionParameters = new TransactionParameters.Builder() .refund("transactionIdentifer") .build(); transactionProvider.getOfflineModule().amendTransaction(refundTransactionParameters, new BasicTransactionProcessListener() { @Override public void onStatusChanged(TransactionProcess transactionProcess, Transaction transaction, TransactionProcessDetails transactionProcessDetails) { //intermediary update } @Override public void onCompleted(TransactionProcess transactionProcess, Transaction transaction, TransactionProcessDetails transactionProcessDetails) { if (transaction.getStatus().equals(TransactionStatus.ACCEPTED)) { //logic for successful offline transaction refund } } });
transactionProvider.getOfflineModule().submitTransactionsBatch(new SubmitTransactionsBatchProcessListener(){ @Override public void onCompleted(SubmitTransactionsBatchProcessDetails submitTransactionsBatchProcessDetails) { if (submitTransactionsBatchProcessDetails.getError() == null) { // The Offline Transactions have been submitted successfully // for later Deferred Authorization. // You can find the submitted transactions by List<SubmittedTransaction> submittedTransactions = submitTransactionsBatchProcessDetails.getAllTransactions(); // You can mark them as submitted in your POS as submitted, but not yet APPROVED/DECLINED } else { // error indicates that there was a problem refunding the transaction // check submitTransactionsBatchProcessDetails.getError().getErrorType() // and submitTransactionsBatchProcessDetails.getError().getInfo() for more information // there could be submitted transaction present even if there are errors // as the error may have occured during submission process( Eg: Internet connectivity issues) // details.getAllTransactions(); // Make your merchants aware that they need to attempt to submit // the Offline Transactions again, until successful } } });
transactionProvider.getOfflineModule().lookupTransaction("add your transaction id here", new LookupTransactionListener(){ @Override public void onCompleted(String transactionIdentifier, Transaction transaction, MposError mposError) { if (mposError == null) { //apply logic for the found transaction } else { //handle error } } });
boolean includeReceipts = false; int offset = 0; int page = 10; FilterParameters filterParameters = new FilterParameters.Builder().build(); transactionProvider.getOfflineModule().queryTransactions(filterParameters, includeReceipts, offset, page, new QueryTransactionsListener() { @Override public void onCompleted(FilterParameters filterParameters, boolean includeReceipts, int offset, int limit, List transactions, MposError error) { if (error == null) { //apply logic for the found transactions } else { //handle error } } });
transactionProvider.getTransactionModule().lookupTransaction("transactionIdentifierOfAcceptedTransaction", new LookupTransactionListener(){ @Override public void onCompleted(String transactionIdentifier, Transaction transaction, MposError mposError) { if (mposError == null) { if(transaction.getStatus() == TransactionStatus.APPROVED) { // Merchant will receive the money. No further actions are required. Log.d("mpos", "Final state: APPROVED"); } else if(transaction.getStatus() == TransactionStatus.DECLINED) { // Merchant will NOT receive money. Log.d("mpos", "Final state: DECLINED"); } else if(transaction.getStatus() == TransactionStatus.PENDING) { // Transaction is still queued for Deferred Authorization, try again later Log.d("mpos", "Still waiting for Deferred Authorization"); } else { // handle error and try again } } else { // handle error and try again } } }); }