podfile. 2.Open the pod file and add: 3. Run it: 4. After the installation, you will have to use <nameOfProject>.xcworkspace pod 'Braintree' # Alternatively: pod 'Braintree', '~> 3.0.0' pod install Installing the SDK Client Side
composer.json file and add: 3. Run it: 4. Create a config file storing in it the API credentials { "require" : {"braintree/braintree_php" : "2.30.0"} } composer install Braintree_Configuration::environment('sandbox'); Braintree_Configuration::merchantId('use_your_merchant_id'); Braintree_Configuration::publicKey('use_your_public_key'); Braintree_Configuration::privateKey('use_your_private_key'); Installing the SDK Server Side
= Braintree_ClientToken::generate(); Simple payment Server Side 2. Receive the payment method nonce from the client $nonce = $_POST["payment_method_nonce"] 3. And use it to create the transaction $amount = $_POST["amount"]; $result = Braintree_Transaction::sale(array( 'amount' => '100.00', 'paymentMethodNonce' => 'nonce-from-the-client'));
=> 'Jones Co.', 'email' => '[email protected]', 'phone' => '281.330.8004', 'fax' => '419.555.1235', 'website' => ‘http://example.com' 'paymentMethodNonce' => 'nonce-from-the-client' )); if ($result->success==TRUE) { echo $result->customer->id; }; Storing info about customers Server Side 1. Storing info of your costumers in Braintree allows you to use the costumer ID Braintree gives you for payments in vault
=> 'Jones Co.', 'email' => '[email protected]', 'phone' => '281.330.8004', 'fax' => '419.555.1235', 'website' => ‘http://example.com' 'paymentMethodNonce' => 'nonce-from-the-client' )); if ($result->success==TRUE) { echo $result->customer->id; echo($result->customer->creditCards[0]->token); }; 1. Storing info of your costumers in Braintree allows you to use the costumer ID Braintree gives you for payments in vault. Storing info about customers Server Side Store this info!
will be able to complete the payments without having to redirect to the costumer to Braintree. Payment in vault Server Side $result = Braintree_Transaction::sale( array( 'paymentMethodToken' => 'the_payment_method_token', 'amount' => '100.00' ) ); $result = Braintree_Transaction::sale( array( 'customerId' => 'the_customer_id', 'amount' => '100.00' ) );