Integrate Fatora With Shopify Store
You can integrate any shopify website with Fatora, follow this steps.
Step1: Access to admin dashboard
-
Go to your website and loginto your account
Step2: Create a custom manual payment method
-
From your Shopify admin, go to Settings > Payments.
-
In the Payment providers section, select Create custom payment method.
-
Fill the popup form controls with the following data:
- Enter the title of payment method in Custom payment method name field e.g: Paying online using Fatora.
- Enter information in Additional details field e.g: You can pay after completing your order In thanks page you will find button cal Pay Now use it to pay online.
- Enter information in the Payment instructions field e.g: Just use your credit card to pay it's very easy.
-
Click the activate payment method button.
Step3: Editing the checkout form options
-
From your Shopify admin, go to Settings > Checkout.
-
In Order processing Find Additional scripts, then add the following code, then click save
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous">
</script>
<script>
var api_key = "E4B73FEE-F492-4607-A38D-852B0EBC91C9";
var payBtn = document.getElementById('gotopay');
function paynow(){
var order_id = ("{{ order_id }}").replace('#','');
var amount = {{ total_price}} / 100;
var client_name = "{{ customer.name }}";
var client_phone = "{{ customer.default_address.phone }}";
var client_email = "{{ email }}";
var currency ="{{currency}}";
var order_id = "{{order_id}}";
var dataToPost = {
"amount": amount,
"currency": currency,
"order_id": order_id,
"client" : {
"name" : client_name,
"phone" : client_phone,
"email" : client_email,
},
"language": "en",
"success_url" : "http://domain.com/payments/success",
"failure_url" : "http://domain.com/payments/failure",
"fcm_token" : "XXXXXXXXX",
"save_token" : false,
"note": "some note here",
}
$.ajax({
url: 'https://api.fatora.io/v1/payments/checkout',
data: JSON.stringify(dataToPost),
type: "POST",
"headers": {
"Content-Type": "application/json",
"api_key": api_key
},
success: function (response) {
if (response.status == "SUCCESS"){
var url = response.result.checkout_url ;
window.location.href = url;
}
else {
var error_code = response.error.error_code;
var description = response.error.description;
window.location.href = failure_url+ "?error_code="+error_code+"&description=" + description ;
}
},
error: function (result) {
console.log("error: " + result.responseText);
}
});
};
</script>
<br/>
<div style="text-align: center;">
<button style=" background-color: #00a2ff; borderradius: 10px; padding: 15px 100px; margin: auto; text-align: center; color: #FFF; fontsize: 22px;" id="gotopay" onclick="paynow()" class="button__text">Pay Now </button>
</div> <br>
Be Attention!
- Replace test
api_key
value with yours which you have in your account. - Replace
success_url
value with yours as you define in your site - Replace
failure_url
value with yours as you define in your site - Replace
language
value with "ar" if you want payent page language in appear in arabic - Replace
client.name
&client.phone
with actual values
Step4: Create Completation Page (success, failure) page
When your client completes the payment, Fatora gateway will redirect to the default Fatora success | failure page, If you pass success_url | failure_url at requesting Standard Checkout API, Fatora will redirect after 2 seconds to the (success | failure) page. In this step we will create the two pages to get the URL of the success and failure page.
-
From your Shopify admin, go to Online Store > Pages.
-
Click on the Add New Page button.
-
Enter the title of your page (success page) and its content.
-
Click on save.
-
Return the same steps to add the Failure page.
-
Provide your Fatora account with the URL of these two pages to redirect to one of them after payment completion.
Create Apps for your Shopify store
You can install Shopify apps to help you build your business, integrate with services, and add features to your Shopify admin. We create an app here to update order status after successful payment completion. Following these steps to do that:
-
From your Shopify setting, go to Apps and sales channels, then select the tab develop apps.
-
click on create new app.
-
In App details section:
- Enter the title of private app name e.g: Fatora
- Enter the emergency developer email e.g: [email protected]
-
Select Configure Admin API scopes section to give the app the right permissions for the orders.
-
Scroll down to order section and give read and write permission
-
Click save, then click install app
-
Keep access_token and your app name, you will need them for webhook setting in the next step.
To trigger webhook
You need to put the URL of webhook in your account
-
From your Fatora account, go to Integration, then go to Integrate with Fatora section.
-
Click on Settings, then put the webhook url exactly in this format:
https://maktapp.credit/Pay/MarkedAsPaid/{shop}.myshopify.com/{accesstoken}
e.g: https://maktapp.credit/Pay/MarkedAsPaid/appname.myshopify.com/shpat_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -
Press Save changes
🛠️ Technical Support
- if you need any help you can check our help center, or contact support team