Modesy Help Center

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

02/08/2023 12:10 Modesy | Help Center

KNOWLEDGE BASE

License System
Adding a New Payment Gateway

Can I use the script on There are 3 steps for adding a payment gateway:
multiple domains?

1. Adding Your Payment Account to the Database


Invalid License Code

Payment systems generally work with API keys ( "public_key" and "secret_key" ). These key names may
How can I change my
be different for some systems, but logically work the same way.
license code
(domain)? To add a new payment system, open the "payment_gateways" table in your database via
phpMyAdmin and click the "Insert" link from the menu above to add your payment system.

How can I move my


site to a new domain
or server? Field Description

Shipping System id Leave this field blank because the id is automatically generated.

How can I change logo name Enter your payment system name.
size?
Example: Modesy Pay

How can I see the


name_key Enter an unique name that does not contain special characters for your
changes after
payment system.
changing the codes?
Example: modesy_pay

How can I use the


script on the NGINX public_key Enter the public_key value you created in your payment account.
server? Example: Adt9g4b-sz6NaQ_dsXGZQ76ah...

Can I use the script on secret_key Enter the secret_key value you created in your payment account.
Windows Server(IIS)? Example: EL6tE3pLtJ13JebQI5n3Fy57xL7...

How can I update my environment This is the payment mode option offered by your payment system. If you
site to a new version?
want to add test API keys for your payment system and perform payment
tests, you must enter "sandbox" here. If you want to enter your live API keys
How can I change a
and receive payments after tests, you must enter "production".
text in the script?
Example: sandbox

Image Upload Problem


base_currency If you want to accept payments in only one currency, you can write the short
name of the currency here. If you want to receive payments in all active
Why are digital files
currencies on your site, you can enter "all" here. You can check the
stored locally?
"currencies" table in your database for the short names of all currencies
available in the system.
PayPal is not working
on my site Example: USD

How can I prevent status 1 or 0. If you do not want the payment system to appear on your site, you
content on my site need to enter 0. Otherwise, you need to enter 1.
from being copied? Example: 1

Content Adding logos Our script displays logos for each payment system on the payment
Problem
methods page. These logos are located in the "assets / img / payment"
folder. For the payment system you add, you can add the logo names you
Adding Static Pages
want to show by putting commas between them. You can upload your own
SVG logos to this folder.
Adding a New Payment
Example: visa,mastercard,amex,discover
Gateway

https://codingest.net/knowledge-base?content=197 1/7
02/08/2023 12:10 Modesy | Help Center

KNOWLEDGE BASE

License System

Can I use the script on


multiple domains?

Invalid License Code

How can I change my


license code
(domain)?

How can I move my


site to a new domain
or server?

Shipping System

How can I change logo


size?
After adding the necessary information, you can click the "Go" button and finish the adding process.

How can I see the


2. Adding Payment System Codes
changes after
changing the codes?
Payment systems generally have 2 different integration methods:

How can I use the


script on the NGINX A. JavaScript Integration: This method allows you to accept payments with the help of a popup or a
server? previously created form. After the payment is completed, your payment system will return the payment
information if the transaction is successful and you can complete the transaction by sending this
Can I use the script on information to the server side with the help of AJAX.
Windows Server(IIS)?

B. Web Redirect Integration: This method allows you to accept payments on an external web page.
How can I update my After the payment is completed, the payment system sends the payment result to the server side.
site to a new version?

You need to read the documentation of the payment gateway you want to add, learn how it works, and
How can I change a
decide which method you want to add. Payment methods usually have several integration methods.
text in the script?
After reading the API documentation of the payment gateway and understanding the working logic, you
can start the integration process.
Image Upload Problem

Why are digital files


1. Creating the View
stored locally?

First you need to add a "view" for the payment method. All HTML, CSS and JavaScript codes of the
PayPal is not working
on my site payment method should be added to this file. To do this, open the
"app/Views/cart/payment_methods"  folder and create a PHP file for your payment method. Your 

How can I prevent "name_key" value that in your database and your file name must be the same. For example, if your
content on my site "name_key" value is "modesy_pay", you must create a file named "_modesy_pay.php".
from being copied?

Content Adding 2. Creating the Function


Problem

You need to add a function to the "app/Controllers/CartController.php" file to verify the payment and
Adding Static Pages add the order to the database after the payment is made. Open this file and create your function. For
example, if your "name_key" is "modesy_pay", you can create this fuction like this:
Adding a New Payment
Gateway

https://codingest.net/knowledge-base?content=197 2/7
02/08/2023 12:10 Modesy | Help Center

/**
* Payment with Modesy Pay
*/
KNOWLEDGE BASE public function modesyPayPaymentPost()
{
License System
}

Can I use the script on


multiple domains? You can add this code after the "mercadoPagoPaymentPost" function in this file.

Invalid License Code


3. Defining a Route to Access This Function
How can I change my
license code You need to define a route to access this fuction. To do this, open the "app/Config/RoutesStatic.php" file
(domain)?
and add your route. For example, if the name of the function that you created is
"modesyPayPaymentPost", you can add your route like this:
How can I move my
site to a new domain
or server? $routes->post('modesy-pay-payment-post', 'CartController::modesyPayPaymentPost');

Shipping System

Modesy has CSRF protection. When this protection is active, a request cannot be sent to your site
How can I change logo
size? from any external source via POST method. If your payment system sends the payment result to
your site with POST method, this request may not reach your site. To solve this problem, you can
How can I see the exclude the requests coming from the route you created. To do this, open the
changes after "app/Config/Filters.php" file and add the route you created as in the example below.
changing the codes?

Example:
How can I use the
script on the NGINX public array $globals = [
server? 'before' => [
'csrf' => ['except' => ['modesy-pay-payment-post']],
Can I use the script on ],
Windows Server(IIS)? ...

How can I update my


site to a new version?

How can I change a


text in the script?

After following these steps, you can add your payment gateway codes to the "_modesy_pay.php" file.
Image Upload Problem The following PHP variables are available in this file and you need to use them for payment process:

Why are digital files


stored locally? $totalAmount: The total amount of the items in the shopping cart. Amount to be paid. This is a
decimal variable (Example: 10.50).  Some payment systems require the payment amount as an

PayPal is not working integer number. In this case, you can multiply the total amount by 100.
on my site $currency: The currency of the payment. (Example: USD)
$mdsPaymentType: There are 3 types of payments in the Modesy. There are "sale", "membership"
How can I prevent and "promote" payments. You can use this variable if you need to make some differences
content on my site according to payment type.
from being copied?
$mdsPaymentToken: This variable has a unique token created for the payment. This token can be
used to verify the payment.
Content Adding
$paymentGateway: This variable is the payment method object chosen by the user. This variable
Problem
contains all the values for the payment method you have added to the database. For example, if
you want to access the "name_key" value for the selected payment method, you can access it
Adding Static Pages
with "$paymentGateway->name_key" code.

Adding a New Payment


Gateway

https://codingest.net/knowledge-base?content=197 3/7
02/08/2023 12:10 Modesy | Help Center

We will use PayPal JavaScript integration codes as an example to show how the payment gateway
codes can be added to the "_modesy_pay.php" file.
KNOWLEDGE BASE

License System The codes below are PayPal JavaScript integration codes. If you add these codes to the
"_modesy_pay.php" file, you will see the PayPal payment button in the payment section. After the
Can I use the script on payment approved, you can send the paymet details to the function you created with AJAX POST
multiple domains? method.

_modesy_pay.php
Invalid License Code

How can I change my <script src="https://www.paypal.com/sdk/js?client-id=<?= $paymentGateway-


license code >public_key; ?>&currency=<?= $currency; ?>"></script>
(domain)? <script>
paypal.Buttons({
createOrder: function (data, actions) {
How can I move my
return actions.order.create({
site to a new domain
or server? purchase_units: [{
amount: {
value: '<?= $totalAmount; ?>'
Shipping System
}
}]
How can I change logo });
size? },
onApprove: function (data, actions) {
How can I see the return actions.order.capture().then(function (details) {
changes after $('.paypal-loader').show();
changing the codes? var dataArray = {
'payment_id': data.orderID,
'currency': '<?= $currency; ?>',
How can I use the
script on the NGINX 'payment_amount': '<?= $totalAmount; ?>',
server? 'payment_status': details.status,
'mds_payment_type': '<?= $mdsPaymentType; ?>'
};
Can I use the script on
$.ajax({
Windows Server(IIS)?
type: 'POST',
url: MdsConfig.baseURL + '/paypal-payment-post',
How can I update my data: setAjaxData(dataArray),
site to a new version?
success: function (response) {
var obj = JSON.parse(response);
How can I change a if (obj.result == 1) {
text in the script? window.location.href = obj.redirectUrl;
} else {
Image Upload Problem location.reload();
}
}
Why are digital files
});
stored locally?
});
},
PayPal is not working onError: function (error) {
on my site alert(error);
}
How can I prevent }).render('#paypal-button-container');
content on my site </script>
from being copied?

3. Verifying the Payment and Adding the Order to the Database


Content Adding
Problem
Once the payment has been received, you must verify this payment with its id before adding the order

Adding Static Pages to the database. Each payment system has a different payment verification system. You can find the
necessary codes in the API documentation of your payment system. You need to add these codes to
the "modesyPayPaymentPost" function that you created in the "app/Controllers/CartController.php"
Adding a New Payment
Gateway file.

https://codingest.net/knowledge-base?content=197 4/7
02/08/2023 12:10 Modesy | Help Center

You can get the variables you send with AJAX POST with inputPost() and inputGet() functions in the
function you created. Also, if your payment system accepts the payments on an external web page and
then returns the necessary variables, you can receive these variables in the same way.

KNOWLEDGE BASE * First you need to check the payment method. If the payment method is not exist or enabled, you
need to return an error.
License System

$paypal = getPaymentGateway('paypal');
Can I use the script on
multiple domains?
if (empty($paypal)) {
setErrorMessage("Payment method not found!");
echo json_encode([
Invalid License Code
'result' => 0
]);
How can I change my exit();
license code }
(domain)?

How can I move my


site to a new domain
or server? * Then you need to validate the payment with the "payment_id" variable that PayPal returned to your
function with POST method.
Shipping System

$paymentId = inputPost('payment_id');
How can I change logo loadLibrary('Paypal');
size? $paypalLib = new \Paypal($paypal);
//validate the order
How can I see the if ($paypalLib->getOrder($paymentId)) {
changes after //payment is valid
changing the codes? }

How can I use the


script on the NGINX
server?
* After validating the payment, you can add the order to the database by calling the

Can I use the script on "executePayment()" function.


Windows Server(IIS)?

if ($paypalLib->getOrder($paymentId)) {
How can I update my $dataTransaction = [
site to a new version? 'payment_method' => 'PayPal',
'payment_id' => $paymentId,
How can I change a 'currency' => inputPost('currency'),
text in the script? 'payment_amount' => inputPost('payment_amount'),
'payment_status' => inputPost('payment_status'),
];
Image Upload Problem
$mdsPaymentType = inputPost('mds_payment_type');
//add order
Why are digital files $response = $this->executePayment($dataTransaction, $mdsPaymentType,
stored locally? langBaseUrl());
if ($response->result == 1) {
PayPal is not working setSuccessMessage($response->message);
on my site echo json_encode([
'result' => 1,
How can I prevent
'redirectUrl' => $response->redirectUrl
content on my site ]);
from being copied? } else {
setErrorMessage($response->message);
echo json_encode([
Content Adding
'result' => 0
Problem
]);
}
Adding Static Pages }

Adding a New Payment


Gateway

https://codingest.net/knowledge-base?content=197 5/7
02/08/2023 12:10 Modesy | Help Center

After combining all these, the function will be like this:

/**
* Payment with Paypal
KNOWLEDGE BASE
*/
License System
public function paypalPaymentPost()
{
$paypal = getPaymentGateway('paypal');
Can I use the script on
if (empty($paypal)) {
multiple domains?
setErrorMessage("Payment method not found!");
echo json_encode([
Invalid License Code 'result' => 0
]);
How can I change my exit();
license code }
(domain)? $paymentId = inputPost('payment_id');
loadLibrary('Paypal');
$paypalLib = new \Paypal($paypal);
How can I move my
site to a new domain //validate the order
or server? if ($paypalLib->getOrder($paymentId)) {
$dataTransaction = [
'payment_method' => 'PayPal',
Shipping System
'payment_id' => $paymentId,
'currency' => inputPost('currency'),
How can I change logo 'payment_amount' => inputPost('payment_amount'),
size? 'payment_status' => inputPost('payment_status'),
];
How can I see the $mdsPaymentType = inputPost('mds_payment_type');
changes after //add order
changing the codes? $response = $this->executePayment($dataTransaction, $mdsPaymentType,
langBaseUrl());
How can I use the if ($response->result == 1) {
script on the NGINX setSuccessMessage($response->message);
server? echo json_encode([
'result' => 1,
'redirectUrl' => $response->redirectUrl
Can I use the script on
]);
Windows Server(IIS)?
} else {
setErrorMessage($response->message);
How can I update my echo json_encode([
site to a new version?
'result' => 0
]);
How can I change a }
text in the script? } else {
setErrorMessage(trans("msg_error"));
Image Upload Problem echo json_encode([
'result' => 0
]);
Why are digital files
}
stored locally?
}

PayPal is not working


on my site

How can I prevent Redirecting to the Order Details Page


content on my site
Once the entire payment process is complete, our codes will return a "redirectUrl" variable. You need to
from being copied?
redirect the page to this URL.

Content Adding
Problem

Adding Static Pages


About Updates: We are constantly making new updates for our script. If we upload a major
update, you will need to update all your files to update your site. After updating your site, if you
Adding a New Payment
copy your "_modesy_pay.php" file, your "modesyPayPaymentPost" function and your new
Gateway
 route to the new version, your payment system will continue to work. Updates do not affect the
https://codingest.net/knowledge-base?content=197 6/7
02/08/2023 12:10 Modesy | Help Center

database, so you do not need to add the same record to the database again.
Also, if you've made an addition to the "csrf" array in the "app/Config/Filters.php" file for your
payment system, don't forget to add it again for the new version as well.

KNOWLEDGE BASE

License System
Important: We have prepared this documentation to show you how you can add a payment
system to our script. We have explained all the details you need to know about our codes.
Can I use the script on
However, adding a payment system can be difficult because almost all payment systems
multiple domains?
work differently and have different codes. If you are unable to add your payment system by

following these steps, or if you encounter errors while adding your payment system, we
Invalid License Code
recommend that you to  work with a developer. As we do not have a support or customization
service, we will not be able to help you to add your payment system or solve the problems you
How can I change my
license code
see.
(domain)?

How can I move my


site to a new domain
or server?

Shipping System
Copyright © 2022 Codingest - All Rights Reserved.

How can I change logo


size?

How can I see the


changes after
changing the codes?

How can I use the


script on the NGINX
server?

Can I use the script on


Windows Server(IIS)?

How can I update my


site to a new version?

How can I change a


text in the script?

Image Upload Problem

Why are digital files


stored locally?

PayPal is not working


on my site

How can I prevent


content on my site
from being copied?

Content Adding
Problem

Adding Static Pages

Adding a New Payment


Gateway

https://codingest.net/knowledge-base?content=197 7/7

You might also like