gpt4 book ai didi

ios - 集成 Paypal SDK for iOS

转载 作者:太空宇宙 更新时间:2023-11-03 16:17:06 26 4
gpt4 key购买 nike

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

谢谢...

最佳答案

按照下面的代码:-

#import "PayPalMobile.h"

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

实现委托(delegate)

<PayPalPaymentDelegate, PayPalFuturePaymentDelegate>

调用以下名为 configPaypalPayment 的方法并按如下方式实现委托(delegate)方法:-

#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);
}

关于ios - 集成 Paypal SDK for iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32943253/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com