Skip to content
New issue

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

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

Already on GitHub? # to your account

Create payment method from card with all available fields #61

Closed
diegogarciar opened this issue Jun 27, 2020 · 13 comments
Closed

Create payment method from card with all available fields #61

diegogarciar opened this issue Jun 27, 2020 · 13 comments
Labels
enhancement New feature or request

Comments

@diegogarciar
Copy link

Hello,
I noticed on my dashboard that the address was not being collected even though I added it to the card object from which I created a payment method.

I did some research and it seems you are not using all the fields when creating a payment method on card.dart

 Map<String, dynamic> toPaymentMethod() {
    Map<String, dynamic> map = {
      'type': 'card',
      'card': {
        FIELD_NUMBER: number,
        FIELD_CVC: cvc,
        FIELD_EXP_MONTH: expMonth,
        FIELD_EXP_YEAR: expYear,
      },
      'billing_details': {
        FIELD_NAME: name,
      }
    };

Could you add all the remaining billing fields?

'billing_details': {
        FIELD_NAME: name,
        "address": {
          "city": addressCity,
          "country": addressCountry,
          'line1' :addressLine1
          'line2' :addressLine2
          "postal_code" : addressZip
          "state": addressState
        }
      }
@cch504
Copy link

cch504 commented Jul 17, 2020

+1, Is there a reason why this was omitted in the first place?

@ezet
Copy link
Owner

ezet commented Jul 22, 2020

Oversight on my part :) Will fix this in the next version

@ezet
Copy link
Owner

ezet commented Jul 22, 2020

Looking at this again, I don't think the "card" model should contain anything related to billing. If you want to add additional billing details, use createPaymentMethod instead of createPaymentMethodFromCard.

@ezet ezet closed this as completed Jul 22, 2020
@diegogarciar
Copy link
Author

So are you also removing the address fields from StripeCard?

@diegogarciar
Copy link
Author

what about the name? that is also related to billing...

@ezet
Copy link
Owner

ezet commented Jul 22, 2020

Yes, I'm thinking that would be the cleanest way to do it. That would avoid future misunderstandings, and I'll also add documentation stating that any additional information should be added to the map before submission if required.

Yes, the name as well. Neither the name nor any other billing details are required for cards, as this is usually present on the customer the card belongs to. Providing a separate billing address or name for a specific card is an edge case, and it seems reasonable to let developers add this themselves if required.

All you need to do is basically:

var data = card.toPaymentMethod();
data['billing_details'] = yourCollectedBillingDetails;
stripe.api.createPaymentMethod(data);

@ezet
Copy link
Owner

ezet commented Jul 22, 2020

Will the above solve your issue? Or do you think this is the wrong approach?

@diegogarciar
Copy link
Author

Yeah that solves it, I would just suggest that you remove the extra fields on StripeCard to avoid future confusions.
I'll prepare my code from now so the fields are still sent when the change occurs...

As background, I wanted to collect the ZIP code as I was receiving to many declines from banks, I thought I was adding it but I was unaware of this bug so declines continued, after overriding your code and adding the zip code, I think declines went to 0.

@ezet
Copy link
Owner

ezet commented Jul 22, 2020

That's interesting. We're using stripe in large scale, and have had 0 declines due to missing zip codes. Could it be that your customer objects are also missing zip codes? Granted, it might vary between countries/regions. I might look at adding billing details later through a different mechanism, but it doesn't strictly relate to the card model.

I also want to keep the library as lightweight and flexible as possible in order to reduce the amount of maintenance required due to API changes. That's why I want to avoid defining the payloads in the library, and rather let that be controlled by the developers, in case something changes.

@diegogarciar
Copy link
Author

Yes seems reasonable... And I'm not saving any address details to my customers as my guess is that only the payment method info is sent to the bank. For declines, banks will not say motives and just say charge seemed fraudulent, but adding the zip code as I've seen some other companies do seemed to make banks happy. (I'm using stripe Mexico)

@ezet
Copy link
Owner

ezet commented Jul 22, 2020

You are probably right. Will keep that in mind, maybe I can add better support for this somehow, outside of the card model. Thanks for your feedback! 👍

@ezet ezet reopened this Nov 6, 2020
@ezet ezet added the enhancement New feature or request label Nov 6, 2020
ezet added a commit that referenced this issue Nov 12, 2020
Add postal code to StripeCard.toPaymentMethod()
Fix misc issues with CardForm

Fix #61
@ezet ezet closed this as completed in 966e65c Nov 13, 2020
@diegogarciar
Copy link
Author

Nice! Should we add to that map the cardholder name?

@ezet
Copy link
Owner

ezet commented Nov 13, 2020

You will still have to add cardholder name manually, at least for now. The official Stripe SDK for android now also collects the postal code, but not the cardholder name, and I'm just following suit. If you are able, you could maybe look into if the official SDKs uses the logged in customers name as the cardholder name? But until then, cardholder is not provided automatically.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants