Skip to content
Danilo edited this page Jun 7, 2020 · 4 revisions

Overview

This framework includes an integration that allows the ability to manage PayPal API services.

PayPal associates a series of API credentials with a specific PayPal account, it is possible to generate credentials from this url, finally it is necessary to convert these credentials into a p12 protected file to be included in the project, so that the framework can use it to request authorization to access to the PayPal API.

Sample

    #import <SOAPEngine64/SOAPEngine.h>

    SOAPEngine *soap = [[SOAPEngine alloc] init];

    // PAYPAL associates a set of API credentials with a specific PayPal account
    // you can generate credentials from this https://developer.paypal.com/docs/classic/api/apiCredentials/
    // and convert to a p12 use : openssl pkcs12 -export -in cert_key_pem.txt -inkey cert_key_pem.txt -out paypal_cert.p12
    // other conversion instructions: https://www.sslshopper.com/ssl-converter.html
    //
    soap.responseHeader = YES;
    soap.authorizationMethod = SOAP_AUTH_PAYPAL;
    soap.username = @"my-username";
    soap.password = @"my-password";
    //
    // API with Certificate : https://api.paypal.com/2.0/ sandbox https://api.sandbox.paypal.com/2.0/
    // API with Signature : https://api-3t.paypal.com/2.0/ sandbox https://api-3t.sandbox.paypal.com/2.0/
    //
    soap.clientCerficateName = @"my-cert.p12";
    soap.clientCertificatePassword = @"cert-password";
    //
    // API version : https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl
    //
    [soap setValue:@"204.0" forKey:@"paypal1:Version"]; // use paypal1 for urn:ebay:apis:eBLBaseComponents namespace
    [soap setValue:@"0" forKey:@"paypal:ReturnAllCurrencies"]; // use paypal for urn:ebay:api:PayPalAPI namespace
    [soap requestURL:@"https://api.paypal.com/2.0/"
          soapAction:@"GetBalance" completeWithDictionary:^(NSInteger statusCode, NSDictionary *dict) {
              NSLog(@"%@", dict);
          } failWithError:^(NSError *error) {
              NSLog(@"%@", error);
          }];