why is the node paypal payer_id is not being returned - node.js

In my node app the paypal response is not sending me a payer_id param
[ { field: 'payer_id', issue: 'Required field missing' } ]
what am i missing?
thanks
Ian

#iancrowther If you would not mind elaborating more, what stage are you needing the payer_id?
1) If you were trying to accept a payment via paypal, you direct the user to the approval_url on PayPal so that user can approve the payment. After the user approves the payment, PayPal redirects the user back to the return_url you specified, and appends the payer ID in return url as PayerID. The documentation for the requests are at
https://developer.paypal.com/webapps/developer/docs/integration/web/accept-paypal-payment/#execute-the-payment
2) If you are storing a credit card in vault for secure storage and charging later, you can include a unique payer_id in the request. The docs are at
https://developer.paypal.com/webapps/developer/docs/integration/direct/store-a-credit-card/

Related

how to receive Issuer field from payment method of Stripe API

When I visit show page of Payment Method (pm_1MZe3SEoS7yEEpyZtE8jW9JC) from dashboard.stripe .com then I can see the "Issuer" field that equal "Stripe Payments UK Limited", but CAN NOT receive this data from Stripe API.
use stripe-ruby client
use last api version: 2022-11-15
screenshots:
show page of Payment Method
require 'stripe'
Stripe.api_key = "api_key"
payment_method = Stripe::PaymentMethod.retrieve('pm_1MZe3SEoS7yEEpyZtE8jW9JC')
payment_method.?
could you please insert documentation API are you reading?
generally, it is not obvious that this information is exposed by API, so you have to read documentation before.

How to retrieve receipt_url upon successful payment completion in Stripe

We are using the Stripe API to make payments for invoices using a SAPUI5/Fiori UI. The payment intent create happens via a node.js project. We are successfully able to initiate the payment and from the Stripe dashboard Payments section we can see that the payment gets processed successfully.
We have the requirement, that upon successful payment completion, we need to redirect the user to the receipt URL (receipt_url) to display the payment receipt of the just processed invoice. Below is the code we are using to invoke the create payment intent on the Stripe server:
const paymentIntent = await stripe.paymentIntents.create(
{
payment_method_types: ['card', 'us_bank_account'],
metadata: {
....
....
....
},
},
{apiKey: secretKey}
);
res.send({
clientSecret: paymentIntent.client_secret,
});
According to the Stripe documentation, we can retrieve the receipt URL by retrieving the charge within the paymentIntent, but the response we receive upon successful processing of the payment by Stripe does not contain the charge object, it just has the payment id. Is it possible in any way, to retrieve the receipt URL using only the payment intent id?
Calling the payment intent create on Stripe to process the payment, but we are not getting in the response the receipt_url value where we want to redirect the user to, upon successful payment completion.
You can find the receipt_url property on the latest_charge property (make sure you use an API version greater than 2022-11-15; in older versions, it was the last item of charges property), which you can expand on your successful Payment Intent.
For that, you need to add a parameter expand when you create a Payment Intent:
const paymentIntent = await stripe.paymentIntents.create({
…
expand: [“latest_charge”]
});
const receiptUrl = paymentIntent.latest_charge.receipt_url;

Add Stripe Credit Card without Payment in SwiftUI

I am struggling to find a solution that isn't UIKit, or one that requires you make a purchase.
My project is trying to integrate Stripe in SwiftUI, using node.js Firebase Functions for backend handling.
I built a STPPaymentCardTextField in UIViewRepresentable. Which allows me to obtain credit card details for the customer via State.
#State var params: STPPaymentMethodCardParams = STPPaymentMethodCardParams()
SwiftUI TextField
StripePaymentCardTextField(cardParams: $params, isValid: $isValid)
Then we can build paymentMethodParms like..
let paymentMethodParams = STPPaymentMethodParams(card: params, billingDetails: billingDetails, metadata: nil)
Now I could easily pass the credit card details to my backend and add the card manually using
Function for adding payment method
const createPaymentMethods = functions.https.onCall(async (data, context) => {
const paymentMethod = await stripe.paymentMethods.create({
customer: '{{CUSTOMER_ID}}',
payment_method: '{{PAYMENT_METHOD_ID}}',
}, {
stripeAccount: '{{CONNECTED_STRIPE_ACCOUNT_ID}}',
});
}
but I am understanding this is bad practice.
I found this post which might be a "duplicate", but is the closest relevant answer. Adding customer's Credit card info in stripe. That user however is using reactjs and wanted to store credit card details in a database, where I only want to pass it to Stripe.
Is there not a way I can send the credit card data to Stripe, get a paymentMethod ID back, and pass that to my backend or something? I have already solved subscriptions, and purchase charging, I just can't get a credit card setup without going through the payment setup process. I want the user to add a credit card manually on creating a new account and/or in settings.
Can you call stripe-ios's createPaymentMethod() function [0]? That is a client-side function your SwiftUI app would call to tokenize the card details from paymentMethodParams into a PaymentMethod object. You can then pass that ID server-side to attach to a Customer.
[0] https://stripe.dev/stripe-ios/docs/Classes/STPAPIClient.html#/c:#CM#Stripe#objc(cs)STPAPIClient(im)createPaymentMethodWithPayment:completion:
To expand on #hmunoz's answer and the way I got this to work is as follows.
Create your user a Stripe account. https://stripe.com/docs/api/customers/create
Log the customers stripe id in your user's Firestore database for easy reference.
Create an "Add card" view to your frontend and call to the add payment method function. https://stripe.com/docs/api/cards/create
Upon checkout as long as the customer's stripe ID is passed in the payment intent it should populate with their saved payment methods.
In summary it is best to keep track of your user that is signed in so that you can do any CRUD needed throughout.

Stripe Session Getting Customer Name

I would also like to retrieve the name of the person who paid. How can I get the name value from the stripe session? I have tried this:
const sessions = await stripe.checkout.sessions.list({
limit: 1,
});
console.log(sessions.data[0].customer)
const customer = await stripe.customers.retrieve(sessions.data[0].customer);
console.log(customer)
which gets me the email, but the name is null.
UPDATE: Customers created through Checkout have a null name because it is not collected/set. The "name on card" field on the Checkout page is for the cardholder name for the payment method, not the name of the customer (see https://stripe.com/docs/api/payment_methods/object#payment_method_object-billing_details-name). If you want a Customer created through Checkout to not have a null name, you'll have to update the Customer after the session is completed.
Stripe has a dashboard setting (https://dashboard.stripe.com/settings/emails) you can enable that automatically sends receipts to customers for successful payments completed in live mode. Payments completed in test mode will not automatically send an email, but you can trigger one manually through the dashboard. You can read more about sending receipts here: https://stripe.com/docs/receipts#automatically-send-receipts-when-payments-are-successful.
If you want to grab the customer’s email and send a receipt yourself it’ll be a bit more complicated.
Wait for the Checkout Session to finish by listening for checkout_session.completed through a webhook endpoint (https://stripe.com/docs/payments/checkout/fulfill-orders#handle-the-checkoutsessioncompleted-event).
Grab the customer ID from the Checkout Session object that comes in with the checkout_session.completed event.
Using the customer ID from the previous step, retrieve the Customer object (https://stripe.com/docs/api/customers/retrieve) and get the customer’s email.

What to do when Strong Customer Authentication fails?

I am trying to implement a Subscription signup and payment flow with Stripe.js V3 and Strong Customer Authentication (SCA) like this:
var stripe = Stripe('pk_test_9hA8gecxBFTY3O6kUm7hl16j');
var paymentIntentSecret = 'pi_91_secret_W9';
stripe.handleCardPayment(
paymentIntentSecret
).then(function (result) {
if (result.error) {
// Display error.message in your UI.
} else {
// The payment has succeeded. Display a success message.
}
})
Everything works great when the payment succeeds.
But what am I supposed to do when it fails?
Should I redirect the user to the initial payment screen, so s/he can start over?
When I do that I get this error:
You cannot confirm this PaymentIntent because it has a status of canceled. Only a PaymentIntent with one of the following statuses may be confirmed: requires_confirmation, requires_action.
Or should I delete everything, including the previously created stripe_customer and stripe_subscription, and then start over?
Thanks for any help.
If the payment fails entirely(maybe it was declined, or 3D Secure was attempted but not completed successfully) , the PaymentIntent from the first invoice should be in the requires_payment_method state and the subscription is incomplete.
You can choose to attempt to collect new payment information from the user and use that to complete the invoice payment and activate the subscription. You can re-use the same PaymentIntent throughout this and try as many times as you wish. For example, if you had a payment form with a Card Element for collecting details, you can have the user enter a new card and call this again :
stripe.handleCardPayment(cardElement,
paymentIntentSecret
).then(function(res){...})
Alternatively you can choose to cancel the subscription entirely if you wish. Otherwise if you do nothing, or the customer isn't able to provide a payment method that works, after 24 hours, Stripe effectively cancels the subscription for you.
Your error message seems to indicate the PaymentIntent was cancelled, which might mean you cancelled the subscription, or you're trying this more than 24 hours after the initial payment, I'm not sure.
This link goes into more detail:
https://stripe.com/docs/billing/lifecycle#incomplete

Resources