payment gateway

Drupal 8 commerce paypal gateway checkout programmatically example

Submitted by august on Tue, 07/25/2017 - 09:26
class OrderController extends ControllerBase implements ContainerInjectionInterface {
  
 ...

 /**
   * Checkout an order.
   *
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The request.
   *
   * @return \Symfony\Component\HttpFoundation\Response
   *   A response which contains the ID.
   */
  public function checkoutOrder(Request $request) {
    $format = $this->getRequestFormat($request);

    $content = $request->getContent();
    $data = $this->serializer->decode($content, $format);

    if (!isset($data['order_id']) || !is_numeric($data['order_id'])) {
      throw ne