BTCardClient.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #import <Foundation/Foundation.h>
  2. #if __has_include("BraintreeCore.h")
  3. #import "BraintreeCore.h"
  4. #else
  5. #import <BraintreeCore/BraintreeCore.h>
  6. #endif
  7. #import "BTCard.h"
  8. #import "BTCardNonce.h"
  9. @class BTCardRequest;
  10. NS_ASSUME_NONNULL_BEGIN
  11. /**
  12. Domain for card errors.
  13. */
  14. extern NSString * const BTCardClientErrorDomain;
  15. /**
  16. Error codes associated with cards.
  17. */
  18. typedef NS_ENUM(NSInteger, BTCardClientErrorType) {
  19. /// Unknown error
  20. BTCardClientErrorTypeUnknown = 0,
  21. /// Braintree SDK is integrated incorrectly
  22. BTCardClientErrorTypeIntegration,
  23. /// Payment option (e.g. UnionPay) is not enabled for this merchant account
  24. BTCardClientErrorTypePaymentOptionNotEnabled,
  25. /// Customer provided invalid input
  26. BTCardClientErrorTypeCustomerInputInvalid,
  27. };
  28. /**
  29. Used to process cards
  30. */
  31. @interface BTCardClient : NSObject
  32. /**
  33. Creates a card client.
  34. @param apiClient An API client
  35. */
  36. - (instancetype)initWithAPIClient:(BTAPIClient *)apiClient NS_DESIGNATED_INITIALIZER;
  37. /**
  38. Base initializer - do not use.
  39. */
  40. - (instancetype)init __attribute__((unavailable("Please use initWithAPIClient:")));
  41. /**
  42. Tokenizes a card.
  43. @param card The card to tokenize.
  44. @param completion A completion block that is invoked when card tokenization has completed. If tokenization succeeds,
  45. `tokenizedCard` will contain a nonce and `error` will be `nil`; if it fails, `tokenizedCard` will be `nil` and `error`
  46. will describe the failure.
  47. */
  48. - (void)tokenizeCard:(BTCard *)card completion:(void (^)(BTCardNonce * _Nullable tokenizedCard, NSError * _Nullable error))completion;
  49. /**
  50. Tokenizes a card.
  51. @param request A card tokenization request that contains an enrolled card, the enrollment ID from `enrollUnionPayCard:completion:`,
  52. and the enrollment auth code sent to the mobile phone number.
  53. @param options A dictionary containing additional options to send when performing tokenization. Optional.
  54. @param completion A completion block that is invoked when card tokenization has completed. If tokenization succeeds, `tokenizedCard` will contain a nonce and `error` will be `nil`; if it fails, `tokenizedCard` will be `nil` and `error` will describe the failure.
  55. */
  56. - (void)tokenizeCard:(BTCardRequest *)request
  57. options:(nullable NSDictionary *)options
  58. completion:(void (^)(BTCardNonce * _Nullable tokenizedCard, NSError * _Nullable error))completion;
  59. @end
  60. NS_ASSUME_NONNULL_END