Stripe Add CreditCard ID response is different from Dashboard - javascript

Currently using Stripe Test Mode I add a credit card using this. The card is added successfully to Stripe Dashboard. But when I was looking closer, the card id returned by the 'stripeResponseHandler' is different to what it is set on the Stripe Dashboard.
What was written to Stripe Dashboard:
Card ID: card_19FxJYDJ3JQRgrDjabcdELef
What the stripeResponseHandler actually returned:
Card ID: card_19FxJYDJ3JQRgrDjcOlENnWX
I used different testing credit card numbers and no errors are apparently returned, same behavior. What can cause this?

This is expected behavior. You shouldn't worry about the card ID you receive in the stripeResponseHandler callback in your frontend code. In the vast majority of cases, all you need to do in the callback is get the token ID ("tok_...") and send it to your backend code so it can be used in an API request, e.g. to create a charge or a customer.

Related

Stripe: Set billing_cycle_anchor on existing subscription product via Stripe Checkout

I'm trying to create a simple subscription in Stripe with billing_cycle_anchor set to a specific date.
I've run into two issues:
1: When using Stripe Checkout with a subscription product made on the dashboard
stripe.checkout.sessions.create
(https://stripe.com/docs/billing/quickstart#add-trial)
I cannot pass billing_cycle_anchor as a parameter, I get error
Received unknown parameter: subscription_data[billing_cycle_anchor]
I'm confused by this as in
https://stripe.com/docs/api/subscriptions/object
It lists 'trial_end' as a parameter and I can successfully use this. While this suits my purpose technically, the Checkout displays text about a Trial and it's not a trial, I just need the subscription to not start until a certain date.
In the Stripe documentation for billing_cycle_anchor, instead of going straight to the checkout with a pre-made product, they create a subscrition billing_cycle_anchor like so:
const subscription = await stripe.subscriptions.create({
customer: 'cus_4fdAW5ftNQow1a',
items: [
{
price: 'price_CBb6IXqvTLXp3f',
},
],
billing_cycle_anchor: 1611008505,
});
But I haven't been able to adapt this to my needs as it won't work without the customer parameter, and I don't want to link this to an existing customer, I want to create a new one (or use their existing account if one exists, but this isn't linked to any sort of a database, I just need a basic button).
I'm confused as to why I can't create a subscription without passing in a parameter for customer, and just create a new one at checkout.
Basically all I need is a way for customers to buy a subscription that has a specific start date. This can't be done with no-code via the Stripe Dashboard so I'm trying to hack it together.
I'm trying to do this using Node and JS. It works with trial_end but not billing_cycle_anchor
Thanks :)
With Checkout, the trial is the way to accomplish this. If you were to use a custom flow with the Payment Element, you could utilize Subscription Schedules to just start a subscription in the future.

Stripe collect payment later workflow Node/Express/EJS

I am working on the payment portion of an app using Stripe and having trouble trying to figure out the best way to route customers. Essentially, the way the app is supposed to work is:
Customer goes to site to enters payment details.
Payment is broken into two parts the Fee and the Deposit.
Customer submits payment details.
If the funds are validated they are brought to a success page.
If the funds are not validated they get an error page.
Later, the funds are captured either with or without the deposit amount.
I have Stripe set up where I am creating the payment intent with capture_method: 'manual' set so I can capture the funds later. I am passing the client secret to the front via EJS, and using stripe.confirmCardPayment() to 'run' the card. All of that seems to be working fine and they are correctly showing up in my Stripe dashboard as uncaptured payments. So, from here what is the best way to route the user to the correct page after the card is 'run'. In other words, if the funds are there then route to success pages, otherwise route to an error page. There needs to be some validation on the server side otherwise the customer could just directly visit the success page route without paying. Thanks for any help and ideas!
stripe.confirmCardPayment returns a Promise that resolves with result.error if there were errors (like the charge declined) or with result.paymentIntent if the PaymentIntent confirmation succeeds: https://stripe.com/docs/js/payment_intents/confirm_card_payment
Once your confirmCardPayment() Promise resolves, you can look at result.paymentIntent.status (which in your case would be requires_capture).
During this, you can make any arbitrary calls to your server (like pass the PaymentIntent/Customer ID and update your database) and then redirect your customer to the success/failure page accordingly.

Paypal Smart Checkout – Multiple merchant ids throw error

On a checkout page, loading the PayPal Javascript SDK, I provide multiple merchant-ids like this (where [my_client_id] is replaced with my id, of course), the email addresses shown have been modified for privacy reasons:
<script src="https://www.paypal.com/sdk/js?client-id=[my_client_id]&currency=EUR&locale=de_DE&merchant-id=*"
data-merchant-id="lobo***#gmail.com,suic***#squar***.de,einkauf#***-games.de,paypal#***.events,***#kst***.at"></script>
I then create a separate Paypal Smart button for each of the merchants. But although I provide the multiple merchant-ids, I will get the following error as soon as a payment button is clicked:
Error: Payee(s) passed in transaction does not match expected merchant
id. Please ensure you are passing merchant-id=****55TUNG or
merchant-id=lobo***#gmail.com to the sdk url.
But that merchant-id is provided in the URL as you can see above. If I press another merchant's pay button, I get the same error message but with that merchant's id listed in the error message.
The payee passed by the PHP script using createOrder is the corresponding email address of the merchant 100 percent correctly.
Is this a bug in the PayPal SDK or am I listing the merchant-ids maybe in the wrong way in the SDK-URL (though it is the way PayPal has described it a discussion on github)?
IMPORTANT SIDE NOTE: If I totally omit providing the merchant-ids in the SDK-URL, I get Javascript warnings about the missing merchant-id, but the payment buttons work just fine (which makes me sure that the PHP backend script is working 100 percent correctly), the payments are being processed.
What interesting, too: If I omit the merchant-ids in the SDK-URL, PayPal will render four different payment options, if I include the merchant-ids in the URL, then only two are shown (and both of them will throw the error).
All of this is referring to production mode.
Only pass a single merchant-id, and have it correspond to the payee that you are going to use.
Alternatively, pass no merchant-id at all, for transaction types that don't require it.

stripe checkout client only integration in reactjs . how to handle the callback urls . how to subscribe for recurring payments?

I am trying to integrate stripe check out (client only integration) in my reactjs application and i see there's lots of confusion about this which are listed below
(i) : first thing is "react-stripe-checkout" , a react library to implement checkout. i could not find any example of how to pass the plan Id to this "react-stripe-checkout" . As in client only integration you create the plans on stripe dashboard and pass the plan id to checkout , but there is no example of how to pass my plan id to "react-stripe-checkout". For example without using this library this is how i use the stripe.js directly in my react app
const stripe = window.Stripe('pk_test_my tst key');
stripe.redirectToCheckout({
clientReferenceId:"abc",
items: [
{plan: 'my-plan-id', quantity: 1}
],
successUrl: '',
cancelUrl: '',
}).then((result) => {
console.log(result)
});
in above code i am passing my plan id to stripe's "redirectToCheckout" method and it redirects me to a new form hosted by stripe and customer can subscribe for the plan there. but how do we accomplish this functionality using "react-stripe-checkout".
(ii) I assume that "react-stripe-checkout" can't be used for client only integration and it just can be used for client server integration , i need a confirmation on that . moreover like "react-stripe-checkout" pops up the form for collecting user card information on the same page whereas stripe.redirectToCheckout() takes the user to a new page to enter his card info. is there a way to collect the user card info on same page in a popup like we do with "react-stripe-checkout".
(iii) Assuming that "react-stripe-checkout can't be used for client only integration" . I have decided to use stripe.redirectToCheckout() anyways. I have already posted the code above and i am confused about how to use callback urls there. I have not seen a single example all over the internet anywhere for handling these callback urls in reactjs. i wonder if anybody has implemented the client only checkout integration in reactjs until now , if so why isn't there any example available to follow.
(iv) I am following the stripe documentation for implementing webhooks on my backend (Nodejs) server.
this is the link https://stripe.com/docs/payments/checkout/fulfillment#webhooks . and there's this line there
"If Stripe does not receive successful acknowledgement after 10 seconds have passed from a successful payment, your customer will be automatically redirected to the success_url page."
what does it mean ? how do i be sure about inside "success_url page" that customer has successfully subscribed to the plan or not ?
(v) from stripe documentation i also do not understand this following line
"If you’d like to access the Checkout Session ID you can add the {CHECKOUT_SESSION_ID} template variable to the success_url (e.g. success_url=https://example.com/success?session_id={CHECKOUT_SESSION_ID}). When your customer is redirected on successful payment, the success_url will contain the Checkout Session ID in place of the {CHECKOUT_SESSION_ID} template variable."
can anyone explain what this {CHECKOUT_SESSION_ID} template variable is for , and what would i pass in it from my frontend ?
kindly help .

What subset of errors can be expected from a call to Stripe.card.createToken()?

When making a call to Stripe.card.createToken() (Stripe.js) it seems that only a subset of the errors described in the api docs could be returned. Some errors, like card_error/card_declined, could only (?) be returned from a server side call to charge a card.
What error types and codes can be expected when making a client side call to Stripe.card.createToken()?
https://stripe.com/docs/testing#cards-responses
Unlike Checkout, Stripe.js only does a basic set of validations on a card such as a Luhn check and whether the expiration is with the valid universe.
You will see a card_error if, for example, the expiration or card properties are invalid, invalid_request_error should you attempt to send invalid parameters to the API, a connection error if there were a time out between your client and Stripe.
But your understanding is correct here, you would never see a decline as (unlike Checkout) an authorization is not attempted until the time at which you add the card to a Customer or create a Charge on your backend.

Categories

Resources