Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagec#
#import <UIKit/UIKit.h>
#import "AssistMobile/AssistMobile.h"
 
@interface ViewController : UIViewController<AssistPayDelegate>
@property (weak, nonatomic) IBOutlet UILabel *result;
- (IBAction)pay:(UIButton *)sender;
 
@end

ViewController.m

Code Block
languagec#
#import "ViewController.h"
@interface ViewController ()
 
@property (strong, nonatomic) PayData* data;
@end
 
@implementation ViewController
- (IBAction)pay:(UIButton *)sender {
    if (!_data) {
        _data = [[PayData alloc] init];
    }
 
    _data.orderAmount = @"100.05";
    _data.orderNumber = @"test_payment_002";
    _data.merchantId = @"679471";
  
    AssistPay* assistPay = [[AssistPay alloc] initWithDelegate: self];
    [assistPay start:self withData: _data];
}
 
- (void)payFinished:(NSString * __nonnull)bill status:(NSString * __nonnull)status message:(NSString * __nullable)message
{
    NSString* res = @"status: ";
    res = [res stringByAppendingString: status];
    res = [res stringByAppendingString: @", billnumber: "];
    res = [res stringByAppendingString: bill];
    res = [res stringByAppendingString: @", message: "];
    res = [res stringByAppendingString: message];
    _result.text = res;
}
 
@end

Интеграция с Apple Pay

  1. Выполнить шаги из раздела 4 «Порядок интеграции мобильного приложения интернет-магазина с фреймворком AssistMobile».
  2. Скомпилировать AssistMobile.framework из исходников.
  3. Добавить фреймворк в свой проект.
  4. Включить опцию Build Settings -> Build Options -> Embedded Content Contains Swift Code в YES в настройках проекта.
  5. Добавить AssisyMobile.framework в настройку General->Embedded Binaries.
  6. В ключ NSLocationWhenInUseUsageDescription в настройках Info.plist -> Information Property List, добавляем параметр типа String со значением 'Permit to send geolocation data to Assist.

Пример кода Swift

Code Block
languagec#
import UIKit
import AssistMobile
 
class ViewController: UIViewController, AssistPayDelegate {
    @IBOutlet weak var result: UILabel! 
    var data = PayData()
     
    @available(iOS 10.0, *)
    @IBAction func payWithApplePay(_ sender: UIButton) {
        data = PayData()
        pay = AssistPay(delegate: self)
        data.merchantId = "your merhcnt id in assist"
        var apmid = "murchant.id.in.apple"
        data.login = "your account login in assist"
        data.password = "your account password in assist"
        data.orderNumber = "order number"
        data.orderComment = "comment"
        data.orderAmount = "100.05"
        data.orderCurrency = .RUB
        data.lastname = "Ivanov"
        data.firstname = "Ivan"
        data.email = "ivan@mailhost.ru"
     
        AssistLinks.currentHost = "https://payments.assist.ru"
     
        pay!.startWithApplePay(self, withData: data, applePayMerchantId: apmid)
    }
     
     func payFinished(bill: String, status: PaymentStatus, message: String?) {
        let msg = message ?? ""
        result.text = "Finished: bill = \(bill), status = \(status.rawValue), message = \(msg)"
    }
}

SDK и пример приложения доступны для скачивания по следующей ссылке:

https://github.com/assist-group/assist-mcommerce-sdk-ios

Наверх