Search code examples
javascriptpythondjangopayment-gatewaybraintree

how to create transaction without plan in braintree js+python?(whiteout subscription)


I am using braintree payment gateway in my application.

i am able to create the transactions with selecting the plan, but what i needed is to create the transaction without selecting any plan. One time payment.

my code

create_sub = braintree.Subscription.create({
                            "payment_method_token": the_token,
                            "plan_id": PLAN_ID
                        })

here subscription is created.

payment_method_result = braintree.PaymentMethod.create({
                        "customer_id": merchant_customer_id,
                        "payment_method_nonce": nonce,
                        "options": {
                            "make_default": True
                        }
                    })

here payment_method is got created

here what i want is to create transaction directly without subscribing. and save all transaction related data to transaction model.


Solution

  • Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.

    You can create a one-time transaction with Braintree's Python API library using the following call:

    result = braintree.Transaction.sale({
        "amount": "10.00",
        "payment_method_token": the_token,
        "options": {
            "submit_for_settlement": True
        }
    })
    

    This creates a single transaction with no affiliation to any plan. In place of the "payment_method_token", you may also use "payment_method_nonce", passing in the nonce received from your client. You can find the full list of available parameters in Braintree's API Documentation.