关于在iphone中从paypal获取交易ID [英] About geting transaction id from paypal in iphone

查看:120
本文介绍了关于在iphone中从paypal获取交易ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的iphone项目中实现了paypal库付款。

I have implement paypal library for payment in my iphone project.

如何在成功调用以下方法后检索事务ID。

How can I retrieve transaction id after following method called successfully.

-(void)paymentSuccessWithKey:(NSString *)payKey andStatus:(PayPalPaymentStatus)paymentStatus {
    status = PAYMENTSTATUS_SUCCESS;
}

- (void)paymentLibraryExit 
{
    UIAlertView *alert1 = nil;

    switch (status) 
        {           
        case PAYMENTSTATUS_SUCCESS:            
                {
                   .......
                   ...........
                }
                ...............
                ..............
         }
}


推荐答案

最后,我得到了使用api的paykey的事务ID,带有以下api详细信息: -
https://www.x.com/developers/paypal/documentation-tools/api/paymentdetails-api-operation

Finally, i got transaction id using paykey by api with following api detail:- https://www.x.com/developers/paypal/documentation-tools/api/paymentdetails-api-operation

你可以得到事务ID通过解析以下api请求代码的响应数据: -

You can get transaction id by parsing data of response of following api request code:-

- (void)paymentSuccessWithKey:(NSString *)payKey andStatus:(PayPalPaymentStatus)paymentStatus {
    status = PAYMENTSTATUS_SUCCESS;

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://svcs.paypal.com/AdaptivePayments/PaymentDetails"]];

    NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:url];


    NSString *parameterString = [NSString stringWithFormat:@"payKey=%@&requestEnvelope.errorLanguage=%@",payKey,@"en_US"];

    NSString *msgLength = [NSString stringWithFormat:@"%d", [parameterString length]];

    [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];

    //do post request for parameter passing 
    [theRequest setHTTPMethod:@"POST"];

    [theRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];

    //passing key as a http header request 
    [theRequest addValue:api_username forHTTPHeaderField:@"X-PAYPAL-SECURITY-USERID"];

    //passing key as a http header request
    [theRequest addValue:api_password forHTTPHeaderField:@"X-PAYPAL-SECURITY-PASSWORD"];

    [theRequest addValue:api_signature forHTTPHeaderField:@"X-PAYPAL-SECURITY-SIGNATURE"];

    [theRequest addValue:@"NV" forHTTPHeaderField:@"X-PAYPAL-REQUEST-DATA-FORMAT"];

    [theRequest addValue:@"NV" forHTTPHeaderField:@"X-PAYPAL-RESPONSE-DATA-FORMAT"];

    [theRequest addValue:app_id forHTTPHeaderField:@"X-PAYPAL-APPLICATION-ID"];

    [theRequest setHTTPBody: [parameterString dataUsingEncoding:NSUTF8StringEncoding]];

    NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

    if( connection )
    {
        webData = [[NSMutableData data] retain];
    }
    else
    {
        NSLog(@"theConnection is NULL");
    }
}

这篇关于关于在iphone中从paypal获取交易ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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