iOS - 如何在iPhone成功交易后从paypal检索交易ID

时间:2012-09-14 06:16:59

标签: iphone paypal

我是iPhone开发新手,我已经在我的iPhone应用程序中实现了paypal sdk并检查了沙盒环境,每件事情都运行得很好, 但是我需要在成功完成后找到paypal返回的交易ID。 我已经检查了下面的这个功能

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

然而它只显示我的状态。

1 个答案:

答案 0 :(得分:1)

您是否看过PayPal提供的示例应用程序..以下是示例应用程序中的委托方法,按照此方法您可以从此获取transactionId ...

//paymentSuccessWithKey:andStatus: is a required method. in it, you should record that the payment
//was successful and perform any desired bookkeeping. you should not do any user interface updates.
//payKey is a string which uniquely identifies the transaction.
//paymentStatus is an enum value which can be STATUS_COMPLETED, STATUS_CREATED, or STATUS_OTHER
- (void)paymentSuccessWithKey:(NSString *)payKey andStatus:(PayPalPaymentStatus)paymentStatus 
{
    NSString* transactionId = [[NSString alloc] initWithString:[payKey substringFromIndex:3]];
    status = PAYMENTSTATUS_SUCCESS;

    [self messageAlert:[NSString stringWithFormat:@"%@",transactionId] 
             title:@"Transaction success" delegate:nil];
    [transactionId release];
}
相关问题