处理用户付款的iOS(Processing payments to users in iOS)

2019-07-31 04:37发布

我探讨是否有可能为我实现一个想法,我已经在iOS版。 然而,这个想法取决于是否能够用户的钱。 这是可能的的iOS? 我知道苹果希望你从用户钱(应用内购买等)时,使用StoreKit,但有即使在StoreKit一种机制, 钱给用户,如果没有,做iOS的规则,让一个使用三阶PayPal等第三方服务提供给用户的钱吗?

Answer 1:

是的,我们可以使用第三方服务如PayPal付款。 为了实现宝机制经过以下几个步骤。

1)下载移动支付库适用于iOS的形式在这里

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

3)包括以下项目的框架 - Security.framework,MapKit,ImageIO的,SystemConfiguration

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

5)如付款创建一个按钮

     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)使用以下代码来实现按钮的操作方法:

    -(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)使用下列代表

    -(void)paymentSuccessWithKey:(NSString *)payKey andStatus:(PayPalPaymentStatus)paymentStatus
    {
           NSLog(@"Successfully Paid");
    }
    -(void)paymentCanceled
    {
           NSLog(@"Cancelled");
    }
    - (void)paymentFailedWithCorrelationID:(NSString *)correlationID
    {
           NSLog(@"Failed");
    }
    -(void)paymentLibraryExit
    {
           NSLog(@"Exit");
    }


文章来源: Processing payments to users in iOS
标签: ios payment