1.Create a Customer

Pass a customerId to MoneyCollect to attach to the customer.

   // Use your customerId 
   var customerId = "cus_1452880617225281538"

2.Construct data, and pay in PaymentSheet model

When creating a payment method, you can specify customer parameters and automatically attach the payment method to an existing customer.

  /** Merchant ID */
   @property (nonatomic,copy) NSString *customerID;
   /** Billing details */
   @property (nonatomic,strong) MCBillingDetails *billingDetails;
   /** Create payment parameter object */
   @property (nonatomic,strong) MCCreatePaymentParams *createPaymentParams;

    // Initiate controller
    MCSelectPaymentCardVC *selectPaymentCardVC = [[MCSelectPaymentCardVC alloc] init];
    selectPaymentCardVC.delegate = self;

    // Build request parameters
    selectPaymentCardVC.customerID = [MCConfigurationFile getCustomerID];
    selectPaymentCardVC.billingDetails = [MCConfigurationFile getBillingDetailsModel];
    selectPaymentCardVC.createPaymentParams = [self constructMCCreatePaymentParams];
    // Display view
    [selectPaymentCardVC present:self];

The details of using constructMCCreatePaymentParams method to construct data, please refer to MCPaymentSheetCheckoutVC class under Example.

3.Start Hosted Payment Page mode

  • Tap “Checkout” button to pay in Hosted Payment Page mode.

  • In Hosted payment page,select the previously saved card or add a new card.

  • Finally, tap the PayNow button to complete the payment.

4.Customer selects "save this card" during payment

  • 4.1 Select "Save this card for your future use" on the Add a card page.

NSString *setupFutureUsage = isSelected ? @"on" : @"off";
_createPaymentParams.setupFutureUsage = setupFutureUsage;

Select the payment card in the future, when using setupFutureUsage set to "on", otherwise to "off"

  • 4.2 Click "Add a card.

  • 4.3 After create a payment method and attach the payment method to customer will save the card details to customer.

5.Return the payment result

@protocol MCSelectPaymentCardVCDelegate <NSObject>
/** Agent method for successful transaction */
- (void)successfulTransactionWithResponseObject:(NSDictionary *_Nullable)responseObject;

#pragma mark - MCSelectPaymentCardVCDelegate
- (void)successfulTransactionWithResponseObject:(NSDictionary *)responseObject
    // Transaction status
    NSString *status = [[responseObject objectForKey:@"data"] objectForKey:@"status"];
    if ([status isEqualToString:@"succeeded"]) {
    }else if ([status isEqualToString:@"failed"]) {
        NSLog(@"%@",[[responseObject objectForKey:@"data"] objectForKey:@"errorMessage"]);
    }else if ([status isEqualToString:@"pending"]) {
    }else if ([status isEqualToString:@"uncaptured"]) {
    }else if ([status isEqualToString:@"canceled"]) {
    }else {

Last updated