1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Apache OSL-2 |
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Yves\Amazonpay\Plugin\Provider; |
9
|
|
|
|
10
|
|
|
use Silex\Application; |
11
|
|
|
use Spryker\Shared\Kernel\Store; |
12
|
|
|
use Spryker\Yves\Application\Plugin\Provider\YvesControllerProvider; |
13
|
|
|
|
14
|
|
|
class AmazonpayControllerProvider extends YvesControllerProvider |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
const CHECKOUT = 'amazonpay_checkout'; |
18
|
|
|
const ENDPOINT = 'amazonpay_endpoint'; |
19
|
|
|
const CONFIRM_PURCHASE = 'amazonpay_confirm_purchase'; |
20
|
|
|
const SUCCESS = 'amazonpay_success'; |
21
|
|
|
const PAYMENT_FAILED = 'amazonpay_payment_failed'; |
22
|
|
|
|
23
|
|
|
const SET_ORDER_REFERENCE = 'amazonpay_set_order_reference'; |
24
|
|
|
const UPDATE_SHIPMENT_METHOD = 'amazonpay_update_shipment_method'; |
25
|
|
|
const GET_SHIPMENT_METHODS = 'amazonpay_get_shipment_methods'; |
26
|
|
|
|
27
|
|
|
const PAY_BUTTON = 'amazonpay_paybutton'; |
28
|
|
|
const CHECKOUT_WIDGET = 'amazonpay_checkout_widget'; |
29
|
|
|
|
30
|
|
|
const BUNDLE_NAME = 'Amazonpay'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param \Silex\Application $app |
34
|
|
|
* |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
|
|
protected function defineControllers(Application $app) |
38
|
|
|
{ |
39
|
|
|
$allowedLocalesPattern = $this->getAllowedLocalesPattern(); |
40
|
|
|
$this->createController('/{amazonpay}/checkout', static::CHECKOUT, self::BUNDLE_NAME, 'Payment', 'checkout') |
41
|
|
|
->assert('amazonpay', $allowedLocalesPattern . 'amazonpay|amazonpay') |
42
|
|
|
->value('amazonpay', 'amazonpay'); |
43
|
|
|
|
44
|
|
|
$this->createController('/{amazonpay}/confirm/purchase', static::CONFIRM_PURCHASE, self::BUNDLE_NAME, 'Payment', 'confirmPurchase') |
45
|
|
|
->assert('amazonpay', $allowedLocalesPattern . 'amazonpay|amazonpay') |
46
|
|
|
->value('amazonpay', 'amazonpay'); |
47
|
|
|
|
48
|
|
|
$this->createController('/{amazonpay}/success', static::SUCCESS, self::BUNDLE_NAME, 'Payment', 'success') |
49
|
|
|
->assert('amazonpay', $allowedLocalesPattern . 'amazonpay|amazonpay') |
50
|
|
|
->value('amazonpay', 'amazonpay'); |
51
|
|
|
|
52
|
|
|
$this->createController('/{amazonpay}/payment-failed', static::PAYMENT_FAILED, self::BUNDLE_NAME, 'Payment', 'paymentFailed') |
53
|
|
|
->assert('amazonpay', $allowedLocalesPattern . 'amazonpay|amazonpay') |
54
|
|
|
->value('amazonpay', 'amazonpay'); |
55
|
|
|
|
56
|
|
|
// ajax |
57
|
|
|
$this->createController('/amazonpay/set-order-reference', static::SET_ORDER_REFERENCE, self::BUNDLE_NAME, 'Payment', 'setOrderReference'); |
58
|
|
|
$this->createController('/amazonpay/update-shipment-method', static::UPDATE_SHIPMENT_METHOD, self::BUNDLE_NAME, 'Payment', 'updateShipmentMethod'); |
59
|
|
|
$this->createController('/{amazonpay}/get-shipment-methods', static::GET_SHIPMENT_METHODS, self::BUNDLE_NAME, 'Payment', 'getShipmentMethods') |
60
|
|
|
->assert('amazonpay', $allowedLocalesPattern . 'amazonpay|amazonpay') |
61
|
|
|
->value('amazonpay', 'amazonpay'); |
62
|
|
|
|
63
|
|
|
// widgets |
64
|
|
|
$this->createController('/{amazonpay}/paybutton', static::PAY_BUTTON, self::BUNDLE_NAME, 'Widget', 'payButton') |
65
|
|
|
->assert('amazonpay', $allowedLocalesPattern . 'amazonpay|amazonpay') |
66
|
|
|
->value('amazonpay', 'amazonpay'); |
67
|
|
|
|
68
|
|
|
$this->createController('/{amazonpay}/checkout-widget', static::CHECKOUT_WIDGET, self::BUNDLE_NAME, 'Widget', 'checkoutWidget') |
69
|
|
|
->assert('amazonpay', $allowedLocalesPattern . 'amazonpay|amazonpay') |
70
|
|
|
->value('amazonpay', 'amazonpay'); |
71
|
|
|
|
72
|
|
|
// endpoint |
73
|
|
|
$this->createController('/amazonpay/endpoint', static::ENDPOINT, self::BUNDLE_NAME, 'Payment', 'endpoint'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return string |
79
|
|
|
*/ |
80
|
|
|
public function getAllowedLocalesPattern() |
81
|
|
|
{ |
82
|
|
|
$systemLocales = Store::getInstance()->getLocales(); |
83
|
|
|
$implodedLocales = implode('|', array_keys($systemLocales)); |
84
|
|
|
|
85
|
|
|
return '(' . $implodedLocales . ')\/'; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
} |
90
|
|
|
|