Skip to content

Commit

Permalink
Moved payments key to Package class (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
DDieter authored and danirabbit committed Apr 7, 2017
1 parent b823d44 commit b0d0766
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/Core/Package.vala
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public class AppCenterCore.Package : Object {
private string? summary = null;
private string? color_primary = null;
private string? color_primary_text = null;
private string? payments_key = null;
private string? _latest_version = null;
public string? latest_version {
private get { return _latest_version; }
Expand Down Expand Up @@ -371,6 +372,15 @@ public class AppCenterCore.Package : Object {
}
}

public string? get_payments_key () {
if (payments_key != null) {
return payments_key;
} else {
payments_key = component.get_custom_value ("x-appcenter-stripe");
return payments_key;
}
}

private string convert_version (string version) {
string returned = version;
returned = returned.split ("+", 2)[0];
Expand Down
7 changes: 2 additions & 5 deletions src/Widgets/AbstractAppContainer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,13 @@ namespace AppCenter {
}
}

private string? payments_key_ = null;
public bool payments_enabled {
get {
if (this.package == null || this.package.component == null || updates_view) {
return false;
} else if (payments_key_ == null) {
payments_key_ = this.package.component.get_custom_value ("x-appcenter-stripe");
}

return payments_key_ != null;
return this.package.get_payments_key() != null;
}
}

Expand All @@ -93,7 +90,7 @@ namespace AppCenter {
action_button.download_requested.connect (() => action_clicked.begin ());

action_button.payment_requested.connect ((amount) => {
var stripe = new Widgets.StripeDialog (amount, this.package_name.label, this.package.component.get_desktop_id ().replace (".desktop", ""), payments_key_);
var stripe = new Widgets.StripeDialog (amount, this.package_name.label, this.package.component.get_desktop_id ().replace (".desktop", ""), this.package.get_payments_key());

stripe.download_requested.connect (() => action_clicked.begin ());
stripe.show ();
Expand Down

0 comments on commit b0d0766

Please sign in to comment.