SecurePay-SCALA (PA)
import java.io.DataOutputStream
import java.io.IOException
import java.io.InputStream
import java.net.URL
import javax.net.ssl.HttpsURLConnection
import org.apache.commons.io.IOUtils
object copyandpay {
def main(args: Array[String]) {
println(prepareCheckout);
}
def prepareCheckout : String = {
val url = "https://test.oppwa.com/v1/checkouts"
val parameters = ("authentication.userId=8a8294184f45ce7e014f4b1d16cc12df"
+ "&authentication.password=j3zCJ2ENaD"
+ "&authentication.entityId=8a8294184f45ce7e014f4b1d16bd12db"
+ "&paymentType=PA"
+ "&amount=50.99"
+ "¤cy=RSD"
)
val conn = new URL(url).openConnection()
conn match {
case secureConn: HttpsURLConnection => secureConn.setRequestMethod("POST")
case _ => throw new ClassCastException
}
conn.setDoInput(true)
conn.setDoOutput(true)
IOUtils.write(parameters, conn.getOutputStream())
conn.connect()
return IOUtils.toString(conn.getInputStream())
}
}
Objavljeno