Skip to content

Instantly share code, notes, and snippets.

@mt-akar
Created February 26, 2022 22:32
Show Gist options
  • Save mt-akar/ce6fb55b6d881ab9a129f94ebfbd68c8 to your computer and use it in GitHub Desktop.
Save mt-akar/ce6fb55b6d881ab9a129f94ebfbd68c8 to your computer and use it in GitHub Desktop.
Iyzico checkout form - Angular
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