Very basic Stripe Connect payment method interface

This commit is contained in:
Rob Harrington
2017-02-17 18:10:17 +11:00
parent d500c20d3f
commit 987ad0df6c
6 changed files with 52 additions and 14 deletions

View File

@@ -0,0 +1,2 @@
angular.module("admin.paymentMethods").controller "StripeController", ($scope, shops) ->
$scope.shops = shops

View File

@@ -1,4 +1,4 @@
angular.module("admin.indexUtils").directive "ofnSelect2", ($sanitize, $timeout, $filter) ->
angular.module("admin.utils").directive "ofnSelect2", ($sanitize, $timeout, $filter) ->
require: 'ngModel'
restrict: 'C'
scope:

View File

@@ -1,6 +1,7 @@
/ replace "div[data-hook='admin_payment_method_form_fields']"
= admin_inject_payment_method
= admin_inject_json_ams_array "admin.paymentMethods", "shops", @hubs, Api::Admin::IdNameSerializer
%div.alpha.eleven.columns{ "ng-app" => "admin.paymentMethods", "ng-controller" => "paymentMethodCtrl" }
.row
.alpha.three.columns

View File

@@ -1,11 +1,31 @@
class Api::Admin::PaymentMethodSerializer < ActiveModel::Serializer
attributes :id, :name, :type, :tag_list, :tags
def tag_list
object.tag_list.join(",")
def serializable_hash
method_serializer.serializable_hash
end
def tags
object.tag_list.map{ |t| { text: t } }
def method_serializer
if object.type == 'Spree::Gateway::StripeConnect'
Api::Admin::PaymentMethod::StripeSerializer.new(object)
else
Api::Admin::PaymentMethod::BaseSerializer.new(object)
end
end
end
module Api::Admin::PaymentMethod
class BaseSerializer < ActiveModel::Serializer
attributes :id, :name, :type, :tag_list, :tags
def tag_list
object.tag_list.join(",")
end
def tags
object.tag_list.map{ |t| { text: t } }
end
end
class StripeSerializer < BaseSerializer
attributes :preferred_enterprise_id
end
end

View File

@@ -1,7 +1,11 @@
- if @payment_method.preferences.present?
%fieldset.alpha.eleven.columns.no-border-bottom#gateway_fields
%legend{ align: "center"}
= t(:provider_settings)
.preference-settings
= fields_for :payment_method, @payment_method do |payment_method_form|
= preference_fields(@payment_method, payment_method_form)
- case @payment_method
- when Spree::Gateway::StripeConnect
= render 'stripe_connect'
- else
- if @payment_method.preferences.present?
%fieldset.alpha.eleven.columns.no-border-bottom#gateway_fields
%legend{ align: "center"}
= t(:provider_settings)
.preference-settings
= fields_for :payment_method, @payment_method do |payment_method_form|
= preference_fields(@payment_method, payment_method_form)

View File

@@ -0,0 +1,11 @@
%fieldset.alpha.eleven.columns.no-border-bottom#gateway_fields
%legend{ align: "center"}
= t(:provider_settings)
.preference-settings{ ng: { controller: "StripeController" } }
= fields_for :payment_method, @payment_method do |payment_method_form|
= payment_method_form.label :stripe_account_owner
%br
-# = payment_method_form.collection_select(:preferred_enterprise_id, @hubs, :id, :name, {:include_blank => true}, {:class => "select2 fullwidth"})
%input.ofn-select2.fullwidth#payment_method_preferred_enterprise_id{ type: 'number',
name: 'payment_method[preferred_enterprise_id]',
data: 'shops', ng: { model: 'paymentMethod.preferred_enterprise_id' } }