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

Fix PayPal payments #1341

Merged
merged 6 commits into from
Oct 31, 2023
Merged

Fix PayPal payments #1341

merged 6 commits into from
Oct 31, 2023

Conversation

JonasWanke
Copy link
Contributor

Fixes: #1211

The serialization of MandateDataCustomerAcceptance was incorrect: In Stripe's API, it corresponds to a sealed union representing an online or an offline mandate. In Stripe's Android SDK, it's modelled the same way, though only online is supported. To maintain backwards compatibility, I kept the existing class structure and only added custom fromJson(…) and toJson(…) implementations, though a cleaner design would probably be a named constructor MandateDataCustomerAcceptance.online(…).

The other problem was that PaymentMethodType was missing a PayPal variant, meaning the native SDK's result message couldn't be parsed.

Now, payment and setup intents for subscriptions in Stripe are working for us both on Android and iOS with the following parameters:

const params = PaymentMethodParams.payPal(
  paymentMethodData: PaymentMethodData(
    mandateData: MandateData(
      customerAcceptance: MandateDataCustomerAcceptance(
        ipAddress: MandateDataOnlineData(
          ipAddress: '127.0.0.1',
          userAgent: 'device',
        ),
      ),
    ),
  ),
);

@remonh87
Copy link
Member

@JonasWanke thanks for the pr. Can you run dart format in your pr so we do not see the formatting changes in your pr?

@JonasWanke
Copy link
Contributor Author

Hi @remonh87, I just ran dart format ., but it only changed another file. The first commit I pushed (495a7fa) was the result of running build_runner, which already changed the files. I'm guessing that either some formatting behavior changed or they were otherwise formatted differently before, since both the build_runner and dart format agree on the current formatting

Copy link
Member

@remonh87 remonh87 left a comment

Choose a reason for hiding this comment

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

thanks

@bonnyfone
Copy link

thanks for the fix! any timeline for when it will be published on pub.dev?

@artemsorochan
Copy link

Any timeline on publishing a new version with this MR would be appreciated. Thanks in advance!

@artemsorochan
Copy link

Any update on this?

@remonh87 remonh87 merged commit c0ec7d7 into flutter-stripe:main Oct 31, 2023
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PayPal payments do not work
4 participants