/
process.php
52 lines (45 loc) · 2.33 KB
/
process.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
use YenePay\Models\CheckoutOptions;
use YenePay\Models\CheckoutItem;
use YenePay\CheckoutHelper;
require_once(__DIR__ .'/vendor/yenepay/php-sdk/src/CheckoutHelper.php');
require_once(__DIR__ .'/vendor/yenepay/php-sdk/src/Models/CheckoutOptions.php');
require_once(__DIR__ .'/vendor/yenepay/php-sdk/src/Models/CheckoutItem.php');
$sellerCode = "YOUR_YENEPAY_SELLER_CODE";
$successUrl = "http://localhost:81/sampleshop/success.php"; //"YOUR_SUCCESS_URL";
$cancelUrl = "http://localhost:81/sampleshop/cancel.php"; //"YOUR_CANCEL_URL";
$ipnUrl = "http://localhost:81/sampleshop/ipn.php"; //"YOUR_IPN_URL";
$useSandbox = true; // set this to false if you are on production environment
$checkoutOptions = new CheckoutOptions($sellerCode, $useSandbox);
$checkoutOptions -> setSuccessUrl($successUrl);
$checkoutOptions -> setCancelUrl($cancelUrl);
$checkoutOptions -> setIPNUrl($ipnUrl);
$checkoutOrderItem = new CheckoutItem($_POST["ItemName"], $_POST["UnitPrice"], $_POST["Quantity"]);
if(isset($_POST["ItemId"]))
{
$checkoutOrderItem -> setId($_POST["ItemId"]);
}
if(isset($_POST["DeliveryFee"]))
{
$checkoutOrderItem -> setDeliveryFee($_POST["DeliveryFee"]);
}
if(isset($_POST["Tax1"]))
{
$checkoutOrderItem -> setTax1($_POST["Tax1"]);
}
if(isset($_POST["Tax2"]))
{
$checkoutOrderItem -> setTax2($_POST["Tax2"]);
}
if(isset($_POST["Discount"]))
{
$checkoutOrderItem -> setDiscount($_POST["Discount"]);
}
if(isset($_POST["HandlingFee"]))
{
$checkoutOrderItem -> setHandlingFee($_POST["HandlingFee"]);
}
$checkoutHelper = new CheckoutHelper();
$checkoutUrl = $checkoutHelper -> getSingleCheckoutUrl($checkoutOptions, $checkoutOrderItem);
header("Location: " . $checkoutUrl);
?>