Increased trust on your ecommerce store, app, classifieds or marketplace
Escrow Kenya’s highly simplified API installs “Buy With Escrow” buttons on your product listings or checkout pages. This way buyers can take advantage of the security of escrow payments without ever leaving your website or app, while sellers can close so much more sales when trust issues are eliminated.
Provided no issues arise between the buyer and seller, money is automatically released to the seller on a specified date or when the buyer approves the release of funds, whichever comes sooner.
Before you begin:
Note: The email address you use to register on the Partner's Portal should match the email address used on the profile that publishes products on your website. This way, orders placed on your website will be matched to your merchant account at Escrow Kenya. If you'd rather use a different email address, a new merchant account will be created on Escrow Kenya, the first time an order is placed on your website.
For Marketplaces: You will see an extra option to declare if your marketplace collects a commission from the sales. If it does, indicate the percentage commission. Your commission will be escrowed in every order and availed for each successful order. You will receive email notifications about all orders.
Once submitted, an API Key will be created and a request to activate it raised with us. You can proceed with integration right away but the integration will not work until the API key is activated. This is typically done within 30 minutes during business hours.
You will receive an email confirmation once the API key is activated and the status will change from “Pending Approval” to “Active”. Should your request be declined, you will receive an email notification advising you on what you should do to resolve the issue. The status will change to “Attention Required” and you will have an option to make amendments and submit them for review.
The API needs to fetch the following data.
The API key and username will be used to create an access token that you will send with every request to Escrow Kenya. To create the access token, concatenate the username and API key with a full stop (.) in between, then encode the string using base64 encoding scheme. The access token and other required data is to be sent as a JSON object. The payload details are as shown below. Because JSON data structure can be generated from any language, we have provided only one illustration using PHP.
<?php //prepare data to send $dataObj = new stdClass(); $dataObj->ek_access_token = base64_encode("{username}.{apikey}"); $dataObj->ek_access_type = "api_access"; $dataObj->ek_redirect_url = "{YOUR_REDIRECT_URL}"; $dataObj->ek_item_unique_identifier = "{UNIQUE_ITEM_OR_ORDER_ID}"; $dataObj->ek_item_title = "{ITEM_TITLE_OR_DESCRIPTION}"; $dataObj->ek_seller_email = "{SELLER_EMAIL}"; $dataObj->ek_seller_phone = "{SELLER_PHONE}"; $dataObj->ek_item_cost = "{ITEM_COST}"; $dataObj->ek_item_currency = "{CURRENCY}"; /* EXTRA FIELDS WHERE YOU WANT TO SKIP LOGIN/REGISTRATION STEP */ $dataObj->ek_item_due_date = "{DUE_DATE_FOR_ORDER}"; $dataObj->ek_item_fee_paid_by = "{FEES_PAID_BY}"; /* optional; might be part of integration app */ $dataObj->ek_item_shipping_fee = "{SHIPPING_FEE}"; /* optional */ $dataObj->ek_buyer_name = "{BUYER_NAME}"; $dataObj->ek_buyer_phone = "{BUYER_PHONE}"; $dataObj->ek_buyer_email = "{BUYER_EMAIL}"; /* optional */ $encodedData = urlencode(json_encode($dataObj)); ?> <form action="https://escrowkenya.com/api/v1/orders/start_view" method="POST"> < ?php foreach ($dataObj as $key => $value) { echo '< input type="hidden" name="' . $key . '" value="' . $value . '">'; } ?> <button type="submit" class="escrow">Buy with Escrow Kenya</button> </form>
Tip: How to Install WooCommerce
1. Before you begin, complete the API Key generation setup (refer to the Get Started section above)
2. Download the Escrow Kenya Gateway Plugin and the add_to_your_functions.php_file.txt file. Note: The plugin is in a zipped folder. Do not extract the files.
3. On your WordPress admin dashboard, click Plugins, then Add New.
4. Click Upload Plugin.
5. Click Choose File and locate the zipped folder named EscrowKenyaGatewayPlugin.zip. Select it and then click Install Now.
6. Wait for the plugin to be installed and then click Activate Plugin.
7. The plugin is now installed and activated. 2 more steps and we are done! Locate the plugin Escrow Kenya Gateway on the list of installed plugins and click Settings.
8. Login to the Partners Portal on a new browser tab or window, go to API Access/Integrations and select the integration for this WordPress website. Ensure that the status reads Active. Copy and paste the API Key, API username and fill out the redirect URL in the corresponding fields on the plugin settings page and then click Save Changes.
9. On your WordPress admin dashboard, click Plugins, then Add New. Search for Code Snippets plugin, install and active it.
10. On your WordPress admin dashboard, click Snippets, the click Add New.
11. Locate the add_to_your_functions.php_file.txt file in your downloads and open it. Copy the text exactly as it appears and paste it in the Code Snippets text area. Do not edit anything. You can name the Snippet Escrow Kenya Theme Functions for easy identification. Once done, click Save and Activate.
function ek_checkout_display(){global $post;$product=wc_get_product($post->ID);$sellerEmail=get_option('admin_email');$soldby=wp_get_object_terms($product->get_id(),'soldby',false);if(empty($soldby)){$seller_id=$soldby[0]->name;$seller=get_user_by('ID',$seller_id);$sellerEmail=$seller->user_email;}$current_user=wp_get_current_user();$ek_options=get_option('woocommerce_wc-escrow-kenya-gateway_settings');$dataObj=new stdClass();$dataObj->ek_access_token=base64_encode($ek_options['api_username'].".".$ek_options['api_key']);$dataObj->ek_access_type="api_access";$dataObj->ek_redirect_url=$ek_options['redirect_url'];$dataObj->ek_item_unique_identifier=$product->get_id();$dataObj->ek_item_title=$product->get_name();$dataObj->ek_seller_email=$sellerEmail;$dataObj->ek_seller_phone="";$dataObj->ek_item_cost=$product->get_price();$dataObj->ek_item_currency=get_option('woocommerce_currency');$dataObj->ek_item_due_date=date('Y-m-d',strtotime("+7 days"));$dataObj->ek_item_fee_paid_by="Buyer";$dataObj->ek_item_shipping_fee="0";if(($current_user instanceof WP_User)){$current_user_id=get_current_user_id();$phone=get_user_meta($current_user_id,'phone',true);if(!isset($phone)||$phone=="")$phone=get_user_meta($current_user_id,'phone_number',true);if(!isset($phone)||$phone=="")$phone=get_user_meta($current_user_id,'user_phone',true);if(!isset($phone)||$phone=="")$phone=get_user_meta($current_user_id,'dbem_phone',true);if(!isset($phone)||$phone=="")$phone=get_user_meta($current_user_id,'billing_phone',true);if(isset($phone)&&$phone!=""){$dataObj->ek_buyer_name=$current_user->user_firstname;$dataObj->ek_buyer_phone=$phone;$dataObj->ek_buyer_email=$current_user->user_email;}}$encodedData=urlencode(json_encode($dataObj));echo '<form action="https://escrowkenya.com/preview/api/v1/orders/start_view"method="POST"><input name="payload"type="hidden"value="'.$encodedData.'"> <button style="background:#3f65ac;color:#fff;padding:7px;border-radius:5px"type="submit">Buy with Escrow Kenya</button></form><br>';}
Note: Although this code can be added directly into the theme functions file through the theme editor, DO NOT do so, as this may cause your website to crash if done incorrectly or cause the API to malfunction.
Should you encounter problems or need assistance with this setup, Contact Us and we will be happy to assist you.