iOS PayPal integration with backend chained payments

∥☆過路亽.° 提交于 2019-12-06 13:44:54

问题


I am working to integrate PayPal in our iOS app. On our backend we have implemented chained payment and exposed that on the api. The backend is responsible for generating the pay key.

On the web app the library opens a light box and injects the pay key for the user to approve the payment by logging in.

We need to accomplish this same thing on the iOS app using either the paypal sdk or MPL library. I see how to do a chained payment from beginning to end in the iOS app but no how to simply jump right into the approval process with an already generated pay key.


回答1:


I have just complete delay chained payment in iPhone

First create transaction with all parameter like amount,receipts etc and get PAY_KEY for the transaction from backend (PHP,JAVA,RUBY or any) with the help of reference paypal link :- Step 2 : https://devtools-paypal.com/guide/ap_chained_payment/php?success=true

Then with paykey we can make payment only in webview so Open UIWebView in ViewController with following URL

[wbView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?paykey=%@&expType=mini",@"[PAY_KEY]"]]]];

and the handle delegate methods

#pragma mark - UIWebView Delgate
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:UIWebViewNavigationType)navigationType
    {
        NSLog(@"\n\n-- %@\n--%@\n\n",request.URL,[request.URL absoluteString]);
        if([[request.URL absoluteString] isEqualToString:@"https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/closewindow"])
        {
            [self validatePayment];
            return YES;
        }            
        return YES;
    }
    - (void)webViewDidStartLoad:(UIWebView *)webView
    {
        if (!actView.isAnimating) {
            [actView startAnimating];
        }
        NSLog(@"start %@",webView.request);
    }
    - (void)webViewDidFinishLoad:(UIWebView *)webView
    {
        NSLog(@"End %@",webView.request);
        [actView stopAnimating];
    }
    - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
    {
        [actView stopAnimating];
    }

This will open popwindow with for login & payment of the given PAYKEY transaction

Login and make payment in Paypal Popup

The finally on close the popup you can validate payment with the PAYKEY

from backend by step 4 in https://devtools-paypal.com/guide/ap_chained_payment/php?success=true




回答2:


At this time, there is no true native flow for Adaptive Payments other than MPL. The caveat with MPL is that it's being deprecated as soon as the Adaptive flow is ported over into the RESTful APIs and subsequently into the mSDK.



来源:https://stackoverflow.com/questions/26149377/ios-paypal-integration-with-backend-chained-payments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!