🍎 Настройка iOS
Подробное руководство по настройке CloudPayments SDK для iOS платформы.
📋 Требования
- iOS: 15.0 или выше
- Xcode: 14.0 или выше
- Swift: 5.7 или выше
- CocoaPods: 1.11.0 или выше
- CloudPayments SDK: 2.1.0 или выше
⚙️ Настройка проекта
1. Обновление Podfile
ios/Podfile
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '15.0'
install! 'cocoapods', :deterministic_uuids => false
target 'YourApp' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => true,
:fabric_enabled => false,
:flipper_configuration => FlipperConfiguration.enabled,
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
# CloudPayments SDK зависимости
pod 'Cloudpayments', :git => "https://gitpub.cloudpayments.ru/integrations/sdk/cloudpayments-ios", :branch => "master"
pod 'CloudpaymentsNetworking', :git => "https://gitpub.cloudpayments.ru/integrations/sdk/cloudpayments-ios", :branch => "master"
target 'YourAppTests' do
inherit! :complete
end
post_install do |installer|
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false
)
# Настройка deployment target
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'
end
end
end
end
2. Установка зависимостей
cd ios
pod install
cd ..
🍎 Apple Pay
1. Настройка Apple Pay в Xcode
- Откройте проект в Xcode:
ios/YourApp.xcworkspace - Выберите ваш проект в навигаторе
- Перейдите на вкладку Signing & Capabilities
- Нажмите + Capability и добавьте Apple Pay
- Настройте Merchant ID
2. Создание Merchant ID
- Войдите в Apple Developer Console
- Перейдите в Certificates, Identifiers & Profiles
- Выберите Identifiers → Merchant IDs
- Создайте новый Merchant ID (например:
merchant.com.yourcompany.yourapp)
3. Настройка в коде
// Проверка доступности Apple Pay
import { PaymentService } from '@lmapp/react-native-cloudpayments';
const checkApplePay = async () => {
try {
const isAvailable = await PaymentService.isApplePayAvailable();
console.log('Apple Pay доступен:', isAvailable);
} catch (error) {
console.log('Apple Pay недоступен:', error);
}
};
4. Настройка платежной формы с Apple Pay
const paymentData = {
amount: '1000.00',
currency: 'RUB',
description: 'Покупка товара',
email: 'user@example.com',
applePayMerchantId: 'merchant.com.yourcompany.yourapp', // Ваш Merchant ID
showApplePay: true,
};
🔐 Настройка безопасности
1. App Transport Security (ATS)
Добавьте в ios/YourApp/Info.plist:
ios/YourApp/Info.plist
<dict>
<!-- Другие настройки -->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>cloudpayments.ru</key>
<dict>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>api.cloudpayments.ru</key>
<dict>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
</dict>
</dict>
</dict>
</dict>
🔗 URL Schemes
1. Настройка для банковских приложений
Добавьте в ios/YourApp/Info.plist:
ios/YourApp/Info.plist
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.yourcompany.yourapp.payments</string>
<key>CFBundleURLSchemes</key>
<array>
<string>yourapp</string>
</array>
</dict>
</array>
<!-- Для открытия банковских приложений -->
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tinkoffbank</string>
<string>sberpay</string>
<string>sbbol</string>
<string>alfabank</string>
<string>vtb24</string>
</array>
2. Обработка в React Native
import { Linking } from 'react-native';
useEffect(() => {
const handleURL = (url: string) => {
console.log('URL received:', url);
// Обработка возврата из банковского приложения
};
const subscription = Linking.addEventListener('url', handleURL);
return () => subscription?.remove();
}, []);
🎨 Кастомизация UI
1. Настройка цветов
ios/YourApp/AppDelegate.mm
#import <CloudPayments/CloudPayments-Swift.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Настройка цветовой схемы CloudPayments
[CloudPaymentsSDK setThemeColor:[UIColor colorWithRed:0.0 green:0.48 blue:1.0 alpha:1.0]];
[CloudPaymentsSDK setAccentColor:[UIColor colorWithRed:0.2 green:0.78 blue:0.35 alpha:1.0]];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}