-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot access StripeCardElement and instantiate object #135
Comments
I am not sure what I am doing wrong here. I followed the examples in the documentation but i cannot seem to instantiate the card properly. |
Hi @d0rf47, happy to help. First question, are you 100% sure both keys (secret key on the server and public key on the front are the same). I've seen this error in the past and the most common reason is mixing test/live keys between back/front |
Hi @d0rf47, The ViewChild is fine. You don't need to use a constructor, Angular will find the element in your view and create it for you. Here is a very simple working example: https://stackblitz.com/edit/ngx-stripe-issue-135. Feel free to fork it and add the necessary changes to reproduce the error. Checking again to your code I've seen two things that are worth considering:
Let me know if any of these helps you R |
Okay Ill give it a try. thanks |
That message from the compiler is because you're using Angular Strict Mode and that mode does not allow to have uninitialise variables. You can make that error go away with one of this 3 options:
This should fix the compiler error, but I'm not sure it will help you with the other error. Just let me know R |
Hey so I eneded up getting it working. You were correct about both issues. I think part of it was the editor too, after i made the changes and then restarted the ide it worked. Thanks for the help! i really appreciate it |
No problem, anytime :) |
Is this a feature request or a bug report?
Possible Bug Report
What's gone wrong?
Cannot Instantiate StripeCardElements. When trying to access getting cannot read property elements of undefined, when access this.card.element.
What was meant to happen?
The object should be accessible to use the service to process the payment
Steps to reproduce
Not currently live anywhere
Other information
Using Angular 11.0.9
app module
imports: [ CKEditorModule, BrowserModule, AppRoutingModule, FormsModule, ReactiveFormsModule, HttpClientModule, CommonModule, BrowserAnimationsModule, // required animations module ToastrModule.forRoot(), // ToastrModule added NgxStripeModule.forRoot('my_key'), ],
component
error in class: "Property 'card' has no initializer and is not definitely assigned in the constructor.ts(2564)"
html
console.log
The text was updated successfully, but these errors were encountered: