public void purchaseScreenActionButtonClick() { if (currentPurchaseStatus == PurchaseStatus.CHECKOUT_READY) { //Open Checkout page in browser string checkoutUrl = StoreProperties.INSTANCE.GetComponent <CreatePaymentAPI_Call>().API_SuccessResponse.links[1].href; if (Application.platform.Equals(RuntimePlatform.WebGLPlayer)) { openWindow(checkoutUrl); } else { Application.OpenURL(checkoutUrl); } PaymentListener newPaymentListener = StoreProperties.INSTANCE.gameObject.AddComponent <PaymentListener>(); CreatePaymentAPI_Call createPaymentAPI_Call = StoreProperties.INSTANCE.GetComponent <CreatePaymentAPI_Call>(); PayPalCreatePaymentJsonResponse createPaymentResponse = createPaymentAPI_Call.API_SuccessResponse; newPaymentListener.accessToken = createPaymentAPI_Call.accessToken; newPaymentListener.listeningInterval = 10f; newPaymentListener.payID = createPaymentResponse.id; InvokeRepeating("checkForPurchaseStatusChange", 1f, 1f); changePurchaseStatus(PurchaseStatus.WAITING); } else if (currentPurchaseStatus == PurchaseStatus.WAITING) { DialogScreenActions.INSTANCE.setContextConfirmAbortPayment(); DialogScreenActions.INSTANCE.ShowDialogScreen(); } }
public void OpenPurchaseItemScreen(StoreItemContent itemToPurchase) { MenuNavigation.INSTANCE.selectPurchaseIcon(); PurchaseItemImageField.sprite = itemToPurchase.itemImage; PurchaseItemNameField.text = itemToPurchase.itemName; PurchaseItemCostField.text = string.Format("{0:N}", itemToPurchase.itemCost); PurchaseItemCostField.text = CurrencyCodeMapper.GetCurrencySymbol(StoreProperties.INSTANCE.currencyCode) + PurchaseItemCostField.text; PurchaseItemDescField.text = itemToPurchase.itemDesc; PurchaseItemCurrCodeField.text = StoreProperties.INSTANCE.currencyCode; changePurchaseStatus(PurchaseStatus.CREATING_PURCHASE); CreatePaymentAPI_Call existingCreatePaymentAPIcall = StoreProperties.INSTANCE.gameObject.GetComponent <CreatePaymentAPI_Call> (); if (existingCreatePaymentAPIcall != null) { Destroy(existingCreatePaymentAPIcall); } CreatePaymentAPI_Call createPaymentAPICall = StoreProperties.INSTANCE.gameObject.AddComponent <CreatePaymentAPI_Call> (); createPaymentAPICall.accessToken = StoreProperties.INSTANCE.GetComponent <GetAccessTokenAPI_Call> ().API_SuccessResponse.access_token; createPaymentAPICall.transactionDescription = "purchased 1 item from x game"; createPaymentAPICall.itemCurrency = StoreProperties.INSTANCE.currencyCode; createPaymentAPICall.itemDescription = itemToPurchase.itemDesc; createPaymentAPICall.itemName = itemToPurchase.itemName; createPaymentAPICall.itemPrice = itemToPurchase.itemCost; createPaymentAPICall.JSON_CreatePaymentRequest = Resources.Load("Misc/CreatePaymentRequestBody") as TextAsset; InvokeRepeating("checkForPurchaseStatusChange", 1f, 1f); }