# iOS SDK Building with an AI agent? Start at https://docs.payme.io/agents.md Legacy SDK, not recommended for new integrations. Integrate PayMe into your iOS app with the PayMe iOS SDK: import the framework, initialize the SDK, and pay sales, pay subscriptions and capture buyers. > **Legacy SDK.** This SDK is no longer recommended for new integrations. It isn't actively updated, it requires your app to collect card details, and it puts your `seller_payme_id` (MPL), a server-side credential, in the app. For new apps, open the [Hosted Payment Page](/payments/hosted-payment-page) in a secure in-app browser (`SFSafariViewController` on iOS), so card details never pass through your app. You can also offer [Apple Pay](/payments/apple-pay) and [Google Pay](/payments/google-pay). > > How to: [Accept payments in a mobile app](/accepting-payments/checkout-and-in-person/mobile-apps). To get the SDK, ask PayMe Partners (partners@payme.io) for access. ## Getting started ### Get the PayMe package Build the framework from sources: 1. Open the PayMe project. 2. Build the project. 3. The new framework is generated automatically in the Products directory of `PMLib.xcodeproj`: `PMLib.framework`. 4. Right-click → **Show in Finder** to get the path of the framework. ### Import the PayMe SDK framework 1. Open the project that needs to import the framework. 2. Select your project's **Targets → General → Embedded Binaries** (or **Build Phases → Embedded Frameworks**). 3. Press **Add (+)** and go to the path of `PMLib.framework`. 4. Build the project. ## Initialize the SDK Create a shared `PayMe` instance, for example in your app delegate: ```objc #import #define SELLERKEY @"/* Your seller_payme_id */" #define WEBSERVICE [PayMe sharedInstant:SELLERKEY stage:STAGING] ``` `stage` sets the environment. The sample uses `STAGING`; ask PayMe Partners for the value to use in production. The samples below call `WEBSERVICE` and leave the success and failure handling to you. ## Integrate with the PayMe API Each API request requires appropriate `PayMeRequest` and `TransactionListener` instances. ### Pay a sale First, create the sale on your server with [generate-sale](/payments/hosted-payment-page/post-generate-sale) and send its `payme_sale_id` to your app. Then create a `PaySaleRequest` and send it: ```objc PaySaleRequest *request = [[PaySaleRequest alloc] init]; //payme_sale_id - Required - From your server request.paymeSaleId = /* payme_sale_id */; //Installments - Required request.installments = installments; //ID - Required only for Israeli cards request.buyerSocialID = buyerSocialID; //Email - Required request.buyerEmail = buyerEmail; //Name - Required request.buyerName = buyerName; //Credit Card Number - Required request.creditCardNumber = creditCardNumber; //CreditCard CVV - Required request.creditCardCVV = creditCardCVV; //Credit Card Expiration - Required request.creditCardExp = creditCardExp; [WEBSERVICE paySale:request success:^(PaySaleResponse *responseObject) { if(responseObject != nil) { //Handle success request } } failure:^(PayMeError *error) { if(error != nil) { //Handle failed request } }]; ``` ### Pay a subscription First, create the subscription on your server with [generate-subscription](/payments/subscriptions/post-generate-subscription) and send its `sub_payme_id` to your app. Then create a `PaySubscriptionRequest` and send it: ```objc PaySubscriptionRequest *request = [[PaySubscriptionRequest alloc] init]; //Name - Required request.buyerName = buyerName; //ID - Required only for Israeli cards request.buyerSocialId = buyerSocialId; //Phone request.buyerPhone = buyerPhone; //Email - Required request.buyerEmail = buyerEmail; //sub_payme_id - Required - From your server request.subPaymeId = /* sub_payme_id */; //Credit Card Number - Required request.creditCardNumber = creditCardNumber; //CreditCard CVV - Required request.creditCardCVV = creditCardCVV; //Credit Card Expiration - Required request.creditCardExp = creditCardExp; [WEBSERVICE paySubscription:request success:^(PaySubscriptionResponse *responseObject) { if(responseObject != nil) { //Handle success request } } failure:^(PayMeError *error) { if(error != nil) { //Handle failed request } }]; ``` ### Capture a buyer token ```objc CaptureBuyerRequest *request = [[CaptureBuyerRequest alloc] init]; //Name - Required request.buyerName = buyerName; //Phone - Required request.buyerPhone = buyerPhone; //Email - Required request.buyerEmail = buyerEmail; //ID - Required only for Israeli cards request.buyerSocialId = buyerSocialId; //SellerID - Required request.sellerPaymeId = /* Your seller_payme_id */; //Permanent request.buyerIsPermanent = buyerIsPermanent; //Credit Card Number - Required request.creditCardNumber = creditCardNumber; //CreditCard CVV - Required request.creditCardCvv = creditCardCVV; //Credit Card Expiration - Required request.creditCardExp = creditCardExp; [WEBSERVICE captureBuyer:request success:^(CaptureBuyerResponse *responseObject) { if(responseObject != nil) { //Handle success request } } failure:^(PayMeError *error) { if(error != nil) { //Handle failed request } }]; ```