Initializing the payment request
When the buyer validates his or her order, the application generates a "payload" containing the details of the shopping cart, the buyer contact information, the shipping details, etc...
The provided example uses the following data:
{ "email": "example@email.com", "orderId": "myOrderId-1", "amount": "200", "currency": "978", "mode": "TEST", "language": "de", "cardType": "" }
The mobile application transmits the payment request to the merchant server via a POST request method.
Excerpt from the sample code for Android:
val conn = URL(serverUrl).openConnection() as HttpURLConnection conn.requestMethod = "POST" conn.setRequestProperty("Content-type", "application/json") conn.setRequestProperty("Accept", "*/*") conn.doInput = true conn.doOutput = true conn.connectTimeout = 15000 val os = conn.outputStream val writer = BufferedWriter(OutputStreamWriter(os, "UTF-8")) writer.write(payload.toString()) writer.flush() writer.close() os.close() conn.connect() val out = OutputStreamWriter(conn.outputStream)
Excerpt from the sample code for iOS:
/// Build an URLRequest according required payment information : server url, email, amount, mode, lang /// /// - Returns: URLRequest object func buildRequest() -> URLRequest? { let serverUrl: NSURL = NSURL(string: PaymentProvider.SERVER_URL)! var urlRequest = URLRequest(url:serverUrl as URL) urlRequest.httpMethod = "POST" var params: [String: String] = ["amount": paymentInfo.amount, "currency": paymentInfo.currency, "mode": paymentInfo.mode, "language": paymentInfo.lang] if !paymentInfo.email.isEmpty{ params["email"] = paymentInfo.email } if !paymentInfo.cardType.isEmpty{ params["cardType"] = paymentInfo.cardType } do{ let jsonParam = try JSONSerialization.data(withJSONObject: params, options: []) urlRequest.httpBody = jsonParam } catch{ return nil } return urlRequest }