BTPayPalRequest.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 "BTPayPalLineItem.h"
  8. NS_ASSUME_NONNULL_BEGIN
  9. /**
  10. Payment intent.
  11. @note Must be set to sale for immediate payment, authorize to authorize a payment for capture later, or order to create an order. Defaults to authorize. Only works in the Single Payment flow.
  12. @see https://developer.paypal.com/docs/integration/direct/payments/capture-payment/ Capture payments later
  13. @see https://developer.paypal.com/docs/integration/direct/payments/create-process-order/ Create and process orders
  14. */
  15. typedef NS_ENUM(NSInteger, BTPayPalRequestIntent) {
  16. /// Authorize
  17. BTPayPalRequestIntentAuthorize = 1,
  18. /// Sale
  19. BTPayPalRequestIntentSale,
  20. /// Order
  21. BTPayPalRequestIntentOrder,
  22. };
  23. /**
  24. Use this option to specify the PayPal page to display when a user lands on the PayPal site to complete the payment.
  25. */
  26. typedef NS_ENUM(NSInteger, BTPayPalRequestLandingPageType) {
  27. /// Default
  28. /// NEXT_MAJOR_VERSION the other sdks do not pass a default value, so we should not as well
  29. BTPayPalRequestLandingPageTypeDefault = 1,
  30. /// Login
  31. BTPayPalRequestLandingPageTypeLogin,
  32. /// Billing
  33. BTPayPalRequestLandingPageTypeBilling,
  34. };
  35. /**
  36. The call-to-action in the PayPal one-time payment checkout flow.
  37. @note By default the final button will show the localized word for "Continue" and implies that the final amount billed is not yet known.
  38. Setting the BTPayPalRequest's userAction to `BTPayPalRequestUserActionCommit` changes the button text to "Pay Now", conveying to
  39. the user that billing will take place immediately.
  40. */
  41. typedef NS_ENUM(NSInteger, BTPayPalRequestUserAction) {
  42. /// Default
  43. BTPayPalRequestUserActionDefault = 1,
  44. /// Commit
  45. BTPayPalRequestUserActionCommit,
  46. };
  47. /**
  48. A PayPal request specifies options that control the PayPal flow.
  49. @note For a one-time payment, the request must specify a transaction amount.
  50. @see BTPayPalDriver
  51. */
  52. @interface BTPayPalRequest : NSObject
  53. /**
  54. Initialize a PayPal request with an amount for a one-time payment.
  55. @param amount Used for a one-time payment. Amount must be greater than or equal to zero, may optionally contain exactly 2 decimal places separated by '.', optional thousands separator ',', and is limited to 7 digits before the decimal point.
  56. @return A PayPal request.
  57. */
  58. - (instancetype)initWithAmount:(NSString *)amount;
  59. /**
  60. Used for a one-time payment.
  61. Amount must be greater than or equal to zero, may optionally contain exactly 2 decimal places separated by '.', optional thousands separator ',', and is limited to 7 digits before the decimal point.
  62. */
  63. @property (nonatomic, readonly, strong) NSString *amount;
  64. /**
  65. Defaults to false. When set to true, the shipping address selector will be displayed.
  66. */
  67. @property (nonatomic, getter=isShippingAddressRequired) BOOL shippingAddressRequired;
  68. /**
  69. Defaults to false. Set to true to enable user editing of the shipping address.
  70. @note Only applies when `shippingAddressOverride` is set.
  71. */
  72. @property (nonatomic, getter=isShippingAddressEditable) BOOL shippingAddressEditable;
  73. /**
  74. Optional: A valid ISO currency code to use for the transaction. Defaults to merchant currency code if not set.
  75. @note This is only used for one-time payments.
  76. */
  77. @property (nonatomic, nullable, copy) NSString *currencyCode;
  78. /**
  79. Optional: A locale code to use for the transaction.
  80. @note Supported locales are:
  81. `da_DK`,
  82. `de_DE`,
  83. `en_AU`,
  84. `en_GB`,
  85. `en_US`,
  86. `es_ES`,
  87. `es_XC`,
  88. `fr_CA`,
  89. `fr_FR`,
  90. `fr_XC`,
  91. `id_ID`,
  92. `it_IT`,
  93. `ja_JP`,
  94. `ko_KR`,
  95. `nl_NL`,
  96. `no_NO`,
  97. `pl_PL`,
  98. `pt_BR`,
  99. `pt_PT`,
  100. `ru_RU`,
  101. `sv_SE`,
  102. `th_TH`,
  103. `tr_TR`,
  104. `zh_CN`,
  105. `zh_HK`,
  106. `zh_TW`,
  107. `zh_XC`.
  108. */
  109. @property (nonatomic, nullable, copy) NSString *localeCode;
  110. /**
  111. Optional: A valid shipping address to be displayed in the transaction flow. An error will occur if this address is not valid.
  112. */
  113. @property (nonatomic, nullable, strong) BTPostalAddress *shippingAddressOverride;
  114. /**
  115. Optional: Display a custom description to the user for a billing agreement.
  116. */
  117. @property (nonatomic, nullable, copy) NSString *billingAgreementDescription;
  118. /**
  119. Optional: Payment intent. Only applies when using checkout flow. Defaults to `BTPayPalRequestIntentAuthorize`.
  120. */
  121. @property (nonatomic) BTPayPalRequestIntent intent;
  122. /**
  123. Optional: Changes the call-to-action in the PayPal flow. This option works for both checkout and vault flows. Defaults to `BTPayPalRequestUserActionDefault`.
  124. */
  125. @property (nonatomic) BTPayPalRequestUserAction userAction;
  126. /**
  127. Optional: Landing page type. Defaults to `BTPayPalRequestLandingPageTypeDefault`.
  128. @note Setting the BTPayPalRequest's landingPageType changes the PayPal page to display when a user lands on the PayPal site to complete the payment. BTPayPalRequestLandingPageTypeLogin specifies a PayPal account login page is used. BTPayPalRequestLandingPageTypeBilling specifies a non-PayPal account landing page is used.
  129. */
  130. @property (nonatomic) BTPayPalRequestLandingPageType landingPageType;
  131. /**
  132. Optional: The merchant name displayed inside of the PayPal flow; defaults to the company name on your Braintree account
  133. */
  134. @property (nonatomic, nullable, copy) NSString *displayName;
  135. /**
  136. Optional: Offers PayPal Credit if the customer qualifies. Defaults to false. Only available with PayPal Checkout and PayPal Billing Agreement.
  137. */
  138. @property (nonatomic) BOOL offerCredit;
  139. /**
  140. Optional: A non-default merchant account to use for tokenization.
  141. */
  142. @property (nonatomic, nullable, copy) NSString *merchantAccountId;
  143. /**
  144. Optional: The line items for this transaction. It can include up to 249 line items.
  145. */
  146. @property (nonatomic, nullable, copy) NSArray<BTPayPalLineItem *> *lineItems;
  147. @end
  148. NS_ASSUME_NONNULL_END