Skip to content

Commit 2cbff1a

Browse files
authored
[chore] more information about backend url
1 parent a525584 commit 2cbff1a

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ public class MainActivity extends AppCompatActivity {
2626

2727
// To get started quickly, change this to your heroku deployment of
2828
// https://github.com/PaystackHQ/sample-charge-card-backend
29-
String new_access_code_url = "";
30-
String verify_url = "";
29+
// Step 1. Visit https://github.com/PaystackHQ/sample-charge-card-backend
30+
// Step 2. Click "Deploy to heroku"
31+
// Step 3. Login with your heroku credentials or create a free heroku account
32+
// Step 4. Provide your secret key and an email with which to start all test transactions
33+
// Step 5. Copy the url generated by heroku (format https://some-url.heroku-app.com) into the space below
34+
String backend_url = "";
3135
// Set this to a public key that matches the secret key you supplied while creating the heroku instance
3236
String paystack_public_key = "";
3337

@@ -52,11 +56,8 @@ protected void onCreate(Bundle savedInstanceState) {
5256
super.onCreate(savedInstanceState);
5357
setContentView(R.layout.activity_main);
5458

55-
if (BuildConfig.DEBUG && (new_access_code_url.equals(""))) {
56-
throw new AssertionError("Please set a url at which to get an access code before running the sample");
57-
}
58-
if (BuildConfig.DEBUG && (verify_url.equals(""))) {
59-
throw new AssertionError("Please set a url at which to verify transactions before running the sample");
59+
if (BuildConfig.DEBUG && (backend_url.equals(""))) {
60+
throw new AssertionError("Please set a backend url before running the sample");
6061
}
6162
if (BuildConfig.DEBUG && (paystack_public_key.equals(""))) {
6263
throw new AssertionError("Please set a public key before running the sample");
@@ -110,7 +111,7 @@ private void startAFreshCharge() {
110111
// Perform transaction/initialize on our server to get an access code
111112
// documentation: https://developers.paystack.co/reference#initialize-a-transaction
112113

113-
new fetchAccessCodeFromServer().execute(new_access_code_url);
114+
new fetchAccessCodeFromServer().execute(backend_url+"/new-access-code");
114115

115116
}
116117

@@ -327,7 +328,7 @@ protected void onPostExecute(String result) {
327328
protected String doInBackground(String... reference) {
328329
try {
329330
this.reference = reference[0];
330-
URL url = new URL(verify_url + this.reference);
331+
URL url = new URL(backend_url + "/verify/" + this.reference);
331332
BufferedReader in = new BufferedReader(
332333
new InputStreamReader(
333334
url.openStream()));

0 commit comments

Comments
 (0)