/* * @return Paymentwall_Product */ public Paymentwall_Product getProduct() { string productType = (this.getProductPeriodLength() > 0 ? Paymentwall_Product.TYPE_SUBSCRIPTION : Paymentwall_Product.TYPE_FIXED); Paymentwall_Product product = new Paymentwall_Product( this.getProductId(), 0, null, null, productType, this.getProductPeriodLength(), this.getProductPeriodType() ); return(product); }
/** * @param string productId your internal product ID, e.g. product1 * @param float amount product price, e.g. 9.99 * @param string currencyCode ISO currency code, e.g. USD * @param string name product name * @param string productType product type, Paymentwall_Product::TYPE_SUBSCRIPTION for recurring billing, or Paymentwall_Product::TYPE_FIXED for one-time payments * @param int periodLength product period length, e.g. 3. Only required if product type is subscription * @param string periodType product period type, e.g. Paymentwall_Product::PERIOD_TYPE_MONTH. Only required if product type is subscription * @param bool recurring if the product recurring * @param Paymentwall_Product trialProduct trial product, product type should be subscription, recurring should be True */ public Paymentwall_Product(string productId, float amount = 0.0f, string currencyCode = null, string name = null, string productType = Paymentwall_Product.TYPE_FIXED, int periodLength = 0, string periodType = null, bool recurring = false, Paymentwall_Product trialProduct = null) { this.productId = productId; this.amount = amount; this.currencyCode = currencyCode; this.name = name; this.productType = productType; this.periodLength = periodLength; this.periodType = periodType; this.recurring = recurring; if (productType == Paymentwall_Product.TYPE_SUBSCRIPTION && this.recurring == true) { this.trialProduct = trialProduct; } else { this.trialProduct = null; } }
/** * @param string productId your internal product ID, e.g. product1 * @param float amount product price, e.g. 9.99 * @param string currencyCode ISO currency code, e.g. USD * @param string name product name * @param string productType product type, Paymentwall_Product::TYPE_SUBSCRIPTION for recurring billing, or Paymentwall_Product::TYPE_FIXED for one-time payments * @param int periodLength product period length, e.g. 3. Only required if product type is subscription * @param string periodType product period type, e.g. Paymentwall_Product::PERIOD_TYPE_MONTH. Only required if product type is subscription * @param bool recurring if the product recurring * @param Paymentwall_Product trialProduct trial product, product type should be subscription, recurring should be True */ public Paymentwall_Product(string productId, float amount = 0.0f, string currencyCode = null, string name = null, string productType = Paymentwall_Product.TYPE_FIXED, int periodLength = 0, string periodType = null, bool recurring = false, Paymentwall_Product trialProduct = null) { this.productId = productId; this.amount = amount; this.currencyCode = currencyCode; this.name = name; this.productType = productType; this.periodLength = periodLength; this.periodType = periodType; this.recurring = recurring; if (productType == Paymentwall_Product.TYPE_SUBSCRIPTION && this.recurring == true) { this.trialProduct = trialProduct; } else { this.trialProduct = null; } }
/* * Return URL for the widget * * @return string */ public string getUrl() { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters["key"] = Paymentwall_Widget.getAppKey(); parameters["uid"] = this.userId; parameters["widget"] = this.widgetCode; int productsNumber = this.products.Count; if (Paymentwall_Widget.getApiType() == Paymentwall_Widget.API_GOODS) { if (productsNumber > 0) { if (productsNumber == 1) { Paymentwall_Product product = this.products[0]; Paymentwall_Product postTrialProduct = null; if (product.getTrialProduct() is Paymentwall_Product) { postTrialProduct = product; product = product.getTrialProduct(); } parameters.Add("amount", product.getAmount().ToString()); parameters.Add("currencyCode", product.getCurrencyCode()); parameters.Add("ag_name", product.getName()); parameters.Add("ag_external_id", product.getId()); parameters.Add("ag_type", product.getType()); if (product.getType() == Paymentwall_Product.TYPE_SUBSCRIPTION) { parameters.Add("ag_period_length", product.getPeriodLength().ToString()); parameters.Add("ag_period_type", product.getPeriodType()); if (product.isRecurring()) { parameters.Add("ag_recurring", (Convert.ToInt32(product.isRecurring())).ToString()); if (postTrialProduct != null) { parameters.Add("ag_trial", "1"); parameters.Add("ag_post_trial_external_id", postTrialProduct.getId()); parameters.Add("ag_post_trial_period_length", postTrialProduct.getPeriodLength().ToString()); parameters.Add("ag_post_trial_period_type", postTrialProduct.getPeriodType()); parameters.Add("ag_post_trial_name", postTrialProduct.getName()); parameters.Add("post_trial_amount", postTrialProduct.getAmount().ToString()); parameters.Add("post_trial_currencyCode", postTrialProduct.getCurrencyCode().ToString()); } } } } //end if (productNumber == 1) else { //TODO: Paymentwall_Widget.appendToErrors('Only 1 product is allowed in flexible widget call'); } } //end if (productNumber > 0) } else if (Paymentwall_Widget.getApiType() == Paymentwall_Widget.API_CART) { int index = 0; foreach (Paymentwall_Product product in this.products) { parameters.Add("external_ids[" + index.ToString() + "]", product.getId()); if (product.getAmount() != -1f) { parameters.Add("prices[" + index.ToString() + "]", product.getAmount().ToString()); } if (product.getCurrencyCode() != null) { parameters.Add("currencies[" + index.ToString() + "]", product.getCurrencyCode()); } index++; } index = 0; } int signatureVersion = this.getDefaultSignatureVersion(); parameters.Add("sign_version", Convert.ToString(signatureVersion)); if (this.extraParams.ContainsKey("sign_version")) { parameters["sign_version"] = this.extraParams["sign_version"]; signatureVersion = Convert.ToInt32(this.extraParams["sign_version"]); } parameters = mergeDictionaries(parameters, extraParams); parameters["sign"] = Paymentwall_Widget.calculateSignature(parameters, Paymentwall_Widget.getSecretKey(), signatureVersion); return(Paymentwall_Widget.BASE_URL + "/" + this.buildController(this.widgetCode) + "?" + this.buildQueryString(parameters, "&")); }
/* * @return Paymentwall_Product */ public Paymentwall_Product getProduct() { string productType = (this.getProductPeriodLength() > 0 ? Paymentwall_Product.TYPE_SUBSCRIPTION : Paymentwall_Product.TYPE_FIXED); Paymentwall_Product product = new Paymentwall_Product( this.getProductId(), 0, null, null, productType, this.getProductPeriodLength(), this.getProductPeriodType() ); return product; }