The format of PUBLIC_SECRET & PRIVATE_SECRET is("Bearer"+PUBLIC_SECRET)
1.2 Modify server port(Default to be 9898)
server.port=9898
The merchant replaces the public key and private key in the code with their own, and then switch on the server code's default port 9099 can be modified.(The dashboard interface address is the local ip:9898)
2. Set up Client-side
Import MoneyCollect iOS sdk, and then initialize the sdk.
2.1 Installation
To integrate MoneyCollect into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'MoneyCollect', '~> 0.0.1'
2.2 Initialize sdk
Initialize MoneyCollect iOS sdk in the project AppDelegate.
/** API publishable Key */
@property (nonatomic,copy) NSString *publishableKey;
/** The customer IP address passed by the merchant*/
@property (nonatomic,copy) NSString *customerIPAddress;
/// Set publishable Key and customer IP Address
/// @param publishableKey publishable Key
/// @param customerIPAddress IP Address
- (void)setPublishableKey:(NSString * _Nonnull)publishableKey atCustomerIPAddress:(NSString *)customerIPAddress;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initiate PublishableKey and IPAddress
[[MCAPIClient shared] setPublishableKey:@"Bearer test_pu_1sWrsjQP9PJiCwGsYv3risSn8YBCIEMNoVFIo8eR6s" atCustomerIPAddress:@"http://192.168.2.100:9898/api"];
return YES;
}
3. Construct the data parameters to initiate transaction, and then start the payment activity
The merchant constructs the transaction request parameters and clicks the Checkout button to start the payment activity.(The details of using constructMCCreatePaymentParams method to construct data please refer to Example)
After the customer completes the payment by clicking Pay Now button, the payment activity will be dismissed and return to the Example's MCPaymentSheetCheckoutVC. At the same time,return the payment result responseObject through the proxy.
#pragma mark - MCSelectPaymentCardVCDelegate
- (void)successfulTransactionWithResponseObject:(NSDictionary *)responseObject
{
// transaction status
NSString *status = [[responseObject objectForKey:@"data"] objectForKey:@"status"];
if ([status isEqualToString:@"succeeded"]) {
NSLog(@"success");
}else if ([status isEqualToString:@"failed"]) {
NSLog(@"%@",[[responseObject objectForKey:@"data"] objectForKey:@"errorMessage"]);
}else if ([status isEqualToString:@"pending"]) {
NSLog(@"pending");
}else if ([status isEqualToString:@"uncaptured"]) {
NSLog(@"uncaptured");
}else if ([status isEqualToString:@"canceled"]) {
NSLog(@"canceled");
}else {
NSLog(@"pending");
}
}
4. Additional testing resources
There are several test cards you can use to make sure your integration is ready for production. Use them with any CVC, postal code, and future expiration date.
Card Number
Brand
DESCRIPTION
4242 4242 4242 4242
Visa
Succeeds and immediately processes the payment.
3566 0020 2036 0505
JCBA
Succeeds and immediately processes the payment.
6011 1111 1111 1117
Discover
Succeeds and immediately processes the payment.
3782 8224 6310 0052
American Express
Succeeds and immediately processes the payment.
5555 5555 5555 4444
Mastercard
Succeeds and immediately processes the payment.
4000002500003155
Visa
This card requires 3D authentication on all transaction