From 7277b70f7013aad8624a7cf36d4fa1888c9f4259 Mon Sep 17 00:00:00 2001 From: ronjunevaldoz Date: Thu, 26 Sep 2024 22:13:25 +0800 Subject: [PATCH] Update README.md and remove unused plugin --- CHANGELOG.md | 5 - README.md | 122 +++++++++--------- .../main/kotlin/module.publication.gradle.kts | 45 ------- 3 files changed, 62 insertions(+), 110 deletions(-) delete mode 100644 convention-plugins/src/main/kotlin/module.publication.gradle.kts diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fd3e15..0e80f0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,9 +13,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Upgrade to multiplatform with WASMJS -### Fix -- Fix wrong query navigation keys -- Fix account activation not working -- Fix svg not supported on android change premium.svg to xml - [unreleased]: https://github.com/ronjunevaldoz/KotlinPaymongo/compare/v1.0.0...HEAD \ No newline at end of file diff --git a/README.md b/README.md index 7fa23d0..9debb8e 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ Paymongo client for kotlin ![Build And Publish](https://github.com/ronjunevaldoz/KotlinPaymongo/actions/workflows/publish.yml/badge.svg) -![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/io.github.ronjunevaldoz/payomongo-kotlin?server=https%3A%2F%2Fs01.oss.sonatype.org) -[![Kotlin](https://img.shields.io/badge/kotlin-2.0.20-Beta2-blue.svg?logo=kotlin)](http://kotlinlang.org) +![Maven Central Version](https://img.shields.io/maven-central/v/io.github.ronjunevaldoz/paymongo-kotlin) +[![Kotlin](https://img.shields.io/badge/kotlin-2.0.20-blue.svg?logo=kotlin)](http://kotlinlang.org) ![GitHub](https://img.shields.io/github/license/ronjunevaldoz/KotlinPaymongo) - + ## Feature - [x] [Create Source](README.md#Usage) - DSL supported @@ -28,7 +28,7 @@ https://developers.paymongo.com/reference ## Usage ```kotlin val config = Paymongo.DefaultConfig.apply{ - secretKey = "sk_123456" + secretKey = "sk_123456" } val client = Paymongo(config) @@ -43,12 +43,12 @@ val source = client.createSource { phone = "09xxxxxxxxx", email = "sample@email.com", address = Address( - line1 = "", - line2 = "", - state = "", - postalCode = "", - city = "", - country = "" + line1 = "", + line2 = "", + state = "", + postalCode = "", + city = "", + country = "" ) ) } @@ -57,70 +57,72 @@ val source = client.createSource { ## Ktor Webhook Integration ```kotlin // http://localhost/paymongo/events -fun Route.payMongo() { - route("paymongo") { - post("events") { - processWebhookEvent(call) - } - } +fun Route.payMongo() { + route("paymongo") { + post("events") { + processWebhookEvent(call) + } + } } // sample webhook process // see instruction how to secure webhook // https://developers.paymongo.com/docs/creating-webhook#3-securing-a-webhook-optional-but-highly-recommended suspend fun processWebhookEvent(call: ApplicationCall) { - val jsonString = call.receiveText() - val webhookEvent = AppJson.decodeFromString(jsonString) - val signature = call.request.header("Paymongo-Signature") - if (signature == null) { - call.respond(HttpStatusCode.Unauthorized, "Missing Paymongo-Signature") - } else { - // signature verification - val sign = signature.split(",") - val t = sign[0].replace("t=", "").toLong() // timestamp - val te = sign[1].replace("te=", "") // test mode - val li = sign[2].replace("li=", "") // live mode - val attributes = webhookEvent.data.attributes - val liveMode = attributes.liveMode - val signatureFromPayload = "$t.$jsonString" - val signatureFromHeader = if (liveMode) { - li - } else { - te - } - val webhookSecretKey = "" // created webhook secret key - // hash signature - val hashedSignature = hash(content = signatureFromPayload, key = webhookSecretKey, algorithm = "HmacSHA256") - // check for a matching signature - if (hashedSignature == signatureFromHeader) { - // process event response here - when (val data = attributes.data) { - is Source -> {} - is Payment -> {} - else -> {} - } - call.respond(HttpStatusCode.OK, "Webhook OK") - } else { - call.respond(HttpStatusCode.Unauthorized, "Invalid signature") - } - } + val jsonString = call.receiveText() + val webhookEvent = AppJson.decodeFromString(jsonString) + val signature = call.request.header("Paymongo-Signature") + if (signature == null) { + call.respond(HttpStatusCode.Unauthorized, "Missing Paymongo-Signature") + } else { + // signature verification + val sign = signature.split(",") + val t = sign[0].replace("t=", "").toLong() // timestamp + val te = sign[1].replace("te=", "") // test mode + val li = sign[2].replace("li=", "") // live mode + val attributes = webhookEvent.data.attributes + val liveMode = attributes.liveMode + val signatureFromPayload = "$t.$jsonString" + val signatureFromHeader = if (liveMode) { + li + } else { + te + } + val webhookSecretKey = "" // created webhook secret key + // hash signature + val hashedSignature = hash(content = signatureFromPayload, key = webhookSecretKey, algorithm = "HmacSHA256") + // check for a matching signature + if (hashedSignature == signatureFromHeader) { + // process event response here + when (val data = attributes.data) { + is Source -> {} + is Payment -> {} + else -> {} + } + call.respond(HttpStatusCode.OK, "Webhook OK") + } else { + call.respond(HttpStatusCode.Unauthorized, "Invalid signature") + } + } } ``` ## Installation ```kotlin -repositories { - mavenCentral() - maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots") } +repositories { + mavenCentral() } ``` -## Dependency +## Common Dependency ```kotlin -implementation("io.github.ronjunevaldoz:kpaymongo-jvm:1.0.0-SNAPSHOT"){ - isChanging = true // this will allow to get all latest changes -} +implementation("io.github.ronjunevaldoz:paymongo-kotlin:1.0.0") ``` +## Platform specific dependency (jvm, ios, android, wasmjs) +```kotlin +implementation("io.github.ronjunevaldoz:paymongo-kotlin-:1.0.0") +``` + ## How do I deploy it to Maven Central? @@ -136,7 +138,7 @@ The most part of the job is already automated for you. However, deployment to Ma gpg --send-keys --keyserver keyserver.ubuntu.com "" ``` 1. - [ ] Now you should create secrets available to your GitHub Actions - 1. via `gh` command + 1. via `gh` command ```bash gh secret set SIGNING_KEY -a actions --body "$(gpg --export-secret-key --armor "")" @@ -147,4 +149,4 @@ The most part of the job is already automated for you. However, deployment to Ma ``` 1- [ ] Deploy command -`./gradlew publishAndReleaseToMavenCentral --no-configuration-cache` +`./gradlew publishAndReleaseToMavenCentral --no-configuration-cache` \ No newline at end of file diff --git a/convention-plugins/src/main/kotlin/module.publication.gradle.kts b/convention-plugins/src/main/kotlin/module.publication.gradle.kts deleted file mode 100644 index 7ed6443..0000000 --- a/convention-plugins/src/main/kotlin/module.publication.gradle.kts +++ /dev/null @@ -1,45 +0,0 @@ -//import gradle.kotlin.dsl.accessors._8edd1b0c1852f0ac869e9c414c462ba9.mavenPublishing -//import org.gradle.api.publish.maven.MavenPublication -//import org.gradle.api.tasks.bundling.Jar -//import org.gradle.kotlin.dsl.`maven-publish` -// -//plugins { -// com.vanniktech.maven.publish -//} -// -//mavenPublishing { -// pom { -// name.set("KotlinPaymongo") -// description.set("Paymongo Kotlin Client") -// licenses { -// license { -// name.set("MIT") -// url.set("https://opensource.org/licenses/MIT") -// } -// } -// url.set("https://ronjunevaldoz.github.io/KotlinPaymongo") -// issueManagement { -// system.set("Github") -// url.set("https://github.com/ronjunevaldoz/KotlinPaymongo/issues") -// } -// scm { -// connection.set("https://github.com/ronjunevaldoz/KotlinPaymongo.git") -// url.set("https://github.com/ronjunevaldoz/KotlinPaymongo") -// } -// developers { -// developer { -// name.set("Ron June Valdoz") -// email.set("ronjune.lopez@gmail.com") -// organization.set("Ron June Valdoz") // TODO update real org -// organizationUrl.set("https://github.com/ronjunevaldoz") // TODO update real org url -// } -// } -// } -//} -// -//signing { -// if (project.hasProperty("signing.gnupg.keyName")) { -// useGpgCmd() -// sign(publishing.publications) -// } -//}