pay 3.0.6 → 3.0.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pay might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/models/pay/charge.rb +12 -0
- data/app/models/pay/customer.rb +1 -1
- data/app/views/pay/payments/show.html.erb +13 -13
- data/config/locales/en.yml +32 -31
- data/lib/pay/errors.rb +2 -2
- data/lib/pay/receipts.rb +26 -17
- data/lib/pay/version.rb +1 -1
- data/lib/pay.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 278b92c6de6eddff30a1e3ad856ea137b7c020570b89ceb2898396d97b94da8a
|
4
|
+
data.tar.gz: 28bb9062e581cb49f36b518a5fe47a1dd7ba248e1c868664881687aa5f0932c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e69eb63bbeb02bf4df7633bee6158b1f5ae21c5606a8807a1a3bc5f39ee9c8d01dae7939583ec00ce6f63d06962ae6b755a4700c14a209ffa4951be17d10015
|
7
|
+
data.tar.gz: bc5b4888956b0cd12de949cd2ebff34f0808b5e1fdd0e81f499ed7680c185cea911becefb201aefcd90e18fd2b6bc33db2f4f9ea1ecd1b6487dac010efdaa4c2
|
data/app/models/pay/charge.rb
CHANGED
@@ -60,6 +60,18 @@ module Pay
|
|
60
60
|
payment_processor.refund!(refund_amount)
|
61
61
|
end
|
62
62
|
|
63
|
+
def refunded?
|
64
|
+
amount_refunded.to_i > 0
|
65
|
+
end
|
66
|
+
|
67
|
+
def full_refund?
|
68
|
+
refunded? && amount == amount_refunded
|
69
|
+
end
|
70
|
+
|
71
|
+
def partial_refund?
|
72
|
+
refunded? && !full_refund?
|
73
|
+
end
|
74
|
+
|
63
75
|
def charged_to
|
64
76
|
case payment_method_type
|
65
77
|
when "card"
|
data/app/models/pay/customer.rb
CHANGED
@@ -24,41 +24,41 @@
|
|
24
24
|
|
25
25
|
<div class="bg-white rounded-lg shadow-xl p-4 sm:py-6 sm:px-10 mb-5">
|
26
26
|
<% if @payment.succeeded? %>
|
27
|
-
<h1 class="text-xl mt-2 mb-4 text-gray-700"><%=t "successful.header" %></h1>
|
28
|
-
<p class="mb-6"><%=t "successful.description" %></p>
|
27
|
+
<h1 class="text-xl mt-2 mb-4 text-gray-700"><%=t "pay.successful.header" %></h1>
|
28
|
+
<p class="mb-6"><%=t "pay.successful.description" %></p>
|
29
29
|
|
30
30
|
<% elsif @payment.canceled? %>
|
31
|
-
<h1 class="text-xl mt-2 mb-4 text-gray-700"><%=t "cancelled.header" %></h1>
|
32
|
-
<p class="mb-6"><%=t "cancelled.description" %></p>
|
31
|
+
<h1 class="text-xl mt-2 mb-4 text-gray-700"><%=t "pay.cancelled.header" %></h1>
|
32
|
+
<p class="mb-6"><%=t "pay.cancelled.description" %></p>
|
33
33
|
|
34
34
|
<% else %>
|
35
35
|
<div data-payment-intent-target="form" id="payment-elements">
|
36
36
|
<!-- Instructions -->
|
37
|
-
<h1 class="text-xl mt-2 mb-4 text-gray-700"><%=t "requires_action.header", amount: number_to_currency(@payment.amount / 100.0) %></h1>
|
38
|
-
<p class="mb-6"><%=t "requires_action.description" %></p>
|
37
|
+
<h1 class="text-xl mt-2 mb-4 text-gray-700"><%=t "pay.requires_action.header", amount: number_to_currency(@payment.amount / 100.0) %></h1>
|
38
|
+
<p class="mb-6"><%=t "pay.requires_action.description" %></p>
|
39
39
|
|
40
40
|
<div data-payment-intent-target="cardFields" class="hidden">
|
41
41
|
<!-- Name -->
|
42
|
-
<label for="cardholder-name" class="inline-block text-sm text-gray-700 font-semibold mb-2"><%=t "requires_action.full_name" %></label>
|
42
|
+
<label for="cardholder-name" class="inline-block text-sm text-gray-700 font-semibold mb-2"><%=t "pay.requires_action.full_name" %></label>
|
43
43
|
<input data-payment-intent-target="name" id="cardholder-name" type="text" placeholder="Jane Doe" required autofocus class="mt-1 mb-6 block w-full px-3 py-2 rounded-md border border-gray-300 shadow-sm focus:outline-none focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50">
|
44
44
|
|
45
45
|
<!-- Card -->
|
46
|
-
<label for="card-element" class="inline-block text-sm text-gray-700 font-semibold mb-2"><%=t "requires_action.card" %></label>
|
46
|
+
<label for="card-element" class="inline-block text-sm text-gray-700 font-semibold mb-2"><%=t "pay.requires_action.card" %></label>
|
47
47
|
<div data-payment-intent-target="card" id="card-element" class="mt-1 mb-6 block w-full px-3 py-4 rounded-md border border-gray-300 shadow-sm focus:outline-none focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50"></div>
|
48
48
|
</div>
|
49
49
|
|
50
50
|
<!-- Pay Button -->
|
51
51
|
<button data-payment-intent-target="button" data-action="click->payment-intent#confirmPayment" class="inline-block w-full px-4 py-3 mb-4 text-white rounded-lg bg-blue-400 hover:bg-blue-500">
|
52
|
-
<%=t "requires_action.button", amount: number_to_currency(@payment.amount / 100.0) %>
|
52
|
+
<%=t "pay.requires_action.button", amount: number_to_currency(@payment.amount / 100.0) %>
|
53
53
|
</button>
|
54
54
|
</div>
|
55
55
|
<% end %>
|
56
56
|
|
57
|
-
<%= link_to t("back"), @redirect_to, class: "inline-block w-full px-4 py-3 bg-gray-100 hover:bg-gray-200 text-center text-gray-600 rounded-lg" %>
|
57
|
+
<%= link_to t("pay.back"), @redirect_to, class: "inline-block w-full px-4 py-3 bg-gray-100 hover:bg-gray-200 text-center text-gray-600 rounded-lg" %>
|
58
58
|
</div>
|
59
59
|
|
60
60
|
<p class="text-center text-gray-500 text-sm">
|
61
|
-
© <%= Date.current.year %> <%= Pay.business_name %> <%=t "all_rights_reserved" %>
|
61
|
+
© <%= Date.current.year %> <%= Pay.business_name %> <%=t "pay.all_rights_reserved" %>
|
62
62
|
</p>
|
63
63
|
</div>
|
64
64
|
</div>
|
@@ -119,14 +119,14 @@
|
|
119
119
|
if (result.error) {
|
120
120
|
if (result.error.code === 'parameter_invalid_empty' &&
|
121
121
|
result.error.param === 'payment_method_data[billing_details][name]') {
|
122
|
-
this.errorMessageValue = '<%=t "requires_action.name_missing" %>'
|
122
|
+
this.errorMessageValue = '<%=t "pay.requires_action.name_missing" %>'
|
123
123
|
} else {
|
124
124
|
this.errorMessageValue = result.error.message
|
125
125
|
this.statusValue = result.error.payment_intent.status
|
126
126
|
}
|
127
127
|
} else {
|
128
128
|
this.completeValue = true;
|
129
|
-
this.successMessageValue = '<%=t "requires_action.success" %>'
|
129
|
+
this.successMessageValue = '<%=t "pay.requires_action.success" %>'
|
130
130
|
}
|
131
131
|
}
|
132
132
|
|
data/config/locales/en.yml
CHANGED
@@ -1,36 +1,37 @@
|
|
1
1
|
en:
|
2
|
-
successful:
|
3
|
-
header: Payment Successful
|
4
|
-
description: This payment was already successfully confirmed.
|
5
|
-
cancelled:
|
6
|
-
header: Payment Cancelled
|
7
|
-
description: This payment was cancelled.
|
8
|
-
requires_action:
|
9
|
-
header: Confirm your %{amount} payment
|
10
|
-
description: Extra confirmation is needed to process your payment. Please confirm your payment by filling out your payment details below.
|
11
|
-
full_name: Full name
|
12
|
-
card: Credit or debit card
|
13
|
-
button: Pay %{amount}
|
14
|
-
name_missing: Please provide your name.
|
15
|
-
success: The payment was successful.
|
16
|
-
all_rights_reserved: All rights reserved.
|
17
|
-
back: Go back
|
18
|
-
receipt:
|
19
|
-
date: Date
|
20
|
-
account_billed: Account Billed
|
21
|
-
product: Product
|
22
|
-
amount: Amount
|
23
|
-
charged_to: Charged to
|
24
|
-
additional_info: Additional Info
|
25
|
-
errors:
|
26
|
-
action_required: "This payment attempt failed because additional action is required before it can be completed."
|
27
|
-
invalid_payment: "This payment attempt failed because of an invalid payment method."
|
28
|
-
email_required: "Email is required to create a customer"
|
29
|
-
no_processor: "No payment processor selected. Make sure to set the %{class_name}'s `processor` attribute to either 'stripe' or 'braintree'."
|
30
|
-
braintree:
|
31
|
-
authorization: "Either the data you submitted is malformed and does not match the API or the API key you used may not be authorized to perform this action."
|
32
|
-
|
33
2
|
pay:
|
3
|
+
successful:
|
4
|
+
header: Payment Successful
|
5
|
+
description: This payment was already successfully confirmed.
|
6
|
+
cancelled:
|
7
|
+
header: Payment Cancelled
|
8
|
+
description: This payment was cancelled.
|
9
|
+
requires_action:
|
10
|
+
header: Confirm your %{amount} payment
|
11
|
+
description: Extra confirmation is needed to process your payment. Please confirm your payment by filling out your payment details below.
|
12
|
+
full_name: Full name
|
13
|
+
card: Credit or debit card
|
14
|
+
button: Pay %{amount}
|
15
|
+
name_missing: Please provide your name.
|
16
|
+
success: The payment was successful.
|
17
|
+
all_rights_reserved: All rights reserved.
|
18
|
+
back: Go back
|
19
|
+
receipt:
|
20
|
+
date: Date
|
21
|
+
account_billed: Account Billed
|
22
|
+
product: Product
|
23
|
+
amount: Amount
|
24
|
+
charged_to: Charged to
|
25
|
+
additional_info: Additional Info
|
26
|
+
refunded: Refunded
|
27
|
+
paid: Paid
|
28
|
+
errors:
|
29
|
+
action_required: "This payment attempt failed because additional action is required before it can be completed."
|
30
|
+
invalid_payment: "This payment attempt failed because of an invalid payment method."
|
31
|
+
email_required: "Email is required to create a customer"
|
32
|
+
no_processor: "No payment processor selected. Make sure to set the %{class_name}'s `processor` attribute to either 'stripe' or 'braintree'."
|
33
|
+
braintree:
|
34
|
+
authorization: "Either the data you submitted is malformed and does not match the API or the API key you used may not be authorized to perform this action."
|
34
35
|
user_mailer:
|
35
36
|
receipt:
|
36
37
|
subject: "Payment receipt"
|
data/lib/pay/errors.rb
CHANGED
@@ -13,13 +13,13 @@ module Pay
|
|
13
13
|
|
14
14
|
class ActionRequired < PaymentError
|
15
15
|
def message
|
16
|
-
I18n.t("errors.action_required")
|
16
|
+
I18n.t("pay.errors.action_required")
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
class InvalidPaymentMethod < PaymentError
|
21
21
|
def message
|
22
|
-
I18n.t("errors.invalid_payment")
|
22
|
+
I18n.t("pay.errors.invalid_payment")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
data/lib/pay/receipts.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Pay
|
2
2
|
module Receipts
|
3
|
+
include ActionView::Helpers::NumberHelper
|
4
|
+
|
3
5
|
def product
|
4
6
|
Pay.application_name
|
5
7
|
end
|
@@ -13,17 +15,20 @@ module Pay
|
|
13
15
|
receipt_pdf.render
|
14
16
|
end
|
15
17
|
|
16
|
-
def receipt_pdf
|
17
|
-
|
18
|
+
def receipt_pdf(**options)
|
19
|
+
defaults = {
|
18
20
|
id: id,
|
19
21
|
product: product,
|
20
22
|
company: {
|
21
23
|
name: Pay.business_name,
|
22
24
|
address: Pay.business_address,
|
23
|
-
email: Pay.support_email
|
25
|
+
email: Pay.support_email,
|
26
|
+
logo: Pay.business_logo
|
24
27
|
},
|
25
28
|
line_items: line_items
|
26
|
-
|
29
|
+
}
|
30
|
+
|
31
|
+
::Receipts::Receipt.new(defaults.deep_merge(options))
|
27
32
|
end
|
28
33
|
|
29
34
|
def invoice_filename
|
@@ -34,12 +39,12 @@ module Pay
|
|
34
39
|
invoice_pdf.render
|
35
40
|
end
|
36
41
|
|
37
|
-
def invoice_pdf
|
38
|
-
|
42
|
+
def invoice_pdf(**options)
|
43
|
+
defaults = {
|
39
44
|
id: id,
|
40
|
-
issue_date: created_at,
|
41
|
-
due_date: created_at,
|
42
|
-
status: "<b><color rgb='#5eba7d'
|
45
|
+
issue_date: I18n.l(created_at, format: :long),
|
46
|
+
due_date: I18n.l(created_at, format: :long),
|
47
|
+
status: "<b><color rgb='#5eba7d'>#{I18n.t("pay.receipt.paid").upcase}</color></b>",
|
43
48
|
bill_to: [
|
44
49
|
customer.customer_name,
|
45
50
|
customer.email
|
@@ -48,21 +53,25 @@ module Pay
|
|
48
53
|
company: {
|
49
54
|
name: Pay.business_name,
|
50
55
|
address: Pay.business_address,
|
51
|
-
email: Pay.support_email
|
56
|
+
email: Pay.support_email,
|
57
|
+
logo: Pay.business_logo
|
52
58
|
},
|
53
59
|
line_items: line_items
|
54
|
-
|
60
|
+
}
|
61
|
+
|
62
|
+
::Receipts::Invoice.new(defaults.deep_merge(options))
|
55
63
|
end
|
56
64
|
|
57
65
|
def line_items
|
58
66
|
line_items = [
|
59
|
-
[I18n.t("receipt.date"), created_at
|
60
|
-
[I18n.t("receipt.account_billed"), "#{customer.customer_name} (#{customer.email})"],
|
61
|
-
[I18n.t("receipt.product"), product],
|
62
|
-
[I18n.t("receipt.amount"),
|
63
|
-
[I18n.t("receipt.charged_to"), charged_to]
|
67
|
+
[I18n.t("pay.receipt.date"), I18n.l(created_at, format: :long)],
|
68
|
+
[I18n.t("pay.receipt.account_billed"), "#{customer.customer_name} (#{customer.email})"],
|
69
|
+
[I18n.t("pay.receipt.product"), product],
|
70
|
+
[I18n.t("pay.receipt.amount"), number_to_currency(amount / 100.0)],
|
71
|
+
[I18n.t("pay.receipt.charged_to"), charged_to]
|
64
72
|
]
|
65
|
-
line_items << [I18n.t("receipt.additional_info"), customer.owner.extra_billing_info] if customer.owner.extra_billing_info?
|
73
|
+
line_items << [I18n.t("pay.receipt.additional_info"), customer.owner.extra_billing_info] if customer.owner.extra_billing_info?
|
74
|
+
line_items << [I18n.t("pay.receipt.refunded"), number_to_currency(amount_refunded / 100.0)] if refunded?
|
66
75
|
line_items
|
67
76
|
end
|
68
77
|
end
|
data/lib/pay/version.rb
CHANGED
data/lib/pay.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Charnes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-09-
|
12
|
+
date: 2021-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|