caboose-cms 0.8.62 → 0.8.63
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29bfd5e0f0743f4775004a3f59719900efc517f4
|
4
|
+
data.tar.gz: 459868d31674a46f4eff2f8bbf2f0ea962028789
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9415b36ed339e43501767cbb4d991890eb1809ce1cf173d43d79e2d393d379c870191e1533cbf4eb6ea2b1e65902659c5959116bfcff80efc231c19892481a7d
|
7
|
+
data.tar.gz: 7306430f0dbcf7d6331d2ffa0c7b22669a3f6f62a726f71fc2fc8a3de6711e11db5d80851510ca0c83429ea620eccc507e4c676b9d4e33182400efc31212124a
|
@@ -717,7 +717,7 @@ InvoiceController.prototype = {
|
|
717
717
|
summary_table: function(table)
|
718
718
|
{
|
719
719
|
var that = this;
|
720
|
-
var requires_shipping = that.invoice_requires_shipping();
|
720
|
+
var requires_shipping = that.invoice_requires_shipping();
|
721
721
|
if (that.invoice.line_items.length > 0 || that.invoice.invoice_packages.length > 0)
|
722
722
|
{
|
723
723
|
table.append($('<tr/>').append($('<th/>').attr('colspan', requires_shipping ? '6' : '5').html(' ')));
|
@@ -938,11 +938,12 @@ InvoiceController.prototype = {
|
|
938
938
|
capture_transaction: function(transaction_id, confirm)
|
939
939
|
{
|
940
940
|
var that = this;
|
941
|
-
var t = that.transaction_with_id(transaction_id);
|
941
|
+
var t = that.transaction_with_id(transaction_id);
|
942
|
+
var amount = that.invoice.total < t.amount ? that.invoice.total : t.amount;
|
942
943
|
if (!confirm)
|
943
944
|
{
|
944
945
|
var p = $('<p/>').addClass('note confirm')
|
945
|
-
.append("Are you sure you want to charge $" + parseFloat(
|
946
|
+
.append("Are you sure you want to charge $" + parseFloat(amount).toFixed(2) + " to the customer?<br />")
|
946
947
|
.append($('<input/>').attr('type','button').val('Yes').click(function() { that.capture_transaction(transaction_id, true); }))
|
947
948
|
.append(' ')
|
948
949
|
.append($('<input/>').attr('type','button').val('No').click(function() { $('#transactions_message').empty(); }));
|
@@ -952,10 +953,12 @@ InvoiceController.prototype = {
|
|
952
953
|
$('#transactions_message').html("<p class='loading'>Capturing funds...</p>");
|
953
954
|
$.ajax({
|
954
955
|
url: '/admin/invoices/' + that.invoice.id + '/transactions/' + transaction_id + '/capture',
|
956
|
+
type: 'get',
|
957
|
+
data: { amount: amount },
|
955
958
|
success: function(resp) {
|
956
|
-
if (resp.error)
|
957
|
-
if (resp.success) { $('#
|
958
|
-
if (resp.refresh) { $('#
|
959
|
+
if (resp.error) $('#transactions_message').html("<p class='note error'>" + resp.error + "</p>");
|
960
|
+
if (resp.success) { $('#transactions_message').empty(); that.refresh_transactions(); }
|
961
|
+
if (resp.refresh) { $('#transactions_message').empty(); that.refresh_transactions(); }
|
959
962
|
}
|
960
963
|
});
|
961
964
|
},
|
@@ -1166,8 +1169,8 @@ InvoiceController.prototype = {
|
|
1166
1169
|
{
|
1167
1170
|
var that = this;
|
1168
1171
|
var requires = false;
|
1169
|
-
$.each(that.invoice.line_items, function(i, li) {
|
1170
|
-
if (li.requires_shipping && !li.downloadable)
|
1172
|
+
$.each(that.invoice.line_items, function(i, li) {
|
1173
|
+
if (li.variant.requires_shipping && !li.variant.downloadable)
|
1171
1174
|
requires = true;
|
1172
1175
|
});
|
1173
1176
|
return requires;
|
@@ -48,12 +48,16 @@ module Caboose
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# Capture funds from a previously authorized transaction
|
51
|
-
def capture
|
51
|
+
def capture(amount = nil)
|
52
52
|
|
53
53
|
return { :error => "This invoice doesn't seem to be authorized." } if !self.success
|
54
54
|
|
55
55
|
ct = InvoiceTransaction.where(:parent_id => self.id, :transaction_type => InvoiceTransaction::TYPE_CAPTURE, :success => true).first
|
56
56
|
return { :error => "Funds for this invoice have already been captured." } if ct
|
57
|
+
|
58
|
+
# Make sure the amount given isn't greater than the invoice total
|
59
|
+
return { :error => "Amount given to capture is greater than the current invoice total." } if amount && amount.to_f > self.invoice.total.to_f
|
60
|
+
amount = self.invoice.total if amount.nil?
|
57
61
|
|
58
62
|
resp = Caboose::StdClass.new
|
59
63
|
sc = self.invoice.site.store_config
|
@@ -63,9 +67,10 @@ module Caboose
|
|
63
67
|
|
64
68
|
Stripe.api_key = sc.stripe_secret_key.strip
|
65
69
|
bt = nil
|
66
|
-
begin
|
67
|
-
c = Stripe::Charge.retrieve(self.transaction_id)
|
68
|
-
|
70
|
+
begin
|
71
|
+
c = Stripe::Charge.retrieve(self.transaction_id)
|
72
|
+
return { :error => "Amount given to capture is greater than the amount authorized." } if amount.to_f > (c.amount/100).to_f
|
73
|
+
c = c.capture({ :amount => (amount*100).to_i })
|
69
74
|
bt = Stripe::BalanceTransaction.retrieve(c.balance_transaction)
|
70
75
|
rescue Exception => ex
|
71
76
|
resp.error = "Error during capture process\n#{ex.message}"
|
data/lib/caboose/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.63
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|