BTClientMetadata.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #import <Foundation/Foundation.h>
  2. /**
  3. Source of the metadata
  4. */
  5. typedef NS_ENUM(NSInteger, BTClientMetadataSourceType) {
  6. /// Unknown source
  7. BTClientMetadataSourceUnknown = 0,
  8. /// PayPal app
  9. BTClientMetadataSourcePayPalApp,
  10. /// PayPal browser
  11. BTClientMetadataSourcePayPalBrowser,
  12. /// Venmo app
  13. BTClientMetadataSourceVenmoApp,
  14. /// Form
  15. BTClientMetadataSourceForm,
  16. };
  17. /**
  18. Integration types
  19. */
  20. typedef NS_ENUM(NSInteger, BTClientMetadataIntegrationType) {
  21. /// Custom
  22. BTClientMetadataIntegrationCustom,
  23. /// Drop-in
  24. BTClientMetadataIntegrationDropIn,
  25. /// Drop-in 2
  26. BTClientMetadataIntegrationDropIn2,
  27. /// Unknown integration
  28. BTClientMetadataIntegrationUnknown
  29. };
  30. NS_ASSUME_NONNULL_BEGIN
  31. /**
  32. Represents the metadata associated with a session for posting along with payment data during tokenization
  33. When a payment method is tokenized, the client api accepts parameters under
  34. _meta which are used to determine where payment data originated.
  35. In general, this data may evolve and be used in different ways by different
  36. integrations in a single app. For example, if both Apple Pay and drop in are
  37. used. In this case, the source and integration may change over time, while
  38. the sessionId should remain constant. To achieve this, users of this class
  39. should use `mutableCopy` to create a new copy based on the existing session
  40. and then update the object as needed.
  41. */
  42. @interface BTClientMetadata : NSObject <NSCopying, NSMutableCopying>
  43. /**
  44. Integration type
  45. */
  46. @property (nonatomic, assign, readonly) BTClientMetadataIntegrationType integration;
  47. /**
  48. Integration source
  49. */
  50. @property (nonatomic, assign, readonly) BTClientMetadataSourceType source;
  51. /**
  52. Auto-generated UUID
  53. */
  54. @property (nonatomic, copy, readonly) NSString *sessionId;
  55. #pragma mark Derived Properties
  56. /**
  57. String representation of the integration
  58. */
  59. @property (nonatomic, copy, readonly) NSString *integrationString;
  60. /**
  61. String representation of the source
  62. */
  63. @property (nonatomic, copy, readonly) NSString *sourceString;
  64. /**
  65. Additional metadata parameters
  66. */
  67. @property (nonatomic, strong, readonly) NSDictionary *parameters;
  68. @end
  69. /**
  70. Mutable `BTClientMetadata`
  71. */
  72. @interface BTMutableClientMetadata : BTClientMetadata
  73. /**
  74. Integration type
  75. @param integration The BTClientMetadataIntegrationType
  76. */
  77. - (void)setIntegration:(BTClientMetadataIntegrationType)integration;
  78. /**
  79. Integration source
  80. @param source The BTClientMetadataSourceType
  81. */
  82. - (void)setSource:(BTClientMetadataSourceType)source;
  83. /**
  84. Auto-generated UUID
  85. @param sessionId A string for the session
  86. */
  87. - (void)setSessionId:(NSString *)sessionId;
  88. @end
  89. NS_ASSUME_NONNULL_END