Stripe: Show Customer Name on place of Email - stripe-payments

Stripe captures Email and Name both in StripeCustomerService(), that is when creating the customer using Stripe.dll...
But in Admin login, it shows Customer Email in heading, as shown below.
Is there any way to change it to Name of a customer?
But if I pass name in Email parameter, it may affect sending a notification email to the customer.
So, is it possible to do so?
Note: I have passed both in parameters list;
var mycust = new StripeCustomerCreateOptions();
//Save Card Details
mycust.CardNumber = txtCard.Text;
mycust.CardExpirationMonth = ddlMonth.SelectedValue;
mycust.CardExpirationYear = ddlYear.SelectedValue;
mycust.CardCvc = txtCSV.Text;
//Save Customer Details
mycust.Email = email;
mycust.CardName = fullName;

Short Answer: No, it is not possible.
There may be any number of customer's by the name of John Doe but each would have a different email such as:
JDoe#email.com, JDoe2#email.com, etc.
Email is a unique identifier while name is not.

Related

Want to payout money to another bank account using stripe

My requirement is to pay out money directly to the user, users will provide their bank account and money will be directly transferred to their given bank account number.
Bank details will be provided by the user and it's not fixed every time. so I cant manually add a bank account to stripe.
in this context, I am using TokenBankAccountOptions in stripe and written the following code for bank account create.
var options = new TokenCreateOptions
{
BankAccount = new TokenBankAccountOptions
{
Country = "US",
Currency = "usd",
AccountHolderName = "Jenny Rosen",
AccountHolderType = "individual",
RoutingNumber = "110000000",
AccountNumber = "000123456789",
},
};
var service = new TokenService();
Token striptoken = await service.CreateAsync(options);
await Transfer(striptoken.Id);
Now I want to transfer or payout money to a given bank account but the stripe not taking any bank details in payout options or transfer options.
As #sinanspd mentioned, you need to use Stripe Connect for this, and I'd also recommend checking with Support to make sure your use case is supported.

Stripe get product_id / price_id from session object

I'm currently using Stripe Webhooks to get notified when user pays for a product. This is working fine. From the payment intent I can get the Seesion and the Customer Object. But I don't find a way to get the product_id or price_id for what the user paid.
Does someone know a way to get product_id or price_id ?
Thanks for the question. As you noticed the Session data included in the checkout.session.completed event does not include the line_items where the Price ID is associated to the Checkout Session.
line_items is one of the expandable properties, so to retrieve the Price ID you'd retrieve the Checkout Session and use expand to include the line items in the response. There is not a way to configure your webhook to have the data sent to you include this data.
There are two approaches to associating a customer's purchase with a Checkout Session. First, you could store the ID of the Checkout Session in your database alongside the cart or list of items purchased by the customer. That way you if a checkout session is successful, you can look up the cart by ID and know which items were purchased.
Alternatively you could listen for the checkout.session.completed webhook event, then when you receive a new notification for a successful checkout, retrieve the Session with expand then use the related price data.
Using stripe-node that would look like the following:
const session = await stripe.checkout.sessions.retrieve(
'cs_test_xxx', {
expand: ['line_items'],
},
);
// note there may be more than one line item, but this is how you access the price ID.
console.log(session.line_items.data[0].price.id);
// the product ID is accessible on the Price object.
console.log(session.line_items.data[0].price.product);
To take this a step further, if you wanted more than just the ID of the product, you could also expand that by passing line_items.data.price.product which would include the line items their related prices and the full product objects for those prices.
While creating the Payment Intent, you can store additional information about the object in the metadata field.
const paymentIntent = await stripe.paymentIntents.create({
amount: 1099,
currency: 'usd',
payment_method_types: ['card'],
metadata: {
product_id: '123',
price_id: '20',
},
});
Once the payment is done, you can retrieve this information from the metadata field.
You can do the same for the Session Object as well.
cjav_dev answer is great! Here is the PHP code for the same.
$event = \Stripe\Event::constructFrom(
json_decode($payload, true), $sig_header, $endpoint_secret
);
$eventObject = $event->data->object;
$stripe = new StripeClient('testsk_ssdfd...sdfs');
$csr = $stripe->checkout->sessions->retrieve($eventObject->id,
['expand' => ['line_items']]
);
$priceid = $csr->line_items['data'][0]['price']['id'];
Note the above is only retrieving the 1st line item. You may have to do a loop for all items.

Change Nick Name of Email while sending the email from netsuite script 2.0

Suppose we have the code
email.send({
author: 17874,
recipients: "sam172#gmail.com",
subject: "mail from netsuite",
body: "test body email order id: " + newOrder
});
Can we modify the sender name only not the email.
I have to implement like if we have the email "test#gmail.com" and nick name as "Test". While sending the email it will show like from Test in recevire side. Can we change the name from test to test123.
This isn't possible as far as I know. You really have two options to modify the name of the sender only:
Either change the name of the user (the one you set in the options.author field).
Or have the correct name from the beginning and then modify the reploy-to instead by setting the options.replyTo
This isn't exactly what you want but I think it's the only workaround.

Stripe does not let a charge be associated with a customer with one-time source

As the title says, I am trying to make a payment using a one-time source (credit card) that is not being saved in the customer's profile. I still want to be able to record that charge on the customer's profile on Stripe.
According to the docs, this can be done by passing the customer's id in customer key in the payload sent to Stripe.customers.createCharge. However, on doing that, I receive an error stating the card is not linked with the customer (which obviously is not, and I don't want it to be).
Customer cus_*** does not have card with ID tok_visa
To get around this, temporarily I have applied the fix mentioned in this answer which basically involves creating a temporary card for the payment and then deleting it.
I was wondering how does the API not work when it is clearly documented otherwise, hope someone experienced with Stripe chimes in on the same.
Here is the code I'm trying to get to run:
await stripeService.charges.create({
source: token, // temporary token received from Checkout
customer: user.stripeCustomerId, // the Stripe customer ID from my database
amount,
currency: 'usd',
description: 'Test charge'
});
The single-use sources document that you link to explicitly only works with Sources, but tok_visa will create a Card object instead. I believe that's why you get the error.
If you try the code with a Source(it has an ID like 'src_xxx') that you obtain through Elements/Checkout on your frontend with, for example, createSource, it will succeed, I've just tested it. You can also test with this code :
const src = await stripe.sources.create({
type : "card",
token : "tok_visa"
});
const charge = await stripe.charges.create({
    source : src.id,
customer : "cus_xxxx",
    amount : 1000,
    currency : "usd"
});
I was able to achieve this by creating the source first followed by the charge where you specify the customerId and sourceId as below:
//Create the source first
var options = new SourceCreateOptions
{
Type = SourceType.Card,
Card = new CreditCardOptions
{
Number = Number,
ExpYear = ExpYear,
ExpMonth = ExpMonth,
Cvc = Cvc
},
Currency = "gbp"
};
var serviceSource = new SourceService();
Source source = serviceSource.Create(options);
//Now do the payment
var optionsCharge = new ChargeCreateOptions
{
Amount = 500,
Currency = "gbp",
Description = "Your description",
SourceId = source.Id,
CustomerId = "yourcustomerid"
};
var service = new ChargeService();
service.Create(optionsCharge);
result = "success";

How to populate DocuSign Name field with something other than Sender name?

I'm using DocuSignAPI SDK to send envelopes. I have a few templates defined and they use a Custom Field called MemberFullName.
The field is of type Name, FullName.
For some templates I want MemberFullName map to a Signer's name, but sometimes I want to map another name to it.
My assumption was if I don't map anything to MemberFullName, then Signer's name will be used. But if I add "fullNameTabs" for MemberFullName, then it will be mapped.
Signer sgnr = new Signer()
{
RoleName = "Someone other than Member",
RecipientId = "1",
Name = "Bob Signer",
Email = "bobsemailaddress#yahoo.com"
};
sgnr.Tabs.FullNameTabs = new List<FullName>();
sgnr.Tabs.FullNameTabs.Add(new FullName() { TabLabel = "MemberFullName", Name = "Joe Smith" });
But MemberFullName is still mapped to Signer name in the resulting document.
How can I map a NON-SIGNER name to a field of type "Name"?
I know I can create a different field of type TEXT and map "Joe Smith" to it, but I wanted to reuse the "MemberFullName" field in both situations.
I apologize as I may not be using correct "docusign terminology" for things.
You will not be able to set the value of FullName tab manually. See this answer
for more information.

Resources