Stripe Api 在创建付款时遇到问题
Stripe Api is having issue while creating a payment
when i try to execute this my data is successfully be stored in
database but unfortunately when it comes with stripe api it gives an error
which i've mentioned below seems like its an error of parameter missing I don't know. Can anyone tell me where I'm wrong
//创建支付的方法
exports.createpayment=async (req,res)=>{
const payment= await paymentdata.create(req.body)
stripe.customers.create({
source: req.body.stripeToken,
fullname: req.body.fullname,
address: req.body.fullname
})
.then((customer) => {
return stripe.charges.create({
amount: req.body.amount, // Charing Rs 25
currency: 'INR',
customer: fullname
});
})
.then((charge) => {
res.send("Success") // If no error occurs
})
.catch((err) => {
res.send(err) // If some error occurs
});
}
//在 运行 条带 Api
时出错
"type": "StripeInvalidRequestError",
"raw": {
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"message": "Received unknown parameter: fullname",
"param": "fullname",
"type": "invalid_request_error",
"headers": {
"server": "nginx",
"date": "Mon, 27 Dec 2021 11:04:48 GMT",
"content-type": "application/json",
"content-length": "242",
"connection": "keep-alive",
"access-control-allow-credentials": "true",
"access-control-allow-methods": "GET, POST, HEAD, OPTIONS, DELETE",
"access-control-allow-origin": "*",
"access-control-expose-headers": "Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required",
"access-control-max-age": "300",
"cache-control": "no-cache, no-store",
"idempotency-key": "30b9c551-4596-4b35-ad09-abc6dfbb3d58",
"original-request": "req_dcy6NACGsy6EJP",
"request-id": "req_dcy6NACGsy6EJP",
"stripe-version": "2020-08-27",
"strict-transport-security": "max-age=31556926; includeSubDomains; preload"
},
"statusCode": 400,
"requestId": "req_dcy6NACGsy6EJP"
},
"rawType": "invalid_request_error",
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"param": "fullname",
"headers": {
"server": "nginx",
"date": "Mon, 27 Dec 2021 11:04:48 GMT",
"content-type": "application/json",
"content-length": "242",
"connection": "keep-alive",
"access-control-allow-credentials": "true",
"access-control-allow-methods": "GET, POST, HEAD, OPTIONS, DELETE",
"access-control-allow-origin": "*",
"access-control-expose-headers": "Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required",
"access-control-max-age": "300",
"cache-control": "no-cache, no-store",
"idempotency-key": "30b9c551-4596-4b35-ad09-abc6dfbb3d58",
"original-request": "req_dcy6NACGsy6EJP",
"request-id": "req_dcy6NACGsy6EJP",
"stripe-version": "2020-08-27",
"strict-transport-security": "max-age=31556926; includeSubDomains; preload"
},
"requestId": "req_dcy6NACGsy6EJP",
"statusCode": 400
}
//这是我的模型架构
const mongoose=require('mongoose');
const paymentSchema = new mongoose.Schema({
fullname:[{
type:mongoose.Schema.ObjectId ,
ref: "userdata",
required:true
}],
cvc:{
type:String
},
country:{
type:String,
},
address:{
type:String,
},
cardnumber:{
type:String,
required:true,
},
expires:{
type:String
},
amount:{
type:String
}
})
module.exports=mongoose.model('paymentdata', paymentSchema);
stripe 期望客户对象中的键是 name
而不是 fullname
。有关更多信息,请参见此处:stripe.com/docs/api/customers/create
在创建付款而不是 fullname
时使用 name
stripe.customers.create({
source: req.body.stripeToken,
name: req.body.fullname,
address: req.body.fullname
})
when i try to execute this my data is successfully be stored in database but unfortunately when it comes with stripe api it gives an error which i've mentioned below seems like its an error of parameter missing I don't know. Can anyone tell me where I'm wrong
//创建支付的方法
exports.createpayment=async (req,res)=>{
const payment= await paymentdata.create(req.body)
stripe.customers.create({
source: req.body.stripeToken,
fullname: req.body.fullname,
address: req.body.fullname
})
.then((customer) => {
return stripe.charges.create({
amount: req.body.amount, // Charing Rs 25
currency: 'INR',
customer: fullname
});
})
.then((charge) => {
res.send("Success") // If no error occurs
})
.catch((err) => {
res.send(err) // If some error occurs
});
}
//在 运行 条带 Api
时出错 "type": "StripeInvalidRequestError",
"raw": {
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"message": "Received unknown parameter: fullname",
"param": "fullname",
"type": "invalid_request_error",
"headers": {
"server": "nginx",
"date": "Mon, 27 Dec 2021 11:04:48 GMT",
"content-type": "application/json",
"content-length": "242",
"connection": "keep-alive",
"access-control-allow-credentials": "true",
"access-control-allow-methods": "GET, POST, HEAD, OPTIONS, DELETE",
"access-control-allow-origin": "*",
"access-control-expose-headers": "Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required",
"access-control-max-age": "300",
"cache-control": "no-cache, no-store",
"idempotency-key": "30b9c551-4596-4b35-ad09-abc6dfbb3d58",
"original-request": "req_dcy6NACGsy6EJP",
"request-id": "req_dcy6NACGsy6EJP",
"stripe-version": "2020-08-27",
"strict-transport-security": "max-age=31556926; includeSubDomains; preload"
},
"statusCode": 400,
"requestId": "req_dcy6NACGsy6EJP"
},
"rawType": "invalid_request_error",
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"param": "fullname",
"headers": {
"server": "nginx",
"date": "Mon, 27 Dec 2021 11:04:48 GMT",
"content-type": "application/json",
"content-length": "242",
"connection": "keep-alive",
"access-control-allow-credentials": "true",
"access-control-allow-methods": "GET, POST, HEAD, OPTIONS, DELETE",
"access-control-allow-origin": "*",
"access-control-expose-headers": "Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required",
"access-control-max-age": "300",
"cache-control": "no-cache, no-store",
"idempotency-key": "30b9c551-4596-4b35-ad09-abc6dfbb3d58",
"original-request": "req_dcy6NACGsy6EJP",
"request-id": "req_dcy6NACGsy6EJP",
"stripe-version": "2020-08-27",
"strict-transport-security": "max-age=31556926; includeSubDomains; preload"
},
"requestId": "req_dcy6NACGsy6EJP",
"statusCode": 400
}
//这是我的模型架构
const mongoose=require('mongoose');
const paymentSchema = new mongoose.Schema({
fullname:[{
type:mongoose.Schema.ObjectId ,
ref: "userdata",
required:true
}],
cvc:{
type:String
},
country:{
type:String,
},
address:{
type:String,
},
cardnumber:{
type:String,
required:true,
},
expires:{
type:String
},
amount:{
type:String
}
})
module.exports=mongoose.model('paymentdata', paymentSchema);
stripe 期望客户对象中的键是 name
而不是 fullname
。有关更多信息,请参见此处:stripe.com/docs/api/customers/create
在创建付款而不是 fullname
时使用 name
stripe.customers.create({
source: req.body.stripeToken,
name: req.body.fullname,
address: req.body.fullname
})