无法使用"v1/vault/信用卡"将信用卡存储在Paypal中. [英] Not able to store credit card in Paypal using "v1/vault/credit-cards"

查看:113
本文介绍了无法使用"v1/vault/信用卡"将信用卡存储在Paypal中.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的一个应用程序使用Paypal保险库.我需要将信用卡存储到Vault中.我使用了贝宝库api( v1/vault/credit-cards ).但是它总是返回500.我也尝试使用实际的信用卡,但没有得到积极的回应.我能够获得访问令牌,并且还能在列表服务中获得成功响应.但无法存储卡. 下面是我的代码:

I am using Paypal vault for one of my application. I need to stored Credit Card into vault. I used the paypal vault api (v1/vault/credit-cards) for it. But It always returns 500. I also tried with actual Credit card, but didn't get positive reponse. I am able to get access token and also get success response in listing service. But not able to stored card. Below is my code:

请求参数:

   NSMutableDictionary *dicCC = [[NSMutableDictionary alloc]init];
            dicCC[@"payer_id"] = @"123345";
            dicCC[@"type"] = @"visa";
            dicCC[@"number"] = @"4427802641004797";
            dicCC[@"expire_month"] = [NSNumber numberWithInt:11];
            dicCC[@"expire_year"] = [NSNumber numberWithInt:2018];
            dicCC[@"first_name"] = @"Jack";
            dicCC[@"last_name"] = @"Sparrow";
            dicCC[@"cvv2"] = @"124";

            NSString *strWebService = [NSString stringWithFormat:@"https://api.sandbox.paypal.com/v1/vault/credit-cards"];
            AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];

            // For HTTPBody with custom String format
            [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            [manager.requestSerializer setValue:strAccessToken forHTTPHeaderField:@"Authorization"];

            [manager POST:strWebService parameters:dicCC progress:^(NSProgress * _Nonnull uploadProgress) {

            } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                NSLog(@"%@",responseObject);
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                NSLog(@"%@",error.description);
            }];

响应:

Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: internal server error (500)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x170233540> { URL: https://api.sandbox.paypal.com/v1/vault/credit-cards } { status code: 500, headers {
    "CORRELATION-ID" = 114a5415672f7;
    Connection = "close, close";
    "Content-Length" = 97;
    "Content-Type" = "application/json";
    Date = "Fri, 23 Dec 2016 10:26:10 GMT";
    "PROXY_SERVER_INFO" = "host=slcsbplatformapiserv3001.slc.paypal.com;threadId=1808";
    "Paypal-Debug-Id" = "114a5415672f7, 114a5415672f7";
    Server = Apache;
    "Set-Cookie" = "X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880%26app%3Dplatformapiserv%26TIME%3D3271253080%26HTTP_X_PP_AZ_LOCATOR%3D; Expires=Fri, 23 Dec 2016 10:56:10 GMT; domain=.paypal.com; path=/; Secure; HttpOnly, X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT";
    Vary = Authorization;
    "X-SLR-RETRY" = 500;
    "X-SLR-RETRY-API" = "/v1/vault/credit-cards";
} }, NSErrorFailingURLKey=https://api.sandbox.paypal.com/v1/vault/credit-cards, com.alamofire.serialization.response.error.data=<7b226e61 6d65223a 22494e54 45524e41 4c5f5345 52564943 455f4552 524f5222 2c226d65 73736167 65223a22 416e2069 6e746572 6e616c20 73657276 69636520 6572726f 72206861 73206f63 63757272 6564222c 22646574 61696c73 223a5b5d 7d>, NSLocalizedDescription=Request failed: internal server error (500)}

有人可以帮我解决这种情况吗?

Can anyone help me out for this situation?

谢谢

推荐答案

 private fun RequestGetCardID() {
        val token = "Bearer " + access_token;
        val external_customer_id = "u-" + M.getID(this@UpgradePlan)
        val card_number = binding!!.editCardnumber.text.toString().trim()
        val expiry_date = binding!!.editExpiry.text.toString().trim()
        val month = expiry_date.substring(0, 2)
        val year = expiry_date.substring(3)
        val cvv = binding!!.editCvv.text.toString().trim()
        val card_holder = binding!!.editCardname.text.toString().trim()
        val retrofitInterface = ApiServicePaypal.getClient().create(RetrofitInterface::class.java)
        retrofitInterface.getAuthentionCard(external_customer_id, card_number, "visa", month, year, cvv, card_holder, card_holder, token, "application/json").enqueue(object : Callback<AuthenticationCardModel> {
            override fun onResponse(call: Call<AuthenticationCardModel>?, response: retrofit2.Response<AuthenticationCardModel>?) {
                if (response != null) {
                    Log.e("response", response!!.body().toString())

                } else {

                    Log.e("response", response!!.errorBody().toString())
                }
            }

            override fun onFailure(call: Call<AuthenticationCardModel>?, t: Throwable?) {
                Log.e("response", t!!.message)
            }

        })

    }

这篇关于无法使用"v1/vault/信用卡"将信用卡存储在Paypal中.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆