RazorPay Button Added

This commit is contained in:
shabinder 2021-03-16 19:35:08 +05:30
parent b5387d8abd
commit a0b5b0d170

View File

@ -1,11 +1,13 @@
package home package home
import kotlinx.browser.document
import kotlinx.css.* import kotlinx.css.*
import kotlinx.dom.appendElement
import kotlinx.dom.createElement
import kotlinx.html.SCRIPT
import kotlinx.html.id
import react.* import react.*
import styled.css import styled.*
import styled.styledA
import styled.styledDiv
import styled.styledImg
external interface IconListProps : RProps { external interface IconListProps : RProps {
var iconsAndPlatforms: Map<String,String> var iconsAndPlatforms: Map<String,String>
@ -22,6 +24,19 @@ fun RBuilder.IconList(handler:IconListProps.() -> Unit): ReactElement {
} }
private val iconList = functionalComponent<IconListProps>("IconList") { props -> private val iconList = functionalComponent<IconListProps>("IconList") { props ->
useEffect {
val form = document.getElementById("razorpay-form")!!
repeat(form.childNodes.length){
form.childNodes.item(it)?.let { it1 -> form.removeChild(it1) }
}
form.appendElement("script"){
this.setAttribute("src","https://checkout.razorpay.com/v1/payment-button.js")
this.setAttribute("async", true.toString())
this.setAttribute("data-payment_button_id", "pl_GnKuuDBdBu0ank")
}
}
styledDiv { styledDiv {
css { css {
margin(18.px) margin(18.px)
@ -30,7 +45,16 @@ private val iconList = functionalComponent<IconListProps>("IconList") { props ->
} }
+ Styles.makeRow + Styles.makeRow
} }
val firstElem = props.iconsAndPlatforms.keys.elementAt(1)
for((icon,platformLink) in props.iconsAndPlatforms){ for((icon,platformLink) in props.iconsAndPlatforms){
if(icon == firstElem && props.isBadge){
//<form><script src="https://checkout.razorpay.com/v1/payment-button.js" data-payment_button_id="pl_GnKuuDBdBu0ank" async> </script> </form>
styledForm {
attrs{
id = "razorpay-form"
}
}
}
styledA(href = platformLink,target="_blank"){ styledA(href = platformLink,target="_blank"){
styledImg { styledImg {
attrs { attrs {