Perform multi-step (multi-page) checkout
504960
function doCheckout() {
	var res;

	group("Checkout 1: review cart", function() {
		// Checkout step 1: Review cart
		res = http.get(baseURL + "/cart");
		check(res, {
			"title is correct": (res) => res.html("title").text() === 'Shopping cart | David li commerce-test'
		});
	});

	// Did we add any products to our cart?  If not, skip the rest of the checkout process
	if (res.body.includes("Your shopping cart is empty.")) {
		return;
	}

	group("Checkout 2: submit cart", function() {
		let formID = res.body.match('name="form_id" value="(.*)"')[1];
		let formToken = res.body.match('name="form_token" value="(.*)"')[1];
		let formBuildID = res.body.match('name="form_build_id" value="(.*)"')[1];
		let formdata = {
			"form_build_id": formBuildID,
			"form_token": formToken,
			"form_id": formID,
			"op": "Checkout"
		};
		let headers = { "Content-Type": "application/x-www-form-urlencoded" };
		res = http.post(baseURL + "/cart", formdata, { headers: headers });
		check(res, {
			"cart submit succeeded": (res) => res.url.includes("/checkout/")
		}) || fail("cart submit failed");
	});

	// The previous POST operation should get redirected to a dynamic URL that has a
	// path that looks like e.g. "/checkout/7". Later checkout steps get redirected
	// to paths that are prefixed with this dynamic string, which means we need to
	// save it in order to be able to (easily) verify that later POSTs are successful
	// and get redirected to e.g. "/checkout/7/shipping"
	let checkoutBaseURL = res.url;

	group("Checkout 3: billing details", function() {
		let formID = res.body.match('name="form_id" value="(.*)"')[1];
		let formToken = res.body.match('name="form_token" value="(.*)"')[1];
		let formBuildID = res.body.match('name="form_build_id" value="(.*)"')[1];
		// try without setting Referer
		let formdata = {
			"customer_profile_billing[commerce_customer_address][und][0][country]": "SE",
			"customer_profile_billing[commerce_customer_address][und][0][name_line]": "Mr Test",
			"customer_profile_billing[commerce_customer_address][und][0][thoroughfare]": "Gotgatan 14",
			"customer_profile_billing[commerce_customer_address][und][0][premise]": "",
			"customer_profile_billing[commerce_customer_address][und][0][postal_code]": "11846",
			"customer_profile_billing[commerce_customer_address][und][0][locality]": "Stockholm",
			"customer_profile_shipping[commerce_customer_profile_copy]": "1",
			"form_build_id": formBuildID,
			"form_token": formToken,
			"form_id": formID,
			"op": "Continue to next step"
		};
		let headers = { "Content-Type": "application/x-www-form-urlencoded" };
		res = http.post(checkoutBaseURL, formdata, { headers: headers });
		check(res, {
			"billing details succeeded": (res) => res.url === (checkoutBaseURL + "/shipping")
		}) || fail("billing details failed"); 
	});

	group("Checkout 4: shipping options", function() {
		let formID = res.body.match('name="form_id" value="(.*)"')[1];
		let formToken = res.body.match('name="form_token" value="(.*)"')[1];
		let formBuildID = res.body.match('name="form_build_id" value="(.*)"')[1];
		let formdata = {
			"commerce_shipping[shipping_service]": "express_shipping",
			"form_build_id": formBuildID,
			"form_token": formToken,
			"form_id": formID,
			"op": "Continue to next step"
		};
		let headers = { "Content-Type": "application/x-www-form-urlencoded" };
		res = http.post(checkoutBaseURL + "/shipping", formdata, { headers: headers });
		check(res, {
			"shipping options succeeded": (res) => res.url === (checkoutBaseURL + "/review")
		}) || console.log("Select shipping failed!");
	});
	
	group("Checkout 5: review and submit", function() {
		let formID = res.body.match('name="form_id" value="(.*)"')[1];
		let formToken = res.body.match('name="form_token" value="(.*)"')[1];
		let formBuildID = res.body.match('name="form_build_id" value="(.*)"')[1];
		let formdata = {
			"commerce_payment[payment_method]": "commerce_payment_example|commerce_payment_commerce_payment_example",
			"commerce_payment[payment_details][credit_card][number]": "4111111111111111",
			"commerce_payment[payment_details][credit_card][exp_month]": "03",
			"commerce_payment[payment_details][credit_card][exp_year]": "2019",
			"form_build_id": formBuildID,
			"form_token": formToken,
			"form_id": formID,
			"op": "Continue to next step"
		};
		let headers = { "Content-Type": "application/x-www-form-urlencoded" };
		res = http.post(checkoutBaseURL + "/review", formdata, { headers: headers });
		// if this POST succeeds, it will redirect to e.g. /checkout/7/payment
		// /checkout/7/payment, in turn, will redirect to /checkout/7/paypal_ec
		// /checkout/7/paypal_ec, in turn, will redirect to /checkout/7/complete
		check(res, {
			"Checkout 6: checkout complete": (res) => res.html("h1").text() === "Checkout complete"
		}) || fail("review and submit failed");
	});
}
1005859
def checkout_task(current_target):
    
    try:
        scm = _make_scm(current_target)
        src_dir = current_target.config.get("dp.src_dir")
        shared_dir = current_target.config.get("dp.src_dir_shared")
        scm.checkout(repo_dir=src_dir, shared_dir=shared_dir)
        scm.update(repo_dir=src_dir)
    except devpipeline_core.toolsupport.MissingToolKey as mtk:
        current_target.executor.warning(mtk)
711647
def checkout(self, revision, options):
        
        rev = revision.key
        self.repo.git.checkout(rev)
595701
def checkout(self, ref, cb=None):
        """"""
        if self.is_api:
            return self._checkout_api(ref, cb=cb)
        else:
            return self._checkout_fs(ref, cb=cb)
898178
def step_four
      redirect_to '/checkout/step-one'   and return if !logged_in?
      redirect_to '/checkout/step-two'   and return if @order.shipping_address.nil? || @order.billing_address.nil?
      redirect_to '/checkout/step-three' and return if @order.shipping_method_code.nil?
      
      # Make sure all the variants still exist      
      @order.line_items.each do |li|
        v = Variant.where(:id => li.variant_id).first
        if v.nil? || v.status == 'Deleted'
          render :file => 'caboose_store/checkout/deleted_variant'
          return
        end
      end
      
      case CabooseStore::payment_processor
        when 'authorize.net'
          @sim_transaction = AuthorizeNet::SIM::Transaction.new(
            CabooseStore::authorize_net_login_id,
            CabooseStore::authorize_net_transaction_key,
            @order.total,
            :relay_url => "#{CabooseStore::root_url}/checkout/relay/#{@order.id}",
            :transaction_type => 'AUTH_ONLY',
            :test => true
          )
        when 'payscape'
          @form_url = CabooseStore::PaymentProcessor.form_url(@order)
      end
    end
289143
def pageFooter(self, form_contents):
        """"""
        if not form_contents:
            form_contents = ''

        self.wfile.write('''\
    <div id="verify-form">
      <form method="get" accept-charset="UTF-8" action=%s>
        Identifier:
        <input type="text" name="openid_identifier" value=%s />
        <input type="submit" value="Verify" /><br />
        <input type="checkbox" name="immediate" id="immediate" /><label for="immediate">Use immediate mode</label>
        <input type="checkbox" name="use_sreg" id="use_sreg" /><label for="use_sreg">Request registration data</label>
        <input type="checkbox" name="use_pape" id="use_pape" /><label for="use_pape">Request phishing-resistent auth policy (PAPE)</label>
        <input type="checkbox" name="use_stateless" id="use_stateless" /><label for="use_stateless">Use stateless mode</label>
      </form>
    </div>
  </body>
</html>
''' % (quoteattr(self.buildURL('verify')), quoteattr(form_contents)))
532078
def step_three
      redirect_to '/checkout/step-one' and return if !logged_in?
      redirect_to '/checkout/step-two' and return if @order.shipping_address.nil? || @order.billing_address.nil?
      @rates = ShippingCalculator.rates(@order)
      @selected_rate = ShippingCalculator.rate(@order)
    end
782510
public function init()
    {
        // If the step is not a registered step exit
        if (!in_array($this->step, CheckoutSteps::getSteps())) {
            $this->redirect($this->Link('/'));
        }

        // If no ReservationSession exists redirect back to the base event controller
        elseif (empty(ReservationSession::get())) {
            $this->redirect($this->Link('/'));
        }

        // If the reservation has been processed end the session and redirect
        elseif (ReservationSession::get()->Status === 'PAID' && $this->step != 'success') {
            ReservationSession::end();
            $this->redirect($this->Link('/'));
        } else {
            $this->reservation = ReservationSession::get();
            parent::init();
        }
    }
1190767
function check() {
        if (done) {
          return;
        }
        checks--;
        if (checks <= 0) {
          return;
        }
        if (checks === 0) {
          done = true;
          finish(new Error('Machine unresponsive to STOP'));
          return;
        }
        var checkOptions = {
          method: 'GET',
          path: self.account + '/machines/' + serverId
        };

        self._request(checkOptions, function (err, body) {
          if (err) { return callback && callback(err) }
          if (body && body.state === 'stopped') {
            done = true;
            finish();
            return;
          }
        });

        setTimeout(check, 5000);
      }
773463
def each_page
      page_obj = load_page(1)
      loop do
        yield page_obj
        break unless page_obj.has_next?
        page_obj = load_page(page_obj.next_page)
      end
    end
912152
public function run()
    {
        $this->_addShipmentsToOrder();
        $this->_addOrderAmountToOrderReference($this->currencyCode);
        $this->_confirmOrderReference();
        $this->_performAuthAndCaptureForOrderShipments();
        $this->_closeOrderReference();
        print HTML_LB.HTML_LB."Split Shipment Checkout Sample is Complete";
    }
988792
function insertQueueStep(step, index) {
  if (index && index < currentSteps.length) {
    return currentSteps.splice(index, 0, step);
  }

  return currentSteps.push(step);
}
1138622
def get_checkouts(self, **params):
        """"""
        response = self._get('v2', 'checkouts', params=params)
        return self._make_api_object(response, Checkout)
1008812
def checkout_to(revision, options = {})
      options = {
        :force => false
      }.merge(options)
      git_args = ['checkout', revision]
      git_args << '--force' if options[:force]
      vet_output(git_args)
      true
    end
1037945
def _step_template(name, run_file, inputs, outputs, parallel, step_parallelism, scatter=None):
    
    scatter_inputs = []
    sinputs = []
    for inp in inputs:
        step_inp = {"id": workflow.get_base_id(inp["id"]), "source": inp["id"]}
        if inp.get("wf_duplicate"):
            step_inp["id"] += "_toolinput"
        for attr in ["source", "valueFrom"]:
            if attr in inp:
                step_inp[attr] = inp[attr]
        sinputs.append(step_inp)
        # An initial parallel scatter and multiple chained parallel sample scatters
        if (parallel == "multi-parallel" and
              (not step_parallelism or
               step_parallelism.get(workflow.get_step_prefix(inp["id"])) == "multi-parallel")):
            scatter_inputs.append(step_inp["id"])
        # scatter on inputs from previous processes that have been arrayed
        elif (_is_scatter_parallel(parallel) and (_do_scatter_var(inp, parallel)
                                                  or (scatter and inp["id"] in scatter))):
            scatter_inputs.append(step_inp["id"])
    out = {"run": run_file,
           "id": name,
           "in": sinputs,
           "out": [{"id": workflow.get_base_id(output["id"])} for output in outputs]}
    if _is_scatter_parallel(parallel):
        assert scatter_inputs, "Did not find items to scatter on: %s" % name
        out.update({"scatterMethod": "dotproduct",
                    "scatter": scatter_inputs})
    return out
1273944
def _check_for_more_pages(self):
        
        self._has_more = len(self._items) > self.per_page

        self._items = self._items[0 : self.per_page]
308860
def checkout(branch_name, opts = {})
      args = []
      args << '--no-track' if opts[:no_track]
      args << '-b' if opts[:new_branch]
      args << branch_name
      args << opts[:new_branch] if opts[:new_branch]
      branches = branches()
      command(:checkout, args)

      branches << GitBranch.new(branch_name, opts[:new_branch] != nil, self)

      if block_given?
        yield
        command(:checkout, branches.current.name)
        branches.current
      else
        branches[branch_name]
      end
    end