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 support for PaymentMethod #806

Merged
merged 1 commit into from Mar 19, 2019
Merged

Conversation

remi-stripe
Copy link
Contributor

cc @stripe/api-libraries

charge.go Outdated

// PaymentMethodDetailsCardWallet represents the details of the card wallet if this Card
// PaymentMethod is part of a card wallet.
type PaymentMethodDetailsCardWallet struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

@remi-stripe should this be prefixed with ChargeXXX like other structs too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it should, nice catch.

paymentmethod.go Outdated
// PaymentMethodTransferDataParams is the set of parameters allowed for the transfer_data hash.
type PaymentMethodTransferDataParams struct {
Destination *string `form:"destination"`
}

Choose a reason for hiding this comment

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

I think this is unintentional—this struct doesn't appear to be used anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes bad copy paste, fixed (won't push while you review)

@remi-stripe remi-stripe force-pushed the remi-add-payment-method branch 4 times, most recently from 02a083e to 00f558e Compare March 14, 2019 04:45
@@ -114,14 +114,16 @@ type PaymentIntentListParams struct {

// PaymentIntentLastPaymentError represents the last error happening on a payment intent.
type PaymentIntentLastPaymentError struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically, this should be Error right? Is it worth changing this and releasing as a major version to be cleaner?

@remi-stripe remi-stripe force-pushed the remi-add-payment-method branch 3 times, most recently from faa9ef8 to 6e68eb4 Compare March 16, 2019 04:45
@remi-stripe
Copy link
Contributor Author

Okay, this should now be feature complete and ready for review.

There is one test failing, TestTokenNew_SharedCustomerBankAccount and it's because of a change in openapi which does not expect bank_account to be a string even though it can be. cc @mickjermsurawong-stripe as this is likely due to a change in our codebase for stripe-java autogeneration.

r? @brandur-stripe

Copy link
Contributor

@mickjermsurawong-stripe mickjermsurawong-stripe left a comment

Choose a reason for hiding this comment

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

Since I reviewed stripe-java against the autogen for schema correctness, it might be easier for me to review stripe-go here too. I reviewed both resource and params here. The params look good to me.

charge.go Outdated

// ChargePaymentMethodDetailsBancontact represents details about the Bancontact PaymentMethod.
type ChargePaymentMethodDetailsBancontact struct {
AccountHolderType BankAccountAccountHolderType `json:"account_holder_type"`
Copy link
Contributor

Choose a reason for hiding this comment

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

whoops i think we accidentally duplicated that from AchDebit here.
Bancontact should have bank_code, bank_name, bic.. and

charge.go Outdated

// ChargePaymentMethodDetailsEps represents details about the EPS PaymentMethod.
type ChargePaymentMethodDetailsEps struct {
Reference string `json:"reference"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we no longer want reference?
It's not in apiRefs anymore: /docs/api/charges/object#charge_object-payment_method_details-eps

SepaDebit *ChargePaymentMethodDetailsSepaDebit `json:"sepa_debit"`
Sofort *ChargePaymentMethodDetailsSofort `json:"sofort"`
StripeAccount *ChargePaymentMethodDetailsStripeAccount `json:"stripe_account"`
Wechat *ChargePaymentMethodDetailsWechat `json:"wechat"`
Copy link
Contributor

Choose a reason for hiding this comment

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

ah we might be missing type field here

// is part of a card wallet.
type PaymentMethodCardWallet struct {
DynamicLast4 string `json:"dynamic_last4"`
Type PaymentMethodCardWalletType `json:"type"`
Copy link
Contributor

Choose a reason for hiding this comment

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

We miss non-empty visa_checkout, master_pass structs here.
docs/api/payment_methods/object#payment_method_object-card-wallet-masterpass
and
docs/api/payment_methods/object#payment_method_object-card-wallet-visa_checkout
Do we also want to include the empty structs like google_pay and samsung_pay like in java and dotnet?

@remi-stripe
Copy link
Contributor Author

@mickjermsurawong-stripe Thanks a lot for the thorough review. I can't believe after all the back and forth I did on those PRs I still missed the wallet fields on Charge. I fixed everything you found I think. PTAL!

@mickjermsurawong-stripe
Copy link
Contributor

thanks remi for the fix!
LGTM

@mickjermsurawong-stripe
Copy link
Contributor

ah the test is failing on /v1/tokens as it is trying to create bank account token with a token.
My change on typed param work requires only the bank_account object instead of hash.
But the failing test here is a valid use case we want to support? I can add this back to support string token as well. @remi-stripe

func TestTokenNew_SharedCustomerBankAccount(t *testing.T) {
	params := &stripe.TokenParams{
		BankAccount: &stripe.BankAccountParams{
			ID: stripe.String("ba_123"),
		},
		Customer: stripe.String("cus_123"),
	}
	params.SetStripeAccount("acct_123")
	token, err := New(params)
	assert.Nil(t, err)
	assert.NotNil(t, token)
}

@remi-stripe
Copy link
Contributor Author

You can ignore that failing test, it's being fixed in another PR in parallel I just didn't want to duplicate the work

Copy link
Contributor

@brandur-stripe brandur-stripe left a comment

Choose a reason for hiding this comment

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

LGTM as well Remi.

PaymentMethodCardBrandMastercard PaymentMethodCardBrand = "mastercard"
PaymentMethodCardBrandUnionpay PaymentMethodCardBrand = "unionpay"
PaymentMethodCardBrandVisa PaymentMethodCardBrand = "visa"
PaymentMethodCardBrandUnknown PaymentMethodCardBrand = "unknown"
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor alphabetization problem here: unknown should be above visa.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, fixed

@remi-stripe
Copy link
Contributor Author

I had to remove a test because we don't support bank_account: "ba_123" when creating tokens anymore. cc @mickjermsurawong-stripe

@remi-stripe remi-stripe changed the title [WIP]Add support for PaymentMethod Add support for PaymentMethod Mar 19, 2019
@mickjermsurawong-stripe
Copy link
Contributor

LGTM

@remi-stripe remi-stripe merged commit 405d49f into master Mar 19, 2019
@remi-stripe remi-stripe deleted the remi-add-payment-method branch March 19, 2019 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants