-
Notifications
You must be signed in to change notification settings - Fork 0
/
payment.php
executable file
·92 lines (71 loc) · 2.76 KB
/
payment.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
* Prestashop Samurai Fee Fighters Payment Module
* @package Samurai Fee Fighters Payment Package
* @copyright Copyright (c) 2011 www.jsmwebsolutions.com
* @author Andy Singh ([email protected])
* @creation date 8th December,2011
* @website www.jsmwebsolutions.com
*/
/* SSL Management */
$useSSL = true;
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../header.php');
include(dirname(__FILE__).'/samuraifeefighters.php');
if (!$cookie->isLogged())
Tools::redirect('authentication.php?back=order.php');
$linkpoint = new Samuraifeefighters();
Samurai::setup(array(
'sandbox' => Configuration::get('sandbox'),
'merchantKey' => Configuration::get('merchantKey'),
'merchantPassword' => Configuration::get('merchantPassword'),
'processorToken' => Configuration::get('processorToken')
));
$paymentMethodToken = $_GET['payment_method_token'];
if($paymentMethodToken) {
foreach(Currency::getCurrencies() as $currencyDetails):
if($currencyDetails['id_currency']==$cookie->id_currency):
$currency_code = $currencyDetails['iso_code'];
endif;
endforeach;
$processor = Samurai_Processor::theProcessor();
$purchase = $processor->purchase(
$paymentMethodToken,
$cart->getOrderTotal(true, 3),
array(
'currency_code' => $currency_code,
'customer_reference' => time(),
'billing_reference' => time()
));
if ($purchase->isSuccess()) {
// get the payment
$linkpoint->doPayment($cart);
$order = new Order($linkpoint->currentOrder);
Tools::redirectLink(__PS_BASE_URI__.'order-confirmation.php?id_cart='.intval($cart->id).'&id_module='.intval($linkpoint->id).'&id_order='.$linkpoint->currentOrder.'&key='.$order->secure_key);
} else {
/*$transaction = isset($transaction) ? $transaction : new Samurai_Transaction();
$paymentMethod = isset($paymentMethod) ? $paymentMethod : new Samurai_PaymentMethod();
if ($transaction->hasErrors() || $paymentMethod->hasErrors()):
if ($transaction->hasErrors()):
foreach ($transaction->errors as $context => $errors):
foreach ($errors as $error):
$errorsList .='<li>'.$error->description.'</li>';
endforeach;
endforeach;
endif;
endif;
if ($paymentMethod->hasErrors()):
foreach ($paymentMethod->errors as $context => $errors):
foreach ($errors as $error):
$errorsList .='<li>'.$error->description.'</li>';
endforeach;
endforeach;
endif;*/
echo $linkpoint->askCC($cart,$paymentMethodToken,true);
}
} else {
// get the CC information
echo $linkpoint->askCC($cart);
}
include_once(dirname(__FILE__).'/../../footer.php');
?>