Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

After upgrading to 9.1.3 createTokenWithBankAccount() not working #809

Closed
RajeshRam opened this issue Jul 16, 2021 · 4 comments
Closed

After upgrading to 9.1.3 createTokenWithBankAccount() not working #809

RajeshRam opened this issue Jul 16, 2021 · 4 comments

Comments

@RajeshRam
Copy link

RajeshRam commented Jul 16, 2021

Problem

After upgrading to 9.1.3 ('com.stripe:stripe-android:16.10.0' ) the createTokenWithBankAccount() is not working. I find it missing in the stripe module. I am using it to create token for bank account.
I am stuck at it. It will be an immense help if anyone provide a solution.
Expecting a release with the fix.

@sebber
Copy link

sebber commented Jul 21, 2021

I found that the implementation of createTokenWithBankAccount for android was removed a while ago, I assume because of breaking changes to the Stripe SDK earler where this library converted the params to a BankAccount and in stripe-android they changed it to a BankAccountTokenParams.

I've just tried a rewrite now though and and gotten it working in my stripe testing environment at least, so I'll try to submit a PR for it soon I hope.

@RajeshRam
Copy link
Author

Hi, Any update on this issue?

@MachochinLopez
Copy link

MachochinLopez commented Jan 18, 2022

Hey guys, I faced the same issue for this and also with the createTokenWithCard method. I didn't had the time to refactor the whole Bank Account process in my project with another library. So I added a quick fix on the following files on the android project:

  • StripeModule.java
  • Converters.java

May not be the best but since it seems like this repo is no longer being maintained I hope this helps people in the same situation as me.

Edited the createTokenWithBankAccount and the createTokenWithCard method in StripeModule.java as follows:

@ReactMethod
public void createTokenWithCard(final ReadableMap cardData, final Promise promise) {
  try {
    ArgCheck.nonNull(mStripe);
    ArgCheck.notEmptyString(mPublicKey);

    mStripe.createCardToken(
      createCard(cardData),
      new ApiResultCallback<Token>() {
        public void onSuccess(Token token) {
          promise.resolve(convertTokenToWritableMap(token));
        }
        public void onError(Exception error) {
          error.printStackTrace();
          promise.reject(toErrorCode(error), error.getMessage());
        }
      });
  } catch (Exception e) {
    promise.reject(toErrorCode(e), e.getMessage());
  }
}

@ReactMethod
public void createTokenWithBankAccount(final ReadableMap accountData, final Promise promise) {
  try {
    ArgCheck.nonNull(mStripe);
    ArgCheck.notEmptyString(mPublicKey);

    mStripe.createBankAccountToken(
      createBankAccount(accountData),
      new ApiResultCallback<Token>() {
        public void onSuccess(Token token) {
          promise.resolve(convertTokenToWritableMap(token));
        }
        public void onError(Exception error) {
          error.printStackTrace();
          promise.reject(toErrorCode(error), error.getMessage());
        }
      }
    );
  } catch (Exception e) {
    promise.reject(toErrorCode(e), e.getMessage());
  }
}

And added the following method on Converters.java

 public static BankAccountTokenParams createBankAccountWithParams(ReadableMap accountData) {
    BankAccountTokenParams account = new BankAccountTokenParams(
      accountData.getString("countryCode"),
      accountData.getString("currency"),
      accountData.getString("accountNumber")
    );

    return account;
  }

NOTE: I only added the obligatory fields, in case you are going to need the accountHolderType, accountHolderName or any of the other optional fields, you'll have to implement them yourself. Those didn't apply on my case so I only added the ones I was using (the obligatory ones).

I followed the example of the previous version of the repo (when the createBankAccount method existed) and the createCard method, when it included the createBankAccount method in Converters.java. I only updated it with the new BankAccountWithParams model.

I think this is really similat to what was actually done in the implementation tasks mentioned above, but they aren't merged yet

@fbartho
Copy link
Collaborator

fbartho commented Jun 20, 2023

Closing this ticket, so that new users don't think this project is still active.

Stripe does not want you using this, and you will find pain if you do; Please migrate to the official @stripe/stripe-react-native package, for your user's safety, and your developer's sanity!

See more: #842

@fbartho fbartho closed this as completed Jun 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants