我正在尝试为PayPal sdk应用程序集成iOS。我已经通过Cocoapods安装了它...现在我想链接一些二进制文件。我是否必须下载它们并手动添加,或者是什么情况?请让我知道这样做的步骤...

谢谢...

最佳答案

请遵循以下代码:

#import "PayPalMobile.h"

@property(nonatomic, strong, readwrite) PayPalConfiguration *payPalConfig;
@property(nonatomic, strong, readwrite) NSString *environment;


实施代表

<PayPalPaymentDelegate, PayPalFuturePaymentDelegate>


调用以下名为configPaypalPayment的方法并实现委托方法,如下所示:

#pragma mark - paypal

- (void)configPaypalPayment {

  _environment = PayPalEnvironmentSandbox;

  [PayPalMobile preconnectWithEnvironment:_environment];

  // Set up payPalConfig

  _payPalConfig = [[PayPalConfiguration alloc] init];
  _payPalConfig.acceptCreditCards = YES;
  _payPalConfig.merchantName = @"Andmine";
_payPalConfig.merchantPrivacyPolicyURL = [NSURL URLWithString:@"https://www.paypal.com/webapps/mpp/ua/privacy-full&#8221"];
    _payPalConfig.merchantUserAgreementURL = [NSURL URLWithString:@"https://www.paypal.com/webapps/mpp/ua/useragreement-full&#8221"];
   _payPalConfig.languageOrLocale = [NSLocale preferredLanguages][0];
   _payPalConfig.payPalShippingAddressOption = PayPalShippingAddressOptionNone;
}

#pragma mark -
#pragma mark PayPalPaymentDelegate methods

- (void)payPalPaymentViewController:
            (PayPalPaymentViewController *)paymentViewController
                 didCompletePayment:(PayPalPayment *)completedPayment {
  NSLog(@"PayPal Payment Success!");

  [self sendCompletedPaymentToServer:completedPayment]; // Payment was processed
                                                        // successfully; send to
                                                        // server for
                                                        // verification and
                                                        // fulfillment
  [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)payPalPaymentDidCancel:
    (PayPalPaymentViewController *)paymentViewController {
  NSLog(@"PayPal Payment Canceled");
  //  self.resultText = nil;
  //  self.successView.hidden = YES;
  [self dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark Proof of payment validation

- (void)sendCompletedPaymentToServer:(PayPalPayment *)completedPayment {
  // TODO: Send completedPayment.confirmation to server
  NSLog(@"Here is your proof of payment:\n\n%@\n\nSend this to your server for "
        @"confirmation and fulfillment.",
        completedPayment.confirmation);
}

#pragma mark - Authorize Future Payments

- (IBAction)getUserAuthorizationForFuturePayments:(id)sender {

  PayPalFuturePaymentViewController *futurePaymentViewController =
      [[PayPalFuturePaymentViewController alloc]
          initWithConfiguration:self.payPalConfig
                       delegate:self];
  [self presentViewController:futurePaymentViewController
                     animated:YES
                   completion:nil];
}

#pragma mark PayPalFuturePaymentDelegate methods

- (void)payPalFuturePaymentViewController:
            (PayPalFuturePaymentViewController *)futurePaymentViewController
                didAuthorizeFuturePayment:
                    (NSDictionary *)futurePaymentAuthorization {
  NSLog(@"PayPal Future Payment Authorization Success!");
//  self.resultText = [futurePaymentAuthorization description];
//  [self showSuccess];

  [self sendFuturePaymentAuthorizationToServer:futurePaymentAuthorization];
  [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)payPalFuturePaymentDidCancel:
    (PayPalFuturePaymentViewController *)futurePaymentViewController {
  NSLog(@"PayPal Future Payment Authorization Canceled");
//  self.successView.hidden = YES;
  [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)sendFuturePaymentAuthorizationToServer:(NSDictionary *)authorization {
  // TODO: Send authorization to server
  NSLog(@"Here is your authorization:\n\n%@\n\nSend this to your server to "
        @"complete future payment setup.",
        authorization);
}

10-08 12:59