I am receiving this token back from stripe.com, this.token tok_1E38C6Hzz3t7gwGKyWMW0mLA, and console.log it before sending it to the back end. It is defined in the console.log code below:
onSubmit() {
this.stripeService
.createToken(this.card.getCard(), this.address)
.subscribe(result => {
if (result.token) {
this.approveCreditCardResponse.token = result.token.id;
console.log('this.address', this.address);
console.log('this.token', this.approveCreditCardResponse.token);
} else if (result.error) {
// Error creating the token
console.log(result.error.message);
}
});
const data = {
"amount" : this.approveCreditCardResponse.amount,
"currency" : this.approveCreditCardResponse.currency,
"description" : this.approveCreditCardResponse.description,
"token" : this.approveCreditCardResponse.token,
"name": this.address.name,
"address_line1": this.address.address_line1,
"address_line2": this.address.address_line2,
"address_city": this.address.address_city,
"address_state" : this.address.address_state,
"address_zip": this.address.address_zip,
"address_country": this.address.address_country
}
console.log('this.token', this.approveCreditCardResponse.token);
this.creditCardService.postCcData(data);
}
I get this response in the google chrome console window:
this.token tok_1E38C6Hzz3t7gwGKyWMW0mLA
I send it to the aspnet core backend with this code:
public async Task<IActionResult> PostCreditCardData([FromBody] StripeDto stripeDto)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
all of the values are defined in stripeDto using a breakpoint except for token. token is defined as ""
This is the StripeDto.cs
public class StripeDto
{
public int id { get; set; }
public string amount { get; set; }
public string currency { get; set; }
public string description { get; set; }
public string token { get; set; }
public string name { get; set; }
public string address_city { get; set; }
public string address_line1 { get; set; }
public string address_line2 { get; set; }
public string address_state { get; set; }
public string address_zip { get; set; }
public string address_country { get; set; }
}
What am I missing?