修复支付问题
This commit is contained in:
@@ -28,6 +28,9 @@ import com.yunbao.main.views.TestWebViewClient;
|
||||
@SuppressLint("ValidFragment")
|
||||
public class GoogleFragment extends Fragment {
|
||||
|
||||
private long lastClickTime = 0;
|
||||
private static final long INTERVAL_TIME = 1500;
|
||||
|
||||
private View view;
|
||||
public static String mOrderid, mProductId, MoneyUsds;
|
||||
|
||||
@@ -99,50 +102,60 @@ public class GoogleFragment extends Fragment {
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidNewGoToGooglePay(String ProductId, String OrderNumber, String MoneyUsd) {
|
||||
Log.e(TAG, "ProductId" + ProductId + "OrderNumber" + OrderNumber + "MoneyUsd" + MoneyUsd);
|
||||
mProductId = ProductId;
|
||||
mOrderid = OrderNumber;
|
||||
MoneyUsds = MoneyUsd;
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (currentTime - lastClickTime > INTERVAL_TIME) {
|
||||
mProductId = ProductId;
|
||||
mOrderid = OrderNumber;
|
||||
MoneyUsds = MoneyUsd;
|
||||
|
||||
googleUtils.setBillingListener(new GoogleUtils.GoogleBillingListener() {
|
||||
@Override
|
||||
public void onPaySuccess(String token, String orderId) {
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CommonHttpUtil.notifyGoogle(token, orderId, mProductId, mOrderid, adid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
Bundle params = new Bundle();
|
||||
params.putString("currency", "HKD");
|
||||
params.putString("money", MoneyUsds);
|
||||
Bundle fb_params = new Bundle();
|
||||
fb_params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD");
|
||||
fb_params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId);
|
||||
//Google官方充值通知
|
||||
Bundle google_params = new Bundle();
|
||||
google_params.putString("currency", "HKD");
|
||||
google_params.putString("product_id", mProductId);
|
||||
google_params.putString("transaction_id", mOrderid);
|
||||
google_params.putString("value", MoneyUsds);
|
||||
google_params.putString("price", MoneyUsds);
|
||||
google_params.putString("quantity", "1");
|
||||
dis();
|
||||
ToastUtil.show("支付成功");
|
||||
googleUtils.setBillingListener(new GoogleUtils.GoogleBillingListener() {
|
||||
@Override
|
||||
public void onPaySuccess(String token, String orderId) {
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CommonHttpUtil.notifyGoogle(token, orderId, mProductId, mOrderid, adid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
Bundle params = new Bundle();
|
||||
params.putString("currency", "HKD");
|
||||
params.putString("money", MoneyUsds);
|
||||
Bundle fb_params = new Bundle();
|
||||
fb_params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD");
|
||||
fb_params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId);
|
||||
//Google官方充值通知
|
||||
Bundle google_params = new Bundle();
|
||||
google_params.putString("currency", "HKD");
|
||||
google_params.putString("product_id", mProductId);
|
||||
google_params.putString("transaction_id", mOrderid);
|
||||
google_params.putString("value", MoneyUsds);
|
||||
google_params.putString("price", MoneyUsds);
|
||||
google_params.putString("quantity", "1");
|
||||
dis();
|
||||
ToastUtil.show("支付成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPayFailed(String msg) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
});
|
||||
googleUtils.purchase(mProductId);
|
||||
@Override
|
||||
public void onPayFailed(String msg) {
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
googleUtils.purchase(mProductId);
|
||||
}
|
||||
lastClickTime = currentTime;
|
||||
|
||||
Log.e(TAG, "ProductId" + ProductId + "OrderNumber" + OrderNumber + "MoneyUsd" + MoneyUsd);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
|
||||
@@ -23,7 +23,8 @@ import com.yunbao.main.views.TestWebViewClient;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class HuaWeiFragment extends Fragment {
|
||||
|
||||
private long lastClickTime = 0;
|
||||
private static final long INTERVAL_TIME = 1500;
|
||||
private View view;
|
||||
public static String mOrderid, mProductId, MoneyUsds;
|
||||
|
||||
@@ -80,17 +81,22 @@ public class HuaWeiFragment extends Fragment {
|
||||
public void androidNewGoToGooglePay(String ProductId, String OrderNumber, String MoneyUsd) {
|
||||
Log.e(TAG, "ProductId:" + ProductId + " OrderNumber:" + OrderNumber + " MoneyUsd:" + MoneyUsd);
|
||||
|
||||
if (ProductId.equals("zs640")) {
|
||||
ProductId = "zs0640";
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (currentTime - lastClickTime > INTERVAL_TIME) {
|
||||
if (ProductId.equals("zs640")) {
|
||||
ProductId = "zs0640";
|
||||
}
|
||||
mProductId = ProductId;
|
||||
mOrderid = OrderNumber;
|
||||
MoneyUsds = MoneyUsd;
|
||||
orderId = OrderNumber;
|
||||
|
||||
HwBuilder hwBuilder = new HwBuilder(getActivity());
|
||||
hwBuilder.pay(mProductId);
|
||||
}
|
||||
lastClickTime = currentTime;
|
||||
|
||||
mProductId = ProductId;
|
||||
mOrderid = OrderNumber;
|
||||
MoneyUsds = MoneyUsd;
|
||||
orderId = OrderNumber;
|
||||
|
||||
HwBuilder hwBuilder = new HwBuilder(getActivity());
|
||||
hwBuilder.pay(mProductId);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
|
||||
@@ -93,8 +93,6 @@ public class MyWalletActivity extends AbsActivity {
|
||||
loadingDialog.setShowText(getString(R.string.order_query));
|
||||
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
|
||||
googleUtils.queryPurchasesAsync();
|
||||
googleUtils.setQueryPurchaseListener(mContext, new GoogleUtils.QueryPurchasesListener() {
|
||||
@Override
|
||||
public void onResult(JSONObject obj) {
|
||||
@@ -139,10 +137,14 @@ public class MyWalletActivity extends AbsActivity {
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
googleUtils.queryPurchasesAsync();
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
hwBuilder.consume();
|
||||
loadingDialog.setShowText(getString(R.string.order_query_success));
|
||||
payHandler.postDelayed(() -> loadingDialog.dismiss(), 2000);
|
||||
} else {
|
||||
loadingDialog.setShowText(getString(R.string.order_query_success));
|
||||
payHandler.postDelayed(() -> loadingDialog.dismiss(), 2000);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user