How can i get bank information from source? - stripe-payments

I have liked a online bank with plaid API to stripe. i have created a stripe customer with source bank token. But later I couldn't get bank information from source. It is showing
An uncaught Exception was encountered
Type: Stripe\Error\InvalidRequest
Message: No such source: btok_1BOiMhGnklINT0gr7TYCRuvO

This error means that the API key you used to make the second API call is not from the Stripe account you linked to your Plaid account and also not the same you used when creating the customer. I'd recommend checking the API keys in both of your scripts.
Also once you fix this part, you should not reuse the token in subsequent calls as it would have been consumed by the customer creation call. You need to use the bank account id that was created instead (ba_xxx).

Related

Stripe - Any way to migrate off older Charges API (Subscriptions) without creating a Customer beforehand?

I am updating my billing page which used Stripe JS V2 tokens and the Charges API (Subscriptions). The new(er) Payment Element looks slick from a future proofing standpoint, but am I understanding it correctly that the Customer object must be created prior to populating the payment form?
I only create the Customer once the payment token is obtained and a user has a clear intent to purchase after evaluating during a trial period. Otherwise my Stripe Dashboard is overrun with "empty" trial users that never sign up (I only have around a 10% signup rate from account creation). I guess this is mostly just a personal peeve, but I also just don't like to share user data and figured this way I would only be sharing with a third party once they become actual customers of mine.
Since a Subscription cannot be created without providing a Customer as part of the required parameters, am I stuck using the Card Element and the older Charges API if I don't create a Customer for every user in my system?
You really should just create a Customer up front. It will be required if you want to use trials with Subscriptions and will be cleaner in the long run.
For a workaround, which I would not overall recommend, you could use a SetupIntent with Payment Element to collect the customer's payment method without actually creating a Customer object. Then you can later create the Customer object and attach the PaymentMethod that was previously collected and then create the Subscription.

Plaid + Stripe ACH (Developer Mode): Do I need to use a stripe production key

Short story, I am able to successfully use the Plaid API (connected to my stripe account) to get a stripe bank token in sandbox mode.
From there, I can add that bank token to a customers profile in my stripe account (again in test mode).
Now I'm trying to use the plaid developer key instead of sandbox. I'm able to verify my real world bank account via plaid and get a bank token back, but when i try to add that token to my stripe account I get the following error:
Invalid Request: No such token: 'btok_xxxxxxxxxxxDequ'; a similar object exists in live mode, but a test mode key was used to make this request.
This seems to indicate when calling the Stripe API I need to use the production stripe key instead of the test key.
Since stripe doesn't have a "developer" mode like plaid, my question is what happens if I do this? Does the bank account get added to a real customer account (I assume it does).
AND if I attempt to make a charge using this bank token I got back from plaid via developer mode, will this make an actual charge in stripe? or does stripe know the difference and not make an actual charge (withdrawal) for my bank account?
I tried to go through plaid documentation, but there is very little information I could extract about the developer mode.
Thank you for any help you guys can provide.

Stripe - Create subscriptions with a customer with PaymentMethod instead of Source (Token)

I'm integrating Stripe Subscriptions in our workflow, but when creating a subscription with a Customer created with a paymentMethod instead of source I receive the error This customer has no attached payment source.
If I call in the browser createToken() and attach it to the customer in the source field it works.
We integrated one-time payments using the new docs with SCA that use createPaymentMethod() and not createToken(), so our customers are saved with paymentMethod, not source, like explained here:
https://stripe.com/docs/payments/cards/saving-cards-after-payment#save-payment-method
curl https://api.stripe.com/v1/customers \
-u sk_test_secret_token \
-d payment_method="{{PAYMENT_METHOD_ID}}"
Furthermore, in the migration guide it says to replace createToken() with createPaymentMethod().
In Scenario 2: Charging customers off-session for their initial payment, I saw the following:
To create subscriptions and charge customers off-session for their
initial payment, you need to:
1) Use CreatePaymentMethod to collect payment information
2) Create a customer using the ID of the PaymentMethod you created
3) Create the subscription
4) Set up error handling using handleCardSetup for authentication failures and handleCardPayment for authorization failures
I followed those steps. I don't create a SetupIntent (just like I don't create it in one-time payments and it works in these cases), and receive the error I said before when trying to create subscriptions.
Is it possible to create subscriptions with a customer with paymentMethod instead of source?
(We reuse cards using the customers created with paymentMethod for one-time payments, so it would be very important to be able to reuse the same customer/card for subscriptions, without the need for the user input data in stripe elements or anything of the sort, because it would break our flow for reusing cards)
I was able to solve it by including the payment method in the field default_payment_method.
This field is described as follows:
ID of the default payment method for the subscription. It must belong
to the customer associated with the subscription. If not set, invoices
will use the default payment method in the customer’s invoice
settings.
So I assumed that it would use the payment method I associated with the customer when not defined. It seems it is not happening, tough, so I needed to pass it explicitly (is it a Stripe bug? or creating the customer with paymentMethod doesn't make it the default payment method in the customer’s invoice settings? I will contact Stripe to make sure).
Update (2019-09-23)
I contacted Stripe asking if this was a bug and they replied:
[...] With that being said though, this wouldn't be a bug on our end, rather
expected behavior.
If you're wanting for the Payment Method that you're adding to the
customer object to be used on subscriptions, or invoices, by default
without specifying the default_payment_method when creating the
subscription then you would want to attach the Payment Method and
specify the invoice_settings.default_payment_method parameter when
updating the customer. This information can be found within our API
reference here:
https://stripe.com/docs/api/payment_methods/attach
The parameter to use when updating this can be found on the customer
object itself, here:
https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
This can also be specified upon customer creation, which can be seen
here:
https://stripe.com/docs/api/customers/create#create_customer-invoice_settings-default_payment_method
Specifying this parameter would indicate that the card being added
would be the default for subscriptions, as well as invoices, so that
the default_payment_method wouldn't need to be specified upon the
subscription, or invoice, creation.

How to verify a Stripe Connect, Account Deactivated web-hook?

With all other web-hooks one can use an account's stripe access token to retrieve the event and then update based on the response of the API call, thus preventing possible spoofing. But with account deactivated, one is no longer able to use that account's stripe access token since the account is deactivated. Any other suggestions? Basic auth is a no-go since each account can see the webhook url.
Stripe returns an error when you attempt to retrieve that event but that error is specific to this situation. You'll get an authentication_error if you attempt to retrieve it while if your weren't connected before you'd get invalid_request_error.
You can see an example in Ruby in this connect app here

Stripe usage with token

I am using Stripe for payment for the first time. While clicking on Pay button when we enter email, card number, date and cvc, I get an error message which asks me to activate my account. I learned that it takes all this information and returns a token which we can save in the database. How do I get a token in return?
thanks for thinking of using Stripe! I work on Support there and can help.
If you're getting that error message about activating your account, it's probably because you're using live keys but don't have a live, active account yet. If you email into Stripe support using the email address associated with your Stripe account, I could look into this for you further (e.g., looking at your logs and status).
As for the token, the token is a short-term representation of the customer's credit card information. You wouldn't need to store the token in your database. You should instead use it to process a charge, or create a customer, and then ignore it (because, at that point, the token will have been consumed).
For more, see this page in our docs:
https://stripe.com/docs/tutorials/charges
Cheers,
Larry

Resources