簡體   English   中英

適用於iOS的PayPal SDK

[英]PayPal SDK for iOS

我正在嘗試在我的iOS應用程序中實現Paypal SDK。 我完全從自述文件指令中復制了代碼,導入了文件,並將按鈕鏈接到我的操作,但是當我單擊按鈕時,它給我一個“線程1信號:SIGABRT”錯誤並崩潰。

這是我的.m文件中的Paypal代碼:

- (IBAction)pay {

// Create a PayPalPayment
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [[NSDecimalNumber alloc] initWithString:@"39.95"];
payment.currencyCode = @"USD";
payment.shortDescription = @"Product";

// Check whether payment is processable.
if (!payment.processable) {
    // If, for example, the amount was negative or the shortDescription was empty, then
    // this payment would not be processable. You would want to handle that here.
}


// Provide a payerId that uniquely identifies a user within the scope of your system,
// such as an email address or user ID.
NSString *aPayerId = @"someone@someone.com";

// Create a PayPalPaymentViewController with the credentials and payerId, the PayPalPayment
// from the previous step, and a PayPalPaymentDelegate to handle the results.
PayPalPaymentViewController *paymentViewController;
paymentViewController = [[PayPalPaymentViewController alloc] initWithClientId:@"MY-CLIENT-ID-HERE"
                                                                receiverEmail:@"MY-EMAIL-HERE"
                                                                      payerId:aPayerId
                                                                      payment:payment
                                                                     delegate:self];

// Present the PayPalPaymentViewController.
[self presentViewController:paymentViewController animated:YES completion:nil];
}

#pragma mark - PayPalPaymentDelegate methods

- (void)payPalPaymentDidComplete:(PayPalPayment *)completedPayment {
// Payment was processed successfully; send to server for verification and fulfillment.
[self verifyCompletedPayment:completedPayment];

// Dismiss the PayPalPaymentViewController.
[self dismissViewControllerAnimated:YES completion:nil];
}

- (void)payPalPaymentDidCancel {
// The payment was canceled; dismiss the PayPalPaymentViewController.
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)verifyCompletedPayment:(PayPalPayment *)completedPayment {
// Send the entire confirmation dictionary
NSData *confirmation = [NSJSONSerialization dataWithJSONObject:completedPayment.confirmation
                                                       options:0
                                                         error:nil];

// Send confirmation to your server; your server should verify the proof of payment
// and give the user their goods or services. If the server is not reachable, save
// the confirmation and try again later.
}

有誰知道可能是什么問題?

你知道嗎?

因為您在貨幣上使用十進制數。 所以你需要在這段代碼中做點什么


//檢查付款是否可處理。

如果(!payment.processable){

// If, for example, the amount was negative or the shortDescription was empty, then
// this payment would not be processable. You would want to handle that here.

}


如果您在調試點可以在付款中找到關鍵字,請顯示,這表示您的貨幣將更改為40.0。 試試吧。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM