Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payment service #671

Merged
merged 8 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/payment-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: payment service ci

on:
push:
branches: ["main"]
paths:
- "payment/**"
- ".github/workflows/actions/action.yaml"
- ".github/workflows/payment-ci.yaml"
pull_request:
branches: ["main"]
paths:
- "payment/**"
- ".github/workflows/actions/action.yaml"
- ".github/workflows/payment-ci.yaml"

workflow_dispatch:

jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: ./.github/workflows/actions
- name: Run Maven Build Command
run: mvn clean install -DskipTests -f payment
- name: Analyze with sonar cloud
if: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.ref == 'refs/heads/main' }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -f payment
- name: Log in to the Container registry
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker images
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@v3
with:
context: ./payment
push: true
tags: ghcr.io/nashtech-garage/yas-payment:latest

Unit-Tests:
needs: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/actions
- name: Run Maven Test
run: mvn test -f payment
- name: Unit Test Results
uses: dorny/test-reporter@v1
if: always()
with:
name: Unit-Test-Results
path: "payment/**/surefire-reports/*.xml"
reporter: java-junit
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ services:
YAS_SERVICES_INVENTORY: http://inventory/inventory
YAS_SERVICES_TAX: http://tax/tax
YAS_SERVICES_PROMOTION: http://promotion/promotion
YAS_SERVICES_PAYMENT: http://payment/payment
storefront-nextjs:
image: ghcr.io/nashtech-garage/yas-storefront:latest
media:
Expand Down Expand Up @@ -114,6 +115,14 @@ services:
YAS_SERVICES_CUSTOMER: http://customer/customer
YAS_SERVICES_PRODUCT: http://product/product
SERVER_PORT: "80"
payment:
image: ghcr.io/nashtech-garage/yas-payment:latest
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/payment
SERVER_SERVLET_CONTEXT_PATH: /payment
YAS_PUBLIC_URL: http://api.yas.local/payment
YAS_SERVICES_ORDER: http://order/order
SERVER_PORT: "80"
location:
image: ghcr.io/nashtech-garage/yas-location:latest
environment:
Expand Down Expand Up @@ -165,6 +174,7 @@ services:
{ url: 'http://api.yas.local/cart/v3/api-docs', name: 'Cart'},
{ url: 'http://api.yas.local/rating/v3/api-docs', name: 'Rating' },
{ url: 'http://api.yas.local/order/v3/api-docs', name: 'Order'},
{ url: 'http://api.yas.local/payment/v3/api-docs', name: 'Payment'},
{ url: 'http://api.yas.local/location/v3/api-docs', name: 'Location'},
{ url: 'http://api.yas.local/inventory/v3/api-docs', name: 'Inventory'},
{ url: 'http://api.yas.local/tax/v3/api-docs', name: 'Tax' },
Expand Down
4 changes: 4 additions & 0 deletions docker/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ scrape_configs:
metrics_path: "/tax/actuator/prometheus"
static_configs:
- targets: ["tax"]
- job_name: "payment"
metrics_path: "/payment/actuator/prometheus"
static_configs:
- targets: ["payment"]
3 changes: 2 additions & 1 deletion identity/realm-export.json
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,7 @@
"redirectUris": [
"http://api.yas.local/*",
"http://localhost:8080/*",
"http://localhost:8081/*",
"http://localhost:8083/*",
"http://localhost:8084/*",
"http://localhost:8085/*",
Expand All @@ -1046,14 +1047,14 @@
"webOrigins": [
"http://api.yas.local",
"http://localhost:8080",
"http://localhost:8081",
"http://localhost:8083",
"http://localhost:8084",
"http://localhost:8085",
"http://localhost:8086",
"http://localhost:8088",
"http://localhost:8089",
"http://localhost:8090",
"http://localhost:8090",
"http://localhost:8091",
"http://localhost:8092"
],
Expand Down
3 changes: 3 additions & 0 deletions nginx/templates/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ server {
location /search/ {
proxy_pass http://search;
}
location /payment/ {
proxy_pass http://payment;
}
}

server {
Expand Down
6 changes: 2 additions & 4 deletions order/src/main/java/com/yas/order/model/Order.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ public class Order extends AbstractAuditEntity{
private String couponCode;
private BigDecimal totalPrice;
private BigDecimal deliveryFee;

@Enumerated(EnumType.STRING)
private EOrderStatus orderStatus;
private EDeliveryMethod deliveryMethod;
private EDeliveryStatus deliveryStatus;
private EPaymentMethod paymentMethod;
private EPaymentStatus paymentStatus;
private Long paymentId;
@OneToMany(mappedBy = "orderId", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
Set<OrderItem> orderItems;

}
}
2 changes: 0 additions & 2 deletions order/src/main/java/com/yas/order/service/OrderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ public OrderVm createOrder(OrderPostVm orderPostVm) {
.orderStatus(EOrderStatus.PENDING)
.deliveryFee(orderPostVm.deliveryFee())
.deliveryMethod(orderPostVm.deliveryMethod())
.paymentMethod(orderPostVm.paymentMethod())
.paymentStatus(orderPostVm.paymentStatus())
.shippingAddressId(shippOrderAddress)
.billingAddressId(billOrderAddress)
.build();
Expand Down
4 changes: 0 additions & 4 deletions order/src/main/java/com/yas/order/viewmodel/OrderVm.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public record OrderVm(
EOrderStatus orderStatus,
EDeliveryMethod deliveryMethod,
EDeliveryStatus deliveryStatus,
EPaymentMethod paymentMethod,
EPaymentStatus paymentStatus,
Set<OrderItemVm> orderItemVms

) {
Expand All @@ -55,8 +53,6 @@ public static OrderVm fromModel(Order order) {
.deliveryFee(order.getDeliveryFee())
.deliveryMethod(order.getDeliveryMethod())
.deliveryStatus(order.getDeliveryStatus())
.paymentMethod(order.getPaymentMethod())
.paymentStatus(order.getPaymentStatus())
.orderItemVms(orderItemVms)
.build();
}
Expand Down
4 changes: 4 additions & 0 deletions order/src/main/resources/db/changelog/ddl/changelog-0007.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alter table if exists "order"
drop column payment_status,
drop column payment_method,
add column payment_id bigint;
33 changes: 33 additions & 0 deletions payment/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
Binary file added payment/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
18 changes: 18 additions & 0 deletions payment/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
3 changes: 3 additions & 0 deletions payment/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM eclipse-temurin:17-jre-alpine
ADD target/payment-0.0.1-SNAPSHOT.jar payment-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java", "-jar", "/payment-0.0.1-SNAPSHOT.jar"]
Loading