当前位置: 首页>>代码示例>>Java>>正文


Java PurchaseCallback类代码示例

本文整理汇总了Java中com.codename1.payment.PurchaseCallback的典型用法代码示例。如果您正苦于以下问题:Java PurchaseCallback类的具体用法?Java PurchaseCallback怎么用?Java PurchaseCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PurchaseCallback类属于com.codename1.payment包,在下文中一共展示了PurchaseCallback类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setMainClass

import com.codename1.payment.PurchaseCallback; //导入依赖的package包/类
public static void setMainClass(Object main) {
    if(main instanceof PushCallback) {
        pushCallback = (PushCallback)main;
    }
    if(main instanceof PurchaseCallback) {
        purchaseCallback = (PurchaseCallback)main;
    }
    if(main instanceof RestoreCallback) {
        restoreCallback = (RestoreCallback)main;
    }
    if (main instanceof LocalNotificationCallback) {
        setLocalNotificationCallback((LocalNotificationCallback) main);
    }
    if (main instanceof BackgroundFetch) {
        backgroundFetchCallback = (BackgroundFetch)main;
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:18,代码来源:IOSImplementation.java

示例2: onPurchaseStateChange

import com.codename1.payment.PurchaseCallback; //导入依赖的package包/类
@Override
        public void onPurchaseStateChange(Consts.PurchaseState purchaseState, String itemId,
                int quantity, long purchaseTime, String developerPayload) {
            if (Consts.DEBUG) {
                Log.i("CodeNameOne", "onPurchaseStateChange() itemId: " + itemId + " " + purchaseState);
            }
            PurchaseCallback pc = getPurchaseCallback();
            if(purchaseState == Consts.PurchaseState.PURCHASED) {
                addItem(itemId);
                if(pc != null) {
                    pc.itemPurchased(itemId);
                }
            } else if(purchaseState == Consts.PurchaseState.REFUNDED || purchaseState == Consts.PurchaseState.CANCELED || purchaseState == Consts.PurchaseState.EXPIRED) {
                if(quantity <= 0) {
                    removeItem(itemId);
                }
                if(pc != null) {
                    pc.itemRefunded(itemId);
                }
            }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:CodenameOneActivity.java

示例3: onRequestPurchaseResponse

import com.codename1.payment.PurchaseCallback; //导入依赖的package包/类
@Override
public void onRequestPurchaseResponse(final BillingService.RequestPurchase request,
        final Consts.ResponseCode responseCode) {
    Object app = getApp();
    if(app != null && app instanceof PurchaseCallback) {
        final PurchaseCallback pc = (PurchaseCallback)app;
        Display.getInstance().callSerially(new Runnable() {

            @Override
            public void run() {
                //we need to handle other response code as well see Consts.ResponseCode
                if (responseCode == Consts.ResponseCode.RESULT_OK) {
                    // purchase was successfully sent to server                             
                    pc.itemPurchased(request.mProductId);
                } else if (responseCode == Consts.ResponseCode.RESULT_USER_CANCELED) {
                    // user canceled purchase
                    pc.itemPurchaseError(request.mProductId, "Canceled");
                } else {
                    // purchase failed
                    pc.itemPurchaseError(request.mProductId, responseCode.name());
                }
            }
        });
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:26,代码来源:CodenameOneActivity.java

示例4: onConsumeFinished

import com.codename1.payment.PurchaseCallback; //导入依赖的package包/类
public void onConsumeFinished(final Purchase purchase, final IabResult result) {

            // if we were disposed of in the meantime, quit.
            if (mHelper == null) {
                return;
            }

            if (result.isFailure()) {
                final PurchaseCallback pc = getPurchaseCallback();
                if (pc != null) {
                    Display.getInstance().callSerially(new Runnable() {

                        @Override
                        public void run() {
                            String sku = null;
                            if(purchase != null){
                                sku = purchase.getSku();
                            }
                            pc.itemPurchaseError(sku, result.getMessage());
                        }
                    });
                }
            }
            if(purchase != null){
                inventory.erasePurchase(purchase.getSku());
            }
        }
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:28,代码来源:CodenameOneActivity.java

示例5: pay

import com.codename1.payment.PurchaseCallback; //导入依赖的package包/类
@Override
public String pay(double amount, String currency) {
    Intent intent = new Intent(activity, CheckoutActivity.class);

    String zoozAppKey = Display.getInstance().getProperty("ZoozAppKey", "");
    boolean isSandBox = Display.getInstance().getProperty("ZoozSandBox", "true").equals("true");
    // send merchant credential, app_key as given in the registration
    intent.putExtra(CheckoutActivity.ZOOZ_APP_KEY, zoozAppKey);
    intent.putExtra(CheckoutActivity.ZOOZ_AMOUNT, amount);
    intent.putExtra(CheckoutActivity.ZOOZ_CURRENCY_CODE, currency);
    intent.putExtra(CheckoutActivity.ZOOZ_IS_SANDBOX, isSandBox);
    String zoozInvoice = Display.getInstance().getProperty("ZoozInvoice", null);
    if(zoozInvoice != null) {
        intent.putExtra(CheckoutActivity.ZOOZ_INVOICE, zoozInvoice);
    }
    // start ZooZCheckoutActivity and wait to the activity result.
    activity.startActivityForResult(intent, ZOOZ_PAYMENT);
    
    Display.getInstance().invokeAndBlock(this);
    
    // use call serially so the purchase callback happens on the 
    // next EDT loop AFTER the value was returned 
    Display.getInstance().callSerially(new Runnable() {
        @Override
        public void run() {
            CodenameOneActivity cn = (CodenameOneActivity)activity;
            PurchaseCallback pc = cn.getPurchaseCallback();
            if(pc != null) {
                if(failMessage != null) {
                    pc.paymentFailed(purchaseId, failMessage);
                } else {
                    pc.paymentSucceeded(purchaseId, ZoozPurchase.this.amount, ZoozPurchase.this.currency);
                }
            }
        }
    });
    return purchaseId;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:39,代码来源:ZoozPurchase.java

示例6: pay

import com.codename1.payment.PurchaseCallback; //导入依赖的package包/类
@Override
public String pay(double amount, String currency) {
    Intent intent = new Intent(activity, CheckoutActivity.class);

    String zoozAppKey = Display.getInstance().getProperty("ZoozAppKey", "");
    boolean isSandBox = Display.getInstance().getProperty("ZoozSandBox", "true").equals("true");
    // send merchant credential, app_key as given in the registration
    intent.putExtra(CheckoutActivity.ZOOZ_APP_KEY, zoozAppKey);
    intent.putExtra(CheckoutActivity.ZOOZ_AMOUNT, amount);
    intent.putExtra(CheckoutActivity.ZOOZ_CURRENCY_CODE, currency);
    intent.putExtra(CheckoutActivity.ZOOZ_IS_SANDBOX, isSandBox);
    // start ZooZCheckoutActivity and wait to the activity result.
    activity.startActivityForResult(intent, ZOOZ_PAYMENT);
    
    Display.getInstance().invokeAndBlock(this);
    
    // use call serially so the purchase callback happens on the 
    // next EDT loop AFTER the value was returned 
    Display.getInstance().callSerially(new Runnable() {
        @Override
        public void run() {
            CodenameOneActivity cn = (CodenameOneActivity)activity;
            PurchaseCallback pc = cn.getPurchaseCallback();
            if(pc != null) {
                if(failMessage != null) {
                    pc.paymentFailed(purchaseId, failMessage);
                } else {
                    pc.paymentSucceeded(purchaseId, ZoozPurchase.this.amount, ZoozPurchase.this.currency);
                }
            }
        }
    });
    return purchaseId;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:35,代码来源:ZoozPurchase.java

示例7: setMainClass

import com.codename1.payment.PurchaseCallback; //导入依赖的package包/类
public static void setMainClass(Object main) {
    if(main instanceof PushCallback) {
        pushCallback = (PushCallback)main;
    }
    if(main instanceof PurchaseCallback) {
        purchaseCallback = (PurchaseCallback)main;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:IOSImplementation.java

示例8: onIabPurchaseFinished

import com.codename1.payment.PurchaseCallback; //导入依赖的package包/类
public void onIabPurchaseFinished(final IabResult result, final String sku, final Purchase purchase) {
    // if we were disposed of in the meantime, quit.
    if (mHelper == null) {
        return;
    }
    final PurchaseCallback pc = getPurchaseCallback();
    
    if(result.isFailure()){
        if (pc != null) {
            Display.getInstance().callSerially(new Runnable() {

                @Override
                public void run() {
                    pc.itemPurchaseError(sku, result.getMessage());
                }
            });
            return;
        }                        
    }

    if (!verifyDeveloperPayload(purchase)) {
        return;
    }            

    if(result.isSuccess()){
        if (pc != null) {
            Display.getInstance().callSerially(new Runnable() {

                @Override
                public void run() {
                    // Sandbox transactions have no order ID, so we'll make a dummy transaction ID
                    // in this case.
                    String transactionId = (purchase.getOrderId() == null || purchase.getOrderId().isEmpty()) ? 
                            "play-sandbox-"+UUID.randomUUID().toString() : purchase.getOrderId();
                    String purchaseJsonStr = purchase.getOriginalJson();
                    try {
                        // In order to verify receipts, we'll need both the order data and the signature
                        // so we'll pack it all into a single JSON string.
                        JSONObject purchaseJson = new JSONObject(purchaseJsonStr);
                        JSONObject rootJson = new JSONObject();
                        rootJson.put("data", purchaseJson);
                        rootJson.put("signature", purchase.getSignature());
                        purchaseJsonStr = rootJson.toString();
                        
                    } catch (JSONException ex) {
                        Logger.getLogger(CodenameOneActivity.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    com.codename1.payment.Purchase.postReceipt(Receipt.STORE_CODE_PLAY, sku, transactionId, purchase.getPurchaseTime(), purchaseJsonStr);
                    pc.itemPurchased(sku);     
                }
            });
            inventory.addPurchase(purchase);
            //This is a temp hack to get the last purchase raw data
            //The IAP API needs to be modified to support this on all platforms
            Display.getInstance().setProperty("lastPurchaseData", purchase.getOriginalJson());
        }            
    }

    //check if this product is a non consumable product
    if (!isConsumable(sku)) {
        return;
    }
    if(purchase.getItemType().equals(IabHelper.ITEM_TYPE_INAPP)){
        mHelper.consumeAsync(purchase, mConsumeFinishedListener);                
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:67,代码来源:CodenameOneActivity.java

示例9: getPurchaseCallback

import com.codename1.payment.PurchaseCallback; //导入依赖的package包/类
public PurchaseCallback getPurchaseCallback() {
    Object app = getApp();
    PurchaseCallback pc = app instanceof PurchaseCallback ? (PurchaseCallback) app : null;
    return pc;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:6,代码来源:CodenameOneActivity.java

示例10: ZoozPurchase

import com.codename1.payment.PurchaseCallback; //导入依赖的package包/类
public ZoozPurchase(IOSImplementation ioImpl, IOSNative nativeInstance, PurchaseCallback callback) {
    this.nativeInstance = nativeInstance;
    this.ioImpl = ioImpl;
    this.callback = callback;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:6,代码来源:ZoozPurchase.java

示例11: getPurchaseCallback

import com.codename1.payment.PurchaseCallback; //导入依赖的package包/类
/**
 * Returns the purchase callback instance
 */
public static PurchaseCallback getPurchaseCallback() {
    return purchaseCallback;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:7,代码来源:CodenameOneImplementation.java

示例12: getPurchaseCallback

import com.codename1.payment.PurchaseCallback; //导入依赖的package包/类
public PurchaseCallback getPurchaseCallback() {
    Object app = getApp();
    PurchaseCallback pc = app instanceof PurchaseCallback ? (PurchaseCallback)app : null;
    return pc;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:6,代码来源:CodenameOneActivity.java

示例13: setPurchaseCallback

import com.codename1.payment.PurchaseCallback; //导入依赖的package包/类
/**
 * Allows the system to register the purchase callback instance
 * 
 * @param pc the pc callback
 */
public static void setPurchaseCallback(PurchaseCallback pc) {
    purchaseCallback = pc;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:9,代码来源:CodenameOneImplementation.java


注:本文中的com.codename1.payment.PurchaseCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。