Braintree Payment Gateway Yii Extension

My first extension I submitted to Yii’s Extension library. You can see the extension here: http://www.yiiframework.com/extension/braintreeapi/

I also have the code in a repo if anyone you are interested: https://bitbucket.org/pitchinnate/braintreeapi-yii-extension

Feel free to leave comments here and I’ll try to help fix any bugs you may encounter.


21 thoughts on “Braintree Payment Gateway Yii Extension”

  • 1
    Tom on August 21, 2013 Reply

    Thanks, I’ll let you know if I have any issues.

  • 2
    Todd Anstis on October 21, 2013 Reply

    I’m sort of a PHP noob, and I’m currently getting the following error when submitting a payment:

    PHP error

    preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead

    /Users/mckracken83/Sites/giga-fit/protected/extensions/BraintreeApi/lib/Braintree/Util.php(164)

    Any help would be greatly appreciated!

    • 3
      Nate on October 22, 2013 Reply

      I’m assuming you are on PHP 5.5 is that correct? This is in Braintree’s API code. I will look to see if they have some updated files that will work with PHP 5.5.

    • 4
      Nate on October 22, 2013 Reply

      Yeah they have updated their API code for PHP 5.5. I will work on updating the plugin to include the new files. In the meantime if you download https://www.braintreepayments.com/assets/client_libraries/php/braintree-php-2.22.2.tgz inside it there is a folder named ‘lib’ you should be able to delete the ‘lib’ folder out of the plugin and replace it with this new ‘lib’ folder and it should work for you.

  • 5
    Nate on October 22, 2013 Reply

    I just replaced the ‘lib’ folder like I explained above and everything still seems to work. I will publish a new plugin sometime today.

    • 6
      Todd Anstis on October 22, 2013 Reply

      awesome, thanks! sorry to bug you, i’ve been killing myself learning yii for this project and now i’m down to the last piece – payments.

  • 7
    Todd Anstis on October 22, 2013 Reply

    its working!

  • 8
    Mark O on April 1, 2014 Reply

    I’m just digging into their api, but have you had any success with recurring payments, yet? Thanks for the work on this. Really helpful.

    • 9
      pitchinnate on April 1, 2014 Reply

      Never tried to use it in a production environment but have had success in their sandbox environment.

      • 10
        Mark O on April 4, 2014 Reply

        I can’t get the credit card info to pass through with a new customer, no matter what I try. I’m trying to create a new customer, along with their credit card, and the customer creates just fine, but no credit card info gets passed with it.

        When I try to tweak the code to test it, I keep getting the error that there is no ‘creditCard’ key in the array. Any thoughts? Have you had success doing this?

        • 11
          pitchinnate on April 4, 2014 Reply

          I’ll setup a dev environment and give it a try.

          • 12
            Mark O on April 5, 2014

            Not sure if it helps, but here is the applicable error. I tried doing it where I create a customer, then in the next step add the credit card number, but as I figured, same error.

            PHP notice

            Undefined index: creditCard

            C:\xampp\htdocs\csportal_test\protected\extensions\BraintreeApi\BraintreeApi.php(69)

          • 13
            pitchinnate on April 8, 2014

            You could create another scenario that does both at the same time. It would go in the BraintreeCCForm.php file basically it would be combining the customer() and creditcard() functions.

          • 14
            Mark O on April 8, 2014

            With this error, it was set to the creditcard scenario. I broke it up into 2 steps, create user then create credit card, since I couldn’t get it to do both at once. But as you can see, I was still having trouble with it with just the creditcard scenario.

          • 15
            pitchinnate on April 8, 2014

            Did you check your form id and the form id you are passing to the widget?

          • 16
            Mark O on April 8, 2014

            Hot damn, that was it. Just worked after changing the ID. Thanks for the help. I’ll probably be hitting you up more as I try to get subscriptions working in this. Hopefully I can muddle through this without bugging you, though!

            Thanks for the help.

          • 17
            pitchinnate on April 9, 2014

            Not a problem glad I could help. Feel free to ask questions anytime I’ll help if I am able to.

          • 18
            pitchinnate on April 8, 2014

            Also make sure your form id is the same as you are passing to the widget otherwise when Braintree’s javascript function to encrypt the creditcard data will not send that data back.

    • 19
      Todd on April 21, 2014 Reply

      I’ve been working with the great widget Nate has provided and I’ve made several adjustments to it in order to use the Braintree Partner API. Basically I set it up to have the ability to use different Braintree config values based on the type of transaction. I’ve always set something up in Iron.io to run scheduled/recurring payments, since using Braintree native recurring billing doesn’t allow you to take transaction fees off of Partner transactions. I’d be happy to share what I’ve got if you’re interested, just let me know. Cheers.

    • 20
      Phuc Nguyen on October 11, 2014 Reply

      I’m waiting for recurring payments and extra notify email to user upon subscriber expried specific day , any good news from that? Thanks advanced for the work on this

  • 21
    fabiof on October 20, 2014 Reply

    I’m interested in creating a form to process sub-merchant on-boarding. Can you start me in the right direction for creating another form?

Leave a Reply

Your email address will not be published. Required fields are marked *