fix statement descriptor param

This commit is contained in:
Rimian Perkins 2019-10-22 09:24:54 +11:00
parent c6dd47d328
commit 2179e3d280
3 changed files with 26 additions and 17 deletions

View File

@ -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

View File

@ -53,12 +53,16 @@
</table>
</p>
<section>
<hr>
<div class="buttons">
<div class="pull-right">
{{#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"}}
{{d-button label="discourse_patrons.admin.products.operations.update" action="updateProduct" icon="check"}}
{{/if}}
</div>
</section>

View File

@ -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' } }