Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
253 views
in Technique[技术] by (71.8m points)

typescript - Angular Stripe implementation with two Public Key depend on the account type

I have two Stripe Public Key which may work depending on what country the user is going to have a payment.

in my environment.ts file

export const environtment = { 
MY_PUBLIC_KEY_CH: 'chqwqw32323erwrerererkey',
MY_PUBLIC_KEY_US: 'usqwqw32323erwrerererkey',

}

in my app.module.ts file

import { NgxStripeModule } from "ngx-stripe";


 @NgModule({
imports: [NgxStripeModule.forRoot(
if(accountType === 'China_Account') {
environment.MY_PUBLIC_KEY_CH
} else if(accountType === 'US_Account'){  
environment.MY_PUBLIC_KEY_US)
 }]})

Is it possible for a two key implementation? I don't know how to implement the dual public key. Please Help. Thank you.

question from:https://stackoverflow.com/questions/65896835/angular-stripe-implementation-with-two-public-key-depend-on-the-account-type

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I resolved this problem using this documentation the old StripeService.

import { Group } from '@app/shared/models/group';

import { GroupService } from '@app/shared/services/api-services/group.service';

export class DetailsComponent implements OnInit {

groupType: Group;

 constructor(
          private groupService: GroupService,
          private stripeApiService: StripeApiService,
          private stripeService: StripeService)
           { }
ngOnInit() {
this.service.getGroup(this.storedUser.Group).subscribe(group => {
this.groupType = group;
if(group.AccountType === 'China_Account'){
  this.stripeService.setKey(environment.MY_PUBLIC_KEY_CH);
} else {
  this.stripeService.setKey(environment.MY_PUBLIC_KEY_US);
}

}) }}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...