tosspayments2-rails 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39febb97b720a3f4b5b8c17869e56d30f512708c553079e158108be18b243856
4
- data.tar.gz: d1d2cb235b61caa90e9bd1477894eed5b5322b7eb497f2f3bf48a5423371401d
3
+ metadata.gz: 84f1e987292ef275a4b3027195f7e6f515eec5090ddb2e1efd6ccc0092c25762
4
+ data.tar.gz: 34165e4d654cdd9aaf4af7dcabd4cffd1167fa1b18f025ee82837a4cf14093c3
5
5
  SHA512:
6
- metadata.gz: 5fe2a225d5d062c68d6078136a77cc0e431e99e8bd22925c7ae86e8489cae598e674a0913fde2fc1ba6a13bebd547e216f14447a7750c2afe7eb34264d0e9281
7
- data.tar.gz: 111e60a9b9339dc92457af01b3749f9c56a6a1a798383ce114e72b4653fa8733464e73a3916783310d0e723df0d36cce93cca48499bb51c9b6d2941aa2ee98cc
6
+ metadata.gz: c7cc8408f58752ccc09104aa8253855c3bc6402c139e66fd7d04b32c703cca33f9d3671a2943bc9bf73825609bca5fa7e39b343628209ce23c342042aa26e831
7
+ data.tar.gz: b07e0ff258ac329d7d740b9fa32eb180cc1dfb13cfdb904cc3c4850287beefe290c5e76e9de4b15824e423f31d750fc17c1a9af945f46e1e6e893b6636147476
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  _No changes yet._
4
4
 
5
+ ## [0.5.1] - 2025-08-21
6
+ ### Fixed
7
+ - Fix NoMethodError in show.html.erb template when @payment is nil
8
+ - Add proper error handling in PaymentsController#set_payment method
9
+ - Add conditional rendering and error message for missing payment records
10
+
5
11
  ## [0.5.0] - 2025-08-21
6
12
  ### Added
7
13
  - Complete PaymentsController with full CRUD operations (index, show, new, create, checkout, success, fail, cancel)
@@ -1,7 +1,7 @@
1
1
  <h1>결제 내역</h1>
2
2
 
3
3
  <div class="mb-3">
4
- <%= link_to '새 결제', new_payment_path, class: 'btn btn-primary' %>
4
+ <%%= link_to '새 결제', new_payment_path, class: 'btn btn-primary' %>
5
5
  </div>
6
6
 
7
7
  <table class="table table-striped">
@@ -16,33 +16,33 @@
16
16
  </tr>
17
17
  </thead>
18
18
  <tbody>
19
- <% if @payments.any? %>
20
- <% @payments.each do |payment| %>
19
+ <%% if @payments.any? %>
20
+ <%% @payments.each do |payment| %>
21
21
  <tr>
22
- <td><%= payment.order_id %></td>
23
- <td><%= payment.formatted_amount %></td>
22
+ <td><%%= payment.order_id %></td>
23
+ <td><%%= payment.formatted_amount %></td>
24
24
  <td>
25
- <span class="badge <%= payment_status_class(payment.status) %>">
26
- <%= payment_status_text(payment.status) %>
25
+ <span class="badge <%%= payment_status_class(payment.status) %>">
26
+ <%%= payment_status_text(payment.status) %>
27
27
  </span>
28
28
  </td>
29
- <td><%= payment.transaction_id %></td>
30
- <td><%= payment.created_at.strftime('%Y-%m-%d %H:%M') %></td>
29
+ <td><%%= payment.transaction_id %></td>
30
+ <td><%%= payment.created_at.strftime('%Y-%m-%d %H:%M') %></td>
31
31
  <td>
32
- <%= link_to '상세', payment_path(payment), class: 'btn btn-sm btn-outline-primary' %>
33
- <% if payment.confirmed? %>
34
- <%= link_to '취소', cancel_payment_path(payment), method: :patch,
32
+ <%%= link_to '상세', payment_path(payment), class: 'btn btn-sm btn-outline-primary' %>
33
+ <%% if payment.confirmed? %>
34
+ <%%= link_to '취소', cancel_payment_path(payment), method: :patch,
35
35
  confirm: '결제를 취소하시겠습니까?',
36
36
  class: 'btn btn-sm btn-outline-danger' %>
37
- <% end %>
37
+ <%% end %>
38
38
  </td>
39
39
  </tr>
40
- <% end %>
41
- <% else %>
40
+ <%% end %>
41
+ <%% else %>
42
42
  <tr>
43
43
  <td colspan="6" class="text-center">결제 내역이 없습니다.</td>
44
44
  </tr>
45
- <% end %>
45
+ <%% end %>
46
46
  </tbody>
47
47
  </table>
48
48
 
@@ -68,7 +68,7 @@ function payment_status_text(status) {
68
68
  }
69
69
  </script>
70
70
 
71
- <%# Bootstrap CSS가 없다면 기본 스타일링 %>
71
+ <%%# Bootstrap CSS가 없다면 기본 스타일링 %>
72
72
  <style>
73
73
  .table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
74
74
  .table th, .table td { padding: 0.75rem; border-bottom: 1px solid #dee2e6; text-align: left; }
@@ -1,28 +1,28 @@
1
1
  <h1>새 결제</h1>
2
2
 
3
- <%= form_with(model: @payment, local: true) do |form| %>
4
- <% if @payment.errors.any? %>
3
+ <%%= form_with(model: @payment, local: true) do |form| %>
4
+ <%% if @payment.errors.any? %>
5
5
  <div class="alert alert-danger">
6
- <h4><%= pluralize(@payment.errors.count, "error") %> 발생:</h4>
6
+ <h4><%%= pluralize(@payment.errors.count, "error") %> 발생:</h4>
7
7
  <ul>
8
- <% @payment.errors.full_messages.each do |message| %>
9
- <li><%= message %></li>
10
- <% end %>
8
+ <%% @payment.errors.full_messages.each do |message| %>
9
+ <li><%%= message %></li>
10
+ <%% end %>
11
11
  </ul>
12
12
  </div>
13
- <% end %>
13
+ <%% end %>
14
14
 
15
15
  <div class="form-group">
16
- <%= form.label :amount, '결제 금액' %>
17
- <%= form.number_field :amount, class: 'form-control', placeholder: '예: 10000', required: true %>
16
+ <%%= form.label :amount, '결제 금액' %>
17
+ <%%= form.number_field :amount, class: 'form-control', placeholder: '예: 10000', required: true %>
18
18
  <small class="form-text text-muted">원 단위로 입력해주세요</small>
19
19
  </div>
20
20
 
21
21
  <div class="actions">
22
- <%= form.submit '결제하기', class: 'btn btn-primary' %>
23
- <%= link_to '취소', payments_path, class: 'btn btn-secondary' %>
22
+ <%%= form.submit '결제하기', class: 'btn btn-primary' %>
23
+ <%%= link_to '취소', payments_path, class: 'btn btn-secondary' %>
24
24
  </div>
25
- <% end %>
25
+ <%% end %>
26
26
 
27
27
  <style>
28
28
  .form-group { margin-bottom: 1rem; }
@@ -69,7 +69,10 @@ class PaymentsController < ApplicationController
69
69
  private
70
70
 
71
71
  def set_payment
72
- @payment = Payment.find(params[:id])
72
+ @payment = Payment.find_by(id: params[:id])
73
+ return if @payment
74
+
75
+ redirect_to payments_path, alert: '결제 정보를 찾을 수 없습니다.'
73
76
  end
74
77
 
75
78
  def payment_params
@@ -1,56 +1,65 @@
1
1
  <h1>결제 상세</h1>
2
2
 
3
+ <%% if @payment %>
3
4
  <div class="payment-detail">
4
5
  <div class="card">
5
6
  <div class="card-header">
6
7
  <h3>결제 정보</h3>
7
- <span class="badge <%= payment_status_class(@payment.status) %>">
8
- <%= payment_status_text(@payment.status) %>
8
+ <span class="badge <%%= payment_status_class(@payment.status) %>">
9
+ <%%= payment_status_text(@payment.status) %>
9
10
  </span>
10
11
  </div>
11
12
 
12
13
  <div class="card-body">
13
14
  <dl class="row">
14
15
  <dt class="col-sm-3">주문번호</dt>
15
- <dd class="col-sm-9"><%= @payment.order_id %></dd>
16
+ <dd class="col-sm-9"><%%= @payment.order_id %></dd>
16
17
 
17
18
  <dt class="col-sm-3">결제금액</dt>
18
- <dd class="col-sm-9"><%= @payment.formatted_amount %></dd>
19
+ <dd class="col-sm-9"><%%= @payment.formatted_amount %></dd>
19
20
 
20
21
  <dt class="col-sm-3">결제상태</dt>
21
22
  <dd class="col-sm-9">
22
- <span class="badge <%= payment_status_class(@payment.status) %>">
23
- <%= payment_status_text(@payment.status) %>
23
+ <span class="badge <%%= payment_status_class(@payment.status) %>">
24
+ <%%= payment_status_text(@payment.status) %>
24
25
  </span>
25
26
  </dd>
26
27
 
27
- <% if @payment.transaction_id.present? %>
28
+ <%% if @payment.transaction_id.present? %>
28
29
  <dt class="col-sm-3">거래ID</dt>
29
- <dd class="col-sm-9"><%= @payment.transaction_id %></dd>
30
- <% end %>
30
+ <dd class="col-sm-9"><%%= @payment.transaction_id %></dd>
31
+ <%% end %>
31
32
 
32
33
  <dt class="col-sm-3">생성일시</dt>
33
- <dd class="col-sm-9"><%= @payment.created_at.strftime('%Y-%m-%d %H:%M:%S') %></dd>
34
+ <dd class="col-sm-9"><%%= @payment.created_at.strftime('%Y-%m-%d %H:%M:%S') %></dd>
34
35
 
35
36
  <dt class="col-sm-3">최종 업데이트</dt>
36
- <dd class="col-sm-9"><%= @payment.updated_at.strftime('%Y-%m-%d %H:%M:%S') %></dd>
37
+ <dd class="col-sm-9"><%%= @payment.updated_at.strftime('%Y-%m-%d %H:%M:%S') %></dd>
37
38
  </dl>
38
39
  </div>
39
40
  </div>
40
41
  </div>
41
42
 
42
43
  <div class="actions">
43
- <%= link_to '목록으로', payments_path, class: 'btn btn-secondary' %>
44
+ <%%= link_to '목록으로', payments_path, class: 'btn btn-secondary' %>
44
45
 
45
- <% if @payment.confirmed? %>
46
- <%= link_to '결제 취소', cancel_payment_path(@payment), method: :patch,
46
+ <%% if @payment.confirmed? %>
47
+ <%%= link_to '결제 취소', cancel_payment_path(@payment), method: :patch,
47
48
  confirm: '정말로 이 결제를 취소하시겠습니까?',
48
49
  class: 'btn btn-danger' %>
49
- <% elsif @payment.pending? %>
50
- <%= link_to '결제 계속하기', checkout_payments_path(order_id: @payment.order_id),
50
+ <%% elsif @payment.pending? %>
51
+ <%%= link_to '결제 계속하기', checkout_payments_path(order_id: @payment.order_id),
51
52
  class: 'btn btn-primary' %>
52
- <% end %>
53
+ <%% end %>
53
54
  </div>
55
+ <%% else %>
56
+ <div class="alert alert-danger">
57
+ 결제 정보를 찾을 수 없습니다.
58
+ </div>
59
+ <div class="actions">
60
+ <%%= link_to '목록으로', payments_path, class: 'btn btn-secondary' %>
61
+ </div>
62
+ <%% end %>
54
63
 
55
64
  <script>
56
65
  function payment_status_class(status) {
@@ -147,4 +156,7 @@ function payment_status_text(status) {
147
156
  .btn-primary { color: #fff; background-color: #007bff; border-color: #007bff; }
148
157
  .btn-secondary { color: #fff; background-color: #6c757d; border-color: #6c757d; }
149
158
  .btn-danger { color: #fff; background-color: #dc3545; border-color: #dc3545; }
159
+
160
+ .alert { padding: 0.75rem 1.25rem; margin-bottom: 1rem; border: 1px solid transparent; border-radius: 0.25rem; }
161
+ .alert-danger { color: #721c24; background-color: #f8d7da; border-color: #f5c6cb; }
150
162
  </style>
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tosspayments2
4
4
  module Rails
5
- VERSION = '0.5.0'
5
+ VERSION = '0.5.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tosspayments2-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucius Choi