Page 1 of 1

2Checkout Integration

Posted: 17 Nov 2016
by tech@fbep.org
I'd like to trigger a payment collection after the completion of a form.

2Checkout Inline Checkout seems like a good canidate for this. They provide a hosted checkout which is triggered in an iframe as modal-style popup above an existing page.

As per their documentation (https://www.2checkout.com/documentation ... e-checkout), integration should be as simple as loading their js library, then loading the correct parameters into this block:

<form action='https://www.2checkout.com/checkout/purchase' method='post'>
<input type='hidden' name='sid' value='1303908' />
<input type='hidden' name='mode' value='2CO' />
<input type='hidden' name='li_0_type' value='product' />
<input type='hidden' name='li_0_name' value='invoice123' />|
<input type='hidden' name='li_0_price' value='25.99' />
<input type='hidden' name='card_holder_name' value='Checkout Shopper' />
<input type='hidden' name='street_address' value='123 Test Address' />
<input type='hidden' name='street_address2' value='Suite 200' />
<input type='hidden' name='city' value='Columbus' />
<input type='hidden' name='state' value='OH' />
<input type='hidden' name='zip' value='43228' />
<input type='hidden' name='country' value='USA' />
<input type='hidden' name='email' value='example@2co.com' />
<input type='hidden' name='phone' value='614-921-2450' />
<input name='submit' type='submit' value='Checkout' />
</form>

Assuming that all the required parameters can be queried from the new Sharepoint entry, how can I passthrough values and trigger this function upon submission of a new item in SPForm?

Re: 2Checkout Integration

Posted: 18 Nov 2016
by Dmitry Kozlov
Hello,

As I can see there is an option to pass parameters to 2CO via query string: https://www.2checkout.com/documentation ... tegration/

So, what you can do. Insert the following code into the new form:

Code: Select all

fd.onsubmit(function(){
	fd.sourceFormParam("/Redirect.aspx?sid=" + fd.field('SID').value() + "&mode=" + fd.field('Mode').value());
	return true;
});
Next, insert JS-code into Redirect.aspx that redirects to https://www.2checkout.com/checkout/purchase with query params:

Code: Select all

window.location = "https://www.2checkout.com/checkout/purchase" + window.location.search;

Re: 2Checkout Integration

Posted: 01 Dec 2016
by tech@fbep.org
Thanks so much for the reply.

Using a redirect would work if that was the only feasible way to accomplish this, but I'd really like to use the inline checkout if at all possible (see https://www.2checkout.com/demo?method=inline). That way the entire transaction can be completed without leaving the sharepoint site.

Any ideas for how to accomplish this?

Re: 2Checkout Integration

Posted: 04 Dec 2016
by Dmitry Kozlov
Well, then you can redirect users from a SharePoint form to another SharePoint page and pass all the required parameters in the quesry string. In that page, put a checkout form and populate it automatically with values from the query string. You can even submit it with code.