mangopay 1.0.2

mangopay 1.0.2

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最后发布2017年2月

VictorMangoPay维护。



mangopay 1.0.2

MANGOPAY iOS卡注册工具包

配置

在iOS 9中配置App Transport Security异常

将应用板的.plist文件作为源代码打开并添加

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <false/>
  <key>NSExceptionDomains</key>
  <dict>
    <key>mangopay.com</key>
    <dict>
      <key>NSExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <key>NSExceptionMinimumTLSVersion</key>
      <string>TLSv1.1</string>
      <key>NSExceptionRequiresForwardSecrecy</key>
      <false/>
      <key>NSIncludesSubdomains</key>
      <true/>
      <key>NSRequiresCertificateTransparency</key>
      <true/>
      <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <key>NSThirdPartyExceptionMinimumTLSVersion</key>
      <string>TLSv1.1</string>
      <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
      <true/>
    </dict>
    <key>payline.com</key>
    <dict>
      <key>NSExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <key>NSExceptionMinimumTLSVersion</key>
      <string>TLSv1.1</string>
      <key>NSExceptionRequiresForwardSecrecy</key>
      <false/>
      <key>NSIncludesSubdomains</key>
      <true/>
      <key>NSRequiresCertificateTransparency</key>
      <true/>
      <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <key>NSThirdPartyExceptionMinimumTLSVersion</key>
      <string>TLSv1.1</string>
      <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
      <true/>
    </dict>
    <key>yourServer.com</key>
    <dict>
      <key>NSExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <key>NSExceptionMinimumTLSVersion</key>
      <string>TLSv1.1</string>
      <key>NSExceptionRequiresForwardSecrecy</key>
      <true/>
      <key>NSIncludesSubdomains</key>
      <true/>
      <key>NSRequiresCertificateTransparency</key>
      <true/>
      <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <key>NSThirdPartyExceptionMinimumTLSVersion</key>
      <string>TLSv1.1</string>
      <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
      <true/>
    </dict>
  </dict>
</dict>

请注意,如果您的应用程序尝试连接到任何不支持最新SSL技术(TLSv1.2)的HTTP服务器(yourserver.com),您的连接将会失败。

手动导入库

  • mangopay.framework导入项目(确保选择了“如有必要则复制项目”)
  • 导入头文件
#import <mangopay/mangopay.h>

使用MANGOPAY卡注册API

重要

  • 由于显然的安全性原因,MANGOPAY密码无法在应用中设置,这需要有一个自己的服务器实例来保持这些敏感信息的私密性。使用这个库,您可以标记一张卡并将其发送到您的服务器,然后您可以向客户收费。流程在此图中描述。
  • 下面的代码示例参考了此仓库中包含的演示应用 - 您可以选择使用它或根据需要创建自己的控制器。

使用

更新您的web应用

您应该已经有一个web应用(与iOS应用通信的服务器上的服务)并需要添加此新的卡注册功能 - 这包括对MANGOPAY的API调用(更多信息)。然后,您将为此iOS工具包提供serverURL以访问此功能(在此配置)。应返回以下格式的JSON响应(该响应包含从MANGOPAY API获取的信息)

{
  "accessKey": "1X0m87dmM2LiwFgxPLBJ",
  "baseURL": "https://api.sandbox.mangopay.com",
  "cardPreregistrationId": "12444838",
  "cardRegistrationURL": "https://homologation-webpayment.payline.com/webpayment/getToken",
  "cardType": "CB_VISA_MASTERCARD",
  "clientId": "sdk-unit-tests",
  "preregistrationData": "ObMObfSdwRfyE4QClGtUc6um8zvFYamY_t-LNSwKAxBisfd7z3cTgS83cCwyP9Gp7qGR3aNxrLUiPbx-Z--VxQ"
}
声明MPAPIClient
@interface ViewController ()
@property (nonatomic, strong) MPAPIClient *mangopayClient;
@end
使用接收到的cardObject初始化MPAPIClient

您可以使用从webapp接收到的信息

@property (nonatomic, strong) NSString *cardRegistrationURL;
@property (nonatomic, strong) NSString *preregistrationData;
@property (nonatomic, strong) NSString *accessKey;
@property (nonatomic, strong) NSString *clientId;
@property (nonatomic, strong) NSString *baseURL;
@property (nonatomic, strong) NSString *cardPreregistrationId;

此对象是实例化MAPIClient的必需项

self.mangopayClient = [[MPAPIClient alloc] initWithCard:cardResponseObject];
从用户收集卡信息并将其添加到mangopayclient
NSString* cardNumber = @"XXXXXXXXXXXXXXXX"; 
NSString* cardExpirationMonth = @"XX"; // ex: @"10"
NSString* cardExpirationYear = @"XX"; // ex: @"16"
NSString* cardCvx = @"XXX"; // ex: @"123"

[self.mangopayClient appendCardInfo:@"XXXXXXXXXXXXXXXX" cardExpirationDate:@"XXXX" cardCvx:@"XXX"];
注册卡
[self.mangopayClient registerCard:^(NSDictionary *response, NSError *error) {
      if (error) {
          NSLog(@"Error: %@", error);
      }
      else { // card was VALIDATED
          NSLog(@"VALIDATED %@", response);
      }
}];