Skip to content

Commit

Permalink
Merge pull request #454 from Sachin-Mamoru/petdesk-billing
Browse files Browse the repository at this point in the history
[PetDesk App] Add ACR based step up authentication for billing api
  • Loading branch information
malithie authored Apr 30, 2024
2 parents cf8071d + 4aebddf commit ad6866b
Show file tree
Hide file tree
Showing 24 changed files with 1,080 additions and 798 deletions.
6 changes: 6 additions & 0 deletions petcare-sample/b2c/web-app/petdesk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
```
bal run
```
1. Navigate to <PROJECT_HOME>/petcare-sample/b2c/web-app/petdesk/apis/ballerina/billing-management-service and start the
pet management service by executing the following command in the terminal.
```
bal run
```
> [!NOTE]
Expand Down Expand Up @@ -40,6 +45,7 @@ dbPort = "<DB_PORT>"
signInRedirectURL: "http://localhost:5173",
signOutRedirectURL: "http://localhost:5173",
resourceServerURL: "http://localhost:9090",
billingServerURL: "http://localhost:9091",
scope: ["openid", "email", "profile"]
```
2. Run the application by executing the following command in the terminal.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"image": "ballerina/ballerina-devcontainer:2201.3.2",
"extensions": ["WSO2.ballerina"],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
org = "sachinm"
name = "billing_management_service"
version = "0.1.0"
distribution = "2201.3.2"

[build-options]
observabilityIncluded = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,307 @@
# AUTO-GENERATED FILE. DO NOT MODIFY.

# This file is auto-generated by Ballerina for managing dependency versions.
# It should not be modified by hand.

[ballerina]
dependencies-toml-version = "2"

[[package]]
org = "ballerina"
name = "auth"
version = "2.5.0"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.array"},
{org = "ballerina", name = "lang.string"},
{org = "ballerina", name = "log"},
{org = "ballerina", name = "regex"}
]

[[package]]
org = "ballerina"
name = "cache"
version = "3.3.0"
dependencies = [
{org = "ballerina", name = "constraint"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "task"},
{org = "ballerina", name = "time"}
]

[[package]]
org = "ballerina"
name = "constraint"
version = "1.0.2"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "crypto"
version = "2.3.2"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"}
]

[[package]]
org = "ballerina"
name = "file"
version = "1.5.0"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "log"},
{org = "ballerina", name = "os"},
{org = "ballerina", name = "regex"},
{org = "ballerina", name = "time"}
]

[[package]]
org = "ballerina"
name = "http"
version = "2.5.4"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "constraint"},
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "file"},
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "jwt"},
{org = "ballerina", name = "lang.array"},
{org = "ballerina", name = "lang.decimal"},
{org = "ballerina", name = "lang.int"},
{org = "ballerina", name = "lang.runtime"},
{org = "ballerina", name = "lang.string"},
{org = "ballerina", name = "lang.value"},
{org = "ballerina", name = "log"},
{org = "ballerina", name = "mime"},
{org = "ballerina", name = "oauth2"},
{org = "ballerina", name = "observe"},
{org = "ballerina", name = "regex"},
{org = "ballerina", name = "time"},
{org = "ballerina", name = "url"}
]
modules = [
{org = "ballerina", packageName = "http", moduleName = "http"}
]

[[package]]
org = "ballerina"
name = "io"
version = "1.3.1"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.value"}
]

[[package]]
org = "ballerina"
name = "jballerina.java"
version = "0.0.0"

[[package]]
org = "ballerina"
name = "jwt"
version = "2.5.0"
dependencies = [
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.int"},
{org = "ballerina", name = "lang.string"},
{org = "ballerina", name = "log"},
{org = "ballerina", name = "regex"},
{org = "ballerina", name = "time"}
]
modules = [
{org = "ballerina", packageName = "jwt", moduleName = "jwt"}
]

[[package]]
org = "ballerina"
name = "lang.__internal"
version = "0.0.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
]

[[package]]
org = "ballerina"
name = "lang.array"
version = "0.0.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.__internal"}
]

[[package]]
org = "ballerina"
name = "lang.decimal"
version = "0.0.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.int"
version = "0.0.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.object"
version = "0.0.0"

[[package]]
org = "ballerina"
name = "lang.regexp"
version = "0.0.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.runtime"
version = "0.0.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.string"
version = "0.0.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.regexp"}
]

[[package]]
org = "ballerina"
name = "lang.value"
version = "0.0.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "log"
version = "2.5.1"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.value"},
{org = "ballerina", name = "observe"}
]

[[package]]
org = "ballerina"
name = "mime"
version = "2.5.1"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.int"}
]

[[package]]
org = "ballerina"
name = "oauth2"
version = "2.5.0"
dependencies = [
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "log"},
{org = "ballerina", name = "time"}
]

[[package]]
org = "ballerina"
name = "observe"
version = "1.0.6"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "os"
version = "1.5.0"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "regex"
version = "1.3.2"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.string"}
]

[[package]]
org = "ballerina"
name = "task"
version = "2.3.2"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"}
]

[[package]]
org = "ballerina"
name = "time"
version = "2.2.5"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "url"
version = "2.2.4"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerinai"
name = "observe"
version = "0.0.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "observe"}
]
modules = [
{org = "ballerinai", packageName = "observe", moduleName = "observe"}
]

[[package]]
org = "sachinm"
name = "billing_management_service"
version = "0.1.0"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "jwt"},
{org = "ballerinai", name = "observe"}
]
modules = [
{org = "sachinm", packageName = "billing_management_service", moduleName = "billing_management_service"}
]


Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
table<Billing> key(owner) billingRecords = table [];

function addBilling(BillingInfo billingInfo, string owner) returns Billing|error {

billingRecords.put({owner: owner, cardName: billingInfo.cardName,
cardNumber: billingInfo.cardNumber, expiryDate: billingInfo.expiryDate,
securityCode: billingInfo.securityCode});
Billing billingRecord = <Billing>billingRecords[owner];
Billing billing = getBillingDetails(billingRecord);
return billing;
}

function getBillingByOwner(string owner) returns Billing|() {

Billing? billingRecord = billingRecords[owner];

if billingRecord is () {
return ();
}

return getBillingDetails(billingRecord);
}

function getBillingDetails(Billing billingRecord) returns Billing {

Billing billing = {
owner: billingRecord.owner,
cardName: billingRecord.cardName,
cardNumber: billingRecord.cardNumber,
expiryDate: billingRecord.expiryDate,
securityCode: billingRecord.securityCode
};

return billing;
}
Loading

0 comments on commit ad6866b

Please sign in to comment.