2013-12-06 2 views
6

Я хочу использовать API-интерфейс Braintree в своем приложении iOS.Использовать платежное приложение Braintree api в приложении iOS

Мое приложение предназначено для аренды, т. Е. Запрашивающий пользователь должен произвести оплату владельцу актива, который он хотел арендовать.

Я проверил следующие ссылки: http://www.youtube.com/watch?v=s7GlgBFM20I

https://www.braintreepayments.com/developers

http://www.youtube.com/watch?v=2y8Tsml6JYo

https://www.braintreepayments.com/braintrust/venmo-touch-screencasts-add-one-touch-payments-to-your-app-in-15-minutes т.д.

Но я не получил ни малейшего представления, где предоставить реквизиты приемника с помощью Брейнтри или Venmo api. Например, мы можем передать электронное письмо получателя в системе PayPal iOS sdk и th en PayPal выплачивает сумму пользователю, зарегистрированному на этом электронном письме.

То же самое, что я ищу в Braintree Payment API.

Любая помощь очень ценится.

Заранее спасибо.

Я использую ниже код: (Используется из образца кода заданной Брэйнтри)

/* Get called when user pay on Pay button on screen. 
    User wil see a form for entering his credit card number, CVV and expiration date. */ 
-(IBAction)payButtonClicked 
{ 
    self.paymentViewController = 
    [BTPaymentViewController paymentViewControllerWithVenmoTouchEnabled:YES]; 
    self.paymentViewController.delegate = self; 

    [self presentViewController:self.paymentViewController animated:YES completion:nil]; 
} 

// When a user types in their credit card information correctly, the BTPaymentViewController sends you 
// card details via the `didSubmitCardWithInfo` delegate method. 
// 
// NB: you receive raw, unencrypted info in the `cardInfo` dictionary, but 
// for easy PCI Compliance, you should use the `cardInfoEncrypted` dictionary 
// to securely pass data through your servers to the Braintree Gateway. 
- (void)paymentViewController:(BTPaymentViewController *)paymentViewController 
     didSubmitCardWithInfo:(NSDictionary *)cardInfo 
     andCardInfoEncrypted:(NSDictionary *)cardInfoEncrypted { 
    [self savePaymentInfoToServer:cardInfoEncrypted]; // send card through your server to Braintree Gateway 
} 

// When a user adds a saved card from Venmo Touch to your app, the BTPaymentViewController sends you 
// a paymentMethodCode that you can pass through your servers to the Braintree Gateway to 
// add the full card details to your Vault. 
- (void)paymentViewController:(BTPaymentViewController *)paymentViewController 
didAuthorizeCardWithPaymentMethodCode:(NSString *)paymentMethodCode { 
    // Create a dictionary of POST data of the format 
    // {"payment_method_code": "[encrypted payment_method_code data from Venmo Touch client]"} 
    NSMutableDictionary *paymentInfo = [NSMutableDictionary dictionaryWithObject:paymentMethodCode 
                      forKey:@"payment_method_code"]; 
    [self savePaymentInfoToServer:paymentInfo]; // send card through your server to Braintree Gateway 
} 

#define SAMPLE_CHECKOUT_BASE_URL @"http://venmo-sdk-sample-two.herokuapp.com" 
//#define SAMPLE_CHECKOUT_BASE_URL @"http://localhost:4567" 

// Pass payment info (eg card data) from the client to your server (and then to the Braintree Gateway). 
// If card data is valid and added to your Vault, display a success message, and dismiss the BTPaymentViewController. 
// If saving to your Vault fails, display an error message to the user via `BTPaymentViewController showErrorWithTitle` 
// Saving to your Vault may fail, for example when 
// * CVV verification does not pass 
// * AVS verification does not pass 
// * The card number was a valid Luhn number, but nonexistent or no longer valid 
- (void) savePaymentInfoToServer:(NSDictionary *)paymentInfo { 

    NSURL *url; 
    if ([paymentInfo objectForKey:@"payment_method_code"]) { 
     url = [NSURL URLWithString: [NSString stringWithFormat:@"%@/card/payment_method_code", SAMPLE_CHECKOUT_BASE_URL]]; 
    } else { 
     url = [NSURL URLWithString: [NSString stringWithFormat:@"%@/card/add", SAMPLE_CHECKOUT_BASE_URL]]; 
    } 
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; 

    // You need a customer id in order to save a card to the Braintree vault. 
    // Here, for the sake of example, we set customer_id to device id. 
    // In practice, this is probably whatever user_id your app has assigned to this user. 
    NSString *customerId = [[UIDevice currentDevice] identifierForVendor].UUIDString; 
    [paymentInfo setValue:customerId forKey:@"customer_id"]; 

    request.HTTPBody = [self postDataFromDictionary:paymentInfo]; 
    request.HTTPMethod = @"POST"; 

    [NSURLConnection sendAsynchronousRequest:request 
             queue:[NSOperationQueue mainQueue] 
          completionHandler:^(NSURLResponse *response, NSData *body, NSError *requestError) 
    { 
     NSError *err = nil; 
     if (!response && requestError) { 
      NSLog(@"requestError: %@", requestError); 
      [self.paymentViewController showErrorWithTitle:@"Error" message:@"Unable to reach the network."]; 
      return; 
     } 

     NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:body options:kNilOptions error:&err]; 
     NSLog(@"saveCardToServer: paymentInfo: %@ response: %@, error: %@", paymentInfo, responseDictionary, requestError); 

     if ([[responseDictionary valueForKey:@"success"] isEqualToNumber:@1]) { // Success! 
      // Don't forget to call the cleanup method, 
      // `prepareForDismissal`, on your `BTPaymentViewController` 
      [self.paymentViewController prepareForDismissal]; 
      // Now you can dismiss and tell the user everything worked. 
      [self dismissViewControllerAnimated:YES completion:^(void) { 
       [[[UIAlertView alloc] initWithTitle:@"Success" message:@"Saved your card!" delegate:nil 
            cancelButtonTitle:@"OK" otherButtonTitles:nil] show]; 
       [[VTClient sharedVTClient] refresh]; 
      }]; 

     } else { // The card did not save correctly, so show the error from server with convenenience method `showErrorWithTitle` 
      [self.paymentViewController showErrorWithTitle:@"Error saving your card" message:[self messageStringFromResponse:responseDictionary]]; 
     } 
    }]; 
} 
+0

Почему сумма голосов здесь? пожалуйста, дайте мне знать причину. – Richa

+1

ваш вопрос будет более приветствуем, если вы добавите код, который показывает, что вы пытаетесь сделать, и где вы застряли. – alfasin

+0

Спасибо alfasin, я также предоставил свой фрагмент кода. – Richa

ответ

1

Я работаю в Braintree. Если у вас есть дополнительные вопросы или вам нужна дополнительная помощь, обратитесь к our support team.

Braintree iOS SDK docs содержит quickstart guide, а также подробную информацию об особенностях библиотеки.

Если вы ищете информацию, в частности о том, как осуществлять платежи между пользователями вашего приложения/веб-сайта, вы должны смотреть на the marketplace guide и VenmoAPIs.

+0

Большое спасибо @agf за ваш ответ, я просмотрю все эти ссылки. – Richa

+0

@agf Я также планирую использовать braintree в приложении iOS. Я прочитал много потоков, и он говорит, что яблоко может отклонить приложение, потому что оно выходит за рамки рекомендаций по покупке In-App. Есть ли возможность отклонения приложения? Я беспокоюсь о принятии приложения яблоком перед тем, как начать с braintree. Заранее спасибо. –

+0

@AkbariDipali Я предлагаю вам отправить нашу службу поддержки по электронной почте. В принципе, это зависит от того, что вы продаете. – agf

Смежные вопросы