Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Make Paypal Payment in iOS

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 933
    Comment on it

    To Integrate paypal in iOS App use the steps below:

    1- Install Pod for paypal

    platform :ios, '6.0'
    pod 'PayPal-iOS-SDK'

    2- #import <PayPalMobile.h> to your viewController.h and also set the delegate in .h @interface myPaymentPaypalViewController : UIViewController<PayPalPaymentDelegate>

    3- Create an object for PayPalConfiguration *payPalConfiguration in ViewController.h file
    Here is the code for paypal Cofiguration
     

    - (void)viewDidLoad {
        [super viewDidLoad];
    
    PayPalMobile initializeWithClientIdsForEnvironments:@{PayPalEnvironmentProduction : @"PRODUCTION_CLIENT_ID",
                                                               PayPalEnvironmentSandbox : @"SANDBOXCLIENTID"}];
        [PayPalMobile preconnectWithEnvironment:PayPalEnvironmentProduction];
    
                              //OR
    
    [PayPalMobile preconnectWithEnvironment:PayPalEnvironmentSandbox];
    
        _payPalConfiguration = [[PayPalConfiguration alloc] init];  
    
    // For example, if you wish to accept PayPal but not payment card payments, then add:   
    
    _payPalConfiguration.acceptCreditCards = NO;
    
        // Or if you wish to have the user choose a Shipping Address from those already
        // associated with the user's PayPal account, then add:
        _payPalConfiguration.payPalShippingAddressOption = PayPalShippingAddressOptionPayPal;
    }
    
    - (IBAction)pay {
        
        // Create a PayPalPayment
        PayPalPayment *payment = [[PayPalPayment alloc] init];
        
    //    // Amount, currency, and description
        payment.amount = [[NSDecimalNumber alloc] initWithString:@"1.0"];
        payment.currencyCode = @"USD";
        payment.shortDescription = @"By Paying $1 You will Get 10 life to play the game";
    
        payment.intent = PayPalPaymentIntentAuthorize;
    
        payment.shippingAddress = nil;
    
        if (!payment.processable) {
            NSLog(@"Request can not be processed!");
            return;
        }
        PayPalPaymentViewController *paymentViewController;
        paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment
                                                                       configuration:self.payPalConfiguration
                                                                            delegate:self];
        
        // Present the PayPalPaymentViewController.
        [self presentViewController:paymentViewController animated:YES completion:nil];
    }
    
    - (void)payPalPaymentViewController:(PayPalPaymentViewController *)paymentViewController
                     didCompletePayment:(PayPalPayment *)completedPayment {
        // Payment was processed successfully; send to server for verification and fulfillment.
        
        // Dismiss the PayPalPaymentViewController.
        [self dismissViewControllerAnimated:YES completion:^{
           
    NSLog("Payment done");
    
        }];
    }

     

     

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: