We have to use payment links as were coming from a native desktop app on MacOS and Windows, Stripe has no support here.
The native desktop apps do not have a web-view.
Using the following API with url params.
https://stripe.com/docs/payments/payment-links#url-parameters
const paymentLink = await stripe.paymentLinks.create({
line_items: [
{
price: price.id,
quantity: 3,
//
},
],
});
The url on the frontend opens as such (note to "client_reference_id")
final url = link + "?client_reference_id=$customerId&prefilled_email=${stripeCustomer!.email}";
The key url params are added.
The problem is, is that "client_reference_id" is ignored and a new customer is created on the Stripe dashboard, this is no good for making payments as we generate the payment for a specific account created on the database.
Any ideas what I could do here?
We tried checkout session but there is no way to open from a link. :-/
I found the answer to this question. So the generic payment link does not work with a customer id, however you can create a session and attach a customer id to it. The session object will return with a url.
Example:
const session = await stripe.checkout.sessions.create({
line_items: [{ price: price_id, quantity: 1 }],
mode: 'subscription',
success_url: 'https://app.seedscout.com',
cancel_url: 'https://app.seedscout.com',
customer: cus_id,
});
You can find more information in their documentation here.
https://stripe.com/docs/api/checkout/sessions/create
Important to note: Stripe has requirements for the format of customer_reference_id:
client_reference_id can be composed of alphanumeric characters,
dashes, or underscores, and be any value up to 200 characters. Invalid
values are silently dropped and your payment page will continue to
work as expected.
I was tearing my hair out trying to work out why client_reference_id wasn't being passed, and it looks like this was the issue – I was separating two values with a period.
Related
I been trying to figure out how to create a user and store his credit card info in stripe for like a day and I cant get it to work.
I can see the following docs:
https://stripe.com/docs/api/customers/create
const stripe = require('stripe')('sk_test_xxx');
const customer = await stripe.customers.create({
description: 'My First Test Customer (created for API docs at https://www.stripe.com/docs/api)',
});
I understand the secret key aspect of the code.
I dont understand how to create the user object, though. where do I add the user name and info and email and stuff?
is there an example I can see using angular?
maybe the example can be for creating and storing the following information:
first name: juan
last name: cheese
email: jcasas#gmail.com
creditcard: 424242424242
csv: 231
creditcard name: juan cheese
exp: 02/02/25
i literally bough a course on udemy for this but that does not work either :(
If your intention is to save payment details, without an initial payment then you should follow this guide from the Stripe documentation.
The process creates a Customer object, and uses Setup Intents to correctly setup and save the payment details to that customer. Stripe.js and the Payment Element are used to safely collect payment details in a PCI compliant manner and handle any requested 3DS/authentication.
What I am trying to do: I am trying to integrate Amazon Pay in my React-Express website following this documentation here.
My Problem: Whenever someone clicks on Amazon Pay Checkout Button, it redirects (refreshes the current page) to the Amazon Pay website to complete the payment. The problem in doing so is that, all the states get reset. What I am trying to do is, open it in a popup window.
Note: I have tried Googling, and there were very few information about it, and most of them says its not possible to do, but it is possible. This site here uses Amazon Pay and is built using React, AND this site is from Amazon itself for a demo. Here the Amazon Pay button opens a popup instead of refreshing, but I could not find the source code of this website anywhere.
My Progress:
In my backend Express server, this is what I did,
const payload = {
storeId: AMAZON_STORE_ID,
scopes: ["name", "email", "billingAddress"],
deliverySpecifications: {
specialRestrictions: ["RestrictPOBoxes"],
},
paymentDetails: {
chargeAmount: {
amount: account.price,
currencyCode: 'EUR'
},
},
// popup: true
}
const signature = amazonPayClient.generateButtonSignature(payload)
console.log(`Sign: ${signature}`)
return res.json({ sign: signature, payLoad: JSON.stringify(payload) })
and then in my frontend React,
amazon.Pay.renderButton('#amazon-pay', {
// set checkout environment
merchantId: config.AMAZON_MERCHANT_ID,
publicKeyId: config.AMAZON_PUBLIC_KEY_ID,
ledgerCurrency: 'EUR',
checkoutLanguage: 'en_GB',
productType: 'PayAndShip',
placement: 'Checkout',
buttonColor: 'Gold',
createCheckoutSessionConfig: {
payloadJSON,
signature
},
popup: true
})
Thanks for helping in advance :D
The reason, my Amazon Pay was opening in a new page, and the one in the Amazon Pay Demo website in a popup was because of currency. If, I change my currency from 'EUR' to 'USD', popup appears.
In the demo site, if you change your currency from USD to EUR from top right corner, you will see the changes take place.
So, to fix this issue, I just have to use US Region, and the USD currency
I'm currently working in a (small) project where we want to create a shop but we aren't selling anything yet.
We are storing our products that we want to sell in our own database.
However I wanted to implement a feature that simulates the payment of an order and I was recommended to use Stripe for it.
However as far as I know I can't create a checkout session without providing a list of products stored in my Stripe account?
So I would need to create all the products in Stripe as well (and have them in my own database too)
Is there no way to just create a checkout session with a total price and when the payment succeeds I can move on?
Yes it’s possible to use Checkout without creating products and prices in Stripe. You need to pass the line_items.price_data object as a parameter when creating the CheckoutSession in order to specify the details of the payment inline (or "ad-hoc").
Here’s an example of how it could look like in node.js:
const session = await stripe.checkout.sessions.create({
line_items: [
{
price_data: {
currency: "usd",
unit_amount: 500,
product_data: {
name: "name of the product",
},
},
quantity: 1,
},
],
mode: "payment",
success_url: "http://example.com/success",
cancel_url: "http://example.com/",
});
You can learn more about Checkout on this documentation page.
In my application, I have to first authorise (Block the payment) the amount from both user. And once they both clicks on confirm once they received the service, I need to perform the charge (Actual cut and transfer payment).
I can do this and works fine but hear I want to get the platform fees but when I add the param of application_fee_amount then it throws an error and says I can only perform this when I do a direct payment transfer.
I think this is very common case which may exist other apps also.
How I'm doing in code...
let obj = {
amount: convertToCents(data.amount),
currency: 'usd',
payment_method_types: ['card'],
capture_method: 'manual',
application_fee_amount: convertToCents(data.amount *0.05), // 5% as a plateform fees...
payment_method: data.payment_method,
customer: data.customer,
confirm: true
}
console.log(obj);
const paymentIntent = await stripe.paymentIntents.create(obj);
Can anyone help me with this?
It doesn't look like you are using a Connect fund flow, like Destination Charges or Direct. ApplicationFees can only be taken on Connect fund flows.
https://stripe.com/docs/connect/charges
Are you using Connect?
I'm new to integrate stripe payment. I confused how to integrate 3D secure authentication. In my application on Backend platform using node with Hapi framework. Here is the some of code of paymnet intent which is given below.
let params = {
amount: 100,
currency: "CAD",
payment_method_types: ['card'],
payment_method: "card_1HqytjG6OdQYWdifbWxCrVGB", //cardId
customer: "users5fc1c5ff44d8605030499c00", //userId
}
let intent = await stripe.paymentIntents.create(params {
idempotencyKey: uuidv4());
let paymetConfirm = await stripe.paymentIntents.confirm(intent.id, intend.payment_method);
It's working fine with some of the test cards which not require 3D secure authentication.
4242424242424242
2223003122003222
Not working with these cards require 3D authentication)
4000002760003184
4000002500003155
So, when I check the response of the API (with 3D authentication card) return one of the sub-object is
next_action: {
type: 'use_stripe_sdk',
use_stripe_sdk: {
type: 'three_d_secure_redirect',
stripe_js: 'https://hooks.stripe.com/redirect/authenticate/src_1Hs1zhG6OdQYWdifEWTcyUvC?client_secret=src_client_secret_okgYE1A4eOovEFL9g0sgN29U',
source: 'src_1Hs1zhG6OdQYWdifEWTcyUvC'
}
},
When I take this URL and paste on the browser it redirects the page of 3d Secure, There are two option
complete authentication
fail authentication
Note-
Stripe SDK is set up only on the backend platform(Node)
My question is that
Is there any way not to confirm from the client-side, automatically confirm from the backend platform.
For the scenario, we have to set up a stripe SDK on the client-side(android,IOS).?
when I click on the URL which are inside next_action object which are given above,There are two option inside it,that is complete and failure authentication(3D page view) how to integrate clicking on itmy API hit respectively. how to achieve it?
Please help me.Thanks
Your payments are failing with 3DS enabled cards because you aren't authenticating them on the client. Your current flow of confirming server side won't work with 3DS enabled cards, as you aren't giving the user an opportunity to do the 3DS flow.
It's not really recommended to confirm the payment server-side, as it adds unnecessary round trips to the server without really adding anything. However if you do still want to confirm server side, Stripe has a guide on how to do that here: https://stripe.com/docs/payments/accept-a-payment-synchronously