Java

Author: Semaka 67 views
				
					OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "merchant_reference=12312312312&amount=5.00&error_url=https://url-to-your-success-page.co.za&success_url=https://url-to-your-success-page.co.za&cancel_url=https://url-to-your-success-page.co.za&notify_url=https://url-to-your-success-page.co.za&payment_type=credit_card");
Request request = new Request.Builder()
  .url("https://gateway.switch.tj/api/v1/payment-key")
  .method("POST", body)
  .addHeader("Authorization", "Basic V2hvb3NoRGVtb0FQSTpmZGZsa2RmZXVlbzM4Mzk4")
  .addHeader("Content-Type", "application/x-www-form-urlencoded")
  .addHeader("Cookie", "PHPSESSID=abk57kqs42fjpdfvv8a78ckfd7")
  .build();
Response response = client.newCall(request).execute();