如何从android中的braintree获取现有的支付方式?

2024-04-26 07:09:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个android客户端,它调用flask python服务器,如下所示:

public void getCustomerPaymentMethods() {
    Uri.Builder builder = new Uri.Builder()
            .scheme("http")
            .authority("www.server.appspot.com")
            .appendPath("get_customer_payment_methods")
            .appendPath(mCustomerId);

    String url = builder.build().toString();

    AsyncHttpClient client = new AsyncHttpClient();
    client.get(url, new BaseJsonHttpResponseHandler<List<>>() {
        @Override
        public void onSuccess(int statusCode, Header[] headers, String rawJsonResponse, List<> response) {
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, Throwable throwable, String rawJsonData, List<> errorResponse) {
            // Display UI for no payment methods
            mNoPaymentMethodImageView.setVisibility(View.VISIBLE);
            mAddPaymentMethodButton.setVisibility(View.VISIBLE);
        }

        @Override
        protected List<> parseResponse(String rawJsonData, boolean isFailure) throws Throwable {
            return null;
        }
    });
}

这是映射到提供的url的服务器端代码:

@app.route('/get_customer_payment_methods/<cutomerId>')
def get_customer_payment_methods(customerId):
    result = braintree.Customer.find(customerId)
    return result.payment_methods

我必须在客户端保存python服务器的响应吗?你知道吗


Tags: 服务器url客户端newgetstringbuildercustomer