> For the complete documentation index, see [llms.txt](https://cydonia.gitbook.io/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cydonia.gitbook.io/doc/cydonia-sdk/ios-integration/ios-sdk-api-doc/1.2-billing.md).

# 1.2充值部分

## 1.2.1 是否是越狱iOS设备

**说明**

检测设备是否是越狱设备，iOS越狱设备不允许进行内购。

**接口**

```
-(BOOL) isJailbreakDevice;
```

**参数说明**

无

**示例**

```objectivec
if (![mCydoniaSDK isJailbreakDevice]) {
//开始内购
}
```

## 1.2.2 是否开启年龄限制

**说明**

检测游戏是否开启年龄限制，在游戏对接阶段就已经确定是否开启年龄限制，对游戏是个固定值。

**接口**

```
-(BOOL) isInAppBillingAgeLimitOn;
```

**参数说明**

无

**示例**

```objectivec
if (![mCydoniaSDK isInAppBillingAgeLimitOn]) {
        NSLog(@"未开启年龄限制，不需要设定年龄");
        return;
    }
```

## 1.2.3 玩家是否设定生日

**说明**

在开启年龄限制的前提下，检测玩家是否设定了生日。如果没有设定需要弹出设定UI.

**接口**

```
-(BOOL) isBirthdaySet;
```

**参数说明**

无

**示例**

```objectivec
if (![mCydoniaSDK isInAppBillingAgeLimitOn]) {
        NSLog(@"未开启年龄限制，不需要设定年龄");
        return;
    }
    Boolean isSetBirthday = [mCydoniaSDK isBirthdaySet];
    if (isSetBirthday) {
        NSLog(@"生日已经设定");
    }else{
        NSLog(@"生日未设定，需要弹出设定UI");
        
    }
```

## 1.2.4 玩家设定生日

**说明**

在开启年龄限制的前提下，需要此API设定玩家生日，配合前面的UI需求。

**接口**

```
-(void) setBirthday:(NSString*)birthday :(SDKResponseBlock) sdkResponse;
```

**参数说明**

* birthday：玩家选择的生日，格式是"yyyyMM"。例如:"200012"

**示例**

```objectivec
if (![mCydoniaSDK isInAppBillingAgeLimitOn]) {
        NSLog(@"未开启年龄限制，不需要设定年龄");
        return;
    }
    //设定生日，格式是年月:"yyyyMM"
    NSString* birthday = @"199001";
    [mCydoniaSDK setBirthday: birthday :^(NSDictionary *resultDictionary) {
        [self describeDictionarya:resultDictionary];
        NSNumber* statusNumber = [resultDictionary objectForKey:@"status"];
        int status = [statusNumber intValue];
        if ( status==200 ) {
            NSLog(@"设定生日成功");
        }else{
            //300:玩家数据不匹配 301:已经设定过密码 302:生日格式不对
            NSString *msg = [resultDictionary objectForKey:@"msg"];
            NSLog(@"%d----------%@",status,msg);
        }
        
    }];
```

## 1.2.5 玩家是否在充值限制内

**说明**

在开启年龄限制的前提下，每次充值都要检测本次充值是否在充值范围内。

**接口**

```
-(void) isInChargeLimit:(NSNumber*)itemPrice :(SDKResponseBlock) sdkResponse;
```

**参数说明**

* itemPrice：需要购买的item的价格

**示例**

```objectivec
//检测购买此道具时是否超过充值限制
            NSNumber * itemPrice = [[NSNumber alloc] initWithDouble:120];
            [mCydoniaSDK isInChargeLimit:itemPrice :^(NSDictionary *resultDictionary) {
                NSNumber* statusNumber = [resultDictionary objectForKey:@"status"];
                int status = [statusNumber intValue];
                if ( status==200 ) {
                    //没有超过限制,可以充值
                    
                }else{
                    //超出了本月年龄限制，本月无法充值
                    NSString *msg = [resultDictionary objectForKey:@"msg"];
                    NSLog(@"%d----------%@",status,msg);
                }
            }];
```

## 1.2.6 充值

**说明**

实现充值功能

**接口**

```
-(BOOL) purchaseItem:(NSString *)productId withBillingPara:(NSString*) billingPara;
```

**参数说明**

* productId：商品ID
* billingPara：便于未消除订单的重新充值，需要自定义标识来识别此订单属于哪个服等

#### 通过实现CydoniaIAPManagerDelegate接收返回结果

* status：状态码
* msg：返回信息
* appleOrderId：苹果订单ID
* receipt：订单收据信息
* para：上面传入的billingPara，用于掉单处理

**示例**

```objectivec
//billingPara一般传入本单所在服务器等信息，主要用于掉单后的补单处理,根据实际需求设定,例如服务器id_服务器商品id
//billingPara不能用特殊符号，仅能使用a-zA-Z0-9_
[mCydoniaSDK purchaseItem:@"com.cydonia.sdkdevelop.item1" withBillingPara:@"1_10111"];
```

## 1.2.7 检测是否有未消除订单

**说明**

充值有时会有掉单发生，这时候订单会缓存在客户端，在玩家重启游戏或者重新打开充值界面时可以调用此API检测是否有掉单发生，如果有未清除订单需要继续跟服务端通讯完成充值，完成充值后进行下面的消单操作。

**接口**

```
-(NSString*) checkIsPayInfoLeft;
```

**参数说明**

无

**示例**

```objectivec
NSString* leftPayInfo = [mCydoniaSDK checkIsPayInfoLeft];
    //NSLog(@"left Pay Info:%@.",leftPayInfo);
    if (leftPayInfo.length > 0) {
        for(NSString* oneReceipt in [leftPayInfo componentsSeparatedByString:@";"] ){
            NSDictionary* resultDictionary = [self dictionaryWithJsonString:oneReceipt];
            NSNumber* statusNumber = [resultDictionary objectForKey:@"status"];
            NSString *receiptData= [resultDictionary objectForKey:@"receipt"];
            NSString *billingPara = [resultDictionary objectForKey:@"para"];
            SheldonLog(@"购买商品成功,statusNumber=%@,receipt:%@,billingPara:%@.",statusNumber,receiptData,billingPara);
        }
    }
```

## 1.2.8 消单

**说明**

充值完成之后调用消单

**接口**

```
-(void) clearPayInfo;
```

**参数说明**

无

**示例**

```
[mCydoniaSDK clearPayInfo];
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cydonia.gitbook.io/doc/cydonia-sdk/ios-integration/ios-sdk-api-doc/1.2-billing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
