this code is expected to do a Payout in PayPal using MassPay. It fails and I don't get a response from PayPal that tells me what is going on. Can somebody point me in the right direction?
let postsEndpoint: String = "https://api-3t.sandbox.paypal.com/nvp"
var postsUrlRequest = NSMutableURLRequest(URL: NSURL(string: postsEndpoint)!)
postsUrlRequest.HTTPMethod = "POST"
let paymentDict = ["USER" : "example.mydomain.com",
"PWD" : "PQDBVQXJYH4***",
"SIGNATURE" : "A9pEq0L3-2vjFoem1ajRi-b-0nWBAkujmPM.O5dJ9u-m7Vf***",
"METHOD" : "MassPay",
"VERSION" : "93",
"RECEIVERTYPE" : "EmailAddress",
"CURRENCYCODE" : "USD",
"EMAILSUBJECT" : "First payment test form swift",
"L_AMT0" : 1.25,
"L_EMAIL0" : "[email protected]",
"L_NOTE0" : "first test from swift",
"L_UNIQUEID0" : "KS1946-3"]
let newPost: NSDictionary = paymentDict
do {
let jsonPost = try NSJSONSerialization.dataWithJSONObject(newPost, options: [])
postsUrlRequest.HTTPBody = jsonPost
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: config)
let createTask = session.dataTaskWithRequest(postsUrlRequest, completionHandler: {
(data, response, error) in
guard let responseData = data else {
print("Error: did not receive data")
return
}
guard error == nil else {
})
createTask.resume()
} catch {
print("Error: cannot create JSON from post")
}
}
working code for MassPay post to PayPal with swift from my App