我正在探索是否有可能在iOS中实现我的想法。然而,这个想法取决于能否给用户钱。这在iOS中是可能的吗?我知道苹果希望你在从用户那里取钱(应用内购等)时使用StoreKit,但StoreKit中是否甚至有一种机制可以向用户提供资金,如果没有,iOS规则是否允许用户使用PayPal这样的第三方服务来给用户提供资金?
发布于 2013-01-30 07:52:55
是的,一个人可以使用第三方服务,如贝宝支付。要实现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");
}https://stackoverflow.com/questions/12132206
复制相似问题