commonMain.io.revenuemonster.sdk.module.PaymentModule.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rm-kotlin-sdk-jvm Show documentation
Show all versions of rm-kotlin-sdk-jvm Show documentation
Revenue Monster Kotlin Multiplatform SDK
package io.revenuemonster.sdk.module
import io.ktor.http.*
import io.revenuemonster.sdk.RevenueMonsterSDK
import io.revenuemonster.sdk.model.Item
import io.revenuemonster.sdk.model.Items
import io.revenuemonster.sdk.model.enum.PaymentMethod
import io.revenuemonster.sdk.model.request.*
import io.revenuemonster.sdk.model.response.*
class PaymentModule(private val sdk: RevenueMonsterSDK) {
// quick pay
suspend fun quickPay(data: QuickPayRequest): Item {
return sdk.call(
url = "/v3/payment/quickpay",
method = HttpMethod.Post,
body = data
)
}
// Transaction QR
suspend fun generateTransactionQR(data: TransactionQRRequest): Item {
return sdk.call(
url = "/v3/payment/transaction/qrcode",
method = HttpMethod.Post,
body = data
)
}
suspend fun getTransactionQRURL(): Items {
return sdk.call>(
url = "/v3/payment/transaction/qrcodes"
)
}
suspend fun getTransactionQRURLByCode(code: String): Item {
return sdk.call>(
url = "/v3/payment/transaction/qrcode/$code"
)
}
suspend fun getTransactionByCode(code: String): Items {
return sdk.call>(
url = "/v3/payment/transaction/qrcode/$code/transactions"
)
}
// Web Mobile Payment
suspend fun webMobilePayment(data: WebMobilePaymentRequest): Item {
return sdk.call(
url = "/v3/payment/online",
method = HttpMethod.Post,
body = data
)
}
// Get QR Code & URL By Checkout ID (QR Code)
suspend fun getQRCodeByCheckoutID(checkoutId: String, method: PaymentMethod): Item {
val data = GetQRURLByCheckoutID(checkoutId, method, "QRCODE")
return sdk.call(
url = "/v3/payment/online/checkout",
method = HttpMethod.Post,
body = data
)
}
//Get QR Code & URL By Checkout ID (URL)
suspend fun getURLByCheckoutID(checkoutId: String, method: PaymentMethod): Item {
val data = GetQRURLByCheckoutID(checkoutId, method, "URL")
return sdk.call(
url = "/v3/payment/online/checkout",
method = HttpMethod.Post,
body = data
)
}
// Get Online Transaction By Checkout ID
suspend fun getOnlineTransactionByCheckoutID(checkoutId: String): Item {
return sdk.call>(
url = "/v3/payment/online?checkoutId=$checkoutId"
)
}
// Refund
suspend fun refund(data: RefundRequest): Item {
return sdk.call(
url = "/v3/payment/refund",
method = HttpMethod.Post,
body = data
)
}
// Reverse
// FIXME : 'Store' didnt return
suspend fun reverse(orderId: String): Item {
val data = ReverseRequest(orderId = orderId)
return sdk.call(
url = "/v3/payment/reverse",
method = HttpMethod.Post,
body = data
)
}
// Query Status By Order ID
suspend fun queryStatusByOrderID(orderId: String): Item {
return sdk.call>(
url = "/v3/payment/transaction/order/$orderId"
)
}
// Query Status by Transaction ID
suspend fun queryStatusByTransactionID(transactionId: String): Item {
return sdk.call>(
url = "/v3/payment/transaction/$transactionId"
)
}
// Get Fpx Bank List
suspend fun getFpxBanks(): Item