Skip to content

Commit

Permalink
Update README.md and remove unused plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ronjunevaldoz committed Sep 26, 2024
1 parent afb9eac commit 7277b70
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 110 deletions.
5 changes: 0 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
122 changes: 62 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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 = ""
)
)
}
Expand All @@ -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<ReceiveWebhookEvent>(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<ReceiveWebhookEvent>(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-<PLATFORM>:1.0.0")
```


## How do I deploy it to Maven Central?

Expand All @@ -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 "<your key id>"
```
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 "<KEY_ID>")"
Expand All @@ -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`
45 changes: 0 additions & 45 deletions convention-plugins/src/main/kotlin/module.publication.gradle.kts

This file was deleted.

0 comments on commit 7277b70

Please sign in to comment.