Using the JPAddCardViewController 2017-03-08T15:09:07+00:00

iOS – Using the JPAddCardViewController

JPAddCardViewController can be used to collect a full set of customer details. These details include the customer name, customer payment card, and payment card billing address. This controller can be displayed in a navigation stack or modally.

The text entry fields displayed by JPAddCardViewController are determined from JPConfiguration. Some fields may not require collecting. By setting JPConfiguration‘s  requiredAddressFields property, specific address fields will be displayed. For example, for AVS registered merchants, you will require all address fields.

JPAddCardViewController displays a number of text entry fields for collecting the above data. These fields can be pre-populated.

JPAddCardViewController can be cancelled or saved, and feedback is provided through the JPAddCardViewControllerDelegate protocol. When saving data, JPAddCardViewController saves this data to the shared JPPaymentContext.

JPAddCardViewController self-validates. The Save button will not be enabled by JPAddCardViewController unless it recognises all data entry fields are complete and valid.

For collecting payment card details, JPAddCardViewController uses JPPaymentCardHorizontalField.

For more details, please see the JetPay Full iOS SDK Reference.

This snippet illustrates how to present an instance of JPAddCardViewController:

void collectCustomerDetails() -> Void {

   let addCardVC = JPAddCardViewController()
   addCardVC.delegate = self

   navigationController?.pushViewController( addCardVC, animated: true)
}

void addCardViewControllerDidCancel( vc: JPAddCardViewController ) -> Void {

   /* user cancelled - no data saved ! */
   let _ = navigationController?.popViewController(animated: true)
}

void addCardViewControllerDidSaveToSharedPaymentContext( vc: JPAddCardViewController) -> Void {

   /* user saved - data has been saved to  */
   let _ = navigationController?.popViewController(animated: true)-+
}

- (void)collectCustomerDetails {

    JPAddCardViewController *addCardVC = [[JPAddCardViewController alloc] init];
    addCardVC.delegate = self;
    [self.navigationController pushViewController:addCardVC animated:TRUE];
}

- (void)addCardViewControllerDidCancel:(JPAddCardViewController *)addCardViewController {
    /* user cancelled - no data saved! */
    [self.navigationController popViewControllerAnimated:TRUE];
}

- (void)addCardViewControllerDidSaveToSharedPaymentContext:(JPAddCardViewController *)addCardViewController {
    /* user saved - data has been saved to the payment context */
    [self.navigationController popViewControllerAnimated:TRUE];
}