У некоторых трудностей с внедрением адаптивных платежей в iOS и, к сожалению, на веб-сайте или в ответ на PayPal очень мало документов. Это код:
- (void)makePaymentSandbox{
NSError *error;
//NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
//NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
NSURL *url = [NSURL URLWithString:@"https://svcs.sandbox.paypal.com/AdaptivePayments/Pay"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:30.0];
//setting
[request setHTTPMethod:@"POST"];
//headers
[request addValue:@"alex-facilitator_api1.fastwebnet.it" forHTTPHeaderField:@"X-PAYPAL-SECURITY-USERID"];
[request addValue:@"FW79EZXASW69NE8X" forHTTPHeaderField:@"X-PAYPAL-SECURITY-PASSWORD"];
[request addValue:@"ABZua9nnv9oieyN4MwVt15YdgetaJHcyzqOHjkLbuM-bGRoI7WRS" forHTTPHeaderField:@"X-PAYPAL-SECURITY-SIGNATURE"];
//NV
[request addValue:@"JSON" forHTTPHeaderField:@"X-PAYPAL-REQUEST-DATA-FORMAT"];
[request addValue:@"JSON" forHTTPHeaderField:@"X-PAYPAL-RESPONSE-DATA-FORMAT"];
[request addValue:@"APP-80W288712P519543T" forHTTPHeaderField:@"X-PAYPAL-APPLICATION-ID"];
[request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request addValue:@"en_US" forHTTPHeaderField:@"Accept-Language"];
//data
/*NSString *userUpdate =[NSString stringWithFormat:@"clientDetails.applicationId=%@&actionType=%@",@"APP-80W284485P519543T", @"PAY",nil];
NSData *data1 = [userUpdate dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:data1];
[request setValue: [NSString stringWithFormat:@"%lu", (unsigned long)[data1 length]] forHTTPHeaderField:@"Content-Length"];*/
NSDictionary *mapData = [[NSDictionary alloc] initWithObjectsAndKeys:
@"PAY", @"actionType",
@"USD", @"currencyCode",
@"http:\\www.cleverlyapp.com", @"cancelUrl",
@"http:\\www.cleverlyapp.com", @"returnUrl",
@"ReturnAll", @"requestEnvelope.detailLevel",
@"en_US", @"requestEnvelope.errorLanguage",
@"[email protected]", @"senderEmail",
@"0.1", @"receiverList.receiver(0).amount",
@"[email protected]", @"receiverList.receiver(0).email",
@"0.1", @"receiverList.receiver(1).amount",
@"[email protected]", @"receiverList.receiver(1).email",
@"APP-80W284485P519543T", @"clientDetails.applicationId",
nil];
NSData *postData = [NSJSONSerialization dataWithJSONObject:mapData options:0 error:&error];
[request setHTTPBody:postData];
[NSURLConnection connectionWithRequest:request delegate:self];
}
Здесь ответ:
String: {
error = (
{
category = Application;
domain = PLATFORM;
errorId = 580001;
message = "Invalid request: {0}";
severity = Error;
subdomain = Application;
}
);
responseEnvelope = {
ack = Failure;
build = 17325060;
correlationId = e82ede718b929;
timestamp = "2015-07-14T09:50:06.222-07:00";
};
}