Created
February 26, 2022 22:32
-
-
Save mt-akar/ce6fb55b6d881ab9a129f94ebfbd68c8 to your computer and use it in GitHub Desktop.
Iyzico checkout form - Angular
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component, Inject, OnInit, Renderer2} from '@angular/core'; | |
import {PaymentService} from "../../services/payment.service"; | |
import {DOCUMENT} from '@angular/common'; | |
@Component({ | |
selector: 'app-subscription-checkout', | |
templateUrl: './subscription-checkout.component.html', | |
styleUrls: ['./subscription-checkout.component.scss'] | |
}) | |
export class SubscriptionCheckoutComponent implements OnInit { | |
constructor( | |
private _service: PaymentService, | |
private _renderer2: Renderer2, | |
@Inject(DOCUMENT) private _document: Document) { | |
} | |
ngOnInit(): void { | |
this._service.startSubscriptionForm().subscribe( | |
(checkoutFormContent) => { | |
let script = this._renderer2.createElement('script'); | |
script.type = `text/javascript`; | |
script.text = checkoutFormContent.replace(/<\/?[^>]+(>|$)/g, ""); // Remove HTML tags | |
this._renderer2.appendChild(this._document.body, script); | |
}, | |
err => { | |
console.log("err: " + JSON.stringify(err)); | |
} | |
); | |
} | |
} | |
// HTML: <div id="iyzipay-checkout-form" class="responsive"></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment