Edit in JSFiddle

/**************************************************************\
            Include Affirm.js Snippet
\**************************************************************/
var _affirm_config = {
  public_api_key: "ARQBLCL7NAMBTZ7F",  /* replace with public api key */
  script:         "https://cdn1-sandbox.affirm.com/js/v2/affirm.js"
};
(function(l,g,m,e,a,f,b){var d,c=l[m]||{},h=document.createElement(f),n=document.getElementsByTagName(f)[0],k=function(a,b,c){return function(){a[b]._.push([c,arguments])}};c[e]=k(c,e,"set");d=c[e];c[a]={};c[a]._=[];d._=[];c[a][b]=k(c,a,b);a=0;for(b="set add save post open empty reset on off trigger ready setProduct".split(" ");a<b.length;a++)d[b[a]]=k(c,e,b[a]);a=0;for(b=["get","token","url","items"];a<b.length;a++)d[b[a]]=function(){};h.async=!0;h.src=g[f];n.parentNode.insertBefore(h,n);delete g[f];d(g);l[m]=c})(window,_affirm_config,"affirm","checkout","ui","script","ready");

var checkout_mode = "modal";

var rad = document.checkout_mode_select.checkout_mode;
    var prev = null;
    for(var i = 0; i < rad.length; i++) {
        rad[i].onclick = function() {
        	console.log(this.value);
        		checkout_mode = this.value;
        };
    }


/**************************************************************\
          Set Affirm Checkout Values
\**************************************************************/



    
/**************************************************************\
              Handle the form submission
\**************************************************************/
$("#submit-form").click(function(){
affirm.checkout({

  "config": {
    "financial_product_key" : "CN29VP56R79EMSEI", //replace with your Affirm financial product key
  },

  "merchant": {
    "user_cancel_url"              : "https://google.com",
    "user_confirmation_url"        : "https://google.com",
    "user_confirmation_url_action" : "POST"
  },
  
  "metadata": {
  	"mode":checkout_mode
  },

  //shipping contact
  "shipping": {
    "name": {
      "first" : "John",
      "last" : "Doe"
      // You can also include the full name
      // "full" : "John Doe"
    },
    "address": {
      "line1"  : "225 Bush Street",
      "line2"  : "Floor 16",
      "city"   : "San Francisco",
      "state"  : "CA",
      "zipcode": "94104"
    },
    "email"          : "joe.doe@email.com",
    "phone_number"   : "4155555555"
  },

  // cart 
  "items": [{
    "display_name"   : "Acme SLR-NG",
    "sku"            : "ACME-SLR-NG-01",
    "unit_price"     : 1500,
    "qty"            : 1,
    "item_image_url" : "https://examplemerchant.com/static/item.png",
    "item_url"       : "https://examplemerchant.com/acme-slr-ng-01.htm",
  }],

  // pricing / charge amount
  "currency"        : "USD",
  "discounts": {
    "savemoney123": {
      "discount_amount" : 500
    }
  },
  "tax_amount"      : 199,
  "shipping_amount" : 399,
  "total"           : 1598
});
	console.log(checkout_mode);
  affirm.checkout.open({
onFail: function(a){console.log(a)},
onSuccess: function(a){console.log(a)}
});
//    affirm.checkout.open();
});
      <div class="container">
              <h3>Checkout Page</h3>
              <br/>
              <h5>Checkout Mode
              </h5>
              <form name="checkout_mode_select">
              <input type="radio" name="checkout_mode" value="modal" checked="checked"> Modal<br/>
              <input type="radio" name="checkout_mode" value="redirect" > Redirect
              
              </form>
              <h5>Payment Method
              </h5>
              <form>
              <input type="radio" value="Affirm" checked="checked"><img id="payment_method-affirm" src="data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1NzEuNjQgMTY2LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6IzJiYzJkZjt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPmxvZ290eXBlX2JsdWU8L3RpdGxlPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTI5OC4zOSwwQTE3LjU3LDE3LjU3LDAsMSwwLDMxNiwxNy41NywxNy41OSwxNy41OSwwLDAsMCwyOTguMzksMFoiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgMCkiLz48cmVjdCBjbGFzcz0iY2xzLTEiIHg9IjI4My4zIiB5PSI0Ni42OCIgd2lkdGg9IjI5Ljk5IiBoZWlnaHQ9IjExOS4zMSIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTQwMy40Nyw0My42MWMtMTUsMC0zMi4yNSwxMC44LTM3Ljkz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uMTgtMTMuMTYsMTYuNjgtMTMuMTYsMjcuNDJ2MTNIMTM3LjY1VjY4LjM3aDEzLjUzVjE2NmgzMFY2OC4zN2gzNS43NlYxNjZoMzBWNjguMzdoMjAuNzdWNDYuNjhIMjQ3di0xMVoiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgMCkiLz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik0xMjIuNDMsMTY2bDAtMTA1LjM2YTE3LjMyLDE3LjMyLDAsMCwwLTE1LjMyLTE3Yy01LjczLS4zNy0xMS44MiwxLjczLTE1LjQxLDYuMzhMMCwxNjZIMjIuNmM5LDAsMTYuMTgtNC42OSwyMS42MS0xMS43TDk1LDkwLjA3VjE2NmgyNy40NVoiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgMCkiLz48L3N2Zz4=" height="16px">
              <h5>How does Affirm work?</h5>
              <span>
              Just enter your basic information and get a real-time credit decision. You will complete your payment on the Affirm website. If you're approved and confirm your loan, your purchase will be on its way as soon as it's ready.
              </span>
              </form>
              <input class="btn btn-primary" type="button" value="Affirm Checkout" id="submit-form" />
      </div>