Java 类com.badlogic.gdx.pay.PurchaseManagerConfig 实例源码
项目:gdx-pay
文件:PurchaseManagerAndroidAmazon.java
@Override
public void install (final PurchaseObserver observer, PurchaseManagerConfig config, boolean autoFetchInformation) {
this.observer = observer;
this.config = config;
// --- copy all available products to the list of productIdentifiers
int offerSize = config.getOfferCount();
productIdentifiers = new HashSet<String>(offerSize);
for (int z = 0; z < config.getOfferCount(); z++) {
productIdentifiers.add(config.getOffer(z).getIdentifierForStore(storeName()));
}
PurchasingService.registerListener(activity.getApplicationContext(), this);
// PurchasingService.IS_SANDBOX_MODE returns a boolean value.
// Use this boolean value to check whether your app is running in test mode under the App Tester
// or in the live production environment.
showMessage(LOGTYPELOG, "Amazon IAP: sandbox mode is:" + PurchasingService.IS_SANDBOX_MODE);
observer.handleInstall();
PurchasingService.getUserData();
PurchasingService.getProductData(productIdentifiers);
}
项目:gdx-pay
文件:PurchaseManageriOSApple.java
@Override
public void purchase (String identifier) {
// Find the SKProduct for this identifier.
String identifierForStore = config.getOffer(identifier).getIdentifierForStore(PurchaseManagerConfig.STORE_NAME_IOS_APPLE);
SKProduct product = getProductByStoreIdentifier(identifierForStore);
if (product == null) {
// Product with this identifier not found: load product info first and try to purchase again
log(LOGTYPELOG, "Requesting product info for " + identifierForStore);
Set<String> identifierForStoreSet = new HashSet<String>(1);
identifierForStoreSet.add(identifierForStore);
productsRequest = new SKProductsRequest(identifierForStoreSet);
productsRequest.setDelegate(new AppleProductsDelegatePurchase());
productsRequest.start();
}
else {
// Create a SKPayment from the product and start purchase flow
log(LOGTYPELOG, "Purchasing product " + identifier + " ...");
SKPayment payment = new SKPayment(product);
SKPaymentQueue.getDefaultQueue().addPayment(payment);
}
}
项目:gdx-pay
文件:AndroidGooglePlayPurchaseManager.java
@Override
public void install(final PurchaseObserver observer, final PurchaseManagerConfig purchaseManagerConfig, final boolean autoFetchInformation) {
this.observer = observer;
this.purchaseManagerConfig = purchaseManagerConfig;
if (googleInAppBillingService.isListeningForConnections()) {
// Supports calling me multiple times.
// TODO: scenario not unit tested, test this!
googleInAppBillingService.disconnect();
}
googleInAppBillingService.requestConnect(new ConnectionListener() {
@Override
public void connected() {
onServiceConnected(observer, autoFetchInformation);
}
@Override
public void disconnected(GdxPayException exception) {
observer.handleInstallError(new GdxPayException("Failed to bind to service", exception));
}
});
}
项目:gdx-pay
文件:InAppPurchaseDataToTransactionConverter.java
public static Transaction convertJSONPurchaseToTransaction(String inAppPurchaseData) throws JSONException {
JSONObject object = new JSONObject(inAppPurchaseData);
Transaction transaction = new Transaction();
transaction.setStoreName(PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE);
if (object.has(PURCHASE_TOKEN)) {
transaction.setTransactionData(object.getString(PURCHASE_TOKEN));
}
if (object.has(ORDER_ID)) {
transaction.setOrderId(object.getString(ORDER_ID));
}
transaction.setIdentifier(object.getString(PRODUCT_ID));
transaction.setPurchaseTime(new Date(object.getLong(PURCHASE_TIME)));
if (object.has(PURCHASE_STATE)) {
fillTransactionForPurchaseState(transaction, object.getInt(PURCHASE_STATE));
}
return transaction;
}
项目:space-travels-3
文件:AndroidServices.java
@Override
protected PurchaseManagerConfig getPurchaseManagerConfig()
{
PurchaseManagerConfig purchaseManagerConfig = new PurchaseManagerConfig();
for (LevelPack levelPack : LevelManager.getLevelPacks())
{
if (!levelPack.isFree())
{
Offer offer = new Offer();
offer
.setType(OfferType.ENTITLEMENT)
.setIdentifier(levelPack.getGoogleSku());
offer.putIdentifierForStore(
PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE,
levelPack.getGoogleSku());
purchaseManagerConfig.addOffer(offer);
}
}
String key = PhysicsComponent.s(com.draga.shape.Circle.s(
GraphicComponent.s(Circle.s)
+ MenuScreen.s(IngameMenuScreen.s, -3)
+ GraphicComponent.s(HudScreen.s)
+ MenuScreen.s(DeadZoneInputModifier.s, 4)
+ GraphicComponent.s(Joystick.s)));
purchaseManagerConfig.addStoreParam(
PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE,
key);
return purchaseManagerConfig;
}
项目:space-travels-3
文件:Services.java
public void setupPurchaseManager()
{
PurchaseSystem.onAppRestarted();
if (PurchaseSystem.hasManager())
{
PurchaseManagerConfig purchaseManagerConfig = getPurchaseManagerConfig();
PurchaseSystem.install(new PurchaseObserver(), purchaseManagerConfig);
}
}
项目:gdx-pay
文件:AmazonTransactionUtils.java
/** Converts a Receipt to our transaction object. */
static Transaction convertReceiptToTransaction(int i, String requestId, Receipt receipt, final UserData userData) {
// build the transaction from the purchase object
Transaction transaction = new Transaction();
transaction.setIdentifier(receipt.getSku());
transaction.setOrderId(receipt.getReceiptId());
transaction.setStoreName(PurchaseManagerConfig.STORE_NAME_ANDROID_AMAZON);
transaction.setRequestId(requestId);
transaction.setUserId(userData.getUserId());
transaction.setPurchaseTime(receipt.getPurchaseDate());
transaction.setPurchaseText("Purchased: " + receipt.getSku().toString());
// transaction.setPurchaseCost(receipt.getSku()); // TODO: GdxPay: impl.
// parsing of COST + CURRENCY via skuDetails.getPrice()!
// transaction.setPurchaseCostCurrency(null);
if (receipt.isCanceled()) {
// order has been refunded or cancelled
transaction.setReversalTime(receipt.getCancelDate());
// transaction.setReversalText(receipt..getPurchaseState() == 1 ?
// "Cancelled" : "Refunded");
} else {
// still valid!
transaction.setReversalTime(null);
transaction.setReversalText(null);
}
transaction.setTransactionData(receipt.toJSON().toString());
// transaction.setTransactionDataSignature(purchase.getSignature());
return transaction;
}
项目:gdx-pay
文件:PurchaseManageriOSApple.java
/**
* @param autoFetchInformation is not used, because without product information on ios it's not possible to fill
* {@link Transaction} object on successful purchase
**/
@Override
public void install (PurchaseObserver observer, PurchaseManagerConfig config, boolean autoFetchInformation) {
this.observer = observer;
this.config = config;
log(LOGTYPELOG, "Installing purchase observer...");
// Check if the device is configured for purchases.
if (SKPaymentQueue.canMakePayments()) {
// Create string set from offer identifiers.
int size = config.getOfferCount();
Set<String> productIdentifiers = new HashSet<String>(size);
for (int i = 0; i < size; i++) {
productIdentifiers.add(config.getOffer(i).getIdentifierForStore(PurchaseManagerConfig.STORE_NAME_IOS_APPLE));
}
// Request configured offers/products.
log(LOGTYPELOG, "Requesting products...");
productsRequest = new SKProductsRequest(productIdentifiers);
productsRequest.setDelegate(new IosFetchProductsAndInstallDelegate());
productsRequest.start();
} else {
log(LOGTYPEERROR, "Error setting up in-app-billing: Device not configured for purchases!");
observer.handleInstallError(new RuntimeException(
"Error installing purchase observer: Device not configured for purchases!"));
}
}
项目:gdx-pay
文件:PurchaseManageriOSApple.java
/**
* @param autoFetchInformation is not used, because without product information on ios it's not possible to fill
* {@link Transaction} object on successful purchase
**/
@Override
public void install(PurchaseObserver observer, PurchaseManagerConfig config, boolean
autoFetchInformation) {
this.observer = observer;
this.config = config;
log(LOGTYPELOG, "Installing purchase observer...");
// Check if the device is configured for purchases.
if (SKPaymentQueue.canMakePayments()) {
// Create string set from offer identifiers.
int size = config.getOfferCount();
NSMutableSet<String> productIdentifiers = (NSMutableSet<String>) NSMutableSet.alloc()
.initWithCapacity(size);
for (int i = 0; i < size; i++) {
productIdentifiers.addObject(config.getOffer(i).getIdentifierForStore
(PurchaseManagerConfig.STORE_NAME_IOS_APPLE));
}
// Request configured offers/products.
log(LOGTYPELOG, "Requesting products...");
productsRequest = SKProductsRequest.alloc().initWithProductIdentifiers
(productIdentifiers);
productsRequest.setDelegate(new IosFetchProductsAndInstallDelegate());
productsRequest.start();
} else {
log(LOGTYPEERROR, "Error setting up in-app-billing: Device not configured for " +
"purchases!");
observer.handleInstallError(new RuntimeException("Error installing purchase observer:" +
" Device not configured for purchases!"));
}
}
项目:gdx-pay
文件:PurchaseManageriOSApple.java
@Override
public void purchase(String identifier) {
// Find the SKProduct for this identifier.
Offer offer = config.getOffer(identifier);
if (offer == null) {
log(LOGTYPEERROR, "Invalid product identifier, " + identifier);
observer.handlePurchaseError(new RuntimeException("Invalid product identifier, " + identifier));
} else {
String identifierForStore = offer.getIdentifierForStore
(PurchaseManagerConfig.STORE_NAME_IOS_APPLE);
SKProduct product = getProductByStoreIdentifier(identifierForStore);
if (product == null) {
// Product with this identifier not found: load product info first and try to purchase again
log(LOGTYPELOG, "Requesting product info for " + identifierForStore);
NSMutableSet<String> identifierForStoreSet = (NSMutableSet<String>) NSMutableSet
.alloc().initWithCapacity(1);
identifierForStoreSet.addObject(identifierForStore);
productsRequest = SKProductsRequest.alloc().initWithProductIdentifiers
(identifierForStoreSet);
productsRequest.setDelegate(new AppleProductsDelegatePurchase());
productsRequest.start();
} else {
// Create a SKPayment from the product and start purchase flow
log(LOGTYPELOG, "Purchasing product " + identifier + " ...");
SKPayment payment = SKPayment.paymentWithProduct(product);
((SKPaymentQueue) SKPaymentQueue.defaultQueue()).addPayment(payment);
}
}
}
项目:gdx-pay
文件:TransactionObjectMother.java
public static Transaction transactionFullEditionEuroGooglePlaySandbox() {
Transaction transaction = new Transaction();
transaction.setPurchaseCostCurrency("EUR");
transaction.setPurchaseCost(100);
transaction.setStoreName(PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE);
transaction.setPurchaseTime(new Date());
transaction.setIdentifier(PRODUCT_IDENTIFIER_FULL_EDITION);
transaction.setTransactionData("minodojglppganfbiedlabed.AO-J1OyNtpooSraUdtKlZ_9gYs0o20ZF_0ryTNACmvaaaG5EwPX0hPruUdGbE3XejoXYCYzJA2xjjAxrDLFhmu9WC4fvTDNL-RDXCWjlHKpzLOigxCr1QhScXR8uXtX8R94iV6MmMHqD");
return transaction;
}
项目:gdx-pay
文件:PurchaseManagerConfigObjectMother.java
public static PurchaseManagerConfig managerConfigGooglePlayOneOfferBuyFullEditionProduct() {
PurchaseManagerConfig config = new PurchaseManagerConfig();
config.addStoreParam(STORE_NAME_ANDROID_GOOGLE, "kbiosdfjoifjkldsfjowei8rfjiwfklmujwemflksdfjmsdklfj/sdifjsdlfkjsdfksd");
config.addOffer(offerFullEditionEntitlement());
return config;
}
项目:gdx-pay
文件:PurchaseManagerConfigObjectMother.java
public static PurchaseManagerConfig managerConfigGooglePlayOneOfferConsumbableProduct() {
PurchaseManagerConfig config = new PurchaseManagerConfig();
config.addStoreParam(STORE_NAME_ANDROID_GOOGLE, "kbiosdfjoifjkldsfjowei8rfjiwfklmujwemflksdfjmsdklfj/sdifjsdlfkjsdfksd");
config.addOffer(offerConsumable());
return config;
}
项目:gdx-pay
文件:PurchaseManagerConfigObjectMother.java
public static PurchaseManagerConfig managerConfigGooglePlayOneOfferSubscriptionProduct() {
PurchaseManagerConfig config = new PurchaseManagerConfig();
config.addStoreParam(STORE_NAME_ANDROID_GOOGLE, "kbiosdfjoifjkldsfjowei8rfjiwfklmujwemflksdfjmsdklfj/sdifjsdlfkjsdfksd");
config.addOffer(offerSubscription());
return config;
}
项目:gdx-pay
文件:PurchaseManagerAndroidOpenIAB.java
private String storeNameFromOpenIAB (String storeNameOpenIAB) {
if (storeNameOpenIAB == null) {
return null;
} else {
if (storeNameOpenIAB.equals(OpenIabHelper.NAME_GOOGLE)) {
return PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE;
} else if (storeNameOpenIAB.equals(OpenIabHelper.NAME_AMAZON)) {
return PurchaseManagerConfig.STORE_NAME_ANDROID_AMAZON;
} else if (storeNameOpenIAB.equals(OpenIabHelper.NAME_SAMSUNG)) {
return PurchaseManagerConfig.STORE_NAME_ANDROID_SAMSUNG;
} else if (storeNameOpenIAB.equals(OpenIabHelper.NAME_NOKIA)) {
return PurchaseManagerConfig.STORE_NAME_ANDROID_NOKIA;
} else if (storeNameOpenIAB.equals(OpenIabHelper.NAME_SLIDEME)) {
return PurchaseManagerConfig.STORE_NAME_ANDROID_SLIDEME;
} else if (storeNameOpenIAB.equals(OpenIabHelper.NAME_APTOIDE)) {
return PurchaseManagerConfig.STORE_NAME_ANDROID_APTOIDE;
} else if (storeNameOpenIAB.equals(OpenIabHelper.NAME_APPLAND)) {
return PurchaseManagerConfig.STORE_NAME_ANDROID_APPLAND;
} else if (storeNameOpenIAB.equals(OpenIabHelper.NAME_YANDEX)) {
return PurchaseManagerConfig.STORE_NAME_ANDROID_YANDEX;
} else {
// we should get here: the correct store should always be mapped!
Log.d(TAG, "Store name could not be mapped: " + storeNameOpenIAB);
return null;
}
}
}
项目:gdx-pay
文件:PurchaseManagerAndroidOpenIAB.java
private String storeNameToOpenIAB (String storeName) {
if (storeName == null) {
return null;
} else {
if (storeName.equals(PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE)) {
return OpenIabHelper.NAME_GOOGLE;
} else if (storeName.equals(PurchaseManagerConfig.STORE_NAME_ANDROID_AMAZON)) {
return OpenIabHelper.NAME_AMAZON;
} else if (storeName.equals(PurchaseManagerConfig.STORE_NAME_ANDROID_SAMSUNG)) {
return OpenIabHelper.NAME_SAMSUNG;
} else if (storeName.equals(PurchaseManagerConfig.STORE_NAME_ANDROID_NOKIA)) {
return OpenIabHelper.NAME_NOKIA;
} else if (storeName.equals(PurchaseManagerConfig.STORE_NAME_ANDROID_SLIDEME)) {
return OpenIabHelper.NAME_SLIDEME;
} else if (storeName.equals(PurchaseManagerConfig.STORE_NAME_ANDROID_APTOIDE)) {
return OpenIabHelper.NAME_APTOIDE;
} else if (storeName.equals(PurchaseManagerConfig.STORE_NAME_ANDROID_APPLAND)) {
return OpenIabHelper.NAME_APPLAND;
} else if (storeName.equals(PurchaseManagerConfig.STORE_NAME_ANDROID_YANDEX)) {
return OpenIabHelper.NAME_YANDEX;
} else {
// we should get here: the correct store should always be mapped!
Log.d(TAG, "Store name could not be mapped: " + storeName);
return null;
}
}
}
项目:space-travels-3
文件:NullServices.java
@Override
protected PurchaseManagerConfig getPurchaseManagerConfig()
{
return null;
}
项目:gdx-pay
文件:PurchaseManagerDesktopApple.java
@Override
public String storeName () {
return PurchaseManagerConfig.STORE_NAME_DESKTOP_APPLE;
}
项目:gdx-pay
文件:PurchaseManagerDesktopApple.java
@Override
public void install (PurchaseObserver observer, PurchaseManagerConfig config, boolean autoFetchInformation) {
// TODO Auto-generated method stub
}
项目:gdx-pay
文件:PurchaseManagerAndroidAmazon.java
@Override
public String storeName () {
return PurchaseManagerConfig.STORE_NAME_ANDROID_AMAZON;
}
项目:gdx-pay
文件:PurchaseManageriOSApple.java
@Override
public String storeName () {
return PurchaseManagerConfig.STORE_NAME_IOS_APPLE;
}
项目:gdx-pay
文件:PurchaseManageriOSApple.java
@Override
public String toString () {
return PurchaseManagerConfig.STORE_NAME_IOS_APPLE; // FIXME: shouldnt this be PurchaseManagerConfig.STORE_NAME_IOS_APPLE or storeName() ??!!
}
项目:gdx-pay
文件:PurchaseManagerAndroidOUYA.java
@Override
public String storeName () {
return PurchaseManagerConfig.STORE_NAME_ANDROID_OUYA;
}
项目:gdx-pay
文件:PurchaseManagerAndroidOUYA.java
@Override
public void install (final PurchaseObserver observer, PurchaseManagerConfig config, boolean autoFetchInformation) {
this.observer = observer;
this.config = config;
// Obtain applicationKey and developer ID. Pass in as follows:
// -------------------------------------------------------------------------
// config.addStoreParam(
// PurchaseManagerConfig.STORE_NAME_ANDROID_OUYA,
// new Object[] { OUYA_DEVELOPERID_STRING, applicationKeyPathSTRING });
// -------------------------------------------------------------------------
Object[] configuration = (Object[])config.getStoreParam(storeName());
String developerID = (String)configuration[0];
applicationKeyPath = (String)configuration[1]; // store our OUYA applicationKey-Path!
ouyaFacade = OuyaFacade.getInstance();
ouyaFacade.init((Context)activity, developerID);
// --- copy all available products to the list of purchasables
productIDList = new ArrayList<Purchasable>(config.getOfferCount());
for (int i = 0; i < config.getOfferCount(); i++) {
productIDList.add(new Purchasable(config.getOffer(i).getIdentifierForStore(storeName())));
}
// Create a PublicKey object from the key data downloaded from the developer portal.
try {
// Read in the key.der file (downloaded from the developer portal)
FileHandle fHandle = Gdx.files.internal(applicationKeyPath);
byte[] applicationKey = fHandle.readBytes();
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(applicationKey);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
ouyaPublicKey = keyFactory.generatePublic(keySpec);
showMessage(LOGTYPELOG, "succesfully created publicKey");
// ---- request the productlist ---------
requestProductList();
// notify of successful initialization
observer.handleInstall();
} catch (Exception e) {
// notify about the problem
showMessage(LOGTYPEERROR, "Problem setting up in-app billing: Unable to create encryption key");
observer.handleInstallError(new RuntimeException(
"Problem setting up in-app billing: Unable to create encryption key: " + e));
}
}
项目:gdx-pay
文件:PurchaseVerifierAndroidGoogle.java
@Override
public String storeName () {
return PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE;
}
项目:gdx-pay
文件:PurchaseVerifierAndroidAmazon.java
@Override
public String storeName () {
return PurchaseManagerConfig.STORE_NAME_ANDROID_AMAZON;
}
项目:gdx-pay
文件:PurchaseVerifieriOSApple.java
@Override
public String storeName () {
return PurchaseManagerConfig.STORE_NAME_IOS_APPLE;
}
项目:gdx-pay
文件:PurchaseManagerGwtGoogleWallet.java
@Override
public String storeName() {
return PurchaseManagerConfig.STORE_NAME_GWT_GOOGLEWALLET;
}
项目:gdx-pay
文件:PurchaseManagerGwtGoogleWallet.java
@Override
public void install (PurchaseObserver observer, PurchaseManagerConfig config, boolean autoFetchInformation) {
// TODO Auto-generated method stub
}
项目:gdx-pay
文件:PurchaseManageriOSApple.java
@Override
public String storeName() {
return PurchaseManagerConfig.STORE_NAME_IOS_APPLE;
}
项目:gdx-pay
文件:PurchaseManageriOSApple.java
@Override
public String toString() {
return PurchaseManagerConfig.STORE_NAME_IOS_APPLE; // FIXME: shouldnt this be PurchaseManagerConfig.STORE_NAME_IOS_APPLE or storeName() ??!!
}
项目:gdx-pay
文件:AndroidGooglePlayPurchaseManager.java
@Override
public String storeName() {
return PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE;
}
项目:space-travels-3
文件:Services.java
protected abstract PurchaseManagerConfig getPurchaseManagerConfig();