我能使用PayPal在iPhone/iPad应用程序中吗?

5

我正在开发一个应用程序,希望通过它出售某些活动门票。

我能否使用PayPal来实现此目的,并且苹果是否会批准使用除StoreKit框架之外的其他方式来开发这个应用程序。

我搜索了这个主题,但是我没有找到任何可能的解决方案。

一些搜索结果说可以使用PayPal,而另一些则表示苹果从不批准使用除In-App Purchase之外的付款网关的应用程序。

请帮帮我!


1
请检查以下内容: https://dev59.com/9nRA5IYBdhLWcg3w8SaJ - Pooja
首先,您需要注意苹果想要分一部分钱的问题。我不确定在您的特定情况下规则是什么,但为了安全起见 :) - Manuel
5个回答

16

是的,您可以在应用程序中使用PayPal支付网关。您可以从以下链接查看完整的文档:

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/library_documentation#mobile

请在您的.h文件中添加以下代码

#import "PayPal.h"
#import "PayPalList.h"

typedef enum PaymentStatuses 
{
    PAYMENTSTATUS_SUCCESS,
    PAYMENTSTATUS_FAILED,
    PAYMENTSTATUS_CANCELED,
} PaymentStatus;

实现"PayPalPaymentDelegate"这个委托方法

PayPalList *payPalList;
PaymentStatus status;

将以下代码添加到您的.m文件中

#import "PayPalPayment.h"
#import "PayPalAdvancedPayment.h"
#import "PayPalAmounts.h"
#import "PayPalReceiverAmounts.h"
#import "PayPalAddress.h"
#import "PayPalInvoiceItem.h"
#define SPACING 3.

- (void)ButtonWithType:(PayPalButtonType)type withAction:(SEL)action 
{

    UIButton *btnPayWithPayPal = [[PayPal getInstance] getPayButtonWithTarget:self andAction:action andButtonType:type];

    CGRect frame;
    frame.origin.x = 60;
    frame.origin.y = 315;
    frame.size.width = 304;
    frame.size.height = 40;

    btnPayWithPayPal.frame = frame;
    [self.view addSubview:btnPayWithPayPal];
}

- (void)viewDidLoad
{
     [self ButtonWithType:BUTTON_194x37 withAction:@selector(simplePayment)];
}

#pragma mark -
#pragma mark PayPalPaymentDelegate methods

- (void)paymentSuccessWithKey:(NSString *)payKey andStatus:(PayPalPaymentStatus)paymentStatus 
{
    status = PAYMENTSTATUS_SUCCESS;
}

- (void)paymentFailedWithCorrelationID:(NSString *)correlationID andErrorCode:(NSString *)errorCode andErrorMessage:(NSString *)errorMessage 
{
    status = PAYMENTSTATUS_FAILED;
}

- (void)paymentCanceled 
{
    status = PAYMENTSTATUS_CANCELED;
}

- (void)paymentLibraryExit 
{
    UIAlertView *alert = nil;
    switch (status) {
        case PAYMENTSTATUS_SUCCESS:
            break;
        case PAYMENTSTATUS_FAILED:
            alert = [[UIAlertView alloc] initWithTitle:@"Order failed" 
                                               message:@"Your order failed. Touch \"Pay with PayPal\" to try again." 
                                              delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            break;
        case PAYMENTSTATUS_CANCELED:
            alert = [[UIAlertView alloc] initWithTitle:@"Order canceled" 
                                               message:@"You canceled your order. Touch \"Pay with PayPal\" to try again." 
                                              delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            break;
    }
    [alert show];
    [alert release];
}

- (PayPalAmounts *)adjustAmountsForAddress:(PayPalAddress const *)inAddress andCurrency:(NSString const *)inCurrency andAmount:(NSDecimalNumber const *)inAmount
                                    andTax:(NSDecimalNumber const *)inTax andShipping:(NSDecimalNumber const *)inShipping andErrorCode:(PayPalAmountErrorCode *)outErrorCode 
{
    //do any logic here that would adjust the amount based on the shipping address
    PayPalAmounts *newAmounts = [[[PayPalAmounts alloc] init] autorelease];
    newAmounts.currency = @"USD";
    newAmounts.payment_amount = (NSDecimalNumber *)inAmount;

    //change tax based on the address
    /*if ([inAddress.state isEqualToString:@"CA"]) {
        newAmounts.tax = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%.2f",[inAmount floatValue] * .1]];
    } else {
        newAmounts.tax = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%.2f",[inAmount floatValue] * .08]];
    }
    newAmounts.shipping = (NSDecimalNumber *)inShipping;*/

    //if you need to notify the library of an error condition, do one of the following
    //outErrorCode = AMOUNT_ERROR_SERVER;
    //outErrorCode = AMOUNT_ERROR_OTHER;

    return newAmounts;
}

#pragma mark -
#pragma mark Actions triggered by Pay with PayPal buttons

- (void)simplePayment 
{
        //optional, set shippingEnabled to TRUE if you want to display shipping
    //options to the user, default: TRUE
    [PayPal getInstance].shippingEnabled = TRUE;

    //optional, set dynamicAmountUpdateEnabled to TRUE if you want to compute
    //shipping and tax based on the user's address choice, default: FALSE
    [PayPal getInstance].dynamicAmountUpdateEnabled = TRUE;

    //optional, choose who pays the fee, default: FEEPAYER_EACHRECEIVER
    [PayPal getInstance].feePayer = FEEPAYER_EACHRECEIVER;

    //for a payment with a single recipient, use a PayPalPayment object
    PayPalPayment *payment = [[[PayPalPayment alloc] init] autorelease];

    payment.recipient = [NSString stringWithFormat:@"%@",payPalList.strRecipientPayPalId];
    payment.paymentCurrency = [NSString stringWithFormat:@"%@",e_commerceAppDelegate.strProductCurrency];
    payment.merchantName = [NSString stringWithFormat:@"%@",payPalList.strPayPalMerchantName];
    payment.ipnUrl = [NSString stringWithFormat:@"%@",payPalList.strIpnUrl];

    //subtotal of all items, without tax and shipping
    payment.subTotal = [NSDecimalNumber decimalNumberWithString:stringsubtotal];

    //invoiceData is a PayPalInvoiceData object which contains tax, shipping, and a list of PayPalInvoiceItem objects
    payment.invoiceData = [[[PayPalInvoiceData alloc] init] autorelease];

    //invoiceItems is a list of PayPalInvoiceItem objects
    //NOTE: sum of totalPrice for all items must equal payment.subTotal
    //NOTE: example only shows a single item, but you can have more than one
    payment.invoiceData.invoiceItems = [NSMutableArray array];
    PayPalInvoiceItem *item = [[[PayPalInvoiceItem alloc] init] autorelease];
    item.totalPrice = payment.subTotal;

    //int i=0;

    for(i=0 ; i<[e_commerceAppDelegate.cartList count] ; i++)
    {
        cart = (Cart*)[e_commerceAppDelegate.cartList objectAtIndex:i];

        item.name = cart.proName;

        item.itemCount = [NSNumber numberWithInteger:cart.quantity];

        NSString *itemSingPrice = [NSString stringWithFormat:@"%.2f",cart.price];
        item.itemPrice = [NSDecimalNumber decimalNumberWithString:itemSingPrice];

        NSString *itemSubTotal = [NSString stringWithFormat:@"%.2f",cart.quantity*cart.price];
        item.totalPrice = [NSDecimalNumber decimalNumberWithString:itemSubTotal];

        [payment.invoiceData.invoiceItems addObject:item];

        item = [[[PayPalInvoiceItem alloc] init] autorelease];
    }

    NSScanner* scanner = [NSScanner localizedScannerWithString:e_commerceAppDelegate.strDeliveryCharges];
    NSDecimal decimal;
    [scanner scanDecimal:&decimal];
    NSDecimalNumber *decimalNumber = [NSDecimalNumber decimalNumberWithDecimal:decimal];

    payment.invoiceData.totalShipping = decimalNumber;

    [[PayPal getInstance] checkoutWithPayment:payment];

}

从以下链接可以了解PayPal相关信息

https://www.x.com/community/ppx/xspaces/mobile/mep

https://www.x.com/docs/DOC-2532

https://cms.paypal.com/cms_content/US/en_US/files/developer/IPNGuide.pdf

https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_MPL_Developer_Guide_and_Reference_Android.pdf

https://www.x.com/thread/45094

https://www.x.com/message/193751#193751

http://googlecheckout.blogspot.com/2010/06/pay-on-go-with-android-payment.html

https://chrome.google.com/webstore/detail/omomllobcfbllglbhpmafongpckhdcdn


但是我对网络上不同种类的回复感到非常困惑。请看这个网址,它说了另外一件事情:http://www.marco.org/2011/02/21/subscriptions-and-the-new-in-app-purchase-requirement - iOS Monster
4
与其阅读不相关的博客文章,不如阅读应用商店审核指南11.3. 使用IAP购买应用外的实体商品或服务的应用将被拒绝。如果您的活动发生在应用程序外部,则不允许使用应用内购买。 - Matthias Bauch
@MatthiasBauch,评论指南中已经没有11.3节了,你引用的那段话也不存在了。现在,相关的章节是3.1.3和3.1.3(e)。 - HangarRash

2

App-store的应用需要向苹果支付大约40%的费用(截至目前为止),因此,除非你将PayPal配置为支付该费用,否则PayPal是不被允许使用的。 - Top-Master

0

不可以。每个iOS应用都必须符合商店审核指南,才能通过苹果的审核。该指南明确规定: - 不允许使用“除应用内购买API(IAP)以外的系统”进行付款购买内容、功能或服务(11.2) - 不允许“使用IAP购买物理商品或在应用之外使用的商品和服务”

确实,有Paypal的API可供此类目的使用,但正如上文所述,使用它的应用将无法通过审核。


0

嗯,我认为这取决于情况。

虽然我确信苹果不会允许除应用内购买之外的任何其他方式,但我知道德国应用商店中至少有一个应用程序可以让你在应用内购买电影院的门票。他们提供信用卡支付和其他一些服务,应用内购买甚至都不可用。

他们以某种方式进入了商店,所以我建议您事先与苹果沟通,并了解他们是否会批准您的业务模式。

也许如果购买包括100%的现实世界物品或服务,并且不会改变应用本身的行为或内容,他们会批准其他付款方式。


他们以某种方式未能到达商店。苹果不允许在应用内购买物理商品。 - Matthias Bauch
是的,我知道 - 但我们正在处理除IAP之外的付款方式,据我所知,苹果尚未正式评论它们用于购买现实世界中的物品/服务。但如果有其他情况,我很乐意了解! - Toastor
没有规定禁止这样做。好的,我们正在谈论苹果,但即使是在苹果上,通常没有规定意味着它是被允许的。你知道一个电影应用程序。我知道电影应用程序、披萨应用程序、活动应用程序等等。显然,所有这些应用程序都没有逃过审查人员的眼睛。通常会有一个明显的“立即支付”按钮。 - Matthias Bauch
好的,所以他们“不知怎么地”没有到店里,但是相当正式。关键是,他们到了店里,这证明了那些声称否则的答案是错误的。 - Toastor

-1

这是可能的,但据我所知,Appstore不允许使用PayPal API。实现此功能的方法是将用户发送到一个处理付款的网站。在这里,您可以使用PHP API等。


苹果是否会批准一款将控制权重定向到网站进行付款的应用程序?因为在审批该应用程序时,他们(苹果)可以清楚地看到他们没有得到他们的份额(30%)。我怀疑他们不会批准它。您能否请帮我解决这个疑问?谢谢。 - iOS Monster
Paypal API的问题不在于它不能在Obj-C中工作,而在于苹果不允许应用内进行任何外部支付。虽然我自己从未使用过它,但因为它不是应用本身的一部分,我认为他们会允许它。不过最好还是给苹果发邮件确认一下。 - Manuel

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接