Paypal smart buttons credit card fill or hide phone number - paypal-rest-sdk

I'm allowing credit card payment with paypal smart buttons. This is how my createOrder looks like:
createOrder: function(data, actions) {
paypalActions = actions;
return fetch('/basket/get/lineitems', {
method: 'get'
}).then(function(res) {
return res.json();
}).then(function(orderData) {
orderDataArray = [orderData]
return actions.order.create({
payer: {
name: {
given_name: "PayPal",
surname: "Customer"
},
address: {
address_line_1: '123 ABC Street',
address_line_2: 'Apt 2',
admin_area_2: 'San Jose',
admin_area_1: 'CA',
postal_code: '95121',
country_code: 'US'
},
email_address: "customer#domain.com",
phone: {
phone_type: "MOBILE",
phone_number: {
national_number: "12345678"
}
}
},
purchase_units: orderDataArray,
shipping_type: 'PICKUP',
application_context: { shipping_preference: 'NO_SHIPPING' }
})
});
},
(The fetch requests gets my card items.)
Following the docs: https://developer.paypal.com/docs/checkout/integration-features/standard-card-fields/#optimize-the-card-fields it's working nicely to pass the billing address which I already have. Only the phone Number does not get filled.
What is needed to fill the phone field with above example? Or even better is it possible to set it to not required?

The number length for National Numbers is a validation for the API; using the US example you needed the correct length of the phone number. For US Numbers it expects 1 ### ### ####

Related

Is there a way to add shipping to paymentIntent with stripe and node.js?

I am able to create a paymentintent in the backend like this:
const payment = await stripe.paymentIntents.create({
amount: req.body.amount,
currency: "USD",
customer: id,
automatic_payment_methods: {enabled:true}
});
And it works perfectly, but when I try to add the shipping address given by the client like this:
const payment = await stripe.paymentIntents.create({
amount: req.body.amount,
currency: "USD",
customer: id,
shipping: {
address: req.body.address,
},
automatic_payment_methods: {enabled:true}
});
It never sends the response, and I don't get any errors at all so I'm not sure what I'm doing wrong here. I checked stripe API and it shows in the documentation that you can provide a shipping address. I don't want to attach it to the customer I created because they may have a different shipping address each time. I would rather attach it to the payment intent.
FYI here is the req.body.address that is being sent:
address: {
"city": "Nashville",
"country": "US",
"line1": "3230 Random Address",
"postal_code": "38118",
"state": "TN",
}
And I can confirm that it doesn't matter what the line1 is, because when I attached it to the createCustomer, it showed the address perfectly fine through stripe's end.
The entire post code:
paymentRouter.post('/create-payment', isAuth, expressAsyncHandler(async (req,res) => {
try {
// check if customer exist in stripe
var customer_exist = await stripe.customers.list({
email: req.body.email,
limit:1,
})
if(customer_exist){
var id = customer_exist.data[0].id
} else {
const customer = await stripe.customers.create({
email: req.body.email,
name: req.body.firstName + " " + req.body.lastName,
});
var id = customer.id
}
const payment = await stripe.paymentIntents.create({
amount: req.body.amount,
currency: "USD",
customer: id,
shipping: {
address: req.body.address,
},
automatic_payment_methods: {enabled:true}
});
res.send({
clientSecret: payment.client_secret,
});
} catch (error) {
res.json({
error: {message: error.message,}
});
}
}));
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
Well of course I found the solution as I post my problem.
It seems I was missing the shipping name. So I added the shipping name and it works perfectly now. And of course the error did not print because I did not console.log it until now.
[Edit]: so the documentation does show name is a requirement and I completely missed it somehow. Issue resolved now and here is what I implemented:
const payment = await stripe.paymentIntents.create({
amount: req.body.amount,
currency: "USD",
customer: id,
shipping: {
name: req.body.firstName + " " + req.body.lastName,
address: req.body.address,
},
automatic_payment_methods: {enabled:true}
});

How can I set up a test, Stripe connect account on the backend and skip onboarding?

When I try to set up a test, Stripe connect account on the backend and skip onboarding, I run into address and identity verification issues. How can I resolve these?
Background: for testing backend features other than Stripe onboarding, it would be helpful to set up a test Stripe connect account that has completed onboarding. There are other answers here indicating that there is no one-call process to complete that, but it's not clear exactly what the steps are.
Below I try to complete this in 3 steps; but I am running into an issue: the address is unverified even though I'm using the address 'token' that the documentation says will automatically verify.
My steps:
Create an account token
Create a bank_account token
Create an account, using those tokens
Result: when I check the account after a few seconds (I wait 10 seconds for verification) I get:
account.payouts_enabled: true
account.charges_enabled: true
account.currently_due: [
"individual.address.line1"
]
account.past_due: []
account.eventually_due: []
account.disabled_reason: requirements.pending_verification
account.pending_verification: [
'individual.address.city',
'individual.address.line1',
'individual.address.postal_code',
'individual.address.state',
'individual.id_number'
]
The problem: why is the address line marked "currently_due" (when I'm using the documented token "address_full_match​") and address verification incomplete? Additionally, why is the individual.id_number pending verification (when I'm using the documented token "222222222")?
Code below, using the Stripe Node API:
const accountToken = await stripe.tokens.create({
account: {
business_type: 'individual',
individual: {
first_name: 'Jenny',
last_name: 'Rosen',
// https://stripe.com/docs/connect/testing
// Use these addresses for line1 to trigger certain verification conditions. You must pass in legitimate values for the city, state, and postal_code arguments.
// address_full_match​ Successful verification.
// address_no_match Unsuccessful verification.
address: {
line1: 'address_full_match​',
city: 'Columbus',
state: 'OH',
postal_code: '43214',
// country: 'US'
},
// https://stripe.com/docs/connect/testing#test-dobs
// 1901-01-01 Successful verification. Any other DOB results in unsuccessful verification.
// 1902-01-01 Successful, immediate verification. The verification result is returned directly in the response, not as part of a webhook event.
// 1900-01-01 This DOB will trigger an Office of Foreign Assets Control (OFAC) alert.
dob: {
day: 1,
month: 1,
year: 1902
},
// https://stripe.com/docs/connect/testing
// Use these personal ID numbers for individual[id_number] or the id_number attribute on the Person object to trigger certain verification conditions.
// 000000000 Successful verification. 0000 also works for SSN last 4 verification.
// 111111111 Unsuccessful verification (identity mismatch).
// 222222222 Successful, immediate verification. The verification result is returned directly in the response, not as part of a webhook event.
id_number: '222222222',
// ssn_last_4: '0000',
email: 'jenny.rosen#example.com',
phone: '000 000 0000'
},
tos_shown_and_accepted: true,
},
});
const bankAccountToken = await stripe.tokens.create({
bank_account: {
country: 'US',
currency: 'usd',
account_holder_name: 'Jenny Rosen',
account_holder_type: 'individual',
routing_number: '110000000',
account_number: '000123456789',
},
});
const account = await stripe.accounts.create({
type: 'custom',
country: 'US',
business_profile: {
mcc: '5734', // Merchant Category Code. 5734 = Computer Software Stores
product_description: 'Cool Beans, Inc',
},
external_account: bankAccountToken.id,
capabilities: {
card_payments: {
requested: true,
},
transfers: {
requested: true,
},
},
account_token: accountToken.id,
});
Here's the config that works for me:
async function createTestStripeAccount() {
return await stripe.accounts.create({
type: 'custom',
country: 'US',
capabilities: {
card_payments: { requested: true },
transfers: { requested: true }
},
business_type: 'individual',
external_account: {
object: 'bank_account',
country: 'US',
currency: 'usd',
routing_number: '110000000',
account_number: '000123456789'
},
tos_acceptance: { date: 1609798905, ip: '8.8.8.8' },
business_profile: { mcc: 5045, url: 'https://bestcookieco.com' },
individual: {
first_name: 'Test',
last_name: 'User',
phone: '+16505551234',
email: 'test#example.com',
id_number: '222222222',
address: {
line1: '123 State St',
city: 'Schenectady',
postal_code: '12345',
state: 'NY'
},
dob: {
day: 10,
month: 11,
year: 1980
}
}
})
}
I've managed to set it up today for my client in sandbox and production.
PHP version with using the official library SDK from stripe.
composer require stripe/stripe-php
At the time of this writing the above version of stripe/stripe-php is exactly v9.6.0
<?php
\Stripe\Stripe::setApiKey('yourSandbox-STRIPE_SECRET_KEY-Here');
\Stripe\Account::create([
"type" => "custom",
"country" => "GB",
"capabilities" => [
"card_payments" => [
"requested" => true,
],
"transfers" => [
"requested" => true,
],
],
"business_type" => "individual",
"external_account" => [
"object" => "bank_account",
"country" => "GB",
"currency" => "gbp",
"account_number" => "00012345",
],
'tos_acceptance' => ['date' => 1609798905, 'ip' => '8.8.8.8'],
"business_profile" => [
"mcc" => 5045,
"url" => "https://exmple.com",
],
"individual" => [
"first_name" => "Test",
"last_name" => "User",
"phone" => "+16505551234",
"email" => "test#example.com",
"id_number" => "222222222",
"address" => [
"line1" => "123 State St",
"city" => "London",
"postal_code" => "TF5 0DL",
],
"dob" => [
"day" => 01,
"month" => 01,
"year" => 1901,
],
],
]);
I hope it will help somebody to save some time. Cheers and good luck.
References:
https://stripe.com/docs/connect/custom-accounts#create
https://stripe.com/docs/connect/testing#identity-and-address-verification
https://stripe.com/docs/connect/updating-accounts
You have to add document field as well for upload document to make the account active for testing purpose.
const account = await stripe.accounts.create({
type: "custom",
country: "US",
capabilities: {
card_payments: { requested: true },
transfers: { requested: true },
},
business_type: "individual",
external_account: {
object: "bank_account",
country: "US",
currency: "usd",
routing_number: "110000000",
account_number: "000123456789",
},
tos_acceptance: { date: new Date(), ip: "8.8.8.8" },
business_profile: { mcc: 5045, url: "https://bestcookieco.com" },
individual: {
first_name: "custom_user",
last_name: "one",
phone: "+16505551234",
email: "custom_user1#yopmail.com",
id_number: "222222222",
address: {
line1: "address_full_match",
city: "Schenectady",
postal_code: "12345",
state: "NY",
},
dob: {
day: 01,
month: 01,
year: 1901,
},
verification: {
document: {
front: "file_identity_document_success",
},
},
},
});

stripe.confirmCardPayment is not a function

when i am creating subscription through stripe it gives err message
As i am doing subscription through stripe
i am also giving some msg about authentication in dashboard like 3d secure authenticatio.
and my cvc_check is unavailable in showing dashboard
1.first issue is 3d secure authentication.
2.cvc check unavailbel in India.
My account is also india
TypeError: stripe.confirmCardPayment is not a function
my code is pls what i am doing wrong
stripe.customers.create(
{
name: name,
email: email,
phone: reqObj.phone,
address: { "city": reqObj.address, "country": "IN",
"line1": "", "line2": "", "state":"India" },
},
function (err, customer) {
if (err) {res.json({ "status": false, "error": err })
console.log(err)
}else {
customer_id=customer.id;
stripe.tokens.create(
{
card: {
number: reqObj.card_no,
exp_month: reqObj.exp_month,
exp_year: reqObj.exp_year,
cvc: reqObj.cvc
},
},
function (err, token) {
if (err) {
res.json({ "status": false, "errorT": err})
} else {
// stripe.customers.createSource(
// customer_id,
// { source: token.id },
// function (err, card) {
// if (err) {
// res.json({ status: "false", "error": err })
// }else {
stripe.plans.list(
{ product: "prod_IMGu6PI2mJbBCi", active: true },
function (err, plans) {
if (!err) {
for(i in plans.data){
if(plans.data[i].amount==reqObj.amount){
var myId=plans.data[i].id
stripe.paymentMethods.create({
type: 'card',
card: {
number: reqObj.card_no,
exp_month: reqObj.exp_month,
exp_year: reqObj.exp_year,
cvc: reqObj.cvc
},
},function(err,result){
// console.log(err,result)
stripe.paymentMethods.attach(result.id, {
customer: customer_id,
},function(err,result1){
// console.log(err,"result1",result1)
stripe.customers.update(
customer_id,
{
invoice_settings: {
default_payment_method: result.id,
},
},function(err,res2){
// console.log(err,"res2")
stripe.subscriptions.create({
customer: customer_id,
items: [{ price: myId}],
expand: ['latest_invoice.payment_intent'],
},function(err,res3){
console.log(err,"res3",
res3.latest_invoice.payment_intent.client_secret)
a=res3.latest_invoice.payment_intent.client_secret
stripe.confirmCardPayment(
res3.latest_invoice.payment_intent.client_secret,
function(err,paymentIntent)
{
console.log(err,"paymentIntent",paymentIntent)
}
)}
);
} );
});
});
}
});
}
// asynchronously called
});
Your code is mixing up client-side and server-side code together which will not work. The stripe.confirmCardPayment() method comes from Stripe.js and should be called client-side in Javascript inside the browser, not server-side with Node.js.
The beginning of your code is updating a Customer with the right default payment method id. Then it's creating a Subscription. And then, if the creation fails to have the first invoice paid, for example if the card is declined or requires 3D Secure, you have to then go back to the client, in the browser, to run the next step which is to confirm the PaymentIntent associated with the Subscription's Invoice.
So you need to go back to the client, where you originally created the PaymentMethod id pm_123456 that you passed in result.id and then try to confirm the PaymentIntent.

Paypal window not showing multiple items

I'm creating my own cart and then using Paypal smart button for the payment in Angular.
For multiple items to handle, I'm uing items array in createOrder method at the backend in Express.
function arrayOfItems() {
art_details.forEach((item, index) => {
let sku = item.message;
let currency = priceDetails.collPriceL[index];
let tax = priceDetails.taxAmtL[index];
let quantity = item.quantity;
let items = [
{
name: "Collection",
sku: sku,
description: '' + item.collid,
unit_amount: { currency_code: "CAD", value: "" + currency },
tax: { currency_code: "CAD", value: "" + tax },
quantity: quantity,
},
];
return items;
});
}
I'm now using arrayOfItems() as items in createOrder:
const request = new checkoutNodeJssdk.orders.OrdersCreateRequest();
request.prefer("return=representation");
request.requestBody({
intent: "CAPTURE",
purchase_units: [
{
amount: {
currency_code: "CAD",
value: ...,
breakdown: {
...
},
},
soft_descriptor: orderkey,
items: arrayOfItems(),
shipping: {
...
},
},
],
});
Suppose I'm creating order for 2 items. art_details contains array of items I need to purchase. My order is creating successfully but the Paypal window doesn't show the items in right side. (it should appear as a dropdown of items).
What am I missing here?
Thanks

Docusign Text Tabs in template not populating

I am using docusign (production account) to allow users to sign documents. I am trying to add data to textTabs that I create through the docusign dashboard. So say if I add a text box and call it nbShares, the below code does not populate the box. All the boxes I add in the dashboard such as signature, text, checkboxes etc are not shown in the generated link. I get no API errors either. I also tried to create customFields, and pass data to them as textTab - however this did not work either.
I think I may misunderstand the flow, I add all recipients and signers programatically - is that why I cant see the placeholders/buttons I add? I have also allowed collaboration in the fields I add, made them mandatory - yet they still do not appear.
Would really appreciate some help on this. This is my envelope definition - Im using the node sdk along with ts types.
const makeEnvelopeDefinition = async (
templateName: string,
user: User,
dealId?: string,
): Promise<EnvelopeDefinition> => {
const personToSign: Signer = {
email: user.email,
name: user.name,
roleName: 'Signer',
// Should this work?
tabs: {
textTabs: [
{ tabLabel: 'nbShares', value: '1000' },
],
},
clientUserId: DOCUSIGN_CLIENT_USER_ID,
recipientId: '1',
}
const compositeTemplate: CompositeTemplate = {
serverTemplates: [
{ sequence: '1', templateId: 'remote-template-id' },
],
inlineTemplates: [
{
sequence: '1',
recipients: {
signers: [personToSign],
certifiedDeliveries: [
{
email: 'someemail#something.com',
recipientId: '77',
name: 'Receipt of transaction',
},
{
email: user.email,
recipientId: '771',
name: user.name,
},
],
},
},
],
}
// create the envelope definition
const envelope: EnvelopeDefinition = {
emailSubject: 'Review signed document',
status: 'sent',
compositeTemplates: [compositeTemplate],
}
return envelope
}
For me the solution was changing my signer to this
const personToSign: Signer = {
email: user.email,
name: user.name,
clientUserId: await getDocusignConfig().DOCUSIGN_CLIENT_USER_ID,
recipientId: '1',
routingOrder: '1', // Was missing this
roleName: 'Signer', // Must match signer specified on docusign dashboard
tabs: {
textTabs: [
{
xPosition: '150',
yPosition: '200',
name: 'First Name',
tabLabel: 'name', // Must match the dataLabel name specified on docusign
value: 'Test',
},
],
},
}
And enabling this setting 'When an envelope is sent, write the initial value of the field for all recipients' in 'Signing Settings' on docusign.

Resources