How do I integrate PayFast with SimpleCart?

How do I integrate PayFast with SimpleCart?

Create a simple shopping cart for use with PayFast using only HTML, CSSand Javascript.

simpleCart(js) PayFast demo

https://github.com/PayFast/mod-simplecart

1. Download and extract https://github.com/PayFast/mod-simplecart/zipball/master

2. Double-click the simplecartjs.html file to see the demo.

Creating a simpleCart(js) shopping cart from scratch

Download and extract https://github.com/wojodesign/simplecart-js/zipball/master

simpleCart(js) depends on 1 of 3 common Javascript libraries (jQuery, Prototype or Mootools)

* Include 1 of these 3 library files (jQuery is used in the example)

* Include the simpleCart.js file itself

<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
      <script type="text/javascript" src="js/simpleCart.js"></script>

* Code the simpleCart object by hand

<script type="text/javascript">
          simpleCart({
              checkout: {
                  type: "SendForm" ,
                  url: "https://sandbox.payfast.co.za/eng/process" ,
                  // HTTP method for form, "POST"
                  method: "POST" ,
                  // URL to redirect browser to after successful checkout
                  success: "http://yourwebsite.co.za/success.html" ,
                  // URL to redirect browser to after checkout was cancelled by buyer
                  cancel: "http://yourwebsite.co.za/cancel.html" ,
                  extra_data: {
                      currency_code: "ZAR",
                      merchant_id: "10000100",
                      merchant_key: "46f0cd694581a",
                      notify_url: "http://yourwebsite.co.za/notify.html", //this is the ITN or callback URL
                      amount: simpleCart.total, // Total amount = item1 + item2 + item3 etc
                      name_first: "Buyer first name",
                      name_last: "Buyer last name",
                  }
              },
              beforeCheckout: function( data ){
                  data.currency = "ZAR";
                  data.cancel_url = data.cancel_return;
                  data.return_url = data.return;
                  var payfast_description = '''';
                  for (var key in data)
                      if (key.match(/^item_name/))
                          payfast_description += '' ''+data[key];
                  data.item_description = data.item_name = payfast_description;
              }
          });
      </script>

Visit https://github.com/PayFast/mod-simplecart and view the sample files for a complete example. 


    • Related Articles

    • How do I integrate PayFast with UberCart?

      To integrate PayFast with UberCart, do the following: Download the PayFast module and extract the uc_payfast folder from the zip folder. Move or copy the folder called ”uc_payfast” into your /modules/ubercart/payment directory. Log in to the admin ...
    • How do I integrate PayFast with Events Manager Pro?

      You’ll need a working installation of WordPress with Events Manager Pro before you can integrate with PayFast. Kindly see their website for more information. To install the PayFast module, do the following: Download the PayFast plugin. Upload the ...
    • How do I integrate PayFast with CS-Cart?

      You’ll need a working installation of CS-Cart before you can integrate with PayFast. Kindly see their website for more information. Installation and testing V4 To install the PayFast payment module, do the following: Download the payment module. ...
    • How do I integrate PayFast with Drupal Commerce?

      You’ll need a working installation of Drupal Commerce before you can integrate with PayFast. Kindly see their website for more information.  Integration steps for Drupal-7 Commerce: Requirements Drupal 7 (or commerce_kickstart) Commerce 7 ...
    • How do I integrate PayFast with osCommerce?

      In order to use PayFast with osCommerce, you will need to install the PayFast payment module for osCommerce which is provided by PayFast. Installation requirements A working osCommerce installation Installation and testing To install the PayFast ...