Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Breaking] Rename "payment method" to "payment option" #1139

Merged
merged 11 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 15.0.0 2019-??-??
* Renames all references to 'PaymentMethod' to 'PaymentOption', in anticipation of a new 'PaymentMethod' type. [#1139](https://github.com/stripe/stripe-ios/pull/1139)
* Renames `STPPaymentMethod` to `STPPaymentOption`
* Renames `STPPaymentMethodType` to `STPPaymentOptionType`
* Renames `STPApplePaymentMethod` to `STPApplePayPaymentOption`
* Renames `STPPaymentMethodTuple` to `STPPaymentOptionTuple`
* Renames `STPPaymentMethodsViewController` to `STPPaymentOptionsViewController`
* Renames all properties, methods, comments referencing 'PaymentMethod' to 'PaymentOption'

## 14.0.0 2018-11-14
* Changes `STPPaymentCardTextField`, which now copies the `cardParams` property. See [MIGRATING.md](/MIGRATING.md) for more details. [#1031](https://github.com/stripe/stripe-ios/pull/1031)
* Renames `STPPaymentIntentParams.returnUrl` to `STPPaymentIntentParams.returnURL`. [#1037](https://github.com/stripe/stripe-ios/pull/1037)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class CheckoutViewController: UIViewController, STPPaymentContextDelegate {
config.requiredBillingAddressFields = settings.requiredBillingAddressFields
config.requiredShippingAddressFields = settings.requiredShippingAddressFields
config.shippingType = settings.shippingType
config.additionalPaymentMethods = settings.additionalPaymentMethods
config.additionalPaymentOptions = settings.additionalPaymentOptions

// Create card sources instead of card tokens
config.createCardSources = true;
Expand All @@ -96,7 +96,7 @@ class CheckoutViewController: UIViewController, STPPaymentContextDelegate {

let paymentSelectionFooter = PaymentContextFooterView(text: "You can add custom footer views to the payment selection screen.")
paymentSelectionFooter.theme = settings.theme
paymentContext.paymentMethodsViewControllerFooterView = paymentSelectionFooter
paymentContext.paymentOptionsViewControllerFooterView = paymentSelectionFooter

let addCardFooter = PaymentContextFooterView(text: "You can add custom footer views to the add card screen.")
addCardFooter.theme = settings.theme
Expand Down Expand Up @@ -155,7 +155,7 @@ class CheckoutViewController: UIViewController, STPPaymentContextDelegate {
self.buyButton.addTarget(self, action: #selector(didTapBuy), for: .touchUpInside)
self.totalRow.detail = self.numberFormatter.string(from: NSNumber(value: Float(self.paymentContext.paymentAmount)/100))!
self.paymentRow.onTap = { [weak self] in
self?.paymentContext.pushPaymentMethodsViewController()
self?.paymentContext.pushPaymentOptionsViewController()
}
self.shippingRow.onTap = { [weak self] in
self?.paymentContext.pushShippingViewController()
Expand Down Expand Up @@ -220,8 +220,8 @@ class CheckoutViewController: UIViewController, STPPaymentContextDelegate {

func paymentContextDidChange(_ paymentContext: STPPaymentContext) {
self.paymentRow.loading = paymentContext.loading
if let paymentMethod = paymentContext.selectedPaymentMethod {
self.paymentRow.detail = paymentMethod.label
if let paymentOption = paymentContext.selectedPaymentOption {
self.paymentRow.detail = paymentOption.label
}
else {
self.paymentRow.detail = "Select Payment"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Stripe

struct Settings {
let theme: STPTheme
let additionalPaymentMethods: STPPaymentMethodType
let additionalPaymentOptions: STPPaymentOptionType
let requiredBillingAddressFields: STPBillingAddressFields
let requiredShippingAddressFields: Set<STPContactField>
let shippingType: STPShippingType
Expand All @@ -20,7 +20,7 @@ struct Settings {
class SettingsViewController: UITableViewController {
var settings: Settings {
return Settings(theme: self.theme.stpTheme,
additionalPaymentMethods: self.applePay.enabled ? .all : STPPaymentMethodType(),
additionalPaymentOptions: self.applePay.enabled ? .all : STPPaymentOptionType(),
requiredBillingAddressFields: self.requiredBillingAddressFields.stpBillingAddressFields,
requiredShippingAddressFields: self.requiredShippingAddressFields.stpContactFields,
shippingType: self.shippingType.stpShippingType)
Expand Down
24 changes: 12 additions & 12 deletions Example/UI Examples/BrowseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
import UIKit
import Stripe

class BrowseViewController: UITableViewController, STPAddCardViewControllerDelegate, STPPaymentMethodsViewControllerDelegate, STPShippingAddressViewControllerDelegate {
class BrowseViewController: UITableViewController, STPAddCardViewControllerDelegate, STPPaymentOptionsViewControllerDelegate, STPShippingAddressViewControllerDelegate {

enum Demo: Int {
static let count = 5
case STPPaymentCardTextField
case STPAddCardViewController
case STPPaymentMethodsViewController
case STPPaymentOptionsViewController
case STPShippingInfoViewController
case ChangeTheme

var title: String {
switch self {
case .STPPaymentCardTextField: return "Card Field"
case .STPAddCardViewController: return "Card Form with Billing Address"
case .STPPaymentMethodsViewController: return "Payment Method Picker"
case .STPPaymentOptionsViewController: return "Payment Option Picker"
case .STPShippingInfoViewController: return "Shipping Info Form"
case .ChangeTheme: return "Change Theme"
}
Expand All @@ -33,7 +33,7 @@ class BrowseViewController: UITableViewController, STPAddCardViewControllerDeleg
switch self {
case .STPPaymentCardTextField: return "STPPaymentCardTextField"
case .STPAddCardViewController: return "STPAddCardViewController"
case .STPPaymentMethodsViewController: return "STPPaymentMethodsViewController"
case .STPPaymentOptionsViewController: return "STPPaymentOptionsViewController"
case .STPShippingInfoViewController: return "STPShippingInfoViewController"
case .ChangeTheme: return ""
}
Expand Down Expand Up @@ -91,12 +91,12 @@ class BrowseViewController: UITableViewController, STPAddCardViewControllerDeleg
let navigationController = UINavigationController(rootViewController: viewController)
navigationController.navigationBar.stp_theme = theme
present(navigationController, animated: true, completion: nil)
case .STPPaymentMethodsViewController:
case .STPPaymentOptionsViewController:
let config = STPPaymentConfiguration()
config.additionalPaymentMethods = .all
config.additionalPaymentOptions = .all
config.requiredBillingAddressFields = .none
config.appleMerchantIdentifier = "dummy-merchant-id"
let viewController = STPPaymentMethodsViewController(configuration: config,
let viewController = STPPaymentOptionsViewController(configuration: config,
theme: theme,
customerContext: self.customerContext,
delegate: self)
Expand Down Expand Up @@ -132,17 +132,17 @@ class BrowseViewController: UITableViewController, STPAddCardViewControllerDeleg
dismiss(animated: true, completion: nil)
}

// MARK: STPPaymentMethodsViewControllerDelegate
// MARK: STPPaymentOptionsViewControllerDelegate

func paymentMethodsViewControllerDidCancel(_ paymentMethodsViewController: STPPaymentMethodsViewController) {
func paymentOptionsViewControllerDidCancel(_ paymentOptionsViewController: STPPaymentOptionsViewController) {
dismiss(animated: true, completion: nil)
}

func paymentMethodsViewControllerDidFinish(_ paymentMethodsViewController: STPPaymentMethodsViewController) {
paymentMethodsViewController.navigationController?.popViewController(animated: true)
func paymentOptionsViewControllerDidFinish(_ paymentOptionsViewController: STPPaymentOptionsViewController) {
paymentOptionsViewController.navigationController?.popViewController(animated: true)
}

func paymentMethodsViewController(_ paymentMethodsViewController: STPPaymentMethodsViewController, didFailToLoadWithError error: Error) {
func paymentOptionsViewController(_ paymentOptionsViewController: STPPaymentOptionsViewController, didFailToLoadWithError error: Error) {
dismiss(animated: true, completion: nil)
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The Stripe iOS SDK makes it quick and easy to build an excellent payment experie
We recommend that you install the Stripe iOS SDK using a package manager such as [Cocoapods or Carthage](https://stripe.com/docs/mobile/ios#getting-started). If you prefer to link the library manually, please use a version from our [releases](https://github.com/stripe/stripe-ios/releases) page because we consider the master branch to be unstable.

If you're reading this on GitHub.com, please make sure you are looking at the [tagged version](https://github.com/stripe/stripe-ios/tags) that corresponds to the release you have installed. Otherwise, the instructions and example code may be mismatched with your copy. You can read the latest tagged version of this README and browse the associated code on GitHub using
[this link](https://github.com/stripe/stripe-ios/tree/v14.0.0).
[this link](https://github.com/stripe/stripe-ios/tree/v15.0.0).

## Requirements

Expand Down
Loading