2Checkout Integration
Posted by [email protected] - Nov 17 ’16 at 07:24
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/checkout/inline-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='[email protected]' />
<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?
-
Dmitry KozlovAdminMember for: 9 years 8 months 16 days
Hello,
As I can see there is an option to pass parameters to 2CO via query string: https://www.2checkout.com/documentation/seller-area/plug-and-play-cart/integration/
So, what you can do. Insert the following code into the new form:
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:
window.location = "https://www.2checkout.com/checkout/purchase" + window.location.search;
-
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?
-
Dmitry KozlovAdminMember for: 9 years 8 months 16 days
[#2]: 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.
-
Goldyy6MemberMember for: 1 year 8 months 26 days
When you order your paper with us, we will ensure you receive top-quality work from a native English speaking paper writer ( https://grademiners.com/ ) who has been hand-picked and trained by our award-winning managing editor.
-
peter0900MemberMember for: 6 months 29 days
I am sharing some settings with you it will be helpful post.
2Checkout Settings: Select "Enable return after sale" under the Redirect URL column. Leave the Approved URL column empty for the Redirect URL section. Header Redirect should be chosen for the Return method. Save settings.