Performing a Keyed Sale

The SDK supports executing a sale without a card being dipped. Here's an example of how to do it:

final AnyPayTransaction transaction = new AnyPayTransaction();
transaction.setTransactionType(TransactionType.SALE);
transaction.setCardExpiryMonth("10");
transaction.setCardExpiryYear("20");
transaction.setAddress("123 Main Street");
transaction.setPostalCode("30004");
transaction.setCVV2("999");
transaction.setCardholderName("Jane Doe");
transaction.setCardNumber("4012888888881881");
transaction.setTotalAmount(new Amount("120.47"));
transaction.setCurrency("USD");

transaction.setOnSignatureRequiredListener(new GenericEventListener() {
	@Override
  public void onEvent() {
    // a signature is required: proceeding with dummy value
    String signature = "base64-encoded image or point map";
    transaction.setSignature(signature);
    transaction.proceed();
  }
});

transaction.execute(transactionListener);
// transaction initialized with initWithType:ANPTransactionType_SALE
transaction.subtotal = [ANPAmount amountWithString:self.textField.text];

ANPTaxLineItem *taxItem = [[ANPTaxLineItem alloc] initWithName:@"TAX1" rate:[ANPAmount amountWithString:@"11"] surchargeCalculationMethod:ANPSurchargeCalculationMethod_PERCENTAGE_SUBTOTAL];
[transaction addTaxItem:taxItem];

ANPFeeLineItem *feeItem = [[ANPFeeLineItem alloc] initWithName:@"FEE1" rate:[ANPAmount amountWithString:@"10"] surchargeCalculationMethod:ANPSurchargeCalculationMethod_FLAT_RATE];
[transaction addFeeItem:feeItem];

[transaction calculateAmounts];

transaction.cardExpiryMonth = @"12";
transaction.cardExpiryYear = @"20";
transaction.cardType = @"VISA";
transaction.cardNumber = @"4111111111111111";
transaction.cardHolderName = @"Jane Dough";
transaction.CVV2 = @"123";

self.transaction = transaction;

[transaction execute:^(ANPTransactionStatus status, ANPMeaningfulError * _Nullable error) {
  if (status == ANPTransactionStatus_APPROVED) {
    NSLog(@"Ref Transaction APPROVED");
    [self appendText:[NSString stringWithFormat:@"\n\n KEYED Sale Transaction Approved"]];


    ANPTipAdjustmentLineItem *tip = [[ANPTipAdjustmentLineItem alloc] initWithRate:[ANPAmount amountWithDouble:15.00] surchargeCalculationMethod:ANPSurchargeCalculationMethod_PERCENTAGE_TOTAL];

    [self appendText:[NSString stringWithFormat:@"\n\n Sending Tip"]];

    [transaction updateWithTipAdjustment:tip resultHandler:^(BOOL submitted, ANPMeaningfulError * _Nullable error) {
      if (error) {
        [self appendText:[NSString stringWithFormat:@"\n\n Sending Tip Error %@", error.detail]];
      }
      else {
        [self appendText:[NSString stringWithFormat:@"\n\n Tip Sent %f", tip.amount.doubleValue]];
      }
    }];

  }
  else if (status == ANPTransactionStatus_DECLINED) {
    NSLog(@"Ref Transaction DECLINED");
    [self appendText:[NSString stringWithFormat:@"\n\n KEYED Sale Transaction DECLINED"]];
  }
  else {
    NSLog(@"Ref Transaction Failed");
    [self appendText:[NSString stringWithFormat:@"\n\n KEYED Sale Transaction Failed -- %@", error.message]];
  }
}];