【问题标题】:Can I use PayPal in iPhone/iPad apps?我可以在 iPhone/iPad 应用程序中使用 PayPal 吗?
【发布时间】:2011-10-19 22:30:31
【问题描述】:

我正在开发一个应用程序,我想通过该应用程序销售一些活动门票。

我可以为此目的使用 PayPal,Apple 是否会批准使用其他 StoreKit 框架的应用程序。

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

一些搜索表明可以使用 paypal,而另一些搜索表明 Apple 绝不会批准使用除 inAppPurchase 之外的支付网关的应用。

请帮帮我!

【问题讨论】:

标签: iphone objective-c in-app-purchase storekit


【解决方案1】:

是的,您可以在您的应用程序中使用 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

【讨论】:

  • 但是我对来自网络的不同类型的响应感到非常困惑。看到这个网址说别的东西marco.org/2011/02/21/…
  • 与其阅读不相关的博客文章,为什么不阅读app store review guidelines11.3. Apps using IAP to purchase physical goods or goods and services used outside of the application will be rejected。如果您的活动发生在您的应用之外,则不允许使用 In-App-Purchase。
【解决方案2】:

不,你不能。 Store Review Guidelines,每个 iOS 应用程序都必须匹配才能被 Apple 通过,它明确指出: - 您不得使用“应用内购买 API (IAP) 以外的系统来购买内容、功能或服务”进行支付 (11.2) - 不允许“使用[e] IAP 购买实体商品或在应用程序外使用的商品和服务”

确实,有一个API from Paypal 用于此目的,但如上所述,使用它的应用程序将无法通过审核。

【讨论】:

    【解决方案3】:

    虽然 iPhone 中存在用于 Paypal 集成的 API,但根据 Apple 指南,它不会批准此类应用程序用于其 AppStore。 请在此处查看 Apple 指南第 11.3 条https://developer.apple.com/appstore/resources/approval/guidelines.html

    【讨论】:

      【解决方案4】:

      我认为这取决于。

      虽然我确信 Apple 不会允许除应用内购买之外的任何其他内容,但我确实知道德国应用商店中至少有一款应用,可让您购买电影院的门票在应用程序内。他们通过信用卡和许多其他服务提供付款,甚至不提供 IAP。

      他们以某种方式到达了商店,所以我建议你提前与 Apple 交谈,看看他们是否会批准你的商业模式。

      如果购买包含 100% 真实世界的对象或服务并且不改变应用本身的行为或内容,他们可能会批准其他付款方式。

      【讨论】:

      • 他们“不知何故”没有进入商店。 Apple 不允许使用 In-App-Purchase 购买实物商品。
      • 是的,我知道——但我们在这里处理的是 IAP 以外的付款方式,而且,AFAIK,Apple 还没有正式评论它们用于购买现实世界的对象/服务。但我很乐意学习其他方式!
      • 没有规则反对它。好的,我们正在谈论苹果,但即使使用苹果,通常也没有规则意味着它是允许的。你知道一个电影应用程序。我知道电影应用程序、披萨应用程序、活动应用程序等等。显然,所有这些应用程序都没有从评论者的视线中溜走。通常有一个大而明显的“立即付款”按钮。
      • 好的,所以他们没有“以某种方式”进入商店,但相当正式。关键是,他们到了商店,这证明了那些说明否则是错误的答案..
      【解决方案5】:

      这是可能的,但据我所知,Appstore 不允许使用 PayPal API。这样做的方法是将用户发送到将处理付款的网站。这里可以使用 PHP API 为例。

      【讨论】:

      • 苹果会批准将控件重定向到网站进行支付的应用程序吗?因为在测试应用程序以获得批准时,他们(Apple)可以清楚地看到他们没有得到削减(30%)。我怀疑他们不会批准它。你能解开我的这个疑问吗,plz。
      • Paypal API 的问题不在于它在 Obj-C 中不起作用,问题在于 Apple 不允许在应用程序内进行任何外部支付。好吧,因为我自己从未使用过它,所以我不能肯定地告诉你,但因为它不是应用程序本身的一部分,我认为他们会允许它。最好邮寄 Apple 以确保。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-22
      • 2012-12-07
      • 1970-01-01
      • 2011-12-03
      相关资源
      最近更新 更多