我正在探索是否有可能实现我在 iOS 中的想法。然而,这个想法取决于能够给用户钱。这在iOS中可能吗?我知道 Apple 希望您在从用户那里收钱(应用内购买等)时使用 StoreKit ,但 StoreKit 中是否有一种机制可以向用户提供资金,如果没有,iOS 规则是否允许使用第三个 -像 PayPal 这样的派对服务给用户钱?
问问题
1142 次
1 回答
3
是的,您可以使用 Paypal 等第三方服务进行付款。要实现 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");
}
于 2013-01-30T07:52:55.450 回答