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

Add STPPaymentIntent, and method to retrieve from the API given a clientSecret #985

Merged
merged 8 commits into from
Jul 10, 2018
36 changes: 36 additions & 0 deletions Stripe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,17 @@
B3A99BC41FEAF2CA003F6ED3 /* STPLegalEntityParams.h in Headers */ = {isa = PBXBuildFile; fileRef = B3A99BC11FEAF2CA003F6ED3 /* STPLegalEntityParams.h */; settings = {ATTRIBUTES = (Public, ); }; };
B3A99BC51FEAF2CA003F6ED3 /* STPLegalEntityParams.m in Sources */ = {isa = PBXBuildFile; fileRef = B3A99BC21FEAF2CA003F6ED3 /* STPLegalEntityParams.m */; };
B3A99BC61FEAF2CA003F6ED3 /* STPLegalEntityParams.m in Sources */ = {isa = PBXBuildFile; fileRef = B3A99BC21FEAF2CA003F6ED3 /* STPLegalEntityParams.m */; };
B3BDCAC220EEF2150034F7F5 /* STPPaymentIntent.m in Sources */ = {isa = PBXBuildFile; fileRef = B3BDCAC020EEF2150034F7F5 /* STPPaymentIntent.m */; };
B3BDCAC320EEF2150034F7F5 /* STPPaymentIntent.m in Sources */ = {isa = PBXBuildFile; fileRef = B3BDCAC020EEF2150034F7F5 /* STPPaymentIntent.m */; };
B3BDCAC420EEF2150034F7F5 /* STPPaymentIntent+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = B3BDCAC120EEF2150034F7F5 /* STPPaymentIntent+Private.h */; };
B3BDCAC520EEF2150034F7F5 /* STPPaymentIntent+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = B3BDCAC120EEF2150034F7F5 /* STPPaymentIntent+Private.h */; };
B3BDCAC820EEF22D0034F7F5 /* STPPaymentIntent.h in Headers */ = {isa = PBXBuildFile; fileRef = B3BDCAC620EEF22D0034F7F5 /* STPPaymentIntent.h */; settings = {ATTRIBUTES = (Public, ); }; };
B3BDCAC920EEF22D0034F7F5 /* STPPaymentIntent.h in Headers */ = {isa = PBXBuildFile; fileRef = B3BDCAC620EEF22D0034F7F5 /* STPPaymentIntent.h */; settings = {ATTRIBUTES = (Public, ); }; };
B3BDCACA20EEF22D0034F7F5 /* STPPaymentIntentEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = B3BDCAC720EEF22D0034F7F5 /* STPPaymentIntentEnums.h */; settings = {ATTRIBUTES = (Public, ); }; };
B3BDCACB20EEF22D0034F7F5 /* STPPaymentIntentEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = B3BDCAC720EEF22D0034F7F5 /* STPPaymentIntentEnums.h */; settings = {ATTRIBUTES = (Public, ); }; };
B3BDCACD20EEF4540034F7F5 /* STPPaymentIntentTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B3BDCACC20EEF4540034F7F5 /* STPPaymentIntentTest.m */; };
B3BDCACF20EEF4640034F7F5 /* STPPaymentIntentFunctionalTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B3BDCACE20EEF4640034F7F5 /* STPPaymentIntentFunctionalTest.m */; };
B3BDCADF20F0142C0034F7F5 /* PaymentIntent.json in Resources */ = {isa = PBXBuildFile; fileRef = B3BDCADE20F0142C0034F7F5 /* PaymentIntent.json */; };
B3C9CF2D2004595A005502ED /* STPConnectAccountFunctionalTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B3C9CF2C2004595A005502ED /* STPConnectAccountFunctionalTest.m */; };
C1054F911FE197AE0033C87E /* STPPaymentContextSnapshotTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C1054F901FE197AE0033C87E /* STPPaymentContextSnapshotTests.m */; };
C1080F491CBECF7B007B2D89 /* STPAddress.h in Headers */ = {isa = PBXBuildFile; fileRef = C1080F471CBECF7B007B2D89 /* STPAddress.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -1056,6 +1067,13 @@
B3A241381FFEB57400A2F00D /* STPConnectAccountParams.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPConnectAccountParams.m; sourceTree = "<group>"; };
B3A99BC11FEAF2CA003F6ED3 /* STPLegalEntityParams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = STPLegalEntityParams.h; path = PublicHeaders/STPLegalEntityParams.h; sourceTree = "<group>"; };
B3A99BC21FEAF2CA003F6ED3 /* STPLegalEntityParams.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPLegalEntityParams.m; sourceTree = "<group>"; };
B3BDCAC020EEF2150034F7F5 /* STPPaymentIntent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPPaymentIntent.m; sourceTree = "<group>"; };
B3BDCAC120EEF2150034F7F5 /* STPPaymentIntent+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "STPPaymentIntent+Private.h"; sourceTree = "<group>"; };
B3BDCAC620EEF22D0034F7F5 /* STPPaymentIntent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPPaymentIntent.h; path = PublicHeaders/STPPaymentIntent.h; sourceTree = "<group>"; };
B3BDCAC720EEF22D0034F7F5 /* STPPaymentIntentEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPPaymentIntentEnums.h; path = PublicHeaders/STPPaymentIntentEnums.h; sourceTree = "<group>"; };
B3BDCACC20EEF4540034F7F5 /* STPPaymentIntentTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPPaymentIntentTest.m; sourceTree = "<group>"; };
B3BDCACE20EEF4640034F7F5 /* STPPaymentIntentFunctionalTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPPaymentIntentFunctionalTest.m; sourceTree = "<group>"; };
B3BDCADE20F0142C0034F7F5 /* PaymentIntent.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = PaymentIntent.json; sourceTree = "<group>"; };
B3C9CF2C2004595A005502ED /* STPConnectAccountFunctionalTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPConnectAccountFunctionalTest.m; sourceTree = "<group>"; };
C1054F901FE197AE0033C87E /* STPPaymentContextSnapshotTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentContextSnapshotTests.m; sourceTree = "<group>"; };
C1080F471CBECF7B007B2D89 /* STPAddress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPAddress.h; path = PublicHeaders/STPAddress.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1551,6 +1569,7 @@
8BD2133B1F0458F5007F6FD1 /* BitcoinSource.json */,
F1BA241C1E57BE5700E4A1CF /* CardSource.json */,
F152322E1EA9344000D65C67 /* iDEALSource.json */,
B3BDCADE20F0142C0034F7F5 /* PaymentIntent.json */,
8BD2133D1F045D31007F6FD1 /* SEPADebitSource.json */,
F16AA26D1F5A05A100207FFF /* AlipaySource.json */,
);
Expand All @@ -1577,6 +1596,7 @@
04CDB5241A5F3A9300B854EE /* STPCardFunctionalTest.m */,
B3C9CF2C2004595A005502ED /* STPConnectAccountFunctionalTest.m */,
C1CFCB6F1ED5E11500BE45DF /* STPFileFunctionalTest.m */,
B3BDCACE20EEF4640034F7F5 /* STPPaymentIntentFunctionalTest.m */,
C1CFCB711ED5E11500BE45DF /* STPPIIFunctionalTest.m */,
C1D7B5241E36C70D002181F5 /* STPSourceFunctionalTest.m */,
);
Expand Down Expand Up @@ -1625,6 +1645,7 @@
0438EF4B1B741B0100D506CC /* STPPaymentCardTextFieldViewModelTest.m */,
8B013C881F1E784A00DD831B /* STPPaymentConfigurationTest.m */,
F14C872E1D4FCDBA00C7CC6A /* STPPaymentContextApplePayTest.m */,
B3BDCACC20EEF4540034F7F5 /* STPPaymentIntentTest.m */,
F1DE87FF1F8D410D00602F4C /* STPPaymentMethodsViewControllerTest.m */,
C1EEDCC91CA2186300A54582 /* STPPhoneNumberValidatorTest.m */,
C1FEE5981CBFF24000A7632B /* STPPostalCodeValidatorTest.m */,
Expand Down Expand Up @@ -1958,6 +1979,10 @@
04F213301BCEAB61001D6F22 /* STPFormEncodable.h */,
B3A99BC11FEAF2CA003F6ED3 /* STPLegalEntityParams.h */,
B3A99BC21FEAF2CA003F6ED3 /* STPLegalEntityParams.m */,
B3BDCAC620EEF22D0034F7F5 /* STPPaymentIntent.h */,
B3BDCAC020EEF2150034F7F5 /* STPPaymentIntent.m */,
B3BDCAC120EEF2150034F7F5 /* STPPaymentIntent+Private.h */,
B3BDCAC720EEF22D0034F7F5 /* STPPaymentIntentEnums.h */,
C1D7B51E1E36C32F002181F5 /* STPSource.h */,
C1D7B51F1E36C32F002181F5 /* STPSource.m */,
F19491DD1E5F6B8C001E1FC2 /* STPSourceCardDetails.h */,
Expand Down Expand Up @@ -2191,6 +2216,7 @@
04B31DDB1D09A4DC00EF1631 /* STPPaymentConfiguration+Private.h in Headers */,
045D710F1CEEE30500F6CD65 /* STPAspects.h in Headers */,
04F94DAF1D229F59004FC826 /* STPPaymentMethodsViewController+Private.h in Headers */,
B3BDCAC520EEF2150034F7F5 /* STPPaymentIntent+Private.h in Headers */,
04633AFD1CD129AF009D4FB5 /* STPPhoneNumberValidator.h in Headers */,
04633AFE1CD129B4009D4FB5 /* STPDelegateProxy.h in Headers */,
F1FA6F961E25960500EB444D /* STPCoreScrollViewController+Private.h in Headers */,
Expand Down Expand Up @@ -2220,6 +2246,8 @@
C113D21A1EBB9A36006FACC2 /* STPEphemeralKey.h in Headers */,
04A4C38E1C4F25F900B3B290 /* UIViewController+Stripe_ParentViewController.h in Headers */,
C18410771EC2529400178149 /* STPEphemeralKeyManager.h in Headers */,
B3BDCAC920EEF22D0034F7F5 /* STPPaymentIntent.h in Headers */,
B3BDCACB20EEF22D0034F7F5 /* STPPaymentIntentEnums.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -2330,6 +2358,7 @@
C1BD9B2E1E3940A200CEE925 /* STPSourceRedirect.h in Headers */,
04BC29A41CD8697900318357 /* STPTheme.h in Headers */,
04B31DF21D09F0A800EF1631 /* UIViewController+Stripe_NavigationItemProxy.h in Headers */,
B3BDCAC420EEF2150034F7F5 /* STPPaymentIntent+Private.h in Headers */,
8BD87B881EFB131700269C2B /* STPSourceCardDetails+Private.h in Headers */,
8BD87B8D1EFB152B00269C2B /* STPSourceRedirect+Private.h in Headers */,
04CDB4D31A5F30A700B854EE /* Stripe.h in Headers */,
Expand Down Expand Up @@ -2359,6 +2388,8 @@
F152322A1EA9306100D65C67 /* NSURLComponents+Stripe.h in Headers */,
F1D3A25A1EB014BD0095BFA9 /* UIImage+Stripe.h in Headers */,
C124A17C1CCAA0C2007D42EE /* NSMutableURLRequest+Stripe.h in Headers */,
B3BDCAC820EEF22D0034F7F5 /* STPPaymentIntent.h in Headers */,
B3BDCACA20EEF22D0034F7F5 /* STPPaymentIntentEnums.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -2507,6 +2538,7 @@
files = (
F1343BEA1D652CAD00F102D8 /* Customer.json in Resources */,
8BD2133E1F045D31007F6FD1 /* SEPADebitSource.json in Resources */,
B3BDCADF20F0142C0034F7F5 /* PaymentIntent.json in Resources */,
8BD213371F044B57007F6FD1 /* BankAccount.json in Resources */,
C1C02CCC1ECCD0ED00DF5643 /* EphemeralKey.json in Resources */,
F1BA24211E57BECA00E4A1CF /* 3DSSource.json in Resources */,
Expand Down Expand Up @@ -2781,6 +2813,7 @@
0438EF4D1B741B0100D506CC /* STPPaymentCardTextFieldViewModelTest.m in Sources */,
8BD87B951EFB1CB100269C2B /* STPSourceVerificationTest.m in Sources */,
C124A1811CCAA1BF007D42EE /* NSMutableURLRequest+StripeTest.m in Sources */,
B3BDCACD20EEF4540034F7F5 /* STPPaymentIntentTest.m in Sources */,
C1EEDCC61CA2126000A54582 /* STPDelegateProxyTest.m in Sources */,
F1D777C01D81DD520076FA19 /* STPStringUtilsTest.m in Sources */,
C1FEE5991CBFF24000A7632B /* STPPostalCodeValidatorTest.m in Sources */,
Expand All @@ -2798,6 +2831,7 @@
C11810991CC6D46D0022FB55 /* NSDecimalNumber+StripeTest.m in Sources */,
8B5B4B441EFDD925005CF475 /* STPSourceOwnerTest.m in Sources */,
8B82C5CA1F2BC78F009639F7 /* STPApplePayPaymentMethodTest.m in Sources */,
B3BDCACF20EEF4640034F7F5 /* STPPaymentIntentFunctionalTest.m in Sources */,
8B013C891F1E784A00DD831B /* STPPaymentConfigurationTest.m in Sources */,
C1EEDCC81CA2172700A54582 /* NSString+StripeTest.m in Sources */,
8BD87B901EFB17AA00269C2B /* STPSourceRedirectTest.m in Sources */,
Expand Down Expand Up @@ -2913,6 +2947,7 @@
04F94DB41D229F71004FC826 /* STPPaymentActivityIndicatorView.m in Sources */,
C1BD9B251E393FFE00CEE925 /* STPSourceReceiver.m in Sources */,
04827D131D2575C6002DB3E8 /* STPImageLibrary.m in Sources */,
B3BDCAC320EEF2150034F7F5 /* STPPaymentIntent.m in Sources */,
045D712F1CF4ED7600F6CD65 /* STPBINRange.m in Sources */,
F148ABCA1D5D334B0014FD92 /* STPLocalizationUtils.m in Sources */,
045D71111CEEE30500F6CD65 /* STPAspects.m in Sources */,
Expand Down Expand Up @@ -2983,6 +3018,7 @@
C1BD9B2A1E39406C00CEE925 /* STPSourceOwner.m in Sources */,
F1DEB89B1E2074480066B8E8 /* STPCoreViewController.m in Sources */,
C1D7B5221E36C32F002181F5 /* STPSource.m in Sources */,
B3BDCAC220EEF2150034F7F5 /* STPPaymentIntent.m in Sources */,
049A3F8A1CC73C7100F57DE7 /* STPPaymentContext.m in Sources */,
C192269F1EBA9A0800BED563 /* STPCustomerContext.m in Sources */,
0426B9731CEAE3EB006AC8DD /* UITableViewCell+Stripe_Borders.m in Sources */,
Expand Down
17 changes: 17 additions & 0 deletions Stripe/PublicHeaders/STPAPIClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,23 @@ static NSString *const STPSDKVersion = @"13.0.3";

@end

#pragma mark Payment Intents

/**
Stripe extensions for working with PaymentIntent objects.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the docs for the other extension interface definitions in this file say "STPAPIClient extensions..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's actually a mix of extensions on STPAPIClient and on Stripe, which I didn't realize at first. Great catch, thanks!

*/
@interface STPAPIClient (PaymentIntents)

/**
Retrieves the PaymentIntent object using the given secret. @see https://stripe.com/docs/api#retrieve_payment_intent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link isn't working for me. Is it going to be soon?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found it :)


@param secret The client secret of the payment intent to be retrieved. Cannot be nil.
@param completion The callback to run with the returned PaymentIntent object, or an error.
*/
- (void)retrievePaymentIntentWithClientSecret:(NSString *)secret
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if there's less ambiguous vocabulary we can use so it's not confused with Stripe client secret? Or is it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the rest of our documentation uses this ambiguous vocabulary so nevermind :)

Copy link
Contributor

@joeydong-stripe joeydong-stripe Jul 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we're confident it's not going to change, maybe we can mention it starts with pi_* and assert for that fact before putting it on the network

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client_secret is a secret for working with a specific PaymentIntent or Source, and is different from the publishable key (or the secret key that should never be part of the SDK). (I think you figured this out, but commenting for posterity)

I'm still not sure what the right level of client-side protection is, vs encoding specifics about the current state of things.

completion:(STPPaymentIntentCompletionBlock)completion;
@end

#pragma mark URL callbacks

/**
Expand Down
9 changes: 9 additions & 0 deletions Stripe/PublicHeaders/STPBlocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@class STPSource;
@class STPCustomer;
@protocol STPSourceProtocol;
@class STPPaymentIntent;

/**
These values control the labels used in the shipping info collection form.
Expand Down Expand Up @@ -106,6 +107,14 @@ typedef void (^STPSourceCompletionBlock)(STPSource * __nullable source, NSError
*/
typedef void (^STPSourceProtocolCompletionBlock)(id<STPSourceProtocol> __nullable source, NSError * __nullable error);

/**
A callback to be run with a PaymentIntent response from the Stripe API.

@param paymentIntent The Stripe PaymentIntent from the response. Will be nil if an error occurs. @see STPPaymentIntent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to specifically say STPPaymentIntent.h here like you did for StripeError.h? I'm just imagining this from a very unaware perspective.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK? I was following the pattern of every other callback here.

I think this is reasonable, because it's saying "see STPPaymentIntent" (the class), vs "see the values in StripeError.h" (the header with a bunch of values).

@param error The error returned from the response, or nil in one occurs. @see StripeError.h for possible values.
Copy link
Contributor

@joeydong-stripe joeydong-stripe Jul 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if* none* occurs

looks like similar typos elsewhere in this file

*/
typedef void (^STPPaymentIntentCompletionBlock)(STPPaymentIntent * __nullable paymentIntent, NSError * __nullable error);

/**
A callback to be run with a validation result and shipping methods for a
shipping address.
Expand Down
98 changes: 98 additions & 0 deletions Stripe/PublicHeaders/STPPaymentIntent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//
// STPPaymentIntent.h
// Stripe
//
// Created by Daniel Jackson on 6/27/18.
// Copyright © 2018 Stripe, Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "STPAPIResponseDecodable.h"
#import "STPPaymentIntentEnums.h"

NS_ASSUME_NONNULL_BEGIN

/**
A PaymentIntent tracks the process of collecting a payment from your customer.

@see https://stripe.com/docs/api#payment_intents
@see https://stripe.com/docs/payments/dynamic-authentication
*/
@interface STPPaymentIntent : NSObject<STPAPIResponseDecodable>

/**
You cannot directly instantiate an `STPPaymentIntent`. You should only use one that
has been returned from an `STPAPIClient` callback.
*/
- (instancetype)init __attribute__((unavailable("You cannot directly instantiate an STPPaymentIntent. You should only use one that has been returned from an STPAPIClient callback.")));

/**
The Stripe ID of the PaymentIntent.
*/
@property (nonatomic, readonly) NSString *stripeId;

/**
The client secret used to fetch this PaymentIntent
*/
@property (nonatomic, readonly) NSString *clientSecret;

/**
The amount associated with the PaymentIntent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our doc has a better sounding description to me: "Amount intended to be collected by this PaymentIntent."

*/
@property (nonatomic, readonly) NSNumber *amount;

/**
If status is canceled, when the PaymentIntent was canceled.
Copy link
Contributor

@joeydong-stripe joeydong-stripe Jul 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"If status is STPPaymentIntentStatusCanceled, when the PaymentIntent was canceled."?

*/
@property (nonatomic, nullable, readonly) NSDate *canceledAt;

/**
Capture method of this PaymentIntent
*/
@property (nonatomic, readonly) STPPaymentIntentCaptureMethod captureMethod;

/**
Confirmation method of this PaymentIntent
*/
@property (nonatomic, readonly) STPPaymentIntentConfirmationMethod confirmationMethod;

/**
When the PaymentIntent was created.
*/
@property (nonatomic, nullable, readonly) NSDate *created;

/**
The currency associated with the PaymentIntent.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our docs nicely mention it's the ISO currency code, I wonder if we mention that elsewhere we reference currency:

"Three-letter ISO currency code, in lowercase. Must be a supported currency."

https://www.iso.org/iso-4217-currency-codes.html
https://stripe.com/docs/currencies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks mixed. Most headers that have a currency don't provide more details, but a couple do. Similarly, we don't explain amount being the smallest currency unit in most places that have an amount.

I think it's reasonable to elide this

*/
@property (nonatomic, readonly) NSString *currency;

/**
The `description` field of the PaymentIntent.
An arbitrary string attached to the object. Often useful for displaying to users.
*/
@property (nonatomic, nullable, readonly) NSString *stripeDescription;

/**
Whether or not this PaymentIntent was created in livemode.
*/
@property (nonatomic, readonly) BOOL livemode;

/**
Email address that the receipt for the resulting payment will be sent to.
*/
@property (nonatomic, nullable, readonly) NSString *receiptEmail;

/**
The Stripe ID of the Source used in this PaymentIntent.
*/
@property (nonatomic, nullable, readonly) NSString *sourceId;

/**
Status of the PaymentIntent
*/
@property (nonatomic, readonly) STPPaymentIntentStatus status;

@end

NS_ASSUME_NONNULL_END
94 changes: 94 additions & 0 deletions Stripe/PublicHeaders/STPPaymentIntentEnums.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
//
// STPPaymentIntentEnums.h
// Stripe
//
// Created by Daniel Jackson on 6/27/18.
// Copyright © 2018 Stripe, Inc. All rights reserved.
//

/**
Status types for an STPPaymentIntent
*/
typedef NS_ENUM(NSInteger, STPPaymentIntentStatus) {
/**
Unknown status
*/
STPPaymentIntentStatusUnknown,

/**
This PaymentIntent requires a Source
*/
STPPaymentIntentStatusRequiresSource,

/**
This PaymentIntent needs to be confirmed
*/
STPPaymentIntentStatusRequiresConfirmation,

/**
The selected Source requires additional authentication steps.
Additional actions found via `next_source_action`
*/
STPPaymentIntentStatusRequiresSourceAction,

/**
Stripe is processing this PaymentIntent
*/
STPPaymentIntentStatusProcessing,

/**
The payment has succeeded
*/
STPPaymentIntentStatusSucceeded,

/**
Indicates the payment must be captured, for STPPaymentIntentCaptureMethodManual
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Indicates the payment must be captured. The captureMethod is also set to STPPaymentIntentCaptureMethodManual."?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess what you have is fine, I'm just wondering what's the intention behind having a separate captureMethod field and if we can communicate that reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

captureMethod might be interesting to the app's business logic even when the status is not .requiresCapture, but yeah, I'm not sure how this is most likely to be used. Primarily just exposing what exists in the API.

*/
STPPaymentIntentStatusRequiresCapture,

/**
This PaymentIntent was canceled and cannot be changed.
*/
STPPaymentIntentStatusCanceled,
};

/**
Capture methods for a STPPaymentIntent
*/
typedef NS_ENUM(NSInteger, STPPaymentIntentCaptureMethod) {
/**
Unknown capture method
*/
STPPaymentIntentCaptureMethodUnknown,

/**
The PaymentIntent will be automatically captured
*/
STPPaymentIntentCaptureMethodAutomatic,

/**
The PaymentIntent must be manually captured once it has the status
`STPPaymentIntentStatusRequiresCapture`
*/
STPPaymentIntentCaptureMethodManual,
};

/**
Confirmation methods for a STPPaymentIntent
*/
typedef NS_ENUM(NSInteger, STPPaymentIntentConfirmationMethod) {
/**
Unknown confirmation method
*/
STPPaymentIntentConfirmationMethodUnknown,

/**
Confirmed via publishable key
*/
STPPaymentIntentConfirmationMethodPublishable,

/**
Confirmed via secret key
*/
STPPaymentIntentConfirmationMethodSecret,
};
2 changes: 2 additions & 0 deletions Stripe/PublicHeaders/Stripe.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#import "STPPaymentCardTextField.h"
#import "STPPaymentConfiguration.h"
#import "STPPaymentContext.h"
#import "STPPaymentIntent.h"
#import "STPPaymentIntentEnums.h"
#import "STPPaymentMethod.h"
#import "STPPaymentMethodsViewController.h"
#import "STPPaymentResult.h"
Expand Down
Loading