php braintree integration

放肆的年华 提交于 2021-02-06 10:55:26

问题


I am trying to integrate the Braintree API into my PHP application. I am new in integrating payment gateway. Please, help me with some example code for Braintree API.


回答1:


Here is the code you will absolutely need to get started:

require_once 'PATH_TO_BRAINTREE/lib/Braintree.php';

Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('your_merchant_id');
Braintree_Configuration::publicKey('your_public_key');
Braintree_Configuration::privateKey('your_private_key');

You can find your merchant ID, public key and private key when you log into your sandbox account by looking under the "Account" menu in the top right, clicking on "My User" then on "API Keys". You can actually just select "PHP" from the language dropdown and then the "Copy" button to get the above code populated correctly with your credentials.

After that I would recommend trying to get a simple transaction created to make sure you have everything working. Take a look at the quick start example on the Braintree PHP docs and see if you can run that code (after replacing the Braintree_Configuration and require lines) as is to get a successful transaction.

If you can get that code working I would either move on to your own integration or you can take a look at this example application in PHP to get a better idea of what a full integration might look like.

If you're still running into problems feel free to contact Braintree support. The support team responds quickly and can even put you in touch with a developer if you have more technical questions.




回答2:


Braintree has a whole documentation on PHP Integration: http://www.braintreepaymentsolutions.com/docs/php




回答3:


1)Sign up for sandbox account https://www.braintreepayments.com/get-started

2)login to your sandbox account https://sandbox.braintreegateway.com

3)On top menu fiund 'Account'-> then sub menu 'My user'

4)then on the page at botom you will see Authorization API Keys link

5) click api keys link.

6) thats all... Njoy




回答4:


You can signup for a BrainTree sandbox account at following URL

http://www.braintreepayments.com/gateway/access-form

Once you get the sandbox account, find the merchant id, public key and private key and put them to the configuration.php.

Hope this helps you.




回答5:


The basic problem is that Braintree_Configuration is in a file called ...lib/braintree/configuration.php so when PHP looks for it, it looks for a file called Braintree_Configuration.php and does not find .../lib/Braintree/Configuration.php so the examples do not work.

In my case this may be related to Yii and how Yii links in files for debugging but it still does not work...looking for answers...




回答6:


OK. In my case, I renamed the folder "lib" into "library". Then I spent dozen minutes until I rename the folder name back to "lib", everything works again.

I can't figure out what kind of horseshit that is, it just works.

Basically you just download the library from

https://developers.braintreepayments.com/start/hello-server/php

Don't touch anything, then things will move along.




回答7:


The Documentation Available on Braintree developer portal(https://developers.braintreepayments.com/start/overview) is awesome.

If still have some questions and want to find demo example, please check below link for same.

http://www.ilovephp.net/php/simple-braintree-paypal-payment-gateway-integration-in-php-with-demo-examples/

If want to integrate Braintree API with 3D secure option check above link.



来源:https://stackoverflow.com/questions/5139382/php-braintree-integration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!