* Add two guards when purchasing credits This prevents sending an empty card to stripe, and avoids a foreseeable error when purchasing 0 credits. Error returned from stripe is "This value must be greater than or equal to 1". * Move redirect back into action method Only use validation methods to check input and set appropriate messages. * Accept organization id if set The payment service will use the organization id (and charge the organization) when that's the purchaser. Don't fail when no stripe token or card selected if an organization admin is purchasing credits. * Move validation into the payment processing service This cleans up the number of details the controller needs to worry about Now only if the process payment service had any tests... * Prevent only organization_id from permitting purchase and move this check to a method, with an intention revealing name * Add i18n translation for error message There weren't any service side error messages - this will be displayed in a view (credits/purchase) but comes from the payment service - other messages (from stripe) are passed through as-is there. If this is the wrong _place_ for the translation I can retool. * Add unit test for payment processing Only checking errors are raised as expected and the internal error message is translated. * Leave translation alone Revert test translation |
||
|---|---|---|
| .. | ||
| customer_spec.rb | ||
| process_credit_purchase_spec.rb | ||