Giter VIP home page Giter VIP logo

Comments (15)

joshbartley avatar joshbartley commented on August 18, 2024 1

Not sure where to document things like this, latest 2.0.0 release metadata to hide the IParcelableCreator classes/interfaces since Java supports covariant return interfaces and c# doesn't. First one fixes the return type, 2nd set just removes the creator classes.

Stripe team, if this is better in a wiki or a GIST let me know.

<metadata>
  <!--
  This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
  <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
  /api/package[@name='com.stripe.stripeterminal']/interface[@name='Callback']
  This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
  <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
-->

  <attr
    path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='PaymentMethod.Creator']/method[@name='createFromParcel' and count(parameter)=1 and parameter[1][@type='android.os.Parcel']]"
    name="managedReturn">
    Java.Lang.Object
  </attr>


  <attr
      path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='PaymentMethod.Creator']/method[@name='newArray' and count(parameter)=1 and parameter[1][@type='int']]"
      name="managedReturn">
    Java.Lang.Object[]
  </attr>

  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.api']/class[@name='ApiError.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='Address.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='CardDetails.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='CardOptions.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='CardPresentDetails.Creator']"/>
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='Charge.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='Location.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='PaymentIntent.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='PaymentMethodDetails.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='PaymentMethodOptions.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='ReceiptDetails.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='RedirectUrl.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='Refund.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='SetupAttempt.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='SetupError.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='SetupIntent.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='SetupIntentCardPresentDetails.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='SetupIntentNextAction.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.models']/class[@name='SetupIntentPaymentMethodDetails.Creator']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.external.serialization']/class[@name='InnerError.Creator']" />  
</metadata>

`

from stripe-terminal-android.

joshbartley avatar joshbartley commented on August 18, 2024

I wrote a Java library to wrap the Callback interface to work around the compiler issue. Using the latest version of Xamarin, since lambdas are used, the d8 compiler messes up something and the init terminal call throws a ClassNotFoundException from DexPathList. At this time, I can't see a way to have this library work with a Xamarin application.

from stripe-terminal-android.

joshbartley avatar joshbartley commented on August 18, 2024

I started a brand new Xamarin project, and that took care of most of the d8 issues. Pulled in all the dependencies.

Now the biggest hangup is that ErrorCallback is not public. DiscoverReaders and ReaderCallback extending that messes up the Xamarin linker, which either drops them from the C# binding, or throws an error. Making it officially public would allow them all to work without having to write a Java wrapper class around the library to get it working with C#, which is what I'm doing at the moment.

from stripe-terminal-android.

danwaters-stripe avatar danwaters-stripe commented on August 18, 2024

Thanks for the feedback. We're excited you're writing Xamarin bindings! We'll be sure to make ErrorCallback public in our next release to help you out. Would you be able to share your work with us / make the bindings open-source so that we can make sure we're supporting this use case in the future?

from stripe-terminal-android.

joshbartley avatar joshbartley commented on August 18, 2024

Most likely yes. Right now everything is prefixed with our company initials to get a demo going. I'm going back and forth between this and the iOS version. The second hardest part of the bindings was getting the dependencies because the Gradle plugin for Visual Studio 2019 seems to be broken, and those had to be pulled in manually. If I can get through the payment intent and reader update, I can see if there is any other interfaces that need to be updated to make things eaiser.

from stripe-terminal-android.

joshbartley avatar joshbartley commented on August 18, 2024

The b8 release fixed a lot of the issues with the Xamarin bindings. About 2 lines of configuration to switch things around in the binding library (very minor) and was able to get a successful payment through Xamarin using b8. I have to work on the iOS side, which may take a bit to have a common C# interface against the Android model and iOS model since Swift has a style different than the java side.

from stripe-terminal-android.

danwaters-stripe avatar danwaters-stripe commented on August 18, 2024

Great! Glad to hear it.

from stripe-terminal-android.

Xandroid4Net avatar Xandroid4Net commented on August 18, 2024

@joshbartley do you have any tips on how to wrap this stripe sdk? I am trying to do the same thing but I keep getting the error below. I have added the kotlin xamarin library. I am using classparse in vs 2019.
Error "generator.exe" exited with code -1073741819

from stripe-terminal-android.

joshbartley avatar joshbartley commented on August 18, 2024

@Xandroid4Net I'll need more details as to what the error is or more build output, and likely a different issue then the one in this thread. Once the private interfaces were marked public I didn't have any issues generating the binding library using VS 2019.

from stripe-terminal-android.

Xandroid4Net avatar Xandroid4Net commented on August 18, 2024

@joshbartley I am not sure how to contact you directly. I tried a new project with just the stripe library aar and tried to build and got the same generator error. Do you know how to get a more detailed build output? Or would you be willing to share your project in a github repo?

from stripe-terminal-android.

chris-oswald avatar chris-oswald commented on August 18, 2024

@joshbartley I would like to second this question from @Xandroid4Net . Were you able to get the release version of the andriod library to build for Xamarin with Kotlin included? The beta version didn't include Kotlin and we were able to get that to build, but not the release version.

from stripe-terminal-android.

joshbartley avatar joshbartley commented on August 18, 2024

@Xandroid4Net I never had luck with the .aar file. I had to unzip it, pull in each .jar as a separate reference. Then look up the dependencies of each .jar on the Maven Repository to be able to pull them down. I have not tried the latest version, but I do need to update our app as we have some people interested in it again.

from stripe-terminal-android.

chris-oswald avatar chris-oswald commented on August 18, 2024

@joshbartley The best I can tell is Stripe has rolled their own versions of Kotlin, okhttp3, okio, in the BBPOSSDK, which is a dependency in the terminal AAR file. The initial release wasn't bloated with all that stuff. I think they should have used a reference. I don't really understand why they went down this new route because now creating the bindings is a nightmare. I'd love a second opinion. @danwaters-stripe

image

from stripe-terminal-android.

joshbartley avatar joshbartley commented on August 18, 2024

It's a common pattern for hardware SDKs, Even the AWS SDKs do these for some dependencies.

from stripe-terminal-android.

joshbartley avatar joshbartley commented on August 18, 2024

@chris-oswald you have to provide details and I think this method of communicating on an old thread is not ideal. You say you are getting a java error, you should provide those full details. This likely either needs a new thread or moved to StackOverflow.

I just tried the 1.0.0 version and was able to get it to compile with a minimal metadata file. I believe some of these may even be duplicates and could be reduced further.

  <remove-node path="/api/package[@name='com.stripe.stripeterminal']/interface[@name='TerminalComponent']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.rpc']/class[@name='ProxyTrace']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.rpc']/class[@name='ReportTraceRequest']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.rpc']/class[@name='ReportEventRequest']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal']/class[@name='TerminalSession']/method[@name='setRpcSessionToken' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal']/class[@name='TerminalSession']/method[@name='setAccountId' and count(parameter)=1 and parameter[1][@type='java.lang.String']]" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.log']/class[@name='Event.Companion']" />
  <remove-node path="/api/package[@name='com.stripe.stripeterminal.log']/class[@name='Log']" />
  <attr path="/api/package[@name='com.stripe.stripeterminal']/class[@name='Terminal']" name="managedName">StripeTerminal</attr>
`

from stripe-terminal-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.