How to pass the billing name in stripe payment card mount? - stripe-payments

I am trying to pass the billing name on my stripe payment (like below)
var cardCvcElement = elements.create('billingName', {
style: style,
placeholder: 'Name on card',
});
cardCvcElement.mount('#card-user-name');
but it is giving me the following error A valid Element name must be provided. Valid Elements are: card, cardNumber, cardExpiry, cardCvc, postalCode, paymentRequestButton, iban, idealBank, p24Bank, auBankAccount, fpxBank, affirmMessage, afterpayClearpayMessage; you passed: billingName.
I am not sure how to send the billing name as part of the payment.

When you create an Element, you can create either a Payment Element (new component) or Card Element (old component).
It looks like you have created a Card Element, hence it's expecting a "valid" element name of card, cardNumber, cardExpiry, cardCvc, postalCode, paymentRequestButton, iban, idealBank, p24Bank, auBankAccount, fpxBank, affirmMessage, afterpayClearpayMessage. See Stripe JS Reference.
I suggest taking a step back and fixing the correct syntax for this call first, before thinking of how to send the billing name. Pretty much you would want Payment Element instead, and as other answer pointed out, you will need to pass the billing Details in the defaultValues under options.

If you are creating a payment element, you need to pass the billing details in the defaultValues object under the options object.

Related

How to get default payment method from Stripe invoice?

I am listening to Stripe's invoice.payment_failed webhook with my web app and I would like to get the default_payment_method from each invoice but for some reason it always returns nothing but an empty array!
When I query for a Stripe invoice on the command line and expand on the default_payment_method like this...
Stripe::Invoice.retrieve('in_3K6dIY2KgYRkshw2LAzya63P', :expand => "default_payment_method")
...I also get empty arrays. This surprises me because all my Stripe customers do have a default payment method associated with them.
What am I missing here?
Thanks for any help.
There are three independent places a default payment method can be set. From more specific to less specific they go :
invoice.default_payment_method (which you are looking at)
subscription.default_payment_method
customer.invoice_settings.default_payment_method
Stripe charges the most specific one if it's set. When reading from the API, those values don't inherit from the level above, they can all be set individually, if they are not set explicitly then they are null. So that's why you see it as null on the Invoice level.
Instead you likely want to look at the Subscription object or the Customer object(and can leverage the expand feature for that), depending on how you built your integration and which one it sets.
Overall though, you probably actually want the PaymentMethod used in the invoice payment though? That would be from the last_payment_error.
inv = Stripe::Invoice.retrieve({
id: 'in_1K8iiKJoUivz182DMzSkuBgp',
expand: ["customer.invoice_settings.default_payment_method",
"subscription.default_payment_method",
"payment_intent"]
}
)
print("invoice : #{inv.default_payment_method} \n")
print("subscription : #{inv.subscription.default_payment_method} \n")
print("customer : #{inv.customer.invoice_settings.default_payment_method} \n")
print("failed charge : #{inv.payment_intent.last_payment_error.payment_method} \n")

Get Default Payment Source (default card) for Stripe Customer?

I created a POC with a customer/credit card in Stripe and I logged into my dashboard within Stripe and was able to see this customer has a default source (the test credit card I added) associated correctly. It shows this card is the default source.
When I run this .Net code:
var customerService = new CustomerService();
var stripeCustomer = await customerService.GetAsync(customerId);
To get that customer, it returns everything correctly except his source. All of the fields I had hoped I can find it from are empty! I want to know his default payment source so I can show it on the front end with a little icon to indicate it's default.
DefaultSource, DefaultSourceId, and Sources properties are all blank/null.
Is there a way to have Stripe return it, or do I need to do something else? I tried the 'expand' property for the GetAsync method but that threw an error saying the above properties are not expandable (i.e. I can't ask Stripe to expand/return Source).
Any ideas what I can do?
FYI I also tried this:
var paymentMethodService = new PaymentMethodService();
var cards = await paymentMethodService.ListAsync(new PaymentMethodListOptions { Customer = customerId, Type = "card"});
and there doesn't seem to be a property anywhere that says the card is default (although it does correctly return all cards). I believe Stripe documentation states the Customer is the holder of the default source, not the card object. What gives?
Thanks in advance!
It looks like you're using Payment Methods, since your payment method list call has the results you expect, which means the customer likely doesn't have any sources. You can try that again with the properly pluralized expand[]=sources if you do know your Customer has Sources attached.
For Payment Methods, there is no general default for the Customer. For one-time Payment Intents, you must always specify the payment_method from among those attached to the Customer for future payments.
For paying invoices (related to recurring subscriptions, eg), you can set the invoice_settings.default_payment_method for Customer. This only applies to invoices.

Stripe: Get card information so customer can update their card

My app uses subscriptions with Stripe.
I want to create a standard "account" page, which will list the customer's current card information (like "MasterCard" and last 4 of card number), and give the customer the option of updating that information.
I'm stuck on the first piece--getting back the current card information. To do this, I need the current card_id. I have tried the "listSources" method, but this returns blank data where the card info is supposed to be. What do I need to do to get that card info?
Here is what I've tried:
(I'm using Node, and running this server side)
The closest method I have found is here:
var stripe = require('stripe')(STRIPE_TOKEN);
stripe.customers.listSources(
CUSTOMER_ID,
{object: 'bank_account', limit: 3},
function(err, cards) {
// asynchronously called
}
);
This returns information (there's no error), but the docs say this method should return a data array of the cards that includes the card id for each. In testing, the data array keeps coming back empty.
I am testing with a customer id that has a valid subscription and a card that I can see on my Stripe dashboard.
Why is the data array coming back empty?
Note: there's also a retrieve source method, which should give back card details, but this method requires you have the id of the card you want info on, and that's what I am not able to get right now.
Converting this to an answer...
Stripe has recently rolled out PaymentMethods, which replace (and are separate from) the older Tokens and Sources API.
OP's issue is that their integration creates PaymentMethod objects, which won't show up in the sources list, but can instead be accessed via stripe.paymentMethods.list.

Custom Paypal credit card payment form required fields for payment api

I'm integrating a custom paypal credit card payment form in my project (Angular2 + Node.js).
Refer:
(1.) https://developer.paypal.com/docs/integration/direct/payments/credit-card-payments/#create-credit-card-payment
(2.) http://code.runnable.com/UXgyne_v2oZyAAC-/pay-with-a-credit-card-using-paypal-api-for-node-js
My question is do we really need to add "first_name" and "last_name" field in the form. Instead I just want to add one field for the name of card holder.
Please sugggest the best solution for my case.
Thankyou!
Well actually you can do that. The name field are not compulsory.
You could add a single field for Cardholder Name and then split it in your code so that you can populate first name and last separately.

How to get list of payment methods/shipping method and assign it to a order (suitescript)

I'm working with creating salesorder in netsuite using suitescript but I can't find any document about "payment method", so how can I get a payment method such as VISA card and assign to the order? (I think it's required a payment method id but I didn't find payment method in supported suitescript records).
[update]
Here is my code:
var order = nlapiCreateRecord("salesorder");
// set some field value
// order.setFieldValue(....)
Now I want get payment method and shipping method id to set to order:
order.setFieldValue("shipmethod", shippingmethodId);
order.setFieldValue("paymentmethod", paymentmethodId);
I already have payment method name "Test Payment Method" and shipping method "Test Shipping Method". How can I get their id using their name?
For Payment Methods:
To get a list of the payment methods and their respective IDs available in your NetSuite account, you should navigate to Setup > Accounting > Accounting Lists. You will see a Type filter on the bottom of the page. Select Payment Method in there and you'll be able to see the different payment methods available for you.
For Shipping Methods:
Navigate to Lists > Accounting > Shipping Items.
Edit:
Actually you don't need to. Use nlobjRecord.setFieldText instead of setFieldValue i.e. order.setFieldText('VISA')
You can use hard-coded values instead of getting the values dynamically.

Resources