关于在iphone中从paypal获取交易id
我已经在我的iphone项目中实现了paypal支付库 成功调用以下方法后,如何检索事务id关于在iphone中从paypal获取交易id,iphone,ios,ipad,paypal,Iphone,Ios,Ipad,Paypal,我已经在我的iphone项目中实现了paypal支付库 成功调用以下方法后,如何检索事务id -(void)paymentSuccessWithKey:(NSString *)payKey andStatus:(PayPalPaymentStatus)paymentStatus { status = PAYMENTSTATUS_SUCCESS; } - (void)paymentLibraryExit { UIAlertView *alert1 = nil; swi
-(void)paymentSuccessWithKey:(NSString *)payKey andStatus:(PayPalPaymentStatus)paymentStatus {
status = PAYMENTSTATUS_SUCCESS;
}
- (void)paymentLibraryExit
{
UIAlertView *alert1 = nil;
switch (status)
{
case PAYMENTSTATUS_SUCCESS:
{
.......
...........
}
...............
..............
}
}
下面方法中的“payKey”是transactionID
-(void)paymentSuccessWithKey:(NSString *)payKey andStatus:(PayPalPaymentStatus)paymentStatus {
status = PAYMENTSTATUS_SUCCESS;
}
下面方法中的“payKey”是transactionID
-(void)paymentSuccessWithKey:(NSString *)payKey andStatus:(PayPalPaymentStatus)paymentStatus {
status = PAYMENTSTATUS_SUCCESS;
}
最后,我使用paykey by api获得了事务id,其中包含以下api详细信息:- 您可以通过解析以下api请求代码的响应数据来获取事务id:-
- (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");
}
}
最后,我使用paykey by api获得了事务id,其中包含以下api详细信息:- 您可以通过解析以下api请求代码的响应数据来获取事务id:-
- (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");
}
}
您在哪里找到api_用户名、api_密码和api_签名????找不到它们:/如果您想要api_用户名、api_密码和api_签名用于测试,那么您可以从原始帐户获得它。如果您想要api_用户名、api_密码和api_签名,那么您可以按照以下链接给出的步骤进行操作:-或者谢谢。。。现在使用沙盒凭据时,它就像一个符咒,但当我使用live凭据时,它总是抛出一个错误,即不允许用户执行该操作。。。付款已正确送达。。。但是当我尝试获取transactionid时,它总是抛出错误。。。一些想法???@Calleth'Zion'-我使用旧的MPL库使用了上述方法(请参阅:-)。但是我没有使用最新的paypal库检查它。你在哪里找到api_用户名、api_密码和api_签名????找不到它们:/如果您想要api_用户名、api_密码和api_签名用于测试,那么您可以从原始帐户获得它。如果您想要api_用户名、api_密码和api_签名,那么您可以按照以下链接给出的步骤进行操作:-或者谢谢。。。现在使用沙盒凭据时,它就像一个符咒,但当我使用live凭据时,它总是抛出一个错误,即不允许用户执行该操作。。。付款已正确送达。。。但是当我尝试获取transactionid时,它总是抛出错误。。。一些想法???@Calleth'Zion'-我使用旧的MPL库使用了上述方法(请参阅:-)。但我并没有使用最新的贝宝库进行检查。