2015-10-08 90 views
0

我在做R & D如何在iOS App中集成PayPal/Apple Pay支付模块。如何在iOS App中集成PayPal/Apple Pay支付模块?

For example in my app i want to integrate PayPal/Apple pay for payment, then what should I do ? What are the process.

如果任何人都可以指导如何做到这一点。请给我建议的步骤。 任何参考链接也欢迎。

回答

2

这取决于您已经集成的付款解决方案。 贝宝将支持账户余额或信用卡/借记卡/银行账户的资金来源。虽然与PayPal钱包不同,Apple Pay/Apple钱包中没有“余额”的功能,纯粹用于卡片标记(您在电子钱包应用中设置的卡片)。

在这个用例中,您的应用程序不一定要检查钱包中是否有$ 20(PayPal或Apple Pay),而是它将启动付款请求,并从支付网关获取响应以处理订单

+1

@Florence,请访问此链接:https://developer.paypal.com/developer/applications/(需要先登录您的LIVE PayPal帐户),然后在那里创建一个APP,获取这两个沙箱的clientID并在该页面的实时环境然后 –

+0

我已经这样做了,但它给了我一个错误 clang:错误:链接器命令失败,退出代码1(使用-v看到调用) –

+0

这不是一个PayPal API响应,你可能在你的问题中添加确切的异常堆栈 –

2

中的AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 

    [PayPalMobile initializeWithClientIdsForEnvironments:@{PayPalEnvironmentProduction : @"YOUR_CLIENT_ID_FOR_PRODUCTION", 
                  PayPalEnvironmentSandbox : @"AeB0tbkw-z4Ys3NvxekUZxnVNk26WXRodQBETFG4x-HtQAuqBf5k4edWOn2zia_l8RWBFJGEUNSVWJWg"}]; 

    return YES; 
} 

与控制器

在您的.h文件中设置委托

@In terface MyCart:UITableViewController

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

在.m文件

- (void)viewDidLoad { 
NSString *[email protected]"sandbox"; 
    self.environment = environment; 
    [PayPalMobile preconnectWithEnvironment:environment]; 


_payPalConfig = [[PayPalConfiguration alloc] init]; 
    _payPalConfig.acceptCreditCards = YES; 
    _payPalConfig.merchantName = @"ScanPay"; 
    _payPalConfig.merchantPrivacyPolicyURL = [NSURL URLWithString:@"https://www.paypal.com/webapps/mpp/ua/privacy-full"]; 
    _payPalConfig.merchantUserAgreementURL = [NSURL URLWithString:@"https://www.paypal.com/webapps/mpp/ua/useragreement-full"]; 

    _payPalConfig.languageOrLocale = [NSLocale preferredLanguages][0]; 

    _payPalConfig.payPalShippingAddressOption = PayPalShippingAddressOptionPayPal; 


} 

与购买按钮事件代码

-(IBAction)btnCheckoutTapped 
{ 
// UIAlertView *alt=[[UIAlertView alloc]initWithTitle:@"ScanPay" message:@"Under Development" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; 
// [alt show]; 

    NSDecimalNumber *subtotal = [[NSDecimalNumber alloc]initWithDouble:Price]; 

    // Optional: include payment details 
    NSDecimalNumber *shipping = [[NSDecimalNumber alloc] initWithString:@"0.00"]; 
    NSDecimalNumber *tax = [[NSDecimalNumber alloc] initWithString:@"0.00"]; 
    PayPalPaymentDetails *paymentDetails = [PayPalPaymentDetails paymentDetailsWithSubtotal:subtotal 
                       withShipping:shipping 
                        withTax:tax]; 
    NSDecimalNumber *total = [[subtotal decimalNumberByAdding:shipping] decimalNumberByAdding:tax]; 

    PayPalPayment *payment = [[PayPalPayment alloc] init]; 
    payment.amount = total; 
    payment.currencyCode = @"USD"; 
    payment.shortDescription = @"You Pay"; 
    payment.paymentDetails = paymentDetails; // if not including payment details, then leave payment.paymentDetails as nil 
    if (!payment.processable) { 
     // This particular payment will always be processable. If, for 
     // example, the amount was negative or the shortDescription was 
     // empty, this payment wouldn't be processable, and you'd want 
     // to handle that here. 
    } 
    // Update payPalConfig re accepting credit cards. 
    self.payPalConfig.acceptCreditCards = YES; 

    PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment 
                           configuration:self.payPalConfig 
                            delegate:self]; 
    [self presentViewController:paymentViewController animated:YES completion:nil]; 


} 

PayPalPaymentDelegate方法

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



    self.resultText = [completedPayment description]; 
    //[self showSuccess]; 

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

    ReceiptScreen *obj=[self.storyboard instantiateViewControllerWithIdentifier:@"ReceiptScreen"]; 
    [self.navigationController pushViewController:obj animated:YES]; 

} 

- (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); 
} 
+0

嗨,@Chirag ...我需要你的帮助...面对一些问题在贝宝整合在ios ... – iSwaroop

+0

是肯定对不起后期重播你能描述你的问题? – Chirag