Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

romk1n/PhoneGap-Braintree-iOS

Repository files navigation

Braintree iOS plug-in for Phone Gap

Plugin to use native Braintree SDK within PhoneGap framework projects

Integration instructions

  1. Add iOSBraintreePhoneGapPlugin.[h|m] to your project (Plugins group).
  2. Copy BrainTreePayment.js to your project's www folder
  3. Add the following to your config.xml:
    <plugin name="BraintreePlugin" value="iOSBraintreePhoneGapPlugin" />

EXAMPLE JS

function callWebService(){

    
    var BTPayment = window.plugins.btreeplugin;
    
    BTPayment.getCardInfo(onGetCardInfoSuccess,onGetCardInfoError);

    function onGetCardInfoSuccess (successObject) {

        
        var cardData;
        
        // Verifying is we got encrypted card infor or token
        //
        if (successObject.cardInfoEncrypted) {
          cardData = successObject.cardInfoEncrypted;
        } else if (successObject.token) {
          cardData = successObject.token;
        } else {
  		// do something
        }
        
        // Communicating with the remote server
        //
        $.post("your endpoint", cardData, function(data) {
          console.log('server returned sucess' + JSON.stringify(data));

        // Received response from Braintree servers
        // now can dismiss the view
        BTPayment.dismiss();

    };

    function onGetCardInfoError (errorObject) {
         console.log('onGetCardInfoError: ' + errorObject);

    };
    
}

Known Issues

If you use PhoneGap's tools to generate project you may need to enable ARC in build settings if you experienced crash when trying to enter credit card number

About

Phonegap plugin for Braintree iOS SDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published