带有DropIn UI和Vault的Braintree Paypal无法正常工作

时间:2018-12-31 16:45:04

标签: android paypal braintree

过去3天,我一直在阅读文档,但无法弄清楚(或至少使它正常工作)。

我想要的是一个Drop-In UI,该UI可以记住以前添加的Paypal帐户,因此用户只需要再次单击该帐户名称,就可以使用保险柜流程。

我所做的如下

  1. 从我的服务器中检索Braintree令牌
  2. 将URL方案定义为:

    <DatePicker>
        <DatePicker.CalendarStyle>
            <Style TargetType="{x:Type Calendar}">
                <Setter Property="CalendarDayButtonStyle">
                    <Setter.Value>
                        <Style TargetType="{x:Type CalendarDayButton}">
                            <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type CalendarDayButton}">
                                            <Grid>
                                                <VisualStateManager.VisualStateGroups>
                                                    <VisualStateGroup x:Name="CommonStates">
                                                        <VisualStateGroup.Transitions>
                                                            <VisualTransition GeneratedDuration="0:0:0.1"/>
                                                        </VisualStateGroup.Transitions>
                                                        <VisualState x:Name="Normal"/>
                                                        <VisualState x:Name="MouseOver">
                                                            <Storyboard>
                                                                <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="Pressed">
                                                            <Storyboard>
                                                                <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="Disabled">
                                                            <Storyboard>
                                                                <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
                                                                <DoubleAnimation Duration="0" To=".35" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NormalText"/>
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                    <VisualStateGroup x:Name="SelectionStates">
                                                        <VisualStateGroup.Transitions>
                                                            <VisualTransition GeneratedDuration="0"/>
                                                        </VisualStateGroup.Transitions>
                                                        <VisualState x:Name="Unselected"/>
                                                        <VisualState x:Name="Selected">
                                                            <Storyboard>
                                                                <DoubleAnimation Duration="0" To=".75" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="SelectedBackground"/>
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                    <VisualStateGroup x:Name="CalendarButtonFocusStates">
                                                        <VisualStateGroup.Transitions>
                                                            <VisualTransition GeneratedDuration="0"/>
                                                        </VisualStateGroup.Transitions>
                                                        <VisualState x:Name="CalendarButtonFocused">
                                                            <Storyboard>
                                                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DayButtonFocusVisual">
                                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                                        <DiscreteObjectKeyFrame.Value>
                                                                            <Visibility>Visible</Visibility>
                                                                        </DiscreteObjectKeyFrame.Value>
                                                                    </DiscreteObjectKeyFrame>
                                                                </ObjectAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="CalendarButtonUnfocused">
                                                            <Storyboard>
                                                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DayButtonFocusVisual">
                                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                                        <DiscreteObjectKeyFrame.Value>
                                                                            <Visibility>Collapsed</Visibility>
                                                                        </DiscreteObjectKeyFrame.Value>
                                                                    </DiscreteObjectKeyFrame>
                                                                </ObjectAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                    <VisualStateGroup x:Name="ActiveStates">
                                                        <VisualStateGroup.Transitions>
                                                            <VisualTransition GeneratedDuration="0"/>
                                                        </VisualStateGroup.Transitions>
                                                        <VisualState x:Name="Active"/>
                                                        <VisualState x:Name="Inactive">
                                                            <Storyboard>
                                                                <ColorAnimation Duration="0" To="#FF777777" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalText"/>
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                    <VisualStateGroup x:Name="DayStates">
                                                        <VisualStateGroup.Transitions>
                                                            <VisualTransition GeneratedDuration="0"/>
                                                        </VisualStateGroup.Transitions>
                                                        <VisualState x:Name="RegularDay"/>
                                                        <VisualState x:Name="Today">
                                                            <Storyboard>
                                                                <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="TodayBackground"/>
                                                                <ColorAnimation Duration="0" To="#FFFFFFFF" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalText"/>
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                    <VisualStateGroup x:Name="BlackoutDayStates">
                                                        <VisualStateGroup.Transitions>
                                                            <VisualTransition GeneratedDuration="0"/>
                                                        </VisualStateGroup.Transitions>
                                                        <VisualState x:Name="NormalDay"/>
                                                        <VisualState x:Name="BlackoutDay">
                                                            <Storyboard>
                                                                <DoubleAnimation Duration="0" To=".2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Blackout"/>
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                </VisualStateManager.VisualStateGroups>
                                                <Rectangle x:Name="TodayBackground" Fill="#FFAAAAAA" Opacity="0" RadiusY="1" RadiusX="1"/>
                                                <Rectangle x:Name="SelectedBackground" Fill="#FFBADDE9" Opacity="0" RadiusY="1" RadiusX="1"/>
                                                <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
                                                <Rectangle x:Name="HighlightBackground" Fill="#FFBADDE9" Opacity="0" RadiusY="1" RadiusX="1"/>
                                                <ContentPresenter x:Name="NormalText" TextElement.Foreground="#FF333333" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="5,1,5,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                                <Path x:Name="Blackout" Data="M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12.962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 z" Fill="#FF000000" HorizontalAlignment="Stretch" Margin="3" Opacity="0" RenderTransformOrigin="0.5,0.5" Stretch="Fill" VerticalAlignment="Stretch"/>
                                                <Rectangle x:Name="DayButtonFocusVisual" IsHitTestVisible="false" RadiusY="1" RadiusX="1" Stroke="Red" Visibility="Collapsed"/><!--Stroke="#FF45D6FA"-->
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                        </Style>
                    </Setter.Value>
                </Setter>
            </Style>
        </DatePicker.CalendarStyle>
    </DatePicker>
    
  3. 使用以下代码初始化BraintreeFragment和Dropin UI:

    android:name="com.braintreepayments.api.BraintreeBrowserSwitchActivity"
        android:launchMode="singleTask">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="${applicationId}.braintree" />
    

当我运行该应用程序时,不会显示下拉式用户界面,而是在屏幕底部看到一个带有进度圈的白色区域。

如果我删除了braintreeFragment = BraintreeFragment.newInstance(getActivity(), braintreeToken); braintreeFragment.addListener(PaymentFragment.this); DropInRequest dropInRequest = new DropInRequest() .clientToken(braintreeToken) .collectDeviceData(true); startActivityForResult(dropInRequest.getIntent(context), 1); @Override public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) { if (paymentMethodNonce instanceof PayPalAccountNonce) { PayPalAccountNonce paypalAccountNonce = (PayPalAccountNonce) paymentMethodNonce; Toasty.info(context, paypalAccountNonce.getFirstName()).show(); } } BraintreeFragment,DropIn UI会正常显示,但是按下Paypal按钮除了关闭该UI不会做任何其他事情。

我在这里做错了什么?我看过很多关于CreditCard实施的教程,但是没有关于Paypal的教程可以帮助我。

0 个答案:

没有答案