How to use Braintree for buyer to seller payments without Merchant account?

Viewed 1233

I'm developing an Android application for Property rental Management where Tenant will be able pay Rent directly to Landlord . I would like to use Braintree as it supports Credit/Debit cards , PayPal & Google Pay.

What I have tried so far ,

  1. I already have tried creating sandbox account of Braintree & performed simple payment transfer to single merchant.
  2. Explored Stripe Connect but looks time consuming documentation.
  3. Also explored Braintree Direct but it shows documentation same as single merchant payment transfer. I've followed steps mentioned & it lead me to implementation of single merchant payment transfer.

My questions:

  1. How a user can send payment directly to another user using Braintree either through Android SDK or PHP sdk on server ?
  2. Do I need Business account of Braintree to implement above service?
  3. Can you recommend any example regarding buyer to seller payment integration regardless of any programming language but using Braintree / Paypal ?
  4. Here is server code to process Payment according to documentation:

    $result=Braintree_Transaction::sale([
        'amount'=>$amount,
        'paymentMethodNonce'=>$nonce,
        'options'=> [
            'submitForSettlement'=>True
            ]
        ]);
    
  5. I'm open to Any other solutions if it fits my needs with example or reference document.

So , is there any parameter to supply through which we can transfer payment to receiver directly?

I know there are lots of questions above but I'm really confused as there is no proper documentation on android app & not found proper example to integrate.

Any guidance would be helpful.

3 Answers

This is a proper documentation for implementing braintree. Check this out -

https://developers.braintreepayments.com/guides/drop-in/setup-and-integration/android/v2

In your gradle add this -

dependencies {
  implementation 'com.braintreepayments.api:drop-in:3.7.1'
}

Call this in your payment button -

public void onBraintreeSubmit(View v) {
  DropInRequest dropInRequest = new DropInRequest().clientToken(clientToken);
  startActivityForResult(dropInRequest.getIntent(this), REQUEST_CODE);
}

You will get a nonce in your Activity's onActivtyResult -

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == REQUEST_CODE) {
    if (resultCode == RESULT_OK) {
      // use the result to update your UI and send the payment method nonce to your server
      DropInResult result = data.getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT);
    } else if (resultCode == RESULT_CANCELED) {
      // the user canceled
    } else {
      // handle errors here, an exception may be available in
      Exception error = (Exception) data.getSerializableExtra(DropInActivity.EXTRA_ERROR);
    }
  }
}

Then if you are not using cards, you call configure different payment methods like Google Pay, etc.

Hope it helps.

public void getpaymentstatus(final Context context,String token,String user_id,String ride_id)
{
    ApiServiceInterface service=getApiInstance(context);
    try {
        service.Passengerpaymentstatus(token,user_id,ride_id)
                .enqueue(new Callback<PaymentStatus>() {
                    @Override
                    public void onResponse(Call<PaymentStatus> call, Response<PaymentStatus> response) {
                        if (response.isSuccessful())
                        {
                            if (response!=null)
                            {
                                try {
                                    PaymentStatus paymentStatus=response.body();
                                    passengerPaymentStatus.Passengerpaymentstatusclass(paymentStatus);
                                }catch (Exception e)
                                {
                                    e.printStackTrace();
                                }
                            }
                        }
                    }

                    @Override
                    public void onFailure(Call<PaymentStatus> call, Throwable t)
                    {
                        String message=context.getResources().getString(R.string.error_message);
                        PopupHelper.displayAlertDialog(context, message);
                        t.printStackTrace();
                    }
                });
    }catch (Exception e)
    {
        e.printStackTrace();
    }
}
private ApiServiceInterface getApiInstance(Context context) {
    HttpLoggingInterceptor logInter = new HttpLoggingInterceptor();
    logInter.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient mIntercepter = new OkHttpClient.Builder()
            .addInterceptor(logInter)
            .build();
    String BASE_URL = "http://192.168.0.14:80/api/auth/";
     Retrofit retrofitInstance = new Retrofit.Builder()
            //.addConverterFactory(new NullOnEmptyConverterFactory())
            .addConverterFactory(GsonConverterFactory.create())
            .baseUrl(BASE_URL)
            .client(mIntercepter)
            .build();
    return retrofitInstance.create(ApiServiceInterface.class);
}
Related