Skip to content

Adds support for 'partner_id' to 'setAppInfo' #602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/main/java/com/stripe/Stripe.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public abstract class Stripe {
public static volatile String apiKey;
public static volatile String apiVersion;
public static volatile String clientId;
public static volatile String partnerId;

// Note that URLConnection reserves the value of 0 to mean "infinite
// timeout", so we use -1 here to represent an unset value which should
Expand Down Expand Up @@ -146,11 +147,15 @@ public static PasswordAuthentication getProxyCredential() {
}

public static void setAppInfo(String name) {
setAppInfo(name, null, null);
setAppInfo(name, null, null, null);
}

public static void setAppInfo(String name, String version) {
setAppInfo(name, version, null);
setAppInfo(name, version, null, null);
}

public static void setAppInfo(String name, String version, String url) {
setAppInfo(name, version, url, null);
}

/**
Expand All @@ -159,15 +164,17 @@ public static void setAppInfo(String name, String version) {
* @param name Name of your application (e.g. "MyAwesomeApp")
* @param version Version of your application (e.g. "1.2.34")
* @param url Website for your application (e.g. "https://myawesomeapp.info")
* @param partnerId Your Stripe Partner ID (e.g. "pp_partner_1234")
*/
public static void setAppInfo(String name, String version, String url) {
public static void setAppInfo(String name, String version, String url, String partnerId) {
if (appInfo == null) {
appInfo = new HashMap<String, String>();
}

appInfo.put("name", name);
appInfo.put("version", version);
appInfo.put("url", url);
appInfo.put("partner_id", partnerId);
}

public static Map<String, String> getAppInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void testCorrectAdditionalOwners() throws StripeException, UnsupportedEnc
public void testAppInfo() {
final RequestOptions options = (new RequestOptionsBuilder()).setApiKey("sk_foobar").build();

Stripe.setAppInfo("MyAwesomePlugin", "1.2.34", "https://myawesomeplugin.info");
Stripe.setAppInfo("MyAwesomePlugin", "1.2.34", "https://myawesomeplugin.info", "pp_partner_1234");

final Map<String, String> headers = LiveStripeResponseGetter.getHeaders(options);

Expand All @@ -190,5 +190,6 @@ public void testAppInfo() {
assertEquals("MyAwesomePlugin", appMap.get("name"));
assertEquals("1.2.34", appMap.get("version"));
assertEquals("https://myawesomeplugin.info", appMap.get("url"));
assertEquals("pp_partner_1234", appMap.get("partner_id"));
}
}