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

feat : 결제 취소 관련 기능 개발 (#70) #95

Merged
merged 18 commits into from
Jan 12, 2023
Merged

Conversation

ImNM
Copy link
Member

@ImNM ImNM commented Jan 11, 2023

개요

작업사항

  • 결제 취소 기능을 개발했습니다.
  • 사용자가 직접 처리하는 환불.
  • 관리자(호스트)가 취소해버리는 취소. 로 두가지로 나눴습니다.
  • 관리자 취소는 권한 아직 냅뒀습니다.

관리자 취소일경우 event_id 가 필요한데
민준이처럼
/api/v1/admin/events/{event_id}/order/{order_id}/cancel

뭐이렇게 url가져가고 useCase 만 저길로 옮기면되니깐!
괜찮을것같긴하네요

  • orderResponse 를 좀더 정보를 더주기로했습니다.
  • orderMapper를 냅둬서 어제 회의시간에 공유했었던 트랜잭션 read_commit 관련 문제를 없애버렸습니다.
  • 오더맵퍼... 아마 보통 쓰는 컨벤션있는것같던데 맞춰가시쥬!
{
  "success": true,
  "status": 200,
  "data": {
    "paymentInfo": {
      "paymentMethod": "간편 결제",
      "provider": "토스페이",
      "supplyAmount": "15000원",
      "discountAmount": "0원",
      "couponName": "사용하지 않음",
      "totalAmount": "15000원",
      "orderStatus": "환불 완료",
      "receiptUrl": "https://dashboard.tosspayments.com/sales-slip?transactionId=c12bjcpoyt6SKKAvoeLDysw5JVY9XTR3lpv7dANK2Z5%2B6qX3IdFZQ627sFhlQoUn&ref=PX"
    },
    "tickets": [
      {
        "ticketName": "계좌이체티켓",
        "orderNo": "R1000028-54",
        "ticketNos": "",
        "paymentAt": "2023-01-12T03:32:04",
        "userName": "이찬진",
        "orderLinePrice": "12000원",
        "purchaseQuantity": 3,
        "answers": [
          {
            "optionGroupType": "Y/N",
            "questionName": "뒷풀이 참석 여부 조사",
            "questionDescription": "오케이포차 조사입니다.",
            "answer": "",
            "additionalPrice": "1000원"
          },
          {
            "optionGroupType": "Y/N",
            "questionName": "신한은행(110- )으로 3000원 입금 바랍니다.",
            "questionDescription": "계좌이체 확인후 티켓을 발급해드립니다 ( 승인 결제 )",
            "answer": "안갈꺼에요",
            "additionalPrice": "0원"
          }
        ]
      },
      {
        "ticketName": "계좌이체티켓",
        "orderNo": "R1000028-55",
        "ticketNos": "",
        "paymentAt": "2023-01-12T03:32:04",
        "userName": "이찬진",
        "orderLinePrice": "3000원",
        "purchaseQuantity": 1,
        "answers": [
          {
            "optionGroupType": "Y/N",
            "questionName": "뒷풀이 참석 여부 조사",
            "questionDescription": "오케이포차 조사입니다.",
            "answer": "아니오",
            "additionalPrice": "0원"
          },
          {
            "optionGroupType": "Y/N",
            "questionName": "신한은행(110- )으로 3000원 입금 바랍니다.",
            "questionDescription": "계좌이체 확인후 티켓을 발급해드립니다 ( 승인 결제 )",
            "answer": "갈게요 ㅋㅋ",
            "additionalPrice": "0원"
          }
        ]
      }
    ],
    "refundInfo": {
      "endAt": "2023-01-12T18:10:51",
      "availAble": true
    },
    "orderUuid": "e411b070-7e33-48b6-a3f7-d4fd4da9deb8",
    "orderId": 28
  },
  "timeStamp": "2023-01-12T03:34:30.60648"
}

변경로직

  • 응답값에 Money 타입이 가능하도록 수정했습니다.
  • 편하게 머니는 Money 타입으로 리턴하세요 알아서 toString으로 바꿔줍니다 ㅎㅎ
  • 이외에도 이넘값들에 JsonValue 어노테이션 달아줘서 클라이언트 편하게 한글값 기준으로 내려주도록 해놨습니다.

@ImNM ImNM added For: API [이슈 대상] 외부 API Type: Feature [이슈 목적] 새로운 기능 추가 labels Jan 11, 2023
@ImNM ImNM self-assigned this Jan 11, 2023
Comment on lines +21 to +29

@JsonCreator
static TossPaymentMethod findValue(String code) {
return Arrays.stream(TossPaymentMethod.values())
.filter(PaymentMethod -> PaymentMethod.getKr().equals(code))
.findFirst()
.orElseThrow(() -> PaymentsEnumNotMatchException.EXCEPTION);
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이부분은 토스페이먼츠로 요청받아서 응답받는 리스폰트 디티오부분인데
jsonCreator 가 역직렬화 하는 어노테이션인데
토스에서 값을 "카드" 이런식으로줘서
위처럼 필터링 돌려서 역직렬화 하는 방식썻습니다!!

easyPay, card 코드도 마찬가지.

Comment on lines -16 to 37
private final Long amount;

@Schema(description = "결제금액")
private final Money amount;

public static CreateOrderResponse from(Order order, Profile profile) {
return CreateOrderResponse.builder()
.customerEmail(profile.getEmail())
.customerName(profile.getName())
.orderName(order.getOrderName())
.orderId(order.getUuid())
.amount(order.getTotalPaymentPrice().longValue())
.amount(order.getTotalPaymentPrice())
.build();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런식으로
응답에 Money 타입을 그대로 쓰세요!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -15,16 +16,19 @@ public class CreateCartResponse {
private final List<CartItemResponse> items;

// 금액
private final String totalPrice;
private final Money totalPrice;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

금액 관련 정보들 Money로 매핑하겠습니다 좋네요

import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class CreateOrderResponse {
@Schema(description = "UUId")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저 스키마 추가를 까먹었네요 감사합니다

Comment on lines +16 to +17
public OrderResponse execute(String orderUuid) {
return orderMapper.toOrderResponse(orderUuid);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mapper 활용 좋아요

Copy link
Member

@sanbonai06 sanbonai06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엄청난 속도군여 LGTM 🌟

Copy link
Member

@kim-wonjin kim-wonjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🌟

@ImNM ImNM merged commit 4fbfe2d into dev Jan 12, 2023
@ImNM ImNM deleted the feature/70-refund-order branch January 12, 2023 06:51
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 141 Code Smells

7.3% 7.3% Coverage
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For: API [이슈 대상] 외부 API Type: Feature [이슈 목적] 새로운 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 [feature] 결제 취소 기능을 개발합니다
3 participants