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 Ecwid?

      To integrate Payfast with Ecwid, do the following: Log in to your Ecwid account. Navigate to Payment. Next to Credit or debit card click Choose payment processor. Select Credit card: Payfast. Enter your Payfast Merchant ID, Merchant Key and ...
    • Does Payfast integrate with a Wix website?

      Unfortunately at this time Payfast doesn’t integrate directly with Wix, but there are ways around this. If you need a shopping cart system on your Wix website you can use Ecwid. Ecwid provides shopping cart functionality to platforms like WordPress, ...
    • 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 Invoice Ninja?

      To integrate your PayFast account with Invoice Ninja, do the following:   Log in to your Invoice Ninja account. Navigate to Settings > Payment Settings. Click on Configure Gateways. Search for and select PayFast as the Provider. Enter your PayFast ...