magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.3k forks source link

Magento2 API Custom Cart with Braintree #4235

Closed kgvconsulting closed 8 years ago

kgvconsulting commented 8 years ago

We are trying to integrate the magento2 with a custom cart for an app we are making, however we are stuck in trying to place the order (we are creating the cart, with items, quantity, and shipping method)

From the magento2 documentation this should be done with a POST to /payment-information but the rest is unclear in terms of the contents of the request.

From the braintree documentation in order to use the drop-in UI to tokenize the card information we need a clientToken which our server should generate, however we cannot find the endpoint which returns that token for us.

Can someone point us to a code snippet or example of the checkout process using braintree or give a high level overview of how to go about getting the necessary information to place an order for /payment-information

Thank you

Edit: Just for reference I see here http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_payment.html it is described that the clientToken (along with other info) is added to the global variable window.checkoutConfig.braintree. So I am assuming that there is no REST call exposed to get this information?

joni-jones commented 8 years ago

Hi @kgvconsulting, to get ClientToken you can use your custom implementation of \Magento\Checkout\Model\ConfigProviderInterface and get token on a client side.

Also, you don't need to implement custom request to place order. The js component for your payment should extend Magento_Payment/js/view/payment/cc-form or Magento_Checkout/js/view/payment/default (depends of your payment).

You can explore Braintree payment module implementation on the develop branch, which implements Hosted Fields (drop-in is the one of Hosted Fields variations).

UPD: current implementation of Braintree payment allows to use Hosted Fields and Braintree PayPal instead drop-in.

alena-marchenko commented 8 years ago

Hi @kgvconsulting

Closing the issue, please feel free using Community Forums or Magento Stack Exchange for further technical questions.