diff --git a/app/controllers/admin/products_controller.rb b/app/controllers/admin/products_controller.rb
index 50772c7..9a32d60 100644
--- a/app/controllers/admin/products_controller.rb
+++ b/app/controllers/admin/products_controller.rb
@@ -20,10 +20,7 @@ module DiscoursePatrons
def create
begin
product = ::Stripe::Product.create(
- type: 'service',
- name: params[:name],
- active: params[:active],
- metadata: metadata
+ product_params.merge(type: 'service')
)
render_json_dump product
@@ -48,9 +45,7 @@ module DiscoursePatrons
begin
product = ::Stripe::Product.update(
params[:id],
- name: params[:name],
- active: params[:active],
- metadata: metadata
+ product_params
)
render_json_dump product
@@ -73,8 +68,13 @@ module DiscoursePatrons
private
- def metadata
- { group_name: params[:metadata][:group_name] }
+ def product_params
+ {
+ name: params[:name],
+ statement_descriptor: params[:statement_descriptor],
+ active: params[:active],
+ metadata: { group_name: params[:metadata][:group_name] }
+ }
end
end
end
diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-products-show.hbs b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-products-show.hbs
index 86c68eb..f968f26 100644
--- a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-products-show.hbs
+++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons-products-show.hbs
@@ -53,12 +53,16 @@
-
-
- {{#if model.product.isNew}}
- {{d-button label="discourse_patrons.admin.products.operations.create" action="createProduct" icon="plus"}}
- {{else}}
- {{d-button label="discourse_patrons.admin.products.operations.update" action="updateProduct" icon="fa-save"}}
- {{/if}}
-
+
+
+
+
+ {{#if model.product.isNew}}
+ {{d-button label="discourse_patrons.admin.products.operations.create" action="createProduct" icon="plus"}}
+ {{else}}
+ {{d-button label="discourse_patrons.admin.products.operations.update" action="updateProduct" icon="check"}}
+ {{/if}}
+
+
+
diff --git a/spec/requests/admin/products_controller_spec.rb b/spec/requests/admin/products_controller_spec.rb
index 6e95f15..eda8cb2 100644
--- a/spec/requests/admin/products_controller_spec.rb
+++ b/spec/requests/admin/products_controller_spec.rb
@@ -69,6 +69,11 @@ module DiscoursePatrons
post "/patrons/admin/products.json", params: { active: 'false', metadata: { group_name: '' } }
end
+ it 'has a statement descriptor' do
+ ::Stripe::Product.expects(:create).with(has_entry(statement_descriptor: 'Blessed are the cheesemakers'))
+ post "/patrons/admin/products.json", params: { statement_descriptor: 'Blessed are the cheesemakers', metadata: { group_name: '' } }
+ end
+
it 'has a metadata' do
::Stripe::Product.expects(:create).with(has_entry(metadata: { group_name: 'discourse-user-group-name' }))
post "/patrons/admin/products.json", params: { metadata: { group_name: 'discourse-user-group-name' } }