iOS PayPal与后端链式支付集成 [英] iOS PayPal integration with backend chained payments

查看:287
本文介绍了iOS PayPal与后端链式支付集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力将PayPal集成到我们的iOS应用中。在我们的后端,我们实施了链式支付并在api上暴露了这种情况。后端负责生成付款密钥。

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.

我们需要使用paypal sdk或MPL库在iOS应用程序上完成同样的事情。我看到如何在iOS应用程序中从头到尾进行链式支付,但没有如何简单地使用已生成的支付键直接进入审批流程。

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.

推荐答案

我在iPhone上完成了延迟链式付款

I have just complete delay chained payment in iPhone

首先使用金额,收据等所有参数创建交易并获得交易的PAY_KEY来自后端(PHP,JAVA,RUBY或任何)
借助参考paypal链接: - 步骤2: https://devtools-paypal.com/guide/ap_chained_pa​​yment/php?success=true

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

然后使用paykey我们只能付款webview so
在ViewController中使用以下URL打开UIWebView

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]"]]]];

和句柄委托方法

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

这将打开popwindow with for login&支付给定的PAYKEY交易

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

登录并在Paypal Popup中付款

Login and make payment in Paypal Popup

最后关闭弹出窗口你可以通过

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

验证付款true> https://devtools-paypal.com/guide/ap_chained_pa​​yment/php?success=true

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

这篇关于iOS PayPal与后端链式支付集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆