平台充值
<h1>平台充值</h1>
<p>调用YTSDKManager的 getInstance(Context context) 静态方法来获取YTSDKManager 的实例。完成实例创建后,就可以使用该实例,调用支付接口。</p>
<h2>接口定义</h2>
<pre><code>public void showPay(Context context, String roleName,String roleid, String money,
String serverName,String serverid, String productname,
String productdesc,String fcallbackurl, String attach,
OnPaymentListener paymentListener)</code></pre>
<h2>接口参数说明</h2>
<table>
<thead>
<tr>
<th>参数名</th>
<th>类型</th>
<th>是否必须</th>
<th>参数说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>context</td>
<td>Context</td>
<td>是</td>
<td>调用者的实例</td>
</tr>
<tr>
<td>roleid</td>
<td>String</td>
<td>是</td>
<td>角色 id</td>
</tr>
<tr>
<td>money</td>
<td>String</td>
<td>是</td>
<td>充值金额(整数,不要包含小数点)</td>
</tr>
<tr>
<td>serverid</td>
<td>String</td>
<td>是</td>
<td>游戏商(CP)游戏服务器id</td>
</tr>
<tr>
<td>productname</td>
<td>String</td>
<td>是</td>
<td>产品名字</td>
</tr>
<tr>
<td>productdesc</td>
<td>String</td>
<td>是</td>
<td>产品描述</td>
</tr>
<tr>
<td>callbackurl</td>
<td>String</td>
<td>否</td>
<td>这个参数目前只是传””字符串</td>
</tr>
<tr>
<td>attach</td>
<td>String</td>
<td>是</td>
<td>商户扩展参数(透传参数)</td>
</tr>
<tr>
<td>paymentListener</td>
<td>OnPaymentListener</td>
<td>是</td>
<td>对充值是否成功进行监听</td>
</tr>
<tr>
<td>roleName</td>
<td>String</td>
<td>是</td>
<td>角色名称</td>
</tr>
<tr>
<td>serverName</td>
<td>String</td>
<td>是</td>
<td>游戏商(CP)游戏服务器名称</td>
</tr>
</tbody>
</table>
<h2>接口回调说明</h2>
<table>
<thead>
<tr>
<th>● 充值成功信息体 PaymentCallbackInfo 解析</th>
<th>参数名</th>
<th>类型</th>
<th>参数说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>msg</td>
<td>String</td>
<td>充值结果描述</td>
</tr>
<tr>
<td>money</td>
<td>int</td>
<td>充值金额数</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>● 充值失败信息体 PaymentCallbackInfo 解析</th>
<th>参数名</th>
<th>类型</th>
<th>参数说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>code</td>
<td>String</td>
<td>状态码</td>
</tr>
<tr>
<td>money</td>
<td>int</td>
<td>意图充值金额数</td>
</tr>
<tr>
<td>msg</td>
<td>String</td>
<td>充值失败消息提示</td>
</tr>
</tbody>
</table>
<h2>调用完整代码(DEMO示例)</h2>
<pre><code>sdkManager.showPay(MainActivity.this, &quot;角色名称&quot;,&quot;角色ID&quot;, money, &quot;服务器名称&quot;,&quot;服务器id&quot;, &quot;道具&quot;, &quot;描述&quot;, &quot;&quot;, &quot;attach&quot;, new OnPaymentListener() {
@Override
public void paymentSuccess(PaymentCallbackInfo paymentCallbackInfo) {
double money = paymentCallbackInfo.money;
String msg = paymentCallbackInfo.msg;
}
@Override
public void paymentError(PaymentErrorMsg paymentErrorMsg) {
int code = paymentErrorMsg.code;
double money = paymentErrorMsg.money;
String msg = paymentErrorMsg.msg;
}
});</code></pre>