首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在iOS中处理给用户的付款

在iOS中处理给用户的付款
EN

Stack Overflow用户
提问于 2012-08-26 17:14:21
回答 1查看 1.2K关注 0票数 0

我正在探索是否有可能在iOS中实现我的想法。然而,这个想法取决于能否给用户钱。这在iOS中是可能的吗?我知道苹果希望你在从用户那里取钱(应用内购等)时使用StoreKit,但StoreKit中是否甚至有一种机制可以向用户提供资金,如果没有,iOS规则是否允许用户使用PayPal这样的第三方服务来给用户提供资金?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-30 07:52:55

是的,一个人可以使用第三方服务,如贝宝支付。要实现Paypal机制,请执行以下步骤。

1)下载iOS表格这里的移动支付库

2)在视图控制器的头文件中导入PayPal.h文件。

( 3)在项目中包括以下框架-- Security.framework、MapKit、ImageIO、SystemConfiguration

4)还包括以下两个库文件-- libz.dylib,libxml2.dylib

5)创建一个支付按钮,如下所示

代码语言:javascript
复制
     UIButton checkOutBtn=[[PayPal getPayPalInst] getPayButtonWithTarget:self andAction:@selector(payWithPayPal) andButtonType:BUTTON_152x33 andButtonText:BUTTON_TEXT_PAY];
     checkOutBtn.frame=CGRectMake(60, 100, 200, 45);
     [self.view addSubview:checkOutBtn];  

6)使用以下代码实现按钮操作方法:

代码语言:javascript
复制
    -(void) payWithPayPal
    {
           [PayPal getPayPalInst].shippingEnabled=TRUE;
           [PayPal getPayPalInst].dynamicAmountUpdateEnabled=TRUE;
           [PayPal getPayPalInst].feePayer=FEEPAYER_EACHRECEIVER;

           PayPalPayment *payment=[[[PayPalPayment alloc] init] autorelease];
           payment.recipient=@"xyz@paypal.com";
           payment.paymentCurrency=@"USD";

           payment.description = @"Paypal";
           payment.merchantName = @"Title Name";

           //subtotal of all items, without tax and shipping

           payment.subTotal = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%1.2f", 5320.50 ]];   // total Price

          //invoiceData is a PayPalInvoiceData object which contains tax, shipping, and a list of PayPalInvoiceItem objects

           payment.invoiceData = [[[PayPalInvoiceData alloc] init] autorelease];
           payment.invoiceData.totalShipping = [NSDecimalNumber decimalNumberWithString:@"2"];   // Shipping Cost
           payment.invoiceData.totalTax = [NSDecimalNumber decimalNumberWithString:@"0.35"];   // Tax On Product

           //invoiceItems is a list of PayPalInvoiceItem objects
           //NOTE: sum of totalPrice for all items must equal payment.subTotal

           payment.invoiceData.invoiceItems = [NSMutableArray array];
           PayPalInvoiceItem *item = [[[PayPalInvoiceItem alloc] init] autorelease];

           item.totalPrice = payment.subTotal;
           item.name = @"Product Name";
           [payment.invoiceData.invoiceItems addObject:item];

           [[PayPal getPayPalInst] checkoutWithPayment:payment];
    }

7)使用下列代表

代码语言:javascript
复制
    -(void)paymentSuccessWithKey:(NSString *)payKey andStatus:(PayPalPaymentStatus)paymentStatus
    {
           NSLog(@"Successfully Paid");
    }
    -(void)paymentCanceled
    {
           NSLog(@"Cancelled");
    }
    - (void)paymentFailedWithCorrelationID:(NSString *)correlationID
    {
           NSLog(@"Failed");
    }
    -(void)paymentLibraryExit
    {
           NSLog(@"Exit");
    }
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12132206

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档