Skip to content

Commit 41f530a

Browse files
committed
[++] Add Plan and Multicurrency support
1 parent 6075c3c commit 41f530a

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

example/src/main/java/co/paystack/example/MainActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ private void validateTransactionForm() {
168168
// .setBearer(Charge.Bearer.subaccount)
169169
// .setTransactionCharge(18);
170170

171+
// OUR SDK is Plans Aware, and MultiCurrency Aware
172+
// You may also set a currency and plan
173+
// charge.setPlan("PLN_sh897hueidh")
174+
// .setCurrency("NGN")
175+
171176
}
172177

173178
/**

paystack/src/main/java/co/paystack/android/api/request/ChargeRequestBody.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class ChargeRequestBody extends BaseRequestBody {
2727
public static final String FIELD_BEARER = "bearer";
2828
public static final String FIELD_HANDLE = "handle";
2929
public static final String FIELD_METADATA = "metadata";
30+
public static final String FIELD_CURRENCY = "currency";
31+
public static final String FIELD_PLAN = "plan";
3032

3133
@SerializedName(FIELD_CLIENT_DATA)
3234
public final String clientData;
@@ -61,6 +63,12 @@ public class ChargeRequestBody extends BaseRequestBody {
6163
@SerializedName(FIELD_METADATA)
6264
public String metadata;
6365

66+
@SerializedName(FIELD_CURRENCY)
67+
public String currency;
68+
69+
@SerializedName(FIELD_PLAN)
70+
public String plan;
71+
6472

6573
public ChargeRequestBody addPin(String pin) {
6674
this.handle = Crypto.encrypt(pin);
@@ -78,6 +86,8 @@ public ChargeRequestBody(Charge charge) {
7886
this.transaction_charge = charge.getTransactionCharge() > 0 ? Integer.toString(charge.getTransactionCharge()) : null;
7987
this.bearer = charge.getBearer() != null ? charge.getBearer().name() : null;
8088
this.metadata = charge.getMetadata();
89+
this.plan = charge.getPlan();
90+
this.currency = charge.getCurrency();
8191
}
8292

8393

@@ -107,7 +117,12 @@ public HashMap<String, String> getParamsHashMap() {
107117
if (metadata != null) {
108118
params.put(FIELD_METADATA, metadata);
109119
}
110-
Log.d("barabara",params.toString());
120+
if (plan != null) {
121+
params.put(FIELD_PLAN, plan);
122+
}
123+
if (currency != null) {
124+
params.put(FIELD_CURRENCY, currency);
125+
}
111126
return params;
112127
}
113128
}

paystack/src/main/java/co/paystack/android/model/Charge.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@ public enum Bearer {
4141
private String reference;
4242
private Bearer bearer;
4343

44+
private String currency;
45+
private String plan;
46+
47+
public String getCurrency() {
48+
return currency;
49+
}
50+
51+
public Charge setCurrency(String currency) {
52+
this.currency = currency;
53+
return this;
54+
}
55+
56+
public String getPlan() {
57+
return plan;
58+
}
59+
60+
public Charge setPlan(String plan) {
61+
this.plan = plan;
62+
return this;
63+
}
64+
4465
public int getTransactionCharge() {
4566
return transactionCharge;
4667
}

0 commit comments

Comments
 (0)