Version Notes
-Updated payments admin screen to make it easier to configure.
-Fixed JQuery conflict on product detail button shortcut.
-Fixed compilation issue. (Issue #52)
-Added button styling options. (Issue #47)
Download this release
Release Info
Developer | Amazon Payments |
Extension | login_and_pay_for_magento |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.1.0
- app/code/community/Amazon/Login/Block/Button.php +47 -0
- app/code/community/Amazon/Login/Model/System/Config/Source/Buttonsize.php +2 -4
- app/code/community/Amazon/Login/etc/system.xml +0 -5
- app/code/community/Amazon/Login/sql/login_setup/install-0.1.0.php +1 -2
- app/code/community/Amazon/Login/sql/login_setup/mysql4-install-0.1.0.php +0 -29
- app/code/community/Amazon/Payments/Model/PaymentMethod.php +1 -1
- app/code/community/Amazon/Payments/Model/System/Config/Source/Buttonsize.php +4 -4
- app/code/community/Amazon/Payments/etc/system.xml +27 -29
- app/design/frontend/base/default/layout/amazon_login.xml +1 -1
- app/design/frontend/base/default/template/amazon_login/button.phtml +1 -2
- app/design/frontend/base/default/template/amazon_payments/button_shortcut.phtml +10 -12
- lib/OffAmazonPaymentsNotifications/Samples/.config.inc.php +0 -12
- lib/OffAmazonPaymentsNotifications/Samples/AddressConsentSample.php +0 -43
- lib/OffAmazonPaymentsNotifications/Samples/AddressConsentSampleResult.php +0 -133
- lib/OffAmazonPaymentsNotifications/Samples/AuthorizationNotificationSample.php +0 -176
- lib/OffAmazonPaymentsNotifications/Samples/AutomaticPayments/address.php +0 -80
- lib/OffAmazonPaymentsNotifications/Samples/AutomaticPayments/signin.php +0 -64
- lib/OffAmazonPaymentsNotifications/Samples/AutomaticPayments/wallet.php +0 -106
- lib/OffAmazonPaymentsNotifications/Samples/AutomaticPaymentsSimpleCheckoutDataInput.php +0 -44
- lib/OffAmazonPaymentsNotifications/Samples/AutomaticPaymentsSimpleCheckoutResult.php +0 -326
- lib/OffAmazonPaymentsNotifications/Samples/BillingAgreementNotificationSample.php +0 -168
- lib/OffAmazonPaymentsNotifications/Samples/CancellationDataInput.php +0 -42
- lib/OffAmazonPaymentsNotifications/Samples/CancellationResult.php +0 -188
- lib/OffAmazonPaymentsNotifications/Samples/CaptureNotificationSample.php +0 -173
- lib/OffAmazonPaymentsNotifications/Samples/IpnHandler.php +0 -132
- lib/OffAmazonPaymentsNotifications/Samples/IpnLogFile.php +0 -91
- lib/OffAmazonPaymentsNotifications/Samples/NotificationSample.php +0 -97
- lib/OffAmazonPaymentsNotifications/Samples/OrderReferenceSample.php +0 -143
- lib/OffAmazonPaymentsNotifications/Samples/PayWithAmazon/address.php +0 -80
- lib/OffAmazonPaymentsNotifications/Samples/PayWithAmazon/signin.php +0 -63
- lib/OffAmazonPaymentsNotifications/Samples/PayWithAmazon/wallet.php +0 -80
- lib/OffAmazonPaymentsNotifications/Samples/ProviderCheckoutDataInput.php +0 -49
- lib/OffAmazonPaymentsNotifications/Samples/ProviderCheckoutResult.php +0 -344
- lib/OffAmazonPaymentsNotifications/Samples/ProviderCreditNotificationSample.php +0 -127
- lib/OffAmazonPaymentsNotifications/Samples/ProviderCreditReversalNotificationSample.php +0 -115
- lib/OffAmazonPaymentsNotifications/Samples/ProviderRefundDataInput.php +0 -38
- lib/OffAmazonPaymentsNotifications/Samples/ProviderRefundResult.php +0 -173
- lib/OffAmazonPaymentsNotifications/Samples/RefundDataInput.php +0 -36
- lib/OffAmazonPaymentsNotifications/Samples/RefundNotificationSample.php +0 -154
- lib/OffAmazonPaymentsNotifications/Samples/RefundResult.php +0 -161
- lib/OffAmazonPaymentsNotifications/Samples/ReverseProviderCreditDataInput.php +0 -34
- lib/OffAmazonPaymentsNotifications/Samples/ReverseProviderCreditResult.php +0 -80
- lib/OffAmazonPaymentsNotifications/Samples/Samples.html +0 -67
- lib/OffAmazonPaymentsNotifications/Samples/SimpleCheckoutDataInput.php +0 -46
- lib/OffAmazonPaymentsNotifications/Samples/SimpleCheckoutResult.php +0 -307
- lib/OffAmazonPaymentsNotifications/Samples/SolutionProviderMerchantNotificationSample.php +0 -89
- lib/OffAmazonPaymentsNotifications/Samples/SplitShipmentsCheckoutDataInput_1.php +0 -41
- lib/OffAmazonPaymentsNotifications/Samples/SplitShipmentsCheckoutDataInput_2.php +0 -49
- lib/OffAmazonPaymentsNotifications/Samples/SplitShipmentsCheckoutResult.php +0 -259
- lib/OffAmazonPaymentsNotifications/Samples/WebServerExample.php +0 -205
- lib/OffAmazonPaymentsNotifications/Samples/address.php +0 -60
- lib/OffAmazonPaymentsNotifications/Samples/signin.php +0 -49
- lib/OffAmazonPaymentsNotifications/Samples/wallet.php +0 -54
- lib/OffAmazonPaymentsService/Client.php +223 -221
- lib/OffAmazonPaymentsService/MerchantValues.php +36 -34
- lib/OffAmazonPaymentsService/Model.php +56 -56
- lib/OffAmazonPaymentsService/RegionSpecificProperties.php +50 -48
- lib/OffAmazonPaymentsService/Samples/.config.inc.php +0 -13
- lib/OffAmazonPaymentsService/Samples/AddressConsentSample.php +0 -78
- lib/OffAmazonPaymentsService/Samples/AuthorizeOnBillingAgreementSample.php +0 -258
- lib/OffAmazonPaymentsService/Samples/AuthorizeSample.php +0 -271
- lib/OffAmazonPaymentsService/Samples/AutomaticPaymentsSimpleCheckoutExample.php +0 -366
- lib/OffAmazonPaymentsService/Samples/AutomaticPaymentsSimpleCheckoutExampleCLI.php +0 -319
- lib/OffAmazonPaymentsService/Samples/CLIExample.php +0 -76
- lib/OffAmazonPaymentsService/Samples/CancelOrderReferenceSample.php +0 -54
- lib/OffAmazonPaymentsService/Samples/CancellationExample.php +0 -263
- lib/OffAmazonPaymentsService/Samples/CancellationExampleCLI.php +0 -164
- lib/OffAmazonPaymentsService/Samples/CaptureSample.php +0 -162
- lib/OffAmazonPaymentsService/Samples/CloseAuthorizationSample.php +0 -54
- lib/OffAmazonPaymentsService/Samples/CloseBillingAgreementSample.php +0 -43
- lib/OffAmazonPaymentsService/Samples/CloseOrderReferenceSample.php +0 -54
- lib/OffAmazonPaymentsService/Samples/ConfirmBillingAgreementSample.php +0 -44
- lib/OffAmazonPaymentsService/Samples/ConfirmOrderReferenceSample.php +0 -54
- lib/OffAmazonPaymentsService/Samples/CreateOrderReferenceForIdSample.php +0 -333
- lib/OffAmazonPaymentsService/Samples/GetAuthorizationDetailsSample.php +0 -266
- lib/OffAmazonPaymentsService/Samples/GetBillingAgreementDetailsSample.php +0 -337
- lib/OffAmazonPaymentsService/Samples/GetCaptureDetailsSample.php +0 -203
- lib/OffAmazonPaymentsService/Samples/GetOrderReferenceDetailsSample.php +0 -368
- lib/OffAmazonPaymentsService/Samples/GetProviderCreditDetailsSample.php +0 -115
- lib/OffAmazonPaymentsService/Samples/GetProviderCreditReversalDetailsSample.php +0 -99
- lib/OffAmazonPaymentsService/Samples/GetRefundDetailsSample.php +0 -162
- lib/OffAmazonPaymentsService/Samples/ProviderCheckoutExampleCLI.php +0 -322
- lib/OffAmazonPaymentsService/Samples/ProviderRefundExampleCLI.php +0 -189
- lib/OffAmazonPaymentsService/Samples/RefundExample.php +0 -223
- lib/OffAmazonPaymentsService/Samples/RefundExampleCLI.php +0 -182
- lib/OffAmazonPaymentsService/Samples/RefundSample.php +0 -180
- lib/OffAmazonPaymentsService/Samples/ReverseProviderCreditExample.php +0 -71
- lib/OffAmazonPaymentsService/Samples/ReverseProviderCreditExampleCLI.php +0 -93
- lib/OffAmazonPaymentsService/Samples/ReverseProviderCreditSample.php +0 -98
- lib/OffAmazonPaymentsService/Samples/SetBillingAgreementDetailsSample.php +0 -337
- lib/OffAmazonPaymentsService/Samples/SetOrderReferenceDetailsSample.php +0 -347
- lib/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php +0 -318
- lib/OffAmazonPaymentsService/Samples/SimpleCheckoutExampleCLI.php +0 -288
- lib/OffAmazonPaymentsService/Samples/SplitShipmentsCheckoutExample.php +0 -331
- lib/OffAmazonPaymentsService/Samples/SplitShipmentsCheckoutExampleCLI.php +0 -252
- lib/OffAmazonPaymentsService/Samples/Utils/CountryRate.php +0 -43
- lib/OffAmazonPaymentsService/Samples/Utils/ShippingAndTaxCostHelper.php +0 -104
- lib/OffAmazonPaymentsService/Samples/ValidateBillingAgreementSample.php +0 -80
- package.xml +8 -5
app/code/community/Amazon/Login/Block/Button.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Amazon Login
|
4 |
+
*
|
5 |
+
* @category Amazon
|
6 |
+
* @package Amazon_Login
|
7 |
+
* @copyright Copyright (c) 2014 Amazon.com
|
8 |
+
* @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Amazon_Login_Block_Button extends Mage_Core_Block_Template
|
12 |
+
{
|
13 |
+
public function getButtonImage()
|
14 |
+
{
|
15 |
+
$button = '';
|
16 |
+
|
17 |
+
switch (Mage::getStoreConfig('amazon_login/settings/button_color')) {
|
18 |
+
case 'DarkGray':
|
19 |
+
$button .= '_drkgry_';
|
20 |
+
break;
|
21 |
+
case 'LightGray':
|
22 |
+
$button .= '_gry_';
|
23 |
+
break;
|
24 |
+
default:
|
25 |
+
$button .= '_gold_';
|
26 |
+
break;
|
27 |
+
}
|
28 |
+
|
29 |
+
$isLarge = (Mage::getStoreConfig('amazon_login/settings/button_size') == 'large');
|
30 |
+
|
31 |
+
switch (Mage::getStoreConfig('amazon_login/settings/button_type')) {
|
32 |
+
case 'Login':
|
33 |
+
$button .= $isLarge ? '152x64' : '76x32';
|
34 |
+
break;
|
35 |
+
case 'A':
|
36 |
+
$button .= $isLarge ? '64x64' : '32x32';
|
37 |
+
break;
|
38 |
+
default:
|
39 |
+
$button .= $isLarge ? '312x64' : '156x32';
|
40 |
+
break;
|
41 |
+
}
|
42 |
+
|
43 |
+
return 'https://images-na.ssl-images-amazon.com/images/G/01/lwa/btnLWA' . $button . '.png';
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
app/code/community/Amazon/Login/Model/System/Config/Source/Buttonsize.php
CHANGED
@@ -13,10 +13,8 @@ class Amazon_Login_Model_System_Config_Source_Buttonsize
|
|
13 |
public function toOptionArray()
|
14 |
{
|
15 |
return array(
|
16 |
-
array('value'=>'
|
17 |
-
array('value'=>'
|
18 |
-
array('value'=>'large', 'label'=>Mage::helper('adminhtml')->__('Large (296px x 60px)')),
|
19 |
-
array('value'=>'x-large', 'label'=>Mage::helper('adminhtml')->__('X-large (400px x 90px)')),
|
20 |
);
|
21 |
}
|
22 |
}
|
13 |
public function toOptionArray()
|
14 |
{
|
15 |
return array(
|
16 |
+
array('value'=>'medium', 'label'=>Mage::helper('adminhtml')->__('Medium')),
|
17 |
+
array('value'=>'large', 'label'=>Mage::helper('adminhtml')->__('Large')),
|
|
|
|
|
18 |
);
|
19 |
}
|
20 |
}
|
app/code/community/Amazon/Login/etc/system.xml
CHANGED
@@ -87,8 +87,6 @@
|
|
87 |
<show_in_store>1</show_in_store>
|
88 |
</popup>
|
89 |
|
90 |
-
|
91 |
-
<!--
|
92 |
<heading_button translate="label">
|
93 |
<label>Button Style</label>
|
94 |
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
@@ -127,9 +125,6 @@
|
|
127 |
<show_in_website>1</show_in_website>
|
128 |
<show_in_store>1</show_in_store>
|
129 |
</button_size>
|
130 |
-
-->
|
131 |
-
|
132 |
-
|
133 |
|
134 |
<heading_advanced translate="label">
|
135 |
<label>Advanced</label>
|
87 |
<show_in_store>1</show_in_store>
|
88 |
</popup>
|
89 |
|
|
|
|
|
90 |
<heading_button translate="label">
|
91 |
<label>Button Style</label>
|
92 |
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
125 |
<show_in_website>1</show_in_website>
|
126 |
<show_in_store>1</show_in_store>
|
127 |
</button_size>
|
|
|
|
|
|
|
128 |
|
129 |
<heading_advanced translate="label">
|
130 |
<label>Advanced</label>
|
app/code/community/Amazon/Login/sql/login_setup/install-0.1.0.php
CHANGED
@@ -8,7 +8,6 @@
|
|
8 |
* @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
|
9 |
*/
|
10 |
|
11 |
-
|
12 |
$installer = $this;
|
13 |
|
14 |
$installer->startSetup();
|
@@ -35,7 +34,7 @@ $amazon_table = $installer->getConnection()
|
|
35 |
$installer->getConnection()->createTable($amazon_table);
|
36 |
|
37 |
$installer->getConnection()->addConstraint(
|
38 |
-
'
|
39 |
$installer->getTable('amazon_login/login'),
|
40 |
'customer_id',
|
41 |
$installer->getTable('customer/entity'),
|
8 |
* @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
|
9 |
*/
|
10 |
|
|
|
11 |
$installer = $this;
|
12 |
|
13 |
$installer->startSetup();
|
34 |
$installer->getConnection()->createTable($amazon_table);
|
35 |
|
36 |
$installer->getConnection()->addConstraint(
|
37 |
+
'fk_amazon_login_customer_entity_id',
|
38 |
$installer->getTable('amazon_login/login'),
|
39 |
'customer_id',
|
40 |
$installer->getTable('customer/entity'),
|
app/code/community/Amazon/Login/sql/login_setup/mysql4-install-0.1.0.php
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Amazon Login
|
4 |
-
*
|
5 |
-
* @category Amazon
|
6 |
-
* @package Amazon_Payments
|
7 |
-
* @copyright Copyright (c) 2014 Amazon.com
|
8 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
9 |
-
*/
|
10 |
-
|
11 |
-
|
12 |
-
$installer = $this;
|
13 |
-
|
14 |
-
$installer->startSetup();
|
15 |
-
|
16 |
-
$installer->run("
|
17 |
-
CREATE TABLE IF NOT EXISTS `{$this->getTable('amazon_login')}` (
|
18 |
-
`login_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
19 |
-
`customer_id` int(10) unsigned NOT NULL,
|
20 |
-
`amazon_uid` varchar(255) NOT NULL,
|
21 |
-
PRIMARY KEY (`login_id`),
|
22 |
-
KEY `amazon_uid` (`amazon_uid`),
|
23 |
-
UNIQUE KEY `customer_id` (`customer_id`),
|
24 |
-
CONSTRAINT `amazon_login_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customer_entity` (`entity_id`) ON DELETE CASCADE
|
25 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
26 |
-
|
27 |
-
");
|
28 |
-
|
29 |
-
$installer->endSetup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Amazon/Payments/Model/PaymentMethod.php
CHANGED
@@ -152,7 +152,7 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
|
|
152 |
$this->_getApi()->cancelOrderReference($payment->getTransactionId());
|
153 |
}
|
154 |
|
155 |
-
Mage::throwException("Amazon could not process your order.\n\n" . $status->
|
156 |
break;
|
157 |
default:
|
158 |
Mage::throwException('Amazon could not process your order.');
|
152 |
$this->_getApi()->cancelOrderReference($payment->getTransactionId());
|
153 |
}
|
154 |
|
155 |
+
Mage::throwException("Amazon could not process your order.\n\n" . $status->getReasonCode() . " (" . $status->getState() . ")\n" . $status->getReasonDescription());
|
156 |
break;
|
157 |
default:
|
158 |
Mage::throwException('Amazon could not process your order.');
|
app/code/community/Amazon/Payments/Model/System/Config/Source/Buttonsize.php
CHANGED
@@ -13,10 +13,10 @@ class Amazon_Payments_Model_System_Config_Source_Buttonsize
|
|
13 |
public function toOptionArray()
|
14 |
{
|
15 |
return array(
|
16 |
-
array('value'=>'small', 'label'=>Mage::helper('adminhtml')->__('Small
|
17 |
-
array('value'=>'medium', 'label'=>Mage::helper('adminhtml')->__('Medium
|
18 |
-
array('value'=>'large', 'label'=>Mage::helper('adminhtml')->__('Large
|
19 |
-
array('value'=>'x-large', 'label'=>Mage::helper('adminhtml')->__('X-large
|
20 |
);
|
21 |
}
|
22 |
}
|
13 |
public function toOptionArray()
|
14 |
{
|
15 |
return array(
|
16 |
+
array('value'=>'small', 'label'=>Mage::helper('adminhtml')->__('Small')),
|
17 |
+
array('value'=>'medium', 'label'=>Mage::helper('adminhtml')->__('Medium')),
|
18 |
+
array('value'=>'large', 'label'=>Mage::helper('adminhtml')->__('Large')),
|
19 |
+
array('value'=>'x-large', 'label'=>Mage::helper('adminhtml')->__('X-large')),
|
20 |
);
|
21 |
}
|
22 |
}
|
app/code/community/Amazon/Payments/etc/system.xml
CHANGED
@@ -31,11 +31,9 @@
|
|
31 |
|
32 |
<strong>Configuring Amazon Payments</strong>
|
33 |
<ol style="list-style:inside decimal;">
|
34 |
-
<li>
|
35 |
-
<li>
|
36 |
-
<li>Add your url to "Allowed JavaScript Origins" in Amazon SellerCentral.
|
37 |
<li>Under General->Web, enable "Use Secure URLs in Frontend." (HTTPS is required.)
|
38 |
-
<li>Configure Amazon Payments below.
|
39 |
</ol>
|
40 |
|
41 |
<div style="clear:both;"></div>
|
@@ -55,9 +53,9 @@
|
|
55 |
<show_in_store>0</show_in_store>
|
56 |
</enabled>
|
57 |
|
58 |
-
|
59 |
-
<heading_creds translate="label">
|
60 |
<label>Client Credentials</label>
|
|
|
61 |
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
62 |
<sort_order>10</sort_order>
|
63 |
<show_in_default>1</show_in_default>
|
@@ -65,27 +63,7 @@
|
|
65 |
<show_in_store>0</show_in_store>
|
66 |
</heading_creds>
|
67 |
|
68 |
-
|
69 |
-
<label>Client ID</label>
|
70 |
-
<frontend_type>text</frontend_type>
|
71 |
-
<backend_model>amazon_payments/system_config_backend_clientid</backend_model>
|
72 |
-
<sort_order>11</sort_order>
|
73 |
-
<show_in_default>1</show_in_default>
|
74 |
-
<show_in_website>1</show_in_website>
|
75 |
-
<show_in_store>0</show_in_store>
|
76 |
-
</client_id>
|
77 |
-
|
78 |
-
<client_secret translate="label">
|
79 |
-
<label>Client Secret</label>
|
80 |
-
<frontend_type>text</frontend_type>
|
81 |
-
<backend_model>amazon_payments/system_config_backend_clientsecret</backend_model>
|
82 |
-
<sort_order>12</sort_order>
|
83 |
-
<show_in_default>1</show_in_default>
|
84 |
-
<show_in_website>1</show_in_website>
|
85 |
-
<show_in_store>0</show_in_store>
|
86 |
-
</client_secret>
|
87 |
-
|
88 |
-
<seller_id translate="label">
|
89 |
<label>Seller/Merchant ID</label>
|
90 |
<frontend_type>text</frontend_type>
|
91 |
<sort_order>15</sort_order>
|
@@ -95,7 +73,7 @@
|
|
95 |
</seller_id>
|
96 |
|
97 |
<access_key translate="label">
|
98 |
-
<label>
|
99 |
<frontend_type>text</frontend_type>
|
100 |
<sort_order>20</sort_order>
|
101 |
<show_in_default>1</show_in_default>
|
@@ -103,7 +81,7 @@
|
|
103 |
<show_in_store>0</show_in_store>
|
104 |
</access_key>
|
105 |
<access_secret translate="label">
|
106 |
-
<label>
|
107 |
<frontend_type>text</frontend_type>
|
108 |
<sort_order>30</sort_order>
|
109 |
<show_in_default>1</show_in_default>
|
@@ -111,6 +89,26 @@
|
|
111 |
<show_in_store>0</show_in_store>
|
112 |
</access_secret>
|
113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
<!--
|
115 |
<region translate="label">
|
116 |
<label>API Region</label>
|
31 |
|
32 |
<strong>Configuring Amazon Payments</strong>
|
33 |
<ol style="list-style:inside decimal;">
|
34 |
+
<li>Register or login to retrieve your account keys:  <button onclick="javascript:window.open('https://sellercentral.amazon.com/hz/me/sp/signup?solutionProviderOptions=lwa%3Bmws-acc%3B&marketplaceId=AGWSWK15IEJJ7&solutionProviderToken=AAAAAQAAAAEAAAAQCz2wulRfR9nOADyzVQrq5wAAAHAIIULh6RBNvlw68WY5S9ATlmInlyg2PLVF44yUVowkyjvDZPhtLf3UYn6fshHlKqwR4qptfBeltbxLtLrrIfK6JoxzuWe9FRTnCfSey8a0sFKuL3mwNenjLyMC9BAN1xU0S6pebxA2mz8t8Y1v5Axi&solutionProviderId=A2K7HE1S3M5XJ', 'get_keys','left=50, top=50, width=950, height=750'); return false;" class="scalable" type="button"><span>Login to Get Your Keys</span></button>
|
35 |
+
<li>Add your url to "Allowed JavaScript Origins" in <a href="https://sellercentral.amazon.com/" target="_blank">Amazon Seller Central</a>.
|
|
|
36 |
<li>Under General->Web, enable "Use Secure URLs in Frontend." (HTTPS is required.)
|
|
|
37 |
</ol>
|
38 |
|
39 |
<div style="clear:both;"></div>
|
53 |
<show_in_store>0</show_in_store>
|
54 |
</enabled>
|
55 |
|
56 |
+
<heading_creds translate="label">
|
|
|
57 |
<label>Client Credentials</label>
|
58 |
+
<frontend_type>text</frontend_type>
|
59 |
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
60 |
<sort_order>10</sort_order>
|
61 |
<show_in_default>1</show_in_default>
|
63 |
<show_in_store>0</show_in_store>
|
64 |
</heading_creds>
|
65 |
|
66 |
+
<seller_id translate="label">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
<label>Seller/Merchant ID</label>
|
68 |
<frontend_type>text</frontend_type>
|
69 |
<sort_order>15</sort_order>
|
73 |
</seller_id>
|
74 |
|
75 |
<access_key translate="label">
|
76 |
+
<label>MWS Access Key</label>
|
77 |
<frontend_type>text</frontend_type>
|
78 |
<sort_order>20</sort_order>
|
79 |
<show_in_default>1</show_in_default>
|
81 |
<show_in_store>0</show_in_store>
|
82 |
</access_key>
|
83 |
<access_secret translate="label">
|
84 |
+
<label>MWS Secret Key</label>
|
85 |
<frontend_type>text</frontend_type>
|
86 |
<sort_order>30</sort_order>
|
87 |
<show_in_default>1</show_in_default>
|
89 |
<show_in_store>0</show_in_store>
|
90 |
</access_secret>
|
91 |
|
92 |
+
<client_id translate="label">
|
93 |
+
<label>Client ID</label>
|
94 |
+
<frontend_type>text</frontend_type>
|
95 |
+
<backend_model>amazon_payments/system_config_backend_clientid</backend_model>
|
96 |
+
<sort_order>31</sort_order>
|
97 |
+
<show_in_default>1</show_in_default>
|
98 |
+
<show_in_website>1</show_in_website>
|
99 |
+
<show_in_store>0</show_in_store>
|
100 |
+
</client_id>
|
101 |
+
|
102 |
+
<client_secret translate="label">
|
103 |
+
<label>Client Secret</label>
|
104 |
+
<frontend_type>text</frontend_type>
|
105 |
+
<backend_model>amazon_payments/system_config_backend_clientsecret</backend_model>
|
106 |
+
<sort_order>32</sort_order>
|
107 |
+
<show_in_default>1</show_in_default>
|
108 |
+
<show_in_website>1</show_in_website>
|
109 |
+
<show_in_store>0</show_in_store>
|
110 |
+
</client_secret>
|
111 |
+
|
112 |
<!--
|
113 |
<region translate="label">
|
114 |
<label>API Region</label>
|
app/design/frontend/base/default/layout/amazon_login.xml
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
<customer_account_login translate="label">
|
14 |
|
15 |
<block type="amazon_login/script" name="amazon_login.script" template="amazon_login/script.phtml" />
|
16 |
-
<block type="
|
17 |
|
18 |
<!-- ifconfig only works with action -->
|
19 |
<reference name="before_body_end">
|
13 |
<customer_account_login translate="label">
|
14 |
|
15 |
<block type="amazon_login/script" name="amazon_login.script" template="amazon_login/script.phtml" />
|
16 |
+
<block type="amazon_login/button" name="amazon_login.button" template="amazon_login/button.phtml" after="customer_form_login" />
|
17 |
|
18 |
<!-- ifconfig only works with action -->
|
19 |
<reference name="before_body_end">
|
app/design/frontend/base/default/template/amazon_login/button.phtml
CHANGED
@@ -25,8 +25,7 @@
|
|
25 |
<br />
|
26 |
|
27 |
<button class="amazon-login-button" style="cursor:pointer; background:none; border:0;">
|
28 |
-
<img src="
|
29 |
-
width="156" height="32" alt="Login with Amazon" border="0" />
|
30 |
</button>
|
31 |
</div>
|
32 |
</div>
|
25 |
<br />
|
26 |
|
27 |
<button class="amazon-login-button" style="cursor:pointer; background:none; border:0;">
|
28 |
+
<img src="<?php echo $this->getButtonImage(); ?>" alt="Login with Amazon" border="0" />
|
|
|
29 |
</button>
|
30 |
</div>
|
31 |
</div>
|
app/design/frontend/base/default/template/amazon_payments/button_shortcut.phtml
CHANGED
@@ -41,7 +41,7 @@
|
|
41 |
|
42 |
<script type="text/javascript">
|
43 |
|
44 |
-
//
|
45 |
|
46 |
var productAddToCartFormAmazon = new VarienForm('product_addtocart_form');
|
47 |
|
@@ -52,9 +52,9 @@
|
|
52 |
|
53 |
var e = null;
|
54 |
|
55 |
-
var data = jQuery(form).serialize();
|
56 |
data += '&isAjax=1';
|
57 |
-
jQuery('#ajax_loader').show();
|
58 |
|
59 |
if (document.location.protocol == 'https:') {
|
60 |
url = url.replace('http:', document.location.protocol);
|
@@ -64,14 +64,12 @@
|
|
64 |
}
|
65 |
|
66 |
// Add via Ajax and redirect to login/payment page
|
67 |
-
jQuery.
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
jQuery("#<?php echo $this->getAmazonPayButtonId(); ?> img[id!='amazon-button-clone']").click();
|
74 |
-
})
|
75 |
;
|
76 |
|
77 |
}
|
@@ -79,7 +77,7 @@
|
|
79 |
|
80 |
|
81 |
// Duplicate Amazon button
|
82 |
-
jQuery("#<?php echo $this->getAmazonPayButtonId(); ?> img")
|
83 |
.hide()
|
84 |
.clone()
|
85 |
.attr("id", "amazon-button-clone")
|
41 |
|
42 |
<script type="text/javascript">
|
43 |
|
44 |
+
// OffAmazonPayments.jQuery loaded by Amazon API
|
45 |
|
46 |
var productAddToCartFormAmazon = new VarienForm('product_addtocart_form');
|
47 |
|
52 |
|
53 |
var e = null;
|
54 |
|
55 |
+
var data = OffAmazonPayments.jQuery(form).serialize();
|
56 |
data += '&isAjax=1';
|
57 |
+
OffAmazonPayments.jQuery('#ajax_loader').show();
|
58 |
|
59 |
if (document.location.protocol == 'https:') {
|
60 |
url = url.replace('http:', document.location.protocol);
|
64 |
}
|
65 |
|
66 |
// Add via Ajax and redirect to login/payment page
|
67 |
+
OffAmazonPayments.jQuery.post(url: url, data,
|
68 |
+
function(){
|
69 |
+
OffAmazonPayments.jQuery('#ajax_loader').hide();
|
70 |
+
OffAmazonPayments.jQuery("#<?php echo $this->getAmazonPayButtonId(); ?> img[id!='amazon-button-clone']").click();
|
71 |
+
}
|
72 |
+
)
|
|
|
|
|
73 |
;
|
74 |
|
75 |
}
|
77 |
|
78 |
|
79 |
// Duplicate Amazon button
|
80 |
+
OffAmazonPayments.jQuery("#<?php echo $this->getAmazonPayButtonId(); ?> img")
|
81 |
.hide()
|
82 |
.clone()
|
83 |
.attr("id", "amazon-button-clone")
|
lib/OffAmazonPaymentsNotifications/Samples/.config.inc.php
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/************************************************************************
|
3 |
-
* OPTIONAL ON SOME INSTALLATIONS
|
4 |
-
*
|
5 |
-
* Set include path to root of library, relative to Samples directory.
|
6 |
-
* Only needed when running library from local directory.
|
7 |
-
* If library is installed in PHP include path, this is not needed
|
8 |
-
***********************************************************************/
|
9 |
-
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . "/../../."));
|
10 |
-
|
11 |
-
require_once "OffAmazonPayments/.autoloader.php";
|
12 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/AddressConsentSample.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
|
18 |
-
<html>
|
19 |
-
<head>
|
20 |
-
<title>Address Consent Sample</title>
|
21 |
-
</head>
|
22 |
-
<body>
|
23 |
-
<div>
|
24 |
-
<h1>Address Consent Example</h1>
|
25 |
-
<br />
|
26 |
-
<p>This example shows the difference in GetOrderRefenceDetails
|
27 |
-
response when using the AddressConsent token field</p>
|
28 |
-
|
29 |
-
<p>Enter an order refererence for a order that is in the draft status,
|
30 |
-
along with the associated access token from the buyer session</p>
|
31 |
-
<p>This example is only available for US based customers of Login and Pay with Amazon.</p>
|
32 |
-
</div>
|
33 |
-
|
34 |
-
<div>
|
35 |
-
<form name="input" action="AddressConsentSampleResult.php">
|
36 |
-
OrderReferenceId: <input type="text" name="orderReferenceId"/><br/><br/>
|
37 |
-
Access Token: <input type="text" name="accessToken"/><br/><br/>
|
38 |
-
<input type="submit" value="Submit"/>
|
39 |
-
</form>
|
40 |
-
</div>
|
41 |
-
|
42 |
-
</body>
|
43 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/AddressConsentSampleResult.php
DELETED
@@ -1,133 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
19 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/WebServerExample.php';
|
20 |
-
require_once 'OffAmazonPaymentsService/Client.php';
|
21 |
-
require_once 'OffAmazonPaymentsService/Samples/AddressConsentSample.php';
|
22 |
-
|
23 |
-
/**
|
24 |
-
* This script shows the difference between the the getOrderReferenceDetails call with
|
25 |
-
* and without an LwA access token for a DRAFT Order Reference object
|
26 |
-
*
|
27 |
-
* Note that this sample is currently applicable only for US customers of
|
28 |
-
* Login and Pay with Amazon
|
29 |
-
*
|
30 |
-
*/
|
31 |
-
class AddressConsentSampleResult extends WebServerExample
|
32 |
-
{
|
33 |
-
/**
|
34 |
-
* Create a new instance of the Address Consent Example
|
35 |
-
*
|
36 |
-
* @param string $queryString url query string
|
37 |
-
*
|
38 |
-
* @return void
|
39 |
-
*/
|
40 |
-
public function __construct($queryString)
|
41 |
-
{
|
42 |
-
parent::__construct($queryString);
|
43 |
-
|
44 |
-
$this->exampleClass = new AddressConsentSample(
|
45 |
-
new OffAmazonPaymentsService_Client(),
|
46 |
-
$this->queryStringParams['orderReferenceId']
|
47 |
-
);
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Execute the example
|
52 |
-
*
|
53 |
-
* @return void
|
54 |
-
*/
|
55 |
-
public function run()
|
56 |
-
{
|
57 |
-
echo '<html><head><title>Address consent result</title></head><body>';
|
58 |
-
$noConsentResponse = $this->_getOrderReferenceDetailsWithoutAddressConsent();
|
59 |
-
$this->_validateOrderReferenceIsInACorrectState($noConsentResponse);
|
60 |
-
|
61 |
-
$consentResponse = $this->_getOrderReferenceDetailsWithAddressConsent();
|
62 |
-
|
63 |
-
$this->_printOrderReferenceResponses($noConsentResponse, $consentResponse);
|
64 |
-
echo '</body></html>';
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Get the order reference detail without passing in the address consent token
|
69 |
-
*
|
70 |
-
* @returns OffAmazonPayments_Model_GetOrderReferenceDetailsResponse object
|
71 |
-
*/
|
72 |
-
private function _getOrderReferenceDetailsWithoutAddressConsent()
|
73 |
-
{
|
74 |
-
return $this->callStepAndCheckForException('getOrderReferenceDetails');
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Validate that the order reference is in a correct state
|
79 |
-
*
|
80 |
-
* @param OffAmazonPayments_Model_GetOrderReferenceDetailsResponse in an unverified state
|
81 |
-
*
|
82 |
-
* @return void
|
83 |
-
* @throws ErrorException if the state does not match the expected state
|
84 |
-
*/
|
85 |
-
private function _validateOrderReferenceIsInACorrectState($getOrderReferenceDetailsResponse)
|
86 |
-
{
|
87 |
-
$this->exampleClass->validateOrderReferenceIsInACorrectState($getOrderReferenceDetailsResponse);
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Get the order reference details using the address consent token
|
92 |
-
*/
|
93 |
-
private function _getOrderReferenceDetailsWithAddressConsent()
|
94 |
-
{
|
95 |
-
return $this->callStepAndCheckForException(
|
96 |
-
'getOrderReferenceDetails',
|
97 |
-
array(
|
98 |
-
$this->queryStringParams['accessToken']
|
99 |
-
)
|
100 |
-
);
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Merge the two response into a single output buffer so that the contents are listed side by side
|
105 |
-
*
|
106 |
-
*/
|
107 |
-
private function _printOrderReferenceResponses($respWithoutConsent, $respWithConsent)
|
108 |
-
{
|
109 |
-
echo '<div style="width:100%">';
|
110 |
-
echo '<div style="float:left; width:45%">';
|
111 |
-
echo '<div style="font-weight:bold">GetOrderReferenceDetails result without address consent token</div>';
|
112 |
-
echo '<div>';
|
113 |
-
echo $this->printResponseToWebpage(
|
114 |
-
"printGetOrderReferenceDetailsResponse", array($respWithoutConsent)
|
115 |
-
);
|
116 |
-
echo '</div>';
|
117 |
-
echo '</div>';
|
118 |
-
echo '<div style="float:right; width:45%; border-left:dashed; padding-left:1%">';
|
119 |
-
echo '<div style="font-weight:bold">GetOrderReferenceDetails result with address consent token</div>';
|
120 |
-
echo '<div>';
|
121 |
-
echo $this->printResponseToWebpage(
|
122 |
-
"printGetOrderReferenceDetailsResponse", array($respWithConsent)
|
123 |
-
);
|
124 |
-
echo '</div>';
|
125 |
-
echo '</div>';
|
126 |
-
echo '</div>';
|
127 |
-
}
|
128 |
-
}
|
129 |
-
|
130 |
-
$addressConsentSampleResult = new AddressConsentSampleResult($_SERVER['QUERY_STRING']);
|
131 |
-
$addressConsentSampleResult->run();
|
132 |
-
|
133 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/AuthorizationNotificationSample.php
DELETED
@@ -1,176 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
|
17 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
18 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/NotificationSample.php';
|
19 |
-
require_once 'OffAmazonPaymentsNotifications/Model/AuthorizationNotification.php';
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Class for handling an authorization notification and print the
|
23 |
-
* contents to the log file
|
24 |
-
*
|
25 |
-
*/
|
26 |
-
class OffAmazonPaymentsNotifications_Samples_AuthorizationNotificationSample
|
27 |
-
extends OffAmazonPaymentsNotifications_Samples_NotificationSample
|
28 |
-
{
|
29 |
-
/**
|
30 |
-
* Create a new instance of the Authorization notification sample
|
31 |
-
*
|
32 |
-
* @param OffAmazonPaymentsNotifications_Model_AuthorizationNotification $notification notification
|
33 |
-
*
|
34 |
-
* @return void
|
35 |
-
*/
|
36 |
-
public function __construct(
|
37 |
-
OffAmazonPaymentsNotifications_Model_AuthorizationNotification $notification
|
38 |
-
) {
|
39 |
-
parent::__construct($notification);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Extract the name of the log file based on the notification
|
44 |
-
*
|
45 |
-
* @throws InvalidArgumentException
|
46 |
-
*
|
47 |
-
* @return string
|
48 |
-
*/
|
49 |
-
protected function getLogFileName()
|
50 |
-
{
|
51 |
-
if (!$this->notification->getAuthorizationDetails()->isSetAmazonAuthorizationId()) {
|
52 |
-
throw new InvalidArgumentException("AuthorizationAuthorizationId is NULL");
|
53 |
-
}
|
54 |
-
|
55 |
-
return $this->notification->getAuthorizationDetails()->getAmazonAuthorizationId()
|
56 |
-
. "_AuthorizationNotification.txt";
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Log the authorization detail contents
|
61 |
-
*
|
62 |
-
* @return void
|
63 |
-
*/
|
64 |
-
public function logNotificationContents()
|
65 |
-
{
|
66 |
-
$this->ipnLogFile->writeLine("Authorization Notification @ ".date("Y-m-d H:i:s") . " (GMT)");
|
67 |
-
$this->ipnLogFile->writeLine("=============================================================================");
|
68 |
-
if ($this->notification->isSetAuthorizationDetails()) {
|
69 |
-
$this->ipnLogFile->writeLine(" AuthorizeDetails");
|
70 |
-
$authorizationDetails = $this->notification->getAuthorizationDetails();
|
71 |
-
if ($authorizationDetails->isSetAmazonAuthorizationId()) {
|
72 |
-
$this->ipnLogFile->writeLine(" AmazonAuthorizationId");
|
73 |
-
$this->ipnLogFile->writeLine(" " . $authorizationDetails->getAmazonAuthorizationId());
|
74 |
-
}
|
75 |
-
if ($authorizationDetails->isSetAuthorizationReferenceId()) {
|
76 |
-
$this->ipnLogFile->writeLine(" AuthorizationReferenceId");
|
77 |
-
$this->ipnLogFile->writeLine(" " . $authorizationDetails->getAuthorizationReferenceId());
|
78 |
-
}
|
79 |
-
if ($authorizationDetails->isSetAuthorizationAmount()) {
|
80 |
-
$this->ipnLogFile->writeLine(" AuthorizationAmount");
|
81 |
-
$authorizationAmount = $authorizationDetails->getAuthorizationAmount();
|
82 |
-
if ($authorizationAmount->isSetAmount()) {
|
83 |
-
$this->ipnLogFile->writeLine(" Amount");
|
84 |
-
$this->ipnLogFile->writeLine(" " . $authorizationAmount->getAmount());
|
85 |
-
}
|
86 |
-
if ($authorizationAmount->isSetCurrencyCode()) {
|
87 |
-
$this->ipnLogFile->writeLine(" CurrencyCode");
|
88 |
-
$this->ipnLogFile->writeLine(" " . $authorizationAmount->getCurrencyCode());
|
89 |
-
}
|
90 |
-
}
|
91 |
-
if ($authorizationDetails->isSetCapturedAmount()) {
|
92 |
-
$this->ipnLogFile->writeLine(" CapturedAmount");
|
93 |
-
$capturedAmount = $authorizationDetails->getCapturedAmount();
|
94 |
-
if ($capturedAmount->isSetAmount()) {
|
95 |
-
$this->ipnLogFile->writeLine(" Amount");
|
96 |
-
$this->ipnLogFile->writeLine(" " . $capturedAmount->getAmount());
|
97 |
-
}
|
98 |
-
if ($capturedAmount->isSetCurrencyCode()) {
|
99 |
-
$this->ipnLogFile->writeLine(" CurrencyCode");
|
100 |
-
$this->ipnLogFile->writeLine(" " . $capturedAmount->getCurrencyCode());
|
101 |
-
}
|
102 |
-
}
|
103 |
-
if ($authorizationDetails->isSetAuthorizationFee()) {
|
104 |
-
$this->ipnLogFile->writeLine(" AuthorizationFee");
|
105 |
-
$authorizationFee = $authorizationDetails->getAuthorizationFee();
|
106 |
-
if ($authorizationFee->isSetAmount()) {
|
107 |
-
$this->ipnLogFile->writeLine(" Amount");
|
108 |
-
$this->ipnLogFile->writeLine(" " . $authorizationFee->getAmount());
|
109 |
-
}
|
110 |
-
if ($authorizationFee->isSetCurrencyCode()) {
|
111 |
-
$this->ipnLogFile->writeLine(" CurrencyCode");
|
112 |
-
$this->ipnLogFile->writeLine(" " . $authorizationFee->getCurrencyCode());
|
113 |
-
}
|
114 |
-
}
|
115 |
-
if ($authorizationDetails->isSetIdList()) {
|
116 |
-
$this->ipnLogFile->writeLine(" IdList");
|
117 |
-
$idList = $authorizationDetails->getIdList();
|
118 |
-
$memberList = $idList->getId();
|
119 |
-
foreach ($memberList as $member) {
|
120 |
-
$this->ipnLogFile->writeLine(" member");
|
121 |
-
$this->ipnLogFile->writeLine(" " . $member);
|
122 |
-
}
|
123 |
-
}
|
124 |
-
if ($authorizationDetails->isSetCreationTimestamp()) {
|
125 |
-
$this->ipnLogFile->writeLine(" CreationTimestamp");
|
126 |
-
$this->ipnLogFile->writeLine(" " . $authorizationDetails->getCreationTimestamp());
|
127 |
-
}
|
128 |
-
if ($authorizationDetails->isSetExpirationTimestamp()) {
|
129 |
-
$this->ipnLogFile->writeLine(" ExpirationTimestamp");
|
130 |
-
$this->ipnLogFile->writeLine(" " . $authorizationDetails->getExpirationTimestamp());
|
131 |
-
}
|
132 |
-
if ($authorizationDetails->isSetAddressVerificationCode()) {
|
133 |
-
$this->ipnLogFile->writeLine(" AddressVerificationCode");
|
134 |
-
$this->ipnLogFile->writeLine(" " . $authorizationDetails->getAddressVerificationCode());
|
135 |
-
}
|
136 |
-
if ($authorizationDetails->isSetAuthorizationStatus()) {
|
137 |
-
$this->ipnLogFile->writeLine(" AuthorizationStatus");
|
138 |
-
$authorizationStatus = $authorizationDetails->getAuthorizationStatus();
|
139 |
-
if ($authorizationStatus->isSetState()) {
|
140 |
-
$this->ipnLogFile->writeLine(" State");
|
141 |
-
$this->ipnLogFile->writeLine(" " . $authorizationStatus->getState());
|
142 |
-
}
|
143 |
-
if ($authorizationStatus->isSetLastUpdateTimestamp()) {
|
144 |
-
$this->ipnLogFile->writeLine(" LastUpdateTimestamp");
|
145 |
-
$this->ipnLogFile->writeLine(" " . $authorizationStatus->getLastUpdateTimestamp());
|
146 |
-
}
|
147 |
-
if ($authorizationStatus->isSetReasonCode()) {
|
148 |
-
$this->ipnLogFile->writeLine(" ReasonCode");
|
149 |
-
$this->ipnLogFile->writeLine(" " . $authorizationStatus->getReasonCode());
|
150 |
-
}
|
151 |
-
if ($authorizationStatus->isSetReasonDescription()) {
|
152 |
-
$this->ipnLogFile->writeLine(" ReasonDescription");
|
153 |
-
$this->ipnLogFile->writeLine(" " . $authorizationStatus->getReasonDescription());
|
154 |
-
}
|
155 |
-
}
|
156 |
-
if ($authorizationDetails->isSetOrderItemCategories()) {
|
157 |
-
$this->ipnLogFile->writeLine(" OrderItemCategories");
|
158 |
-
$orderItemCategories = $authorizationDetails->getOrderItemCategories();
|
159 |
-
$orderItemCategoryList = $orderItemCategories->getOrderItemCategory();
|
160 |
-
foreach ($orderItemCategoryList as $orderItemCategory) {
|
161 |
-
$this->ipnLogFile->writeLine(" OrderItemCategory");
|
162 |
-
$this->ipnLogFile->writeLine(" " . $orderItemCategory);
|
163 |
-
}
|
164 |
-
}
|
165 |
-
if ($authorizationDetails->isSetCaptureNow()) {
|
166 |
-
$this->ipnLogFile->writeLine(" CaptureNow");
|
167 |
-
$this->ipnLogFile->writeLine(" " . $authorizationDetails->getCaptureNow());
|
168 |
-
}
|
169 |
-
if ($authorizationDetails->isSetSoftDescriptor()) {
|
170 |
-
$this->ipnLogFile->writeLine(" SoftDescriptor");
|
171 |
-
$this->ipnLogFile->writeLine(" " . $authorizationDetails->getSoftDescriptor());
|
172 |
-
}
|
173 |
-
}
|
174 |
-
}
|
175 |
-
}
|
176 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/AutomaticPayments/address.php
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<?php
|
18 |
-
require_once realpath(dirname(__FILE__) . "/../.config.inc.php");
|
19 |
-
require_once("OffAmazonPaymentsService/Client.php");
|
20 |
-
$client = new OffAmazonPaymentsService_Client();
|
21 |
-
$merchantValues = $client->getMerchantValues();
|
22 |
-
?>
|
23 |
-
|
24 |
-
<!DOCTYPE html>
|
25 |
-
<html>
|
26 |
-
<head>
|
27 |
-
<title>Address page</title>
|
28 |
-
<script type="text/javascript">
|
29 |
-
window.onAmazonLoginReady = function () {
|
30 |
-
amazon.Login.setClientId('<?php print $merchantValues->getClientId(); ?>');
|
31 |
-
};
|
32 |
-
</script>
|
33 |
-
<script type="text/javascript" src=<?php print "'" . $merchantValues->getWidgetUrl() . "'"; ?> ></script>
|
34 |
-
</head>
|
35 |
-
<body>
|
36 |
-
<div id="AmazonAddressWidget"></div>
|
37 |
-
|
38 |
-
<p>Click <a id="WalletLink" href="">here</a> to go to the
|
39 |
-
wallet page once you have completed the signin</p>
|
40 |
-
|
41 |
-
<script type='text/javascript' >
|
42 |
-
function getParamFromQueryString(name, url) {
|
43 |
-
var regexString = "[\\?&]" + name + "=([^&#]*)";
|
44 |
-
var regex = new RegExp(regexString);
|
45 |
-
var results = regex.exec(url);
|
46 |
-
|
47 |
-
var result = null;
|
48 |
-
|
49 |
-
if (results != null && results.length >= 2 && results[1] != null) {
|
50 |
-
var result = results[1].replace("?" + name);
|
51 |
-
}
|
52 |
-
|
53 |
-
return result;
|
54 |
-
}
|
55 |
-
|
56 |
-
var url = window.location.href;
|
57 |
-
var session = getParamFromQueryString("session", url);
|
58 |
-
var access_token = getParamFromQueryString("access_token", url);
|
59 |
-
|
60 |
-
if (session == null && access_token == null) {
|
61 |
-
alert("Missing query string parameters from request, verify that session & access_token are present.");
|
62 |
-
} else {
|
63 |
-
document.getElementById("WalletLink").href = "wallet.php?session=" + session + "&access_token=" + access_token;
|
64 |
-
}
|
65 |
-
|
66 |
-
new OffAmazonPayments.Widgets.AddressBook({
|
67 |
-
sellerId: <?php print "\"" . $merchantValues->getMerchantId() . "\""; ?>,
|
68 |
-
amazonBillingAgreementId: session,
|
69 |
-
displayMode: 'Edit',
|
70 |
-
design:{size: { width:'400', height:'228' } },
|
71 |
-
onAddressSelect: function(billingAgreement) {
|
72 |
-
|
73 |
-
},
|
74 |
-
onError: function(error) {
|
75 |
-
alert(error.getErrorCode() + ": " + error.getErrorMessage());
|
76 |
-
}
|
77 |
-
}).bind("AmazonAddressWidget");
|
78 |
-
</script>
|
79 |
-
</body>
|
80 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/AutomaticPayments/signin.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<!DOCTYPE html>
|
18 |
-
<?php
|
19 |
-
require_once realpath ( dirname ( __FILE__ ) . "/../.config.inc.php" );
|
20 |
-
require_once ("OffAmazonPaymentsService/Client.php");
|
21 |
-
$client = new OffAmazonPaymentsService_Client ();
|
22 |
-
$merchantValues = $client->getMerchantValues ();
|
23 |
-
?>
|
24 |
-
|
25 |
-
<html>
|
26 |
-
<head>
|
27 |
-
<title>Login page</title>
|
28 |
-
<script type="text/javascript">
|
29 |
-
window.onAmazonLoginReady = function () {
|
30 |
-
amazon.Login.setClientId('<?php print $merchantValues->getClientId(); ?>');
|
31 |
-
};
|
32 |
-
</script>
|
33 |
-
<script type="text/javascript"
|
34 |
-
src=<?php print "'" . $merchantValues->getWidgetUrl() . "'"; ?>>
|
35 |
-
</script>
|
36 |
-
</head>
|
37 |
-
<body>
|
38 |
-
<div id="AmazonPayButton"></div>
|
39 |
-
<script type='text/javascript'>
|
40 |
-
var authRequest;
|
41 |
-
OffAmazonPayments.Button("AmazonPayButton", "<?php print $merchantValues->getMerchantId(); ?>", {
|
42 |
-
type: "PwA",
|
43 |
-
useAmazonAddressBook: true,
|
44 |
-
agreementType: 'BillingAgreement',
|
45 |
-
authorization: function() {
|
46 |
-
loginOptions =
|
47 |
-
{ scope: "profile payments:widget payments:shipping_address" };
|
48 |
-
authRequest = amazon.Login.authorize(loginOptions);
|
49 |
-
},
|
50 |
-
onSignIn: function(billingAgreement) {
|
51 |
-
// The following OAuth 2 response parameters will be included in
|
52 |
-
// the query string when the customer's browser is redirected to
|
53 |
-
// the URL below: access_token, token_type, expires_in, and scope.
|
54 |
-
authRequest.onComplete("address.php?session="
|
55 |
-
+ billingAgreement.getAmazonBillingAgreementId());
|
56 |
-
},
|
57 |
-
onError: function(error) {
|
58 |
-
alert(error.getErrorCode() + ": " + error.getErrorMessage());
|
59 |
-
}
|
60 |
-
});
|
61 |
-
</script>
|
62 |
-
<p>Sign in with a test buyer account to redirect to the address widget page</p>
|
63 |
-
</body>
|
64 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/AutomaticPayments/wallet.php
DELETED
@@ -1,106 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<!DOCTYPE html>
|
18 |
-
<?php
|
19 |
-
require_once realpath ( dirname ( __FILE__ ) . "/../.config.inc.php" );
|
20 |
-
require_once ("OffAmazonPaymentsService/Client.php");
|
21 |
-
$client = new OffAmazonPaymentsService_Client ();
|
22 |
-
$merchantValues = $client->getMerchantValues ();
|
23 |
-
?>
|
24 |
-
|
25 |
-
<html>
|
26 |
-
<head>
|
27 |
-
<title>Wallet page</title>
|
28 |
-
<script type="text/javascript">
|
29 |
-
window.onAmazonLoginReady = function () {
|
30 |
-
amazon.Login.setClientId('<?php print $merchantValues->getClientId(); ?>');
|
31 |
-
};
|
32 |
-
</script>
|
33 |
-
<script type="text/javascript"
|
34 |
-
src=<?php print "'" . $merchantValues->getWidgetUrl() . "'"; ?>>
|
35 |
-
</script>
|
36 |
-
</head>
|
37 |
-
<body>
|
38 |
-
<div id="AmazonWalletWidget"></div>
|
39 |
-
<div id="AmazonConsentWidget"></div>
|
40 |
-
<div id="SessionInformation"></div>
|
41 |
-
|
42 |
-
<script type='text/javascript'>
|
43 |
-
function getParamFromQueryString(name, url) {
|
44 |
-
var regexString = "[\\?&]" + name + "=([^&#]*)";
|
45 |
-
var regex = new RegExp(regexString);
|
46 |
-
var results = regex.exec(url);
|
47 |
-
|
48 |
-
var result = null;
|
49 |
-
|
50 |
-
if (results != null && results.length >= 2 && results[1] != null ) {
|
51 |
-
var result = results[1].replace("?" + name);
|
52 |
-
}
|
53 |
-
|
54 |
-
return result;
|
55 |
-
}
|
56 |
-
|
57 |
-
var url = window.location.href;
|
58 |
-
var session = getParamFromQueryString("session", url);
|
59 |
-
var access_token = getParamFromQueryString("access_token", url);
|
60 |
-
|
61 |
-
if (session == null && access_token == null) {
|
62 |
-
alert("Missing query string parameters from request, verify that session & access_token are present.");
|
63 |
-
} else {
|
64 |
-
document.getElementById("SessionInformation").innerHTML = "Billing Agreement Number: " + session + "<p> Access Token : " + access_token;
|
65 |
-
}
|
66 |
-
|
67 |
-
new OffAmazonPayments.Widgets.Wallet({
|
68 |
-
sellerId: <?php print "\"" . $merchantValues->getMerchantId() . "\""; ?>,
|
69 |
-
amazonBillingAgreementId: session,
|
70 |
-
displayMode: 'Edit',
|
71 |
-
design: { size: { width: '400', height: '228' } },
|
72 |
-
onPaymentSelect: function (billingAgreement) {
|
73 |
-
|
74 |
-
},
|
75 |
-
onError: function (error) {
|
76 |
-
alert(error.getErrorCode() + ": " + error.getErrorMessage());
|
77 |
-
}
|
78 |
-
}).bind("AmazonWalletWidget");
|
79 |
-
|
80 |
-
new OffAmazonPayments.Widgets.Consent({
|
81 |
-
sellerId: <?php print "\"" . $merchantValues->getMerchantId() . "\""; ?>,
|
82 |
-
// amazonBillingAgreementId obtained from createBillingAgreement
|
83 |
-
amazonBillingAgreementId: session,
|
84 |
-
design: { size: { width: '400', height: '260' } },
|
85 |
-
onRender: function(billingAgreementConsentStatus){
|
86 |
-
// Called after widget renders
|
87 |
-
// buyerBillingAgreementConsentStatus =
|
88 |
-
// billingAgreementConsentStatus.getConsentStatus();
|
89 |
-
// getConsentStatus returns true or false
|
90 |
-
// true – checkbox is selected
|
91 |
-
},// false – checkbox is unselected - default
|
92 |
-
onConsent: function(billingAgreementConsentStatus) {
|
93 |
-
// buyerBillingAgreementConsentStatus =
|
94 |
-
// billingAgreementConsentStatus.getConsentStatus();
|
95 |
-
// getConsentStatus returns true or false
|
96 |
-
// true – checkbox is selected – buyer has consented
|
97 |
-
// false – checkbox is unselected – buyer has not consented
|
98 |
-
// Replace this code with the action that you want to perform
|
99 |
-
// after the consent checkbox is selected/unselected.
|
100 |
-
},
|
101 |
-
onError: function(error) {
|
102 |
-
}// your error handling code
|
103 |
-
}).bind("AmazonConsentWidget");
|
104 |
-
</script>
|
105 |
-
</body>
|
106 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/AutomaticPaymentsSimpleCheckoutDataInput.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/* *****************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<html>
|
18 |
-
<head>
|
19 |
-
<title>Automatic Payment Simple Checkout Example</title>
|
20 |
-
</head>
|
21 |
-
<body>
|
22 |
-
<h1>Automatic Payment Simple Checkout Example</h1>
|
23 |
-
|
24 |
-
<h2>This page will demonstrates a typical use case of automatic
|
25 |
-
payment. With a buyer consented billing agreement, the cost of each
|
26 |
-
payment is calculated based on the buyer selected address. And then
|
27 |
-
three payments are performed on this billing agreement.</h2>
|
28 |
-
|
29 |
-
<form name="input" action="AutomaticPaymentsSimpleCheckoutResult.php">
|
30 |
-
Buyer Consented Billing Agreement Id:
|
31 |
-
<input type="text" name="billingAgreementId" /><br />
|
32 |
-
Shipping speed:
|
33 |
-
<select name="shipping">
|
34 |
-
<option value="1">Overnight</option>
|
35 |
-
<option value="2">2-day shipping</option>
|
36 |
-
<option value="3">5-day shipping</option>
|
37 |
-
</select><br />
|
38 |
-
Amount of Each Payment:
|
39 |
-
<input type="text"name="paymentAmount" /><br />
|
40 |
-
3 payments of above amount will be performed in this example.<br />
|
41 |
-
<input type="submit" value="Submit" />
|
42 |
-
</form>
|
43 |
-
</body>
|
44 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/AutomaticPaymentsSimpleCheckoutResult.php
DELETED
@@ -1,326 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
18 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/WebServerExample.php';
|
19 |
-
require_once 'OffAmazonPaymentsService/Client.php';
|
20 |
-
require_once 'OffAmazonPaymentsService/Samples/AutomaticPaymentsSimpleCheckoutExample.php';
|
21 |
-
|
22 |
-
/**
|
23 |
-
* This script simulates a simple checkout example for automatic payment
|
24 |
-
* and generates html for the page
|
25 |
-
*
|
26 |
-
*/
|
27 |
-
class AutomaticPaymentsSimpleCheckoutResult extends WebServerExample
|
28 |
-
{
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Create a new instance of the Automatic Payment Simple Checkout Example
|
32 |
-
*
|
33 |
-
* @param string $queryString url query string
|
34 |
-
*
|
35 |
-
* @return void
|
36 |
-
*/
|
37 |
-
public function __construct ($queryString)
|
38 |
-
{
|
39 |
-
parent::__construct($queryString);
|
40 |
-
|
41 |
-
$this->exampleClass = new AutomaticPaymentsSimpleCheckoutExample(
|
42 |
-
new OffAmazonPaymentsService_Client(),
|
43 |
-
$this->queryStringParams['billingAgreementId']);
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Execute the example
|
48 |
-
*
|
49 |
-
* @return void
|
50 |
-
*/
|
51 |
-
public function run ()
|
52 |
-
{
|
53 |
-
// Calculate payment amount based on buyer selected shipping address
|
54 |
-
$paymentTotal = $this->_calculatePaymentAmountBasedOnBuyerDestinationAddress();
|
55 |
-
|
56 |
-
// Added custom information and seller note to the billing agreement
|
57 |
-
$this->_addSellerInformationToBillingAgreement();
|
58 |
-
|
59 |
-
/*
|
60 |
-
* Confirm billing agreement. The billing agreement has to be consented
|
61 |
-
* by buyer before you confirm the billing agreement.
|
62 |
-
*/
|
63 |
-
$this->_confirmBillingAgreement();
|
64 |
-
|
65 |
-
// Validate billing agreement (optional)
|
66 |
-
$this->_validateBillingAgreement();
|
67 |
-
|
68 |
-
// First payment
|
69 |
-
$amazonAuthorizationId1 = $this->_authorizePaymentAmount($paymentTotal,
|
70 |
-
$this->queryStringParams['billingAgreementId'] . "-A01");
|
71 |
-
$this->_waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId1);
|
72 |
-
$this->_capturePaymentAmount($paymentTotal, $amazonAuthorizationId1);
|
73 |
-
|
74 |
-
// Second payment with capture now
|
75 |
-
$this->_authorizePaymentAmountWithCaptureNow($paymentTotal,
|
76 |
-
$this->queryStringParams['billingAgreementId'] . "-A02");
|
77 |
-
|
78 |
-
// Third payment with capture now
|
79 |
-
$this->_authorizePaymentAmountWithCaptureNow($paymentTotal,
|
80 |
-
$this->queryStringParams['billingAgreementId'] . "-A03");
|
81 |
-
|
82 |
-
// Close the billing agreement when this automatic payment is no longer
|
83 |
-
// needed
|
84 |
-
$this->_closeBillingAgreement();
|
85 |
-
|
86 |
-
print HTML_LB . HTML_LB . "Automatic payment simple checkout sample is complete";
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Retreive the current information about the order as indicated by the buyer
|
91 |
-
* and calculate the total amount to charge, based on address destination state
|
92 |
-
* and country
|
93 |
-
*
|
94 |
-
* @return string total amount for the order that the merchant will
|
95 |
-
* charge the buyer
|
96 |
-
*/
|
97 |
-
private function _calculatePaymentAmountBasedOnBuyerDestinationAddress ()
|
98 |
-
{
|
99 |
-
$response = $this->callStepAndCheckForException('getBillingAgreementDetails');
|
100 |
-
|
101 |
-
$this->printResponseToWebpage("printGetBillingAgreementDetailsResponse", array(
|
102 |
-
$response
|
103 |
-
));
|
104 |
-
|
105 |
-
$paymentAmountPreTaxAndShipping = $this->_getPreTaxAndShippingPaymentAmountFromQueryParams();
|
106 |
-
$shippingType = $this->_getShippingTypeFromQueryParams();
|
107 |
-
|
108 |
-
return $this->exampleClass->calculatePaymentAmountBasedOnBuyerDetails(
|
109 |
-
$response->getGetBillingAgreementDetailsResult()
|
110 |
-
->getBillingAgreementDetails(), $paymentAmountPreTaxAndShipping, $shippingType);
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Add seller information by making the call to setBillingAgreementDetails
|
115 |
-
* with seller notes and custom information.
|
116 |
-
*
|
117 |
-
*/
|
118 |
-
private function _addSellerInformationToBillingAgreement ()
|
119 |
-
{
|
120 |
-
$response = $this->callStepAndCheckForException('addSellerInformationToBillingAgreement');
|
121 |
-
$this->printResponseToWebpage("printSetBillingAgreementDetailsResponse", array(
|
122 |
-
$response
|
123 |
-
));
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Confirm the billing agreement
|
128 |
-
*
|
129 |
-
* @return void
|
130 |
-
*/
|
131 |
-
private function _confirmBillingAgreement ()
|
132 |
-
{
|
133 |
-
$response = $this->callStepAndCheckForException('confirmBillingAgreement');
|
134 |
-
|
135 |
-
$this->printResponseToWebpage("printConfirmBillingAgreementResponse", array(
|
136 |
-
$response
|
137 |
-
));
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Check that the billing agreement is in valid status and the selected payment
|
142 |
-
* method is also valid.
|
143 |
-
*/
|
144 |
-
private function _validateBillingAgreement ()
|
145 |
-
{
|
146 |
-
$response = $this->callStepAndCheckForException('validateBillingAgreement');
|
147 |
-
|
148 |
-
$this->printResponseToWebpage("printValidateBillingAgreementResponse", array(
|
149 |
-
$response
|
150 |
-
));
|
151 |
-
}
|
152 |
-
|
153 |
-
/**
|
154 |
-
* Perform authorize call on billing agreement
|
155 |
-
*
|
156 |
-
* @param float $authorizationAmount
|
157 |
-
* @param string $authorizationReferenceId
|
158 |
-
*/
|
159 |
-
private function _authorizePaymentAmount ($authorizationAmount, $authorizationReferenceId)
|
160 |
-
{
|
161 |
-
$response = $this->callStepAndCheckForException('authorizePaymentAmount',
|
162 |
-
array(
|
163 |
-
$authorizationAmount,
|
164 |
-
$authorizationReferenceId
|
165 |
-
));
|
166 |
-
|
167 |
-
$this->printResponseToWebpage("printAuthorizeOnBillingAgreementResponse", array(
|
168 |
-
$response
|
169 |
-
));
|
170 |
-
|
171 |
-
return getAmazonAuthorizationIdFromAuthorizeOnBillingAgreementResponse($response);
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Perform authorize call on billing agreement
|
176 |
-
*
|
177 |
-
* @param float $authorizationAmount
|
178 |
-
* @param string $authorizationReferenceId
|
179 |
-
*/
|
180 |
-
private function _authorizePaymentAmountWithCaptureNow ($authorizationAmount,
|
181 |
-
$authorizationReferenceId)
|
182 |
-
{
|
183 |
-
$response = $this->callStepAndCheckForException('authorizePaymentAmountWithCaptureNow',
|
184 |
-
array(
|
185 |
-
$authorizationAmount,
|
186 |
-
$authorizationReferenceId
|
187 |
-
));
|
188 |
-
|
189 |
-
$this->printResponseToWebpage("printAuthorizeOnBillingAgreementResponse", array(
|
190 |
-
$response
|
191 |
-
));
|
192 |
-
|
193 |
-
return getAmazonAuthorizationIdFromAuthorizeOnBillingAgreementResponse($response);
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Check that we have received an IPN notification for the authorization
|
198 |
-
*
|
199 |
-
* For PHP, there is an IPN handler that will write the contents of the IPN to
|
200 |
-
* a file in the format of
|
201 |
-
* <amazonOrderReferenceId>_<amazonAuthorizationId>_Authorization.
|
202 |
-
* This method will check for the presnece of this file
|
203 |
-
* and will loop/timeout until the notification has been handled.
|
204 |
-
*
|
205 |
-
* Merchants can use alternative approaches such as memory caches,
|
206 |
-
* shared memory or database storage so that scripts serving user
|
207 |
-
* pages are able to check on the status of a notification
|
208 |
-
*
|
209 |
-
* @param string $amazonAuthorizationId authorization transaction to query
|
210 |
-
*
|
211 |
-
* @return GetAuthorizationDetailsResponse
|
212 |
-
*/
|
213 |
-
private function _waitUntilAuthorizationProcessingIsCompleted ($amazonAuthorizationId)
|
214 |
-
{
|
215 |
-
// Check for the presence of the ipn notification
|
216 |
-
$this->waitForNotificationToBeProcessedBeforeContinuing($amazonAuthorizationId,
|
217 |
-
"AuthorizationNotification");
|
218 |
-
}
|
219 |
-
|
220 |
-
/**
|
221 |
-
* Display additional information about a completed authorization
|
222 |
-
*
|
223 |
-
* Once an IPN has been received to notify the transition of an IPN to
|
224 |
-
* one of the terminal states, the merchant may optionally call
|
225 |
-
* GetAuthorizationDetails to obtain additional information about the authorization.
|
226 |
-
*
|
227 |
-
* In countries which require VAT invoicing, this approach will allow you to obtain
|
228 |
-
* the buyers billing address so that the invocing requirements can be met.
|
229 |
-
*/
|
230 |
-
private function _getAdditionalInformationForProcessedAuthorization ($amazonAuthorizationId)
|
231 |
-
{
|
232 |
-
// Notification is present, go and get the full
|
233 |
-
// information for this notification
|
234 |
-
$response = $this->callStepAndCheckForException('getAuthorizationDetails',
|
235 |
-
array(
|
236 |
-
$amazonAuthorizationId
|
237 |
-
));
|
238 |
-
|
239 |
-
$this->printResponseToWebpage("printGetAuthorizationDetailsResponse", array(
|
240 |
-
$response
|
241 |
-
));
|
242 |
-
|
243 |
-
validateThatAuthorizationIsOpen($response);
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* Perform the capture call for the order
|
248 |
-
* Throw an exception if the capture is not processed, as this is the
|
249 |
-
* expected result
|
250 |
-
*
|
251 |
-
* @param float $captureAmount amount to capture from the buyer
|
252 |
-
* @param string $amazonAuthorizationId auth id to perform the capture on
|
253 |
-
*
|
254 |
-
* @return no response
|
255 |
-
*/
|
256 |
-
private function _capturePaymentAmount ($captureAmount, $amazonAuthorizationId)
|
257 |
-
{
|
258 |
-
$response = $this->callStepAndCheckForException('captureOrderAmount',
|
259 |
-
array(
|
260 |
-
$captureAmount,
|
261 |
-
$amazonAuthorizationId,
|
262 |
-
$this->currencyCode
|
263 |
-
));
|
264 |
-
|
265 |
-
$captureId = $response->getCaptureResult()
|
266 |
-
->getCaptureDetails()
|
267 |
-
->getAmazonCaptureId();
|
268 |
-
|
269 |
-
// Check for the presence of the ipn notification
|
270 |
-
$this->waitForNotificationToBeProcessedBeforeContinuing($captureId, "CaptureNotification");
|
271 |
-
|
272 |
-
$response = $this->callStepAndCheckForException('getCaptureDetails', array(
|
273 |
-
$captureId
|
274 |
-
));
|
275 |
-
|
276 |
-
validateThatCaptureIsCompleted($response->getGetCaptureDetailsResult());
|
277 |
-
$this->printResponseToWebpage("printGetCaptureDetailsResponse", array(
|
278 |
-
$response
|
279 |
-
));
|
280 |
-
}
|
281 |
-
|
282 |
-
/**
|
283 |
-
* Close this billing agreement to indicate that the automatic payment is complete, and
|
284 |
-
* no further payments will be performed on this billing agreement
|
285 |
-
*
|
286 |
-
* @return no value
|
287 |
-
*/
|
288 |
-
private function _closeBillingAgreement ()
|
289 |
-
{
|
290 |
-
$response = $this->callStepAndCheckForException('closeBillingAgreement');
|
291 |
-
$this->printResponseToWebpage("printCloseBillingAgreementResponse", array(
|
292 |
-
$response
|
293 |
-
));
|
294 |
-
}
|
295 |
-
|
296 |
-
/**
|
297 |
-
* Capture the pre tax order amount from standard input,
|
298 |
-
* making sure that it is a numeric string
|
299 |
-
*
|
300 |
-
* @return string total amount of the order before tax and shipping charges
|
301 |
-
*/
|
302 |
-
private function _getPreTaxAndShippingPaymentAmountFromQueryParams ()
|
303 |
-
{
|
304 |
-
$orderAmount = $this->queryStringParams['paymentAmount'];
|
305 |
-
return $orderAmount;
|
306 |
-
}
|
307 |
-
|
308 |
-
/**
|
309 |
-
* Capture the shipping type for this order, which determines
|
310 |
-
* the shipping charge
|
311 |
-
*
|
312 |
-
* @return number selected shipping type index
|
313 |
-
*/
|
314 |
-
private function _getShippingTypeFromQueryParams ()
|
315 |
-
{
|
316 |
-
$shippingType = $this->queryStringParams['shipping'];
|
317 |
-
return $shippingType - 1;
|
318 |
-
}
|
319 |
-
|
320 |
-
}
|
321 |
-
|
322 |
-
$AutomaticPaymentsSimpleCheckoutResult = new AutomaticPaymentsSimpleCheckoutResult(
|
323 |
-
$_SERVER['QUERY_STRING']);
|
324 |
-
$AutomaticPaymentsSimpleCheckoutResult->run();
|
325 |
-
|
326 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/BillingAgreementNotificationSample.php
DELETED
@@ -1,168 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
17 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/NotificationSample.php';
|
18 |
-
require_once 'OffAmazonPaymentsNotifications/Model/BillingAgreementNotification.php';
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Class for handling an order reference notification and print the
|
22 |
-
* contents to the log file
|
23 |
-
*
|
24 |
-
*/
|
25 |
-
class OffAmazonPaymentsNotifications_Samples_BillingAgreementNotificationSample extends OffAmazonPaymentsNotifications_Samples_NotificationSample
|
26 |
-
{
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Create a new instance of the billing agreement notification sample
|
30 |
-
*
|
31 |
-
* @param OffAmazonPaymentsNotifications_Model_BillingAgreementNotification $notification notification
|
32 |
-
*
|
33 |
-
* @return void
|
34 |
-
*/
|
35 |
-
public function __construct (
|
36 |
-
OffAmazonPaymentsNotifications_Model_BillingAgreementNotification $notification)
|
37 |
-
{
|
38 |
-
parent::__construct($notification);
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Extract the name of the log file based on the notification
|
43 |
-
*
|
44 |
-
* @throws InvalidArgumentException
|
45 |
-
*
|
46 |
-
* @return string
|
47 |
-
*/
|
48 |
-
protected function getLogFileName ()
|
49 |
-
{
|
50 |
-
if (! $this->notification->getBillingAgreement()->isSetAmazonBillingAgreementId()) {
|
51 |
-
throw new InvalidArgumentException("BillingAgreementId is NULL");
|
52 |
-
}
|
53 |
-
|
54 |
-
return $this->notification->getBillingAgreement()->getAmazonBillingAgreementId() .
|
55 |
-
"_BillingAgreementNotification.txt";
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Log the notification contents
|
60 |
-
*
|
61 |
-
* @return void
|
62 |
-
*/
|
63 |
-
protected function logNotificationContents ()
|
64 |
-
{
|
65 |
-
$this->ipnLogFile->writeLine("BillingAgreement @ " . date("Y-m-d H:i:s"));
|
66 |
-
$this->ipnLogFile->writeLine(
|
67 |
-
"=============================================================================");
|
68 |
-
if ($this->notification->isSetBillingAgreement()) {
|
69 |
-
$this->ipnLogFile->writeLine(" BillingAgreement");
|
70 |
-
$billingAgreement = $this->notification->getBillingAgreement();
|
71 |
-
if ($billingAgreement->isSetAmazonBillingAgreementId()) {
|
72 |
-
$this->ipnLogFile->writeLine(" AmazonBillingAgreementId");
|
73 |
-
$this->ipnLogFile->writeLine(
|
74 |
-
" " . $billingAgreement->getAmazonBillingAgreementId());
|
75 |
-
}
|
76 |
-
if ($billingAgreement->isSetSellerBillingAgreementAttributes()) {
|
77 |
-
$this->ipnLogFile->writeLine(" SellerBillingAgreementAttributes");
|
78 |
-
$sellerBillingAgreementAttributes = $billingAgreement->getSellerBillingAgreementAttributes();
|
79 |
-
if ($sellerBillingAgreementAttributes->isSetSellerId()) {
|
80 |
-
$this->ipnLogFile->writeLine(" SellerId");
|
81 |
-
$this->ipnLogFile->writeLine(
|
82 |
-
" " . $sellerBillingAgreementAttributes->getSellerId());
|
83 |
-
}
|
84 |
-
if ($sellerBillingAgreementAttributes->isSetSellerBillingAgreementId()) {
|
85 |
-
$this->ipnLogFile->writeLine(" SellerBillingAgreementId");
|
86 |
-
$this->ipnLogFile->writeLine(
|
87 |
-
" " .
|
88 |
-
$sellerBillingAgreementAttributes->getSellerBillingAgreementId());
|
89 |
-
}
|
90 |
-
}
|
91 |
-
if ($billingAgreement->isSetBillingAgreementLimits()) {
|
92 |
-
$this->ipnLogFile->writeLine(" BillingAgreementLimits");
|
93 |
-
$billingAgreementLimits = $billingAgreement->getBillingAgreementLimits();
|
94 |
-
if ($billingAgreementLimits->isSetAmountLimitPerTimePeriod()) {
|
95 |
-
$this->ipnLogFile->writeLine(" AmountLimitPerTimePeriod");
|
96 |
-
$amountLimitPerTimePeriod = $billingAgreementLimits->getAmountLimitPerTimePeriod();
|
97 |
-
if ($amountLimitPerTimePeriod->isSetAmount()) {
|
98 |
-
$this->ipnLogFile->writeLine(" Amount");
|
99 |
-
$this->ipnLogFile->writeLine(
|
100 |
-
" " . $amountLimitPerTimePeriod->getAmount());
|
101 |
-
}
|
102 |
-
if ($amountLimitPerTimePeriod->isSetCurrencyCode()) {
|
103 |
-
$this->ipnLogFile->writeLine(" CurrencyCode");
|
104 |
-
$this->ipnLogFile->writeLine(
|
105 |
-
" " . $amountLimitPerTimePeriod->getCurrencyCode());
|
106 |
-
}
|
107 |
-
}
|
108 |
-
if ($billingAgreementLimits->isSetTimePeriodStartDate()) {
|
109 |
-
$this->ipnLogFile->writeLine(" TimePeriodStartDate");
|
110 |
-
$this->ipnLogFile->writeLine(
|
111 |
-
" " . $billingAgreementLimits->getTimePeriodStartDate());
|
112 |
-
}
|
113 |
-
if ($billingAgreementLimits->isSetTimePeriodEndDate()) {
|
114 |
-
$this->ipnLogFile->writeLine(" TimePeriodEndDate");
|
115 |
-
$this->ipnLogFile->writeLine(
|
116 |
-
" " . $billingAgreementLimits->getTimePeriodEndDate());
|
117 |
-
}
|
118 |
-
if ($billingAgreementLimits->isSetCurrentRemainingBalance()) {
|
119 |
-
$this->ipnLogFile->writeLine(" CurrentRemainingBalance");
|
120 |
-
$currentRemainingBalance = $billingAgreementLimits->getCurrentRemainingBalance();
|
121 |
-
if ($currentRemainingBalance->isSetAmount()) {
|
122 |
-
$this->ipnLogFile->writeLine(" Amount");
|
123 |
-
$this->ipnLogFile->writeLine(
|
124 |
-
" " . $currentRemainingBalance->getAmount());
|
125 |
-
}
|
126 |
-
if ($currentRemainingBalance->isSetCurrencyCode()) {
|
127 |
-
$this->ipnLogFile->writeLine(" CurrencyCode");
|
128 |
-
$this->ipnLogFile->writeLine(
|
129 |
-
" " . $currentRemainingBalance->getCurrencyCode());
|
130 |
-
}
|
131 |
-
}
|
132 |
-
}
|
133 |
-
if ($billingAgreement->isSetBillingAgreementStatus()) {
|
134 |
-
$this->ipnLogFile->writeLine(" BillingAgreementStatus");
|
135 |
-
$billingAgreementStatus = $billingAgreement->getBillingAgreementStatus();
|
136 |
-
if ($billingAgreementStatus->isSetState()) {
|
137 |
-
$this->ipnLogFile->writeLine(" State");
|
138 |
-
$this->ipnLogFile->writeLine(" " . $billingAgreementStatus->getState());
|
139 |
-
}
|
140 |
-
if ($billingAgreementStatus->isSetLastUpdateTimestamp()) {
|
141 |
-
$this->ipnLogFile->writeLine(" LastUpdateTimestamp");
|
142 |
-
$this->ipnLogFile->writeLine(
|
143 |
-
" " . $billingAgreementStatus->getLastUpdateTimestamp());
|
144 |
-
}
|
145 |
-
if ($billingAgreementStatus->isSetReasonCode()) {
|
146 |
-
$this->ipnLogFile->writeLine(" ReasonCode");
|
147 |
-
$this->ipnLogFile->writeLine(
|
148 |
-
" " . $billingAgreementStatus->getReasonCode());
|
149 |
-
}
|
150 |
-
if ($billingAgreementStatus->isSetReasonDescription()) {
|
151 |
-
$this->ipnLogFile->writeLine(" ReasonDescription");
|
152 |
-
$this->ipnLogFile->writeLine(
|
153 |
-
" " . $billingAgreementStatus->getReasonDescription());
|
154 |
-
}
|
155 |
-
}
|
156 |
-
if ($billingAgreement->isSetCreationTimestamp()) {
|
157 |
-
$this->ipnLogFile->writeLine(" CreationTimestamp");
|
158 |
-
$this->ipnLogFile->writeLine(" " . $billingAgreement->getCreationTimestamp());
|
159 |
-
}
|
160 |
-
if ($billingAgreement->isSetBillingAgreementConsent()) {
|
161 |
-
$this->ipnLogFile->writeLine(" BillingAgreementConsent");
|
162 |
-
$this->ipnLogFile->writeLine(
|
163 |
-
" " . $billingAgreement->getBillingAgreementConsent());
|
164 |
-
}
|
165 |
-
}
|
166 |
-
}
|
167 |
-
}
|
168 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/CancellationDataInput.php
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<html>
|
18 |
-
<head>
|
19 |
-
<title>Cancellation Example</title>
|
20 |
-
</head>
|
21 |
-
<body>
|
22 |
-
<h1>Cancellation Example</h1>
|
23 |
-
|
24 |
-
<h2>This page demonstrates a merchant use case where the order needs to be
|
25 |
-
cancelled before the first cancelOrderReference has been performed
|
26 |
-
<br/><br/>
|
27 |
-
This is done using the CancelOrderReference call to cancel to order,
|
28 |
-
and can be called prior to the first cancelOrderReference has been performed.
|
29 |
-
<br/><br/>
|
30 |
-
If a cancelOrderReference has been performed, then the merchant will need to close
|
31 |
-
the order reference if there is an outstanding total and perform a
|
32 |
-
refund on existing cancelOrderReferenced amounts if required.</h2>
|
33 |
-
|
34 |
-
<br/><br/>
|
35 |
-
|
36 |
-
<form name="input" action="CancellationResult.php">
|
37 |
-
Order Reference Id: <input type="text" name="orderReferenceId"/>
|
38 |
-
<br/><br/>
|
39 |
-
<input type="submit" value="Run Cancellation Sample"/>
|
40 |
-
</form>
|
41 |
-
</body>
|
42 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/CancellationResult.php
DELETED
@@ -1,188 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* *****************************************************************************
|
5 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
6 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
-
*
|
8 |
-
* You may not use this file except in compliance with the License.
|
9 |
-
* You may obtain a copy of the License at:
|
10 |
-
* http://aws.amazon.com/apache2.0
|
11 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
12 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
13 |
-
* for the
|
14 |
-
* specific language governing permissions and limitations under the
|
15 |
-
* License.
|
16 |
-
* *****************************************************************************
|
17 |
-
*/
|
18 |
-
|
19 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
20 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/WebServerExample.php';
|
21 |
-
require_once 'OffAmazonPaymentsService/Client.php';
|
22 |
-
require_once 'OffAmazonPaymentsService/Samples/CancellationExample.php';
|
23 |
-
require_once 'OffAmazonPaymentsService/Samples/CancelOrderReferenceSample.php';
|
24 |
-
require_once 'OffAmazonPaymentsService/Samples/SetOrderReferenceDetailsSample.php';
|
25 |
-
require_once 'OffAmazonPaymentsService/Samples/ConfirmOrderReferenceSample.php';
|
26 |
-
require_once 'OffAmazonPaymentsService/Samples/GetOrderReferenceDetailsSample.php';
|
27 |
-
require_once 'OffAmazonPaymentsService/Samples/GetAuthorizationDetailsSample.php';
|
28 |
-
|
29 |
-
/**
|
30 |
-
* This script simulates a simple checkout example and generates
|
31 |
-
* html for the page
|
32 |
-
*
|
33 |
-
*/
|
34 |
-
class CancellationResult extends WebServerExample
|
35 |
-
{
|
36 |
-
/**
|
37 |
-
* Create a new instance of the Simple Checkout Example
|
38 |
-
*
|
39 |
-
* @param string $queryString url query string
|
40 |
-
*
|
41 |
-
* @return void
|
42 |
-
*/
|
43 |
-
public function __construct($queryString)
|
44 |
-
{
|
45 |
-
parent::__construct($queryString);
|
46 |
-
|
47 |
-
$this->exampleClass = new CancellationExample(
|
48 |
-
new OffAmazonPaymentsService_Client(),
|
49 |
-
$this->queryStringParams['orderReferenceId'],
|
50 |
-
"100.00",
|
51 |
-
$this->currencyCode
|
52 |
-
);
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Execute the example
|
57 |
-
*
|
58 |
-
* @return void
|
59 |
-
*/
|
60 |
-
public function run()
|
61 |
-
{
|
62 |
-
$this->_setupOrderReference();
|
63 |
-
$this->_confirmOrderReference();
|
64 |
-
$amazonAuthorizationId = $this->_performAuthorization();
|
65 |
-
$this->_waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId);
|
66 |
-
$this->_cancelOrder();
|
67 |
-
$this->_getOrderReferenceDetails();
|
68 |
-
print HTML_LB.HTML_LB."Cancellation Sample is Complete";
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Add information to the payment contract so that it can be confirmed
|
73 |
-
* in a later step
|
74 |
-
* Simulates a merchant adding the order details to the payment contract
|
75 |
-
*
|
76 |
-
* @return void
|
77 |
-
*/
|
78 |
-
private function _setupOrderReference()
|
79 |
-
{
|
80 |
-
$response = $this->callStepAndCheckForException('setupOrderReference');
|
81 |
-
echo $this->printResponseToWebpage(
|
82 |
-
"printSetOrderReferenceDetailsResponse", array($response)
|
83 |
-
);
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Confirm the order reference information, allowing for
|
88 |
-
* authorizations and captures to be created
|
89 |
-
*
|
90 |
-
* @return void
|
91 |
-
*/
|
92 |
-
private function _confirmOrderReference()
|
93 |
-
{
|
94 |
-
$response = $this->callStepAndCheckForException('confirmOrderReference');
|
95 |
-
echo $this->printResponseToWebpage(
|
96 |
-
"printConfirmOrderReferenceResponse", array($response)
|
97 |
-
);
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Perform the authorize call for the order
|
102 |
-
*
|
103 |
-
* @return string amazonAuthorizationId
|
104 |
-
* amazon generated authorization id reference
|
105 |
-
*/
|
106 |
-
private function _performAuthorization()
|
107 |
-
{
|
108 |
-
$response = $this->callStepAndCheckForException('performAuthorization');
|
109 |
-
echo $this->printResponseToWebpage(
|
110 |
-
"printAuthorizeResponse", array($response)
|
111 |
-
);
|
112 |
-
return $response->getAuthorizeResult()
|
113 |
-
->getAuthorizationDetails()->getAmazonAuthorizationId();
|
114 |
-
}
|
115 |
-
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Cancel the payment contract - this can be performed on any order reference
|
119 |
-
* that does not have a completed transaction
|
120 |
-
*
|
121 |
-
* @return void
|
122 |
-
*/
|
123 |
-
private function _cancelOrder()
|
124 |
-
{
|
125 |
-
$response = $this->callStepAndCheckForException('cancelOrderReference');
|
126 |
-
echo $this->printResponseToWebpage(
|
127 |
-
"printCancelOrderReferenceResponse", array($response)
|
128 |
-
);
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* Get the status of the order reference request object to show that it
|
133 |
-
* now cancelled
|
134 |
-
*
|
135 |
-
* @return void
|
136 |
-
*/
|
137 |
-
private function _getOrderReferenceDetails()
|
138 |
-
{
|
139 |
-
$response = $this->callStepAndCheckForException('getOrderReferenceDetails');
|
140 |
-
echo $this->printResponseToWebpage(
|
141 |
-
"printGetOrderReferenceDetailsResponse", array($response)
|
142 |
-
);
|
143 |
-
}
|
144 |
-
/**
|
145 |
-
* Check that we have received an IPN notification for the authorization
|
146 |
-
*
|
147 |
-
* For PHP, there is an IPN handler that will write the contents of the IPN to
|
148 |
-
* a file in the format of
|
149 |
-
* <amazonAuthorizationId>_Authorization.
|
150 |
-
* This method will check for the presnece of this file
|
151 |
-
* and will loop/timeout until the notification has been handled.
|
152 |
-
*
|
153 |
-
* Merchants can use alternative approaches such as memory caches,
|
154 |
-
* shared memory or database storage so that scripts serving user
|
155 |
-
* pages are able to check on the status of a notification
|
156 |
-
*
|
157 |
-
* @param string $amazonAuthorizationId authorization transaction to query
|
158 |
-
*
|
159 |
-
* @return void
|
160 |
-
*/
|
161 |
-
private function _waitUntilAuthorizationProcessingIsCompleted
|
162 |
-
($amazonAuthorizationId)
|
163 |
-
{
|
164 |
-
// Check for the presence of the ipn notification
|
165 |
-
$this->waitForNotificationToBeProcessedBeforeContinuing(
|
166 |
-
$amazonAuthorizationId,
|
167 |
-
"AuthorizationNotification"
|
168 |
-
);
|
169 |
-
|
170 |
-
// Notification is present, go and get the full
|
171 |
-
// information for this notification
|
172 |
-
$response
|
173 |
-
= $this->callStepAndCheckForException(
|
174 |
-
'getAuthorizationDetails',
|
175 |
-
array($amazonAuthorizationId)
|
176 |
-
);
|
177 |
-
|
178 |
-
echo $this->printResponseToWebpage(
|
179 |
-
"printGetAuthorizationDetailsResponse", array($response)
|
180 |
-
);
|
181 |
-
validateThatAuthorizationIsOpen($response);
|
182 |
-
}
|
183 |
-
}
|
184 |
-
|
185 |
-
$cancellationResult = new CancellationResult($_SERVER['QUERY_STRING']);
|
186 |
-
$cancellationResult->run();
|
187 |
-
|
188 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/CaptureNotificationSample.php
DELETED
@@ -1,173 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
|
17 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
18 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/NotificationSample.php';
|
19 |
-
require_once 'OffAmazonPaymentsNotifications/Model/CaptureNotification.php';
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Class for handling an capture notification and print the
|
23 |
-
* contents to the log file
|
24 |
-
*
|
25 |
-
*/
|
26 |
-
class OffAmazonPaymentsNotifications_Samples_CaptureNotificationSample
|
27 |
-
extends OffAmazonPaymentsNotifications_Samples_NotificationSample
|
28 |
-
{
|
29 |
-
/**
|
30 |
-
* Create a new instance of the Capture notification sample
|
31 |
-
*
|
32 |
-
* @param OffAmazonPaymentsNotifications_Model_CaptureNotification $notification notification
|
33 |
-
*
|
34 |
-
* @return void
|
35 |
-
*/
|
36 |
-
public function __construct(
|
37 |
-
OffAmazonPaymentsNotifications_Model_CaptureNotification $notification
|
38 |
-
) {
|
39 |
-
parent::__construct($notification);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Extract the name of the log file based on the notification
|
44 |
-
*
|
45 |
-
* @throws InvalidArgumentException
|
46 |
-
*
|
47 |
-
* @return string
|
48 |
-
*/
|
49 |
-
protected function getLogFileName()
|
50 |
-
{
|
51 |
-
if (! $this->notification->getCaptureDetails()->isSetAmazonCaptureId()) {
|
52 |
-
throw new InvalidArgumentException("CaptureId is NULL");
|
53 |
-
}
|
54 |
-
|
55 |
-
return $this->notification->getCaptureDetails()->getAmazonCaptureId()."_CaptureNotification.txt";
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Log the notification contents
|
60 |
-
*
|
61 |
-
* @return void
|
62 |
-
*/
|
63 |
-
protected function logNotificationContents()
|
64 |
-
{
|
65 |
-
$this->ipnLogFile->writeLine("Capture Notification @ ".date("Y-m-d H:i:s") . " (GMT)");
|
66 |
-
$this->ipnLogFile->writeLine("=============================================================================");
|
67 |
-
if ($this->notification->isSetCaptureDetails()) {
|
68 |
-
$this->ipnLogFile->writeLine(" CaptureDetails");
|
69 |
-
$captureDetails = $this->notification->getCaptureDetails();
|
70 |
-
if ($captureDetails->isSetAmazonCaptureId()) {
|
71 |
-
$this->ipnLogFile->writeLine(" AmazonCaptureId");
|
72 |
-
$this->ipnLogFile->writeLine(" " . $captureDetails->getAmazonCaptureId());
|
73 |
-
}
|
74 |
-
if ($captureDetails->isSetCaptureReferenceId()) {
|
75 |
-
$this->ipnLogFile->writeLine(" CaptureReferenceId");
|
76 |
-
$this->ipnLogFile->writeLine(" " . $captureDetails->getCaptureReferenceId());
|
77 |
-
}
|
78 |
-
if ($captureDetails->isSetCaptureAmount()) {
|
79 |
-
$this->ipnLogFile->writeLine(" CaptureAmount");
|
80 |
-
$captureAmount = $captureDetails->getCaptureAmount();
|
81 |
-
if ($captureAmount->isSetAmount()) {
|
82 |
-
$this->ipnLogFile->writeLine(" Amount");
|
83 |
-
$this->ipnLogFile->writeLine(" " . $captureAmount->getAmount());
|
84 |
-
}
|
85 |
-
if ($captureAmount->isSetCurrencyCode()) {
|
86 |
-
$this->ipnLogFile->writeLine(" CurrencyCode");
|
87 |
-
$this->ipnLogFile->writeLine(" " . $captureAmount->getCurrencyCode());
|
88 |
-
}
|
89 |
-
}
|
90 |
-
if ($captureDetails->isSetRefundedAmount()) {
|
91 |
-
$this->ipnLogFile->writeLine(" RefundedAmount");
|
92 |
-
$refundedAmount = $captureDetails->getRefundedAmount();
|
93 |
-
if ($refundedAmount->isSetAmount()) {
|
94 |
-
$this->ipnLogFile->writeLine(" Amount");
|
95 |
-
$this->ipnLogFile->writeLine(" " . $refundedAmount->getAmount());
|
96 |
-
}
|
97 |
-
if ($refundedAmount->isSetCurrencyCode()) {
|
98 |
-
$this->ipnLogFile->writeLine(" CurrencyCode");
|
99 |
-
$this->ipnLogFile->writeLine(" " . $refundedAmount->getCurrencyCode());
|
100 |
-
}
|
101 |
-
}
|
102 |
-
if ($captureDetails->isSetCaptureFee()) {
|
103 |
-
$this->ipnLogFile->writeLine(" CaptureFee");
|
104 |
-
$captureFee = $captureDetails->getCaptureFee();
|
105 |
-
if ($captureFee->isSetAmount()) {
|
106 |
-
$this->ipnLogFile->writeLine(" Amount");
|
107 |
-
$this->ipnLogFile->writeLine(" " . $captureFee->getAmount());
|
108 |
-
}
|
109 |
-
if ($captureFee->isSetCurrencyCode()) {
|
110 |
-
$this->ipnLogFile->writeLine(" CurrencyCode");
|
111 |
-
$this->ipnLogFile->writeLine(" " . $captureFee->getCurrencyCode());
|
112 |
-
}
|
113 |
-
}
|
114 |
-
if ($captureDetails->isSetIdList()) {
|
115 |
-
$this->ipnLogFile->writeLine(" IdList");
|
116 |
-
$idList = $captureDetails->getIdList();
|
117 |
-
$memberList = $idList->getId();
|
118 |
-
foreach ($memberList as $member) {
|
119 |
-
$this->ipnLogFile->writeLine(" member");
|
120 |
-
$this->ipnLogFile->writeLine(" " . $member);
|
121 |
-
}
|
122 |
-
}
|
123 |
-
if ($captureDetails->isSetCreationTimestamp()) {
|
124 |
-
$this->ipnLogFile->writeLine(" CreationTimestamp");
|
125 |
-
$this->ipnLogFile->writeLine(" " . $captureDetails->getCreationTimestamp());
|
126 |
-
}
|
127 |
-
if ($captureDetails->isSetCaptureStatus()) {
|
128 |
-
$this->ipnLogFile->writeLine(" CaptureStatus");
|
129 |
-
$captureStatus = $captureDetails->getCaptureStatus();
|
130 |
-
if ($captureStatus->isSetState()) {
|
131 |
-
$this->ipnLogFile->writeLine(" State");
|
132 |
-
$this->ipnLogFile->writeLine(" " . $captureStatus->getState());
|
133 |
-
}
|
134 |
-
if ($captureStatus->isSetLastUpdateTimestamp()) {
|
135 |
-
$this->ipnLogFile->writeLine(" LastUpdateTimestamp");
|
136 |
-
$this->ipnLogFile->writeLine(" " . $captureStatus->getLastUpdateTimestamp());
|
137 |
-
}
|
138 |
-
if ($captureStatus->isSetReasonCode()) {
|
139 |
-
$this->ipnLogFile->writeLine(" ReasonCode");
|
140 |
-
$this->ipnLogFile->writeLine(" " . $captureStatus->getReasonCode());
|
141 |
-
}
|
142 |
-
if ($captureStatus->isSetReasonDescription()) {
|
143 |
-
$this->ipnLogFile->writeLine(" ReasonDescription");
|
144 |
-
$this->ipnLogFile->writeLine(" " . $captureStatus->getReasonDescription());
|
145 |
-
}
|
146 |
-
}
|
147 |
-
if($captureDetails->isSetProviderCreditSummaryList()){
|
148 |
-
$this->ipnLogFile->writeLine( " ProviderCreditSummaryList");
|
149 |
-
$providerCreditSummaryList = $captureDetails->getProviderCreditSummaryList();
|
150 |
-
if($providerCreditSummaryList->isSetProviderCreditSummary()){
|
151 |
-
$values = $providerCreditSummaryList->getProviderCreditSummary();
|
152 |
-
foreach($values as $value){
|
153 |
-
$this->ipnLogFile->writeLine( " ProviderCreditSummary");
|
154 |
-
if($value->isSetProviderSellerId()){
|
155 |
-
$this->ipnLogFile->writeLine( " ProviderSellerId");
|
156 |
-
$this->ipnLogFile->writeLine( " ".$value->getProviderSellerId());
|
157 |
-
}
|
158 |
-
if($value->isSetProviderCreditId()){
|
159 |
-
$this->ipnLogFile->writeLine( " ProviderCreditId");
|
160 |
-
$this->ipnLogFile->writeLine( " ".$value->getProviderCreditId());
|
161 |
-
}
|
162 |
-
}
|
163 |
-
}
|
164 |
-
}
|
165 |
-
if ($captureDetails->isSetSoftDescriptor()) {
|
166 |
-
$this->ipnLogFile->writeLine(" SoftDescriptor");
|
167 |
-
$this->ipnLogFile->writeLine(" " . $captureDetails->getSoftDescriptor());
|
168 |
-
}
|
169 |
-
|
170 |
-
}
|
171 |
-
}
|
172 |
-
}
|
173 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/IpnHandler.php
DELETED
@@ -1,132 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
19 |
-
require_once 'OffAmazonPaymentsNotifications/InvalidMessageException.php';
|
20 |
-
require_once 'OffAmazonPaymentsNotifications/Client.php';
|
21 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/AuthorizationNotificationSample.php';
|
22 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/CaptureNotificationSample.php';
|
23 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/RefundNotificationSample.php';
|
24 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/OrderReferenceSample.php';
|
25 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/BillingAgreementNotificationSample.php';
|
26 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/ProviderCreditNotificationSample.php';
|
27 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/ProviderCreditReversalNotificationSample.php';
|
28 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/SolutionProviderMerchantNotificationSample.php';
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
/**
|
33 |
-
* IPN_Handler
|
34 |
-
*
|
35 |
-
* This file is invoked whenever a new notification needs to be processed,
|
36 |
-
* and will call the IPN API
|
37 |
-
*
|
38 |
-
* Note that if the IPN Client throws an exception, the IPH_Handler routine is
|
39 |
-
* expected to throw a HTTP error response to signal that there has been an issue
|
40 |
-
* with the message
|
41 |
-
*
|
42 |
-
* This class logs information to an error logs,
|
43 |
-
* and places the last received notification
|
44 |
-
* into the session context as a way to pass to other pages
|
45 |
-
*
|
46 |
-
*/
|
47 |
-
$headers = getallheaders();
|
48 |
-
$body = file_get_contents('php://input');
|
49 |
-
try {
|
50 |
-
$client = new OffAmazonPaymentsNotifications_Client();
|
51 |
-
$result = $client->parseRawMessage($headers, $body);
|
52 |
-
} catch (OffAmazonPaymentsNotifications_InvalidMessageException $ex) {
|
53 |
-
error_log($ex->getMessage());
|
54 |
-
header("HTTP/1.1 503 Service Unavailable");
|
55 |
-
exit(0);
|
56 |
-
}
|
57 |
-
|
58 |
-
try {
|
59 |
-
logNotification($result);
|
60 |
-
} catch (Exception $ex) {
|
61 |
-
error_log($ex->getMessage());
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Return the identifier for this notification
|
66 |
-
*
|
67 |
-
* @param OffAmazonPaymentsNotifications_Notification $notification to extract
|
68 |
-
* value from
|
69 |
-
*
|
70 |
-
* @return string id string in format notificationType:id
|
71 |
-
*/
|
72 |
-
function logNotification(
|
73 |
-
OffAmazonPaymentsNotifications_Notification $notification
|
74 |
-
) {
|
75 |
-
if (is_null($notification)) {
|
76 |
-
error_log("No notification received");
|
77 |
-
return;
|
78 |
-
}
|
79 |
-
|
80 |
-
$type = $notification->getNotificationType();
|
81 |
-
switch($type) {
|
82 |
-
case "OrderReferenceNotification":
|
83 |
-
error_log("Received Order Reference Notification");
|
84 |
-
$obj = new OffAmazonPaymentsNotifications_Samples_OrderReferenceSample($notification);
|
85 |
-
error_log("Order Reference Notification Logged");
|
86 |
-
break;
|
87 |
-
case "BillingAgreementNotification":
|
88 |
-
error_log("Received Billing Agreement Notification");
|
89 |
-
$obj = new OffAmazonPaymentsNotifications_Samples_BillingAgreementNotificationSample($notification);
|
90 |
-
error_log("Billing Agreement Notification Logged");
|
91 |
-
break;
|
92 |
-
case "AuthorizationNotification":
|
93 |
-
error_log("Received Auth notification");
|
94 |
-
$obj = new OffAmazonPaymentsNotifications_Samples_AuthorizationNotificationSample($notification);
|
95 |
-
error_log("Auth notification logged");
|
96 |
-
break;
|
97 |
-
case "CaptureNotification":
|
98 |
-
error_log("Received Capture Notification");
|
99 |
-
$obj = new OffAmazonPaymentsNotifications_Samples_CaptureNotificationSample($notification);
|
100 |
-
error_log("Capture Notification logged");
|
101 |
-
break;
|
102 |
-
case "RefundNotification":
|
103 |
-
error_log("Received Refund Notification");
|
104 |
-
$obj = new OffAmazonPaymentsNotifications_Samples_RefundNotificationSample($notification);
|
105 |
-
error_log("Refund Notification logged");
|
106 |
-
break;
|
107 |
-
case "ProviderCreditNotification":
|
108 |
-
error_log("Received ProviderCredit Notification");
|
109 |
-
$obj = new OffAmazonPaymentsNotifications_Samples_ProviderCreditNotificationSample($notification);
|
110 |
-
error_log("ProviderCredit Notification logged");
|
111 |
-
break;
|
112 |
-
case "ProviderCreditReversalNotification":
|
113 |
-
error_log("Received ProviderCreditReversal Notification");
|
114 |
-
$obj = new OffAmazonPaymentsNotifications_Samples_ProviderCreditReversalNotificationSample($notification);
|
115 |
-
error_log("ProviderCreditReversal Notification logged");
|
116 |
-
break;
|
117 |
-
case "SolutionProviderMerchantNotification":
|
118 |
-
error_log("Received SolutionProviderMerchant Notification");
|
119 |
-
$obj = new OffAmazonPaymentsNotifications_Samples_SolutionProviderMerchantNotificationSample($notification);
|
120 |
-
error_log("SolutionProviderMerchant Notification logged");
|
121 |
-
break;
|
122 |
-
default:
|
123 |
-
error_log("Received Unknown Notification Type: ".$notification->getNotificationType());
|
124 |
-
return "Unknown Notification Type";
|
125 |
-
}
|
126 |
-
|
127 |
-
$obj->logNotification();
|
128 |
-
error_log("*********************************************************************************");
|
129 |
-
error_log("IPN Logging Completed for: ".$type);
|
130 |
-
error_log("*********************************************************************************");
|
131 |
-
}
|
132 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/IpnLogFile.php
DELETED
@@ -1,91 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
|
17 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
18 |
-
require_once 'OffAmazonPaymentsService/OffAmazonPaymentsService.config.inc.php';
|
19 |
-
|
20 |
-
/*
|
21 |
-
* Make the variable declared in the properties file a constant
|
22 |
-
* for use inside the application
|
23 |
-
*/
|
24 |
-
define('LOG_FILE_LOCATION', $logFileLocation);
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Wrapper around a log file used to capture the ipn notifications
|
28 |
-
*
|
29 |
-
*/
|
30 |
-
class OffAmazonPaymentsNotifications_Samples_IpnLogFile
|
31 |
-
{
|
32 |
-
/**
|
33 |
-
* Name of the log file without directory path
|
34 |
-
*
|
35 |
-
* @var string
|
36 |
-
*/
|
37 |
-
private $_fileName = null;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* File handle
|
41 |
-
*
|
42 |
-
* @var int id
|
43 |
-
*/
|
44 |
-
private $_fileHandler = null;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Create a new instance of the class
|
48 |
-
*
|
49 |
-
* @param string $fileName name of the log file
|
50 |
-
*
|
51 |
-
* @return void
|
52 |
-
*/
|
53 |
-
public function __construct($fileName)
|
54 |
-
{
|
55 |
-
$this->_fileName = $fileName;
|
56 |
-
$this->_fileHandler = fopen(LOG_FILE_LOCATION . $this->getFileName(), 'a');
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Get the name of the file
|
61 |
-
*
|
62 |
-
* @return string
|
63 |
-
*/
|
64 |
-
public function getFileName()
|
65 |
-
{
|
66 |
-
return $this->_fileName;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Write a single line to the log file
|
71 |
-
*
|
72 |
-
* @param string $content content to write
|
73 |
-
*
|
74 |
-
* @return void
|
75 |
-
*/
|
76 |
-
public function writeLine($content)
|
77 |
-
{
|
78 |
-
fwrite($this->_fileHandler, $content . PHP_EOL);
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Close the file
|
83 |
-
*
|
84 |
-
* @return void
|
85 |
-
*/
|
86 |
-
public function closeFile()
|
87 |
-
{
|
88 |
-
fclose($this->_fileHandler);
|
89 |
-
}
|
90 |
-
}
|
91 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/NotificationSample.php
DELETED
@@ -1,97 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
|
17 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
18 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/IpnLogFile.php';
|
19 |
-
require_once 'OffAmazonPaymentsNotifications/Notification.php';
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Abstract parent class for handling an notification and print the
|
23 |
-
* contents to the log file
|
24 |
-
*
|
25 |
-
*/
|
26 |
-
abstract class OffAmazonPaymentsNotifications_Samples_NotificationSample
|
27 |
-
{
|
28 |
-
/**
|
29 |
-
* Log file handle
|
30 |
-
*
|
31 |
-
* @var OffAmazonPaymentsNotifications_Samples_IpnLogFile
|
32 |
-
*/
|
33 |
-
protected $ipnLogFile = null;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Notification to print to the log
|
37 |
-
*
|
38 |
-
* @var OffAmazonPaymentsNotifications_Notification notification
|
39 |
-
*/
|
40 |
-
protected $notification = null;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Create a new instance of the notification handler
|
44 |
-
*
|
45 |
-
* @param OffAmazonPaymentsNotifications_Model_Notification $notification notification
|
46 |
-
* to handle
|
47 |
-
*
|
48 |
-
* @throws InvalidArgumentException
|
49 |
-
*
|
50 |
-
* @return void
|
51 |
-
*/
|
52 |
-
public function __construct($notification)
|
53 |
-
{
|
54 |
-
if (!isset($notification)) {
|
55 |
-
throw new InvalidArgumentException("notification is NULL");
|
56 |
-
} else {
|
57 |
-
$this->notification = $notification;
|
58 |
-
$this->ipnLogFile
|
59 |
-
= new OffAmazonPaymentsNotifications_Samples_IpnLogFile(
|
60 |
-
$this->getLogFileName()
|
61 |
-
);
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Extract the name of the log file based on the notification=
|
67 |
-
*
|
68 |
-
* @throws InvalidArgumentException
|
69 |
-
*
|
70 |
-
* @return string
|
71 |
-
*/
|
72 |
-
protected abstract function getLogFileName();
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Log the notification to the file
|
76 |
-
*
|
77 |
-
* @return void
|
78 |
-
*/
|
79 |
-
public function logNotification()
|
80 |
-
{
|
81 |
-
try {
|
82 |
-
$this->logNotificationContents();
|
83 |
-
$this->ipnLogFile->writeLine("=============================================================================");
|
84 |
-
$this->ipnLogFile->closeFile();
|
85 |
-
} catch (Exception $ex){
|
86 |
-
error_log($ex->getMessage());
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Log the notification contents
|
92 |
-
*
|
93 |
-
* @return void
|
94 |
-
*/
|
95 |
-
protected abstract function logNotificationContents();
|
96 |
-
}
|
97 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/OrderReferenceSample.php
DELETED
@@ -1,143 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
|
17 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
18 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/NotificationSample.php';
|
19 |
-
require_once 'OffAmazonPaymentsNotifications/Model/OrderReferenceNotification.php';
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Class for handling an order reference notification and print the
|
23 |
-
* contents to the log file
|
24 |
-
*
|
25 |
-
*/
|
26 |
-
class OffAmazonPaymentsNotifications_Samples_OrderReferenceSample
|
27 |
-
extends OffAmazonPaymentsNotifications_Samples_NotificationSample
|
28 |
-
{
|
29 |
-
/**
|
30 |
-
* Create a new instance of the Order reference notification sample
|
31 |
-
*
|
32 |
-
* @param OffAmazonPaymentsNotifications_Model_OrderReferenceNotification $notification notification
|
33 |
-
*
|
34 |
-
* @return void
|
35 |
-
*/
|
36 |
-
public function __construct(
|
37 |
-
OffAmazonPaymentsNotifications_Model_OrderReferenceNotification $notification
|
38 |
-
) {
|
39 |
-
parent::__construct($notification);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Extract the name of the log file based on the notification
|
44 |
-
*
|
45 |
-
* @throws InvalidArgumentException
|
46 |
-
*
|
47 |
-
* @return string
|
48 |
-
*/
|
49 |
-
protected function getLogFileName()
|
50 |
-
{
|
51 |
-
if (!$this->notification->getOrderReference()->isSetAmazonOrderReferenceId()) {
|
52 |
-
throw new InvalidArgumentException("OrderReferenceId is NULL");
|
53 |
-
}
|
54 |
-
|
55 |
-
return $this->notification->getOrderReference()->getAmazonOrderReferenceId()
|
56 |
-
. "_OrderReference.txt";
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Log the notification contents
|
61 |
-
*
|
62 |
-
* @return void
|
63 |
-
*/
|
64 |
-
protected function logNotificationContents()
|
65 |
-
{
|
66 |
-
$this->ipnLogFile->writeLine("OrderReference @ ".date("Y-m-d H:i:s"));
|
67 |
-
$this->ipnLogFile->writeLine("=============================================================================");
|
68 |
-
if ($this->notification->isSetOrderReference()) {
|
69 |
-
$this->ipnLogFile->writeLine(" OrderReference");
|
70 |
-
$orderReference = $this->notification->getOrderReference();
|
71 |
-
if ($orderReference->isSetAmazonOrderReferenceId()) {
|
72 |
-
$this->ipnLogFile->writeLine(" AmazonOrderReferenceId");
|
73 |
-
$this->ipnLogFile->writeLine(" " . $orderReference->getAmazonOrderReferenceId());
|
74 |
-
}
|
75 |
-
if ($orderReference->isSetOrderTotal()) {
|
76 |
-
$this->ipnLogFile->writeLine(" OrderTotal");
|
77 |
-
$orderTotal = $orderReference->getOrderTotal();
|
78 |
-
if ($orderTotal->isSetAmount()) {
|
79 |
-
$this->ipnLogFile->writeLine(" Amount");
|
80 |
-
$this->ipnLogFile->writeLine(" " . $orderTotal->getAmount());
|
81 |
-
}
|
82 |
-
if ($orderTotal->isSetCurrencyCode()) {
|
83 |
-
$this->ipnLogFile->writeLine(" CurrencyCode");
|
84 |
-
$this->ipnLogFile->writeLine(" " . $orderTotal->getCurrencyCode());
|
85 |
-
}
|
86 |
-
}
|
87 |
-
if ($orderReference->isSetSellerOrderAttributes()) {
|
88 |
-
$this->ipnLogFile->writeLine(" SellerOrderAttributes");
|
89 |
-
$sellerOrderAttributes = $orderReference->getSellerOrderAttributes();
|
90 |
-
if ($sellerOrderAttributes->isSetSellerId()) {
|
91 |
-
$this->ipnLogFile->writeLine(" SellerId");
|
92 |
-
$this->ipnLogFile->writeLine(" " . $sellerOrderAttributes->getSellerId());
|
93 |
-
}
|
94 |
-
if ($sellerOrderAttributes->isSetSellerOrderId()) {
|
95 |
-
$this->ipnLogFile->writeLine(" SellerOrderId");
|
96 |
-
$this->ipnLogFile->writeLine(" " . $sellerOrderAttributes->getSellerOrderId());
|
97 |
-
}
|
98 |
-
if ($sellerOrderAttributes->isSetOrderItemCategories()) {
|
99 |
-
$this->ipnLogFile->writeLine(" OrderItemCategories");
|
100 |
-
$orderItemCategories = $sellerOrderAttributes->getOrderItemCategories();
|
101 |
-
$orderItemCategoryList = $orderItemCategories->getOrderItemCategory();
|
102 |
-
foreach ($orderItemCategoryList as $orderItemCategory) {
|
103 |
-
$this->ipnLogFile->writeLine(" OrderItemCategory");
|
104 |
-
$this->ipnLogFile->writeLine(" " . $orderItemCategory);
|
105 |
-
}
|
106 |
-
}
|
107 |
-
}
|
108 |
-
if ($orderReference->isSetOrderReferenceStatus()) {
|
109 |
-
$this->ipnLogFile->writeLine(" OrderReferenceStatus");
|
110 |
-
$orderReferenceStatus = $orderReference->getOrderReferenceStatus();
|
111 |
-
if ($orderReferenceStatus->isSetState())
|
112 |
-
{
|
113 |
-
$this->ipnLogFile->writeLine(" State");
|
114 |
-
$this->ipnLogFile->writeLine(" " . $orderReferenceStatus->getState());
|
115 |
-
}
|
116 |
-
if ($orderReferenceStatus->isSetLastUpdateTimestamp())
|
117 |
-
{
|
118 |
-
$this->ipnLogFile->writeLine(" LastUpdateTimestamp");
|
119 |
-
$this->ipnLogFile->writeLine(" " . $orderReferenceStatus->getLastUpdateTimestamp());
|
120 |
-
}
|
121 |
-
if ($orderReferenceStatus->isSetReasonCode())
|
122 |
-
{
|
123 |
-
$this->ipnLogFile->writeLine(" ReasonCode");
|
124 |
-
$this->ipnLogFile->writeLine(" " . $orderReferenceStatus->getReasonCode());
|
125 |
-
}
|
126 |
-
if ($orderReferenceStatus->isSetReasonDescription())
|
127 |
-
{
|
128 |
-
$this->ipnLogFile->writeLine(" ReasonDescription");
|
129 |
-
$this->ipnLogFile->writeLine(" " . $orderReferenceStatus->getReasonDescription());
|
130 |
-
}
|
131 |
-
}
|
132 |
-
if ($orderReference->isSetCreationTimestamp()) {
|
133 |
-
$this->ipnLogFile->writeLine(" CreationTimestamp");
|
134 |
-
$this->ipnLogFile->writeLine(" " . $orderReference->getCreationTimestamp());
|
135 |
-
}
|
136 |
-
if ($orderReference->isSetExpirationTimestamp()) {
|
137 |
-
$this->ipnLogFile->writeLine(" ExpirationTimestamp");
|
138 |
-
$this->ipnLogFile->writeLine(" " . $orderReference->getExpirationTimestamp());
|
139 |
-
}
|
140 |
-
}
|
141 |
-
}
|
142 |
-
}
|
143 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/PayWithAmazon/address.php
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<?php
|
18 |
-
require_once realpath(dirname(__FILE__) . "/../.config.inc.php");
|
19 |
-
require_once("OffAmazonPaymentsService/Client.php");
|
20 |
-
$client = new OffAmazonPaymentsService_Client();
|
21 |
-
$merchantValues = $client->getMerchantValues();
|
22 |
-
?>
|
23 |
-
|
24 |
-
<!DOCTYPE html>
|
25 |
-
<html>
|
26 |
-
<head>
|
27 |
-
<title>Address page</title>
|
28 |
-
<script type="text/javascript">
|
29 |
-
window.onAmazonLoginReady = function () {
|
30 |
-
amazon.Login.setClientId('<?php print $merchantValues->getClientId(); ?>');
|
31 |
-
};
|
32 |
-
</script>
|
33 |
-
<script type="text/javascript" src=<?php print "'" . $merchantValues->getWidgetUrl() . "'"; ?> ></script>
|
34 |
-
</head>
|
35 |
-
<body>
|
36 |
-
<div id="AmazonAddressWidget"></div>
|
37 |
-
|
38 |
-
<p>Click <a id="WalletLink" href="">here</a> to go to the
|
39 |
-
wallet page once you have completed the signin</p>
|
40 |
-
|
41 |
-
<script type='text/javascript' >
|
42 |
-
function getParamFromQueryString(name, url) {
|
43 |
-
var regexString = "[\\?&]" + name + "=([^&#]*)";
|
44 |
-
var regex = new RegExp(regexString);
|
45 |
-
var results = regex.exec(url);
|
46 |
-
|
47 |
-
var result = null;
|
48 |
-
|
49 |
-
if (results != null && results.length >= 2 && results[1] != null) {
|
50 |
-
var result = results[1].replace("?" + name);
|
51 |
-
}
|
52 |
-
|
53 |
-
return result;
|
54 |
-
}
|
55 |
-
|
56 |
-
var url = window.location.href;
|
57 |
-
var session = getParamFromQueryString("session", url);
|
58 |
-
var access_token = getParamFromQueryString("access_token", url);
|
59 |
-
|
60 |
-
if (session == null && access_token == null) {
|
61 |
-
alert("Missing query string parameters from request, verify that session & access_token are present.");
|
62 |
-
} else {
|
63 |
-
document.getElementById("WalletLink").href = "wallet.php?session=" + session + "&access_token=" + access_token;
|
64 |
-
}
|
65 |
-
|
66 |
-
new OffAmazonPayments.Widgets.AddressBook({
|
67 |
-
sellerId: <?php print "\"" . $merchantValues->getMerchantId() . "\""; ?>,
|
68 |
-
amazonOrderReferenceId: session,
|
69 |
-
displayMode: 'Edit',
|
70 |
-
design:{size: { width:'400', height:'228' } },
|
71 |
-
onAddressSelect: function(orderReference) {
|
72 |
-
|
73 |
-
},
|
74 |
-
onError: function(error) {
|
75 |
-
alert(error.getErrorCode() + ": " + error.getErrorMessage());
|
76 |
-
}
|
77 |
-
}).bind("AmazonAddressWidget");
|
78 |
-
</script>
|
79 |
-
</body>
|
80 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/PayWithAmazon/signin.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<!DOCTYPE html>
|
18 |
-
<?php
|
19 |
-
require_once realpath ( dirname ( __FILE__ ) . "/../.config.inc.php" );
|
20 |
-
require_once ("OffAmazonPaymentsService/Client.php");
|
21 |
-
$client = new OffAmazonPaymentsService_Client ();
|
22 |
-
$merchantValues = $client->getMerchantValues ();
|
23 |
-
?>
|
24 |
-
|
25 |
-
<html>
|
26 |
-
<head>
|
27 |
-
<title>Login page</title>
|
28 |
-
<script type="text/javascript">
|
29 |
-
window.onAmazonLoginReady = function () {
|
30 |
-
amazon.Login.setClientId('<?php print $merchantValues->getClientId(); ?>');
|
31 |
-
};
|
32 |
-
</script>
|
33 |
-
<script type="text/javascript"
|
34 |
-
src=<?php print "'" . $merchantValues->getWidgetUrl() . "'"; ?>>
|
35 |
-
</script>
|
36 |
-
</head>
|
37 |
-
<body>
|
38 |
-
<div id="AmazonPayButton"></div>
|
39 |
-
<script type='text/javascript'>
|
40 |
-
var authRequest;
|
41 |
-
OffAmazonPayments.Button("AmazonPayButton", "<?php print $merchantValues->getMerchantId(); ?>", {
|
42 |
-
type: "PwA",
|
43 |
-
useAmazonAddressBook: true,
|
44 |
-
authorization: function() {
|
45 |
-
loginOptions =
|
46 |
-
{ scope: "profile payments:widget payments:shipping_address" };
|
47 |
-
authRequest = amazon.Login.authorize(loginOptions);
|
48 |
-
},
|
49 |
-
onSignIn: function(orderReference) {
|
50 |
-
// The following OAuth 2 response parameters will be
|
51 |
-
// included in the query string when the cusomers browser is
|
52 |
-
// redirected to the URL below: access_token, token_type, expires_in, and scope.
|
53 |
-
authRequest.onComplete('address.php?session=' +
|
54 |
-
orderReference.getAmazonOrderReferenceId());
|
55 |
-
},
|
56 |
-
onError: function(error) {
|
57 |
-
alert(error.getErrorCode() + ": " + error.getErrorMessage());
|
58 |
-
}
|
59 |
-
});
|
60 |
-
</script>
|
61 |
-
<p>Sign in with a test buyer account to redirect to the address widget page</p>
|
62 |
-
</body>
|
63 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/PayWithAmazon/wallet.php
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<!DOCTYPE html>
|
18 |
-
<?php
|
19 |
-
require_once realpath(dirname(__FILE__) . "/../.config.inc.php");
|
20 |
-
require_once ("OffAmazonPaymentsService/Client.php");
|
21 |
-
$client = new OffAmazonPaymentsService_Client();
|
22 |
-
$merchantValues = $client->getMerchantValues();
|
23 |
-
?>
|
24 |
-
|
25 |
-
<html>
|
26 |
-
<head>
|
27 |
-
<title>Wallet page</title>
|
28 |
-
<script type="text/javascript">
|
29 |
-
window.onAmazonLoginReady = function () {
|
30 |
-
amazon.Login.setClientId('<?php print $merchantValues->getClientId(); ?>');
|
31 |
-
};
|
32 |
-
</script>
|
33 |
-
<script type="text/javascript"
|
34 |
-
src=<?php print "'" . $merchantValues->getWidgetUrl() . "'"; ?>>
|
35 |
-
</script>
|
36 |
-
</head>
|
37 |
-
<body>
|
38 |
-
<div id="AmazonWalletWidget"></div>
|
39 |
-
<div id="SessionInformation"></div>
|
40 |
-
|
41 |
-
<script type='text/javascript'>
|
42 |
-
function getParamFromQueryString(name, url) {
|
43 |
-
var regexString = "[\\?&]" + name + "=([^&#]*)";
|
44 |
-
var regex = new RegExp(regexString);
|
45 |
-
var results = regex.exec(url);
|
46 |
-
|
47 |
-
var result = null;
|
48 |
-
|
49 |
-
if (results != null && results.length >= 2 && results[1] != null ) {
|
50 |
-
var result = results[1].replace("?" + name);
|
51 |
-
}
|
52 |
-
|
53 |
-
return result;
|
54 |
-
}
|
55 |
-
|
56 |
-
var url = window.location.href;
|
57 |
-
var session = getParamFromQueryString("session", url);
|
58 |
-
var access_token = getParamFromQueryString("access_token", url);
|
59 |
-
|
60 |
-
if (session == null && access_token == null) {
|
61 |
-
alert("Missing query string parameters from request, verify that session & access_token are present.");
|
62 |
-
} else {
|
63 |
-
document.getElementById("SessionInformation").innerHTML = "Order Reference Number: " + session + "<p> Access Token : " + access_token;
|
64 |
-
}
|
65 |
-
|
66 |
-
new OffAmazonPayments.Widgets.Wallet({
|
67 |
-
sellerId: <?php print "\"" . $merchantValues->getMerchantId() . "\""; ?>,
|
68 |
-
amazonOrderReferenceId: session,
|
69 |
-
displayMode: 'Edit',
|
70 |
-
design: { size: { width: '400', height: '228' } },
|
71 |
-
onPaymentSelect: function (orderReference) {
|
72 |
-
|
73 |
-
},
|
74 |
-
onError: function (error) {
|
75 |
-
alert(error.getErrorCode() + ": " + error.getErrorMessage());
|
76 |
-
}
|
77 |
-
}).bind("AmazonWalletWidget");
|
78 |
-
</script>
|
79 |
-
</body>
|
80 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/ProviderCheckoutDataInput.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<html>
|
18 |
-
<head>
|
19 |
-
<title>Provider Checkout Example</title>
|
20 |
-
</head>
|
21 |
-
<body>
|
22 |
-
<h1>Provider Checkout Example</h1>
|
23 |
-
|
24 |
-
<h2>This page will perform a simple checkout with provider credit that
|
25 |
-
demonstrates using a tax calculations based on the buyer address to
|
26 |
-
determine an order cost, then perform all transactions required to
|
27 |
-
transfer the funds from buyer to seller, and seller to provider.
|
28 |
-
</h2>
|
29 |
-
|
30 |
-
<form name="input" action="ProviderCheckoutResult.php">
|
31 |
-
Order Reference Id: <input type="text" name="orderReferenceId"/><br/>
|
32 |
-
Order total: <input type="text" name="orderTotal"/><br/>
|
33 |
-
Shipping speed:
|
34 |
-
<select name="shipping">
|
35 |
-
<option value="1">Overnight</option>
|
36 |
-
<option value="2">2-day shipping</option>
|
37 |
-
<option value="3">5-day shipping</option>
|
38 |
-
</select><br/>
|
39 |
-
Authorization Type:
|
40 |
-
<select name ="authOption">
|
41 |
-
<option value ="1">Regular Authorization (Asynchronous Response) [Default]</option>
|
42 |
-
<option value ="2">Fast Authorization (Synchronous Response)</option>
|
43 |
-
</select><br/>
|
44 |
-
Provider Id: <input type="text" name="providerId"/><br/>
|
45 |
-
ProviderCredit Amount: <input type="text" name="providerCreditAmount"/><br/>
|
46 |
-
<input type="submit" value="Submit"/>
|
47 |
-
</form>
|
48 |
-
</body>
|
49 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/ProviderCheckoutResult.php
DELETED
@@ -1,344 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
require_once realpath ( dirname ( __FILE__ ) . "/.config.inc.php" );
|
18 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/WebServerExample.php';
|
19 |
-
require_once 'OffAmazonPaymentsService/Client.php';
|
20 |
-
require_once 'OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php';
|
21 |
-
require_once 'OffAmazonPaymentsService/Samples/GetProviderCreditDetailsSample.php';
|
22 |
-
|
23 |
-
/**
|
24 |
-
* This script simulates a simple checkout example and generates
|
25 |
-
* html for the page
|
26 |
-
*/
|
27 |
-
class ProviderCheckoutResult extends WebServerExample {
|
28 |
-
/**
|
29 |
-
* Create a new instance of the Simple Checkout Example
|
30 |
-
*
|
31 |
-
* @param string $queryString
|
32 |
-
* url query string
|
33 |
-
*
|
34 |
-
* @return void
|
35 |
-
*/
|
36 |
-
public function __construct($queryString) {
|
37 |
-
parent::__construct ( $queryString );
|
38 |
-
|
39 |
-
$this->exampleClass = new SimpleCheckoutExample ( new OffAmazonPaymentsService_Client (), $this->queryStringParams ['orderReferenceId'] );
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Execute the example
|
44 |
-
*
|
45 |
-
* @return void
|
46 |
-
*/
|
47 |
-
public function run() {
|
48 |
-
$orderTotal = $this->_calculateOrderTotalBasedOnBuyerInfo();
|
49 |
-
$this->_addOrderTotalAndSellerInformationToOrder($orderTotal );
|
50 |
-
$this->_confirmOrderReference();
|
51 |
-
$amazonAuthorizationId = $this->_authorizeBasedOnOptionSelected ($orderTotal );
|
52 |
-
$this->_getAdditionalInformationForProcessedAuthorization ( $amazonAuthorizationId );
|
53 |
-
$providerCreditInfo = $this->_getProviderCreditInfoFromQueryParams();
|
54 |
-
$captureResponse = $this->_captureOrderAmount ( $orderTotal, $amazonAuthorizationId , $providerCreditInfo);
|
55 |
-
$providerCreditSummaryList = $this->_waitForProviderCreditSummaryList ( $captureResponse );
|
56 |
-
$this->_confirmProviderCreditSummaries ( $providerCreditSummaryList );
|
57 |
-
$this->_closeOrderReference ();
|
58 |
-
print HTML_LB . HTML_LB . "Provider Checkout Sample is Complete";
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Retreive the current information about the order as indicated by the buyer
|
63 |
-
* and calculate the total amount to charge, based on address destination state
|
64 |
-
* and country
|
65 |
-
*
|
66 |
-
* @return string total amount for the order that the merchant will
|
67 |
-
* charge the buyer
|
68 |
-
*/
|
69 |
-
private function _calculateOrderTotalBasedOnBuyerInfo() {
|
70 |
-
$response = $this->callStepAndCheckForException ( 'getOrderReferenceDetails' );
|
71 |
-
|
72 |
-
$this->printResponseToWebpage ( "printGetOrderReferenceDetailsResponse", array (
|
73 |
-
$response
|
74 |
-
) );
|
75 |
-
|
76 |
-
$orderTotalPreTaxAndShipping = $this->_getPreTaxAndShippingOrderAmountFromQueryParams ();
|
77 |
-
$shippingType = $this->_getShippingTypeFromQueryParams ();
|
78 |
-
|
79 |
-
return $this->exampleClass->calculateOrderTotalBasedOnBuyerDetails ( $response->getGetOrderReferenceDetailsResult ()->getOrderReferenceDetails (), $orderTotalPreTaxAndShipping, $shippingType);
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Add order information by making the call to setOrderReferenceDetails with
|
84 |
-
* the total order amount, as well as notes describing the order information
|
85 |
-
*
|
86 |
-
* @param float $orderTotal
|
87 |
-
* total value of the order, incl shipping and tax
|
88 |
-
*
|
89 |
-
* @return void
|
90 |
-
*/
|
91 |
-
private function _addOrderTotalAndSellerInformationToOrder($orderTotal) {
|
92 |
-
$response = $this->callStepAndCheckForException ( 'addOrderTotalAndSellerInformationToOrder', array (
|
93 |
-
$orderTotal
|
94 |
-
) );
|
95 |
-
|
96 |
-
$this->printResponseToWebpage ( "printSetOrderReferenceDetailsResponse", array (
|
97 |
-
$response
|
98 |
-
) );
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Confirm the order reference information, allowing for
|
103 |
-
* authorizations and captures to be created
|
104 |
-
*
|
105 |
-
* @return void
|
106 |
-
*/
|
107 |
-
private function _confirmOrderReference() {
|
108 |
-
$response = $this->callStepAndCheckForException ( 'confirmOrderReference' );
|
109 |
-
|
110 |
-
$this->printResponseToWebpage ( "printConfirmOrderReferenceResponse", array (
|
111 |
-
$response
|
112 |
-
) );
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Perform Authorize using Regular Authorization or Fast Authorization.
|
117 |
-
*
|
118 |
-
* @param float $authorizationAmount
|
119 |
-
* amount to authorize from the buyer
|
120 |
-
*
|
121 |
-
* @return string amazonAuthorizationId amazon generated authorization id reference
|
122 |
-
*/
|
123 |
-
private function _authorizeBasedOnOptionSelected($authorizationAmount) {
|
124 |
-
$authOption = $this->_getAuthOptionFromQueryParams();
|
125 |
-
$amazonAuthorizationId = $this->_authorizeOrderAmount ( $authorizationAmount, $authOption );
|
126 |
-
$this->_waitUntilAuthorizationProcessingIsCompleted ( $amazonAuthorizationId );
|
127 |
-
return $amazonAuthorizationId;
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Perform the authorize call for the order
|
132 |
-
*
|
133 |
-
* @param float $authorizationAmount
|
134 |
-
* amount to authorize from the buyer
|
135 |
-
*
|
136 |
-
* @return string amazonAuthorizationId amazon generated authorization rest
|
137 |
-
* id reference
|
138 |
-
*/
|
139 |
-
private function _authorizeOrderAmount($authorizationAmount, $authOption = 1) {
|
140 |
-
$response = $this->callStepAndCheckForException ( 'authorizeOrderAmount', array (
|
141 |
-
$authorizationAmount,
|
142 |
-
$authOption
|
143 |
-
) );
|
144 |
-
|
145 |
-
$this->printResponseToWebpage ( "printAuthorizeResponse", array (
|
146 |
-
$response
|
147 |
-
) );
|
148 |
-
|
149 |
-
return getAmazonAuthorizationIdFromAuthorizeResponse ( $response );
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Check that we have received an IPN notification for the authorization
|
154 |
-
*
|
155 |
-
* For PHP, there is an IPN handler that will write the contents of the IPN to
|
156 |
-
* a file in the format of
|
157 |
-
* <amazonOrderReferenceId>_<amazonAuthorizationId>_Authorization.
|
158 |
-
* This method will check for the presnece of this file
|
159 |
-
* and will loop/timeout until the notification has been handled.
|
160 |
-
*
|
161 |
-
* Merchants can use alternative approaches such as memory caches,
|
162 |
-
* shared memory or database storage so that scripts serving user
|
163 |
-
* pages are able to check on the status of a notification
|
164 |
-
*
|
165 |
-
* @param string $amazonAuthorizationId
|
166 |
-
* authorization transaction to query
|
167 |
-
*
|
168 |
-
* @return GetAuthorizationDetailsResponse
|
169 |
-
*/
|
170 |
-
private function _waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId) {
|
171 |
-
// Check for the presence of the ipn notification
|
172 |
-
$this->waitForNotificationToBeProcessedBeforeContinuing ( $amazonAuthorizationId, "AuthorizationNotification" );
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Display additional information about a completed authorization
|
177 |
-
*
|
178 |
-
* Once an IPN has been received to notify the transition of an IPN to
|
179 |
-
* one of the terminal states, the merchant may optionally call
|
180 |
-
* GetAuthorizationDetails to obtain additional information about the authorization.
|
181 |
-
*
|
182 |
-
* In countries which require VAT invoicing, this approach will allow you to obtain
|
183 |
-
* the buyers billing address so that the invocing requirements can be met.
|
184 |
-
*/
|
185 |
-
private function _getAdditionalInformationForProcessedAuthorization($amazonAuthorizationId) {
|
186 |
-
// Notification is present, go and get the full
|
187 |
-
// information for this notification
|
188 |
-
$response = $this->callStepAndCheckForException ( 'getAuthorizationDetails', array (
|
189 |
-
$amazonAuthorizationId
|
190 |
-
) );
|
191 |
-
|
192 |
-
$this->printResponseToWebpage ( "printGetAuthorizationDetailsResponse", array (
|
193 |
-
$response
|
194 |
-
) );
|
195 |
-
|
196 |
-
validateThatAuthorizationIsOpen ( $response );
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Perform the capture call for the order
|
201 |
-
* Throw an exception if the capture is not processed, as this is the
|
202 |
-
* expected result
|
203 |
-
*
|
204 |
-
* @param float $captureAmount
|
205 |
-
* amount to capture from the buyer
|
206 |
-
* @param string $amazonAuthorizationId
|
207 |
-
* auth id to perform the capture on
|
208 |
-
*
|
209 |
-
* @return no response
|
210 |
-
*/
|
211 |
-
private function _captureOrderAmount($captureAmount, $amazonAuthorizationId, $providerCreditInfo = null) {
|
212 |
-
|
213 |
-
$response = $this->callStepAndCheckForException ( 'captureOrderAmount',
|
214 |
-
array($captureAmount,
|
215 |
-
$amazonAuthorizationId,
|
216 |
-
$providerCreditInfo) );
|
217 |
-
$this->printResponseToWebpage ( "printCaptureResponse", array (
|
218 |
-
$response
|
219 |
-
) );
|
220 |
-
$captureId = $response->getCaptureResult()->getCaptureDetails()->getAmazonCaptureId();
|
221 |
-
|
222 |
-
// Check for the presence of the ipn notification
|
223 |
-
$this->waitForNotificationToBeProcessedBeforeContinuing(
|
224 |
-
$captureId,
|
225 |
-
"CaptureNotification"
|
226 |
-
);
|
227 |
-
|
228 |
-
validateThatCaptureIsCompleted ( $response->getCaptureResult () );
|
229 |
-
$this->printResponseToWebpage ( "printCaptureResponse", array (
|
230 |
-
$response
|
231 |
-
) );
|
232 |
-
|
233 |
-
return $response;
|
234 |
-
}
|
235 |
-
private function _waitForProviderCreditSummaryList($captureResponse) {
|
236 |
-
$amazonCaptureId = $captureResponse->getCaptureResult()->getCaptureDetails()->getAmazonCaptureId ();
|
237 |
-
|
238 |
-
$maxSleepTime = 60;
|
239 |
-
$getCaptureDetailsResponse = null;
|
240 |
-
$providerCreditSummaryList = null;
|
241 |
-
while ( is_null ( $providerCreditSummaryList ) && $maxSleepTime > 0 ) {
|
242 |
-
sleep ( 5 );
|
243 |
-
$maxSleepTime -= 5;
|
244 |
-
$getCaptureDetailsResponse = $this->callStepAndCheckForException ( 'getCaptureDetails', array (
|
245 |
-
$amazonCaptureId
|
246 |
-
) );
|
247 |
-
$providerCreditSummaryList = $getCaptureDetailsResponse->getGetCaptureDetailsResult()->getCaptureDetails()->getProviderCreditSummaryList();
|
248 |
-
}
|
249 |
-
|
250 |
-
validateThatCaptureIsCompleted ( $getCaptureDetailsResponse->getGetCaptureDetailsResult () );
|
251 |
-
$this->printResponseToWebpage ( "printGetCaptureDetailsResponse", array (
|
252 |
-
$getCaptureDetailsResponse
|
253 |
-
) );
|
254 |
-
if (is_null($providerCreditSummaryList)) {
|
255 |
-
throw new ErrorException("No providerCreditSummaryList found in getCaptureDetails response");
|
256 |
-
}
|
257 |
-
return $providerCreditSummaryList;
|
258 |
-
}
|
259 |
-
|
260 |
-
/**
|
261 |
-
*/
|
262 |
-
private function _confirmProviderCreditSummaries($providerCreditSummaryList) {
|
263 |
-
if (! is_null ( $providerCreditSummaryList ) && $providerCreditSummaryList->isSetmember()) {
|
264 |
-
$values = $providerCreditSummaryList->getmember ();
|
265 |
-
foreach ( $values as $value ) {
|
266 |
-
if ($value->isSetProviderCreditId ()) {
|
267 |
-
$providerCreditId = $value->getProviderCreditId ();
|
268 |
-
// Check for the presence of the ipn notification
|
269 |
-
$this->waitForNotificationToBeProcessedBeforeContinuing ( $providerCreditId, "ProviderCreditNotification" );
|
270 |
-
|
271 |
-
$response = $this->callStepAndCheckForException ( 'getProviderCreditDetails', array (
|
272 |
-
$providerCreditId
|
273 |
-
) );
|
274 |
-
$this->printResponseToWebpage ( "printProviderCreditDetailsResponse", array (
|
275 |
-
$response
|
276 |
-
) );
|
277 |
-
}
|
278 |
-
}
|
279 |
-
}
|
280 |
-
}
|
281 |
-
|
282 |
-
/**
|
283 |
-
* Close this order reference to indicate that the order is complete, and
|
284 |
-
* no further authorizations and captures will be performed on this order
|
285 |
-
*
|
286 |
-
* @return no value
|
287 |
-
*/
|
288 |
-
private function _closeOrderReference() {
|
289 |
-
$response = $this->callStepAndCheckForException ( 'closeOrderReference' );
|
290 |
-
$this->printResponseToWebpage ( "printCloseOrderReferenceResponse", array (
|
291 |
-
$response
|
292 |
-
) );
|
293 |
-
}
|
294 |
-
|
295 |
-
/**
|
296 |
-
* Get the authorization type selected from the request params
|
297 |
-
* i.e.
|
298 |
-
* Check if fast auth was selected.
|
299 |
-
*
|
300 |
-
* @return true for fast authorization, false for regular authorization
|
301 |
-
*/
|
302 |
-
private function _getAuthOptionFromQueryParams() {
|
303 |
-
$authOption = $this->queryStringParams ['authOption'];
|
304 |
-
return $authOption;
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
* Capture the pre tax order amount from standard input,
|
309 |
-
* making sure that it is a numeric string
|
310 |
-
*
|
311 |
-
* @return string total amount of the order before tax and shipping charges
|
312 |
-
*/
|
313 |
-
private function _getPreTaxAndShippingOrderAmountFromQueryParams() {
|
314 |
-
$orderAmount = $this->queryStringParams ['orderTotal'];
|
315 |
-
return $orderAmount;
|
316 |
-
}
|
317 |
-
|
318 |
-
/**
|
319 |
-
* Capture the shipping type for this order, which determines
|
320 |
-
* the shipping charge
|
321 |
-
*
|
322 |
-
* @return number selected shipping type index
|
323 |
-
*/
|
324 |
-
private function _getShippingTypeFromQueryParams() {
|
325 |
-
$shippingType = $this->queryStringParams ['shipping'];
|
326 |
-
return $shippingType - 1;
|
327 |
-
}
|
328 |
-
|
329 |
-
/**
|
330 |
-
* Get provider id and credit amount for this order
|
331 |
-
*/
|
332 |
-
private function _getProviderCreditInfoFromQueryParams() {
|
333 |
-
$providerId = $this->queryStringParams ['providerId'];
|
334 |
-
$providerCreditAmount = $this->queryStringParams ['providerCreditAmount'];
|
335 |
-
if(empty($providerId) || empty($providerCreditAmount))
|
336 |
-
throw new ErrorException("No provider id or provider credit amount empty.");
|
337 |
-
return array($providerId , $providerCreditAmount);
|
338 |
-
}
|
339 |
-
}
|
340 |
-
|
341 |
-
$result = new ProviderCheckoutResult ( $_SERVER ['QUERY_STRING'] );
|
342 |
-
$result->run ();
|
343 |
-
|
344 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/ProviderCreditNotificationSample.php
DELETED
@@ -1,127 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
require_once realpath ( dirname ( __FILE__ ) . "/.config.inc.php" );
|
17 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/NotificationSample.php';
|
18 |
-
require_once 'OffAmazonPaymentsNotifications/Model/ProviderCreditNotification.php';
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Class for handling an capture notification and $this->ipnLogFile->writeLine( the
|
22 |
-
* contents to the log file
|
23 |
-
*/
|
24 |
-
class OffAmazonPaymentsNotifications_Samples_ProviderCreditNotificationSample extends OffAmazonPaymentsNotifications_Samples_NotificationSample {
|
25 |
-
/**
|
26 |
-
* Create a new instance of the ProviderCredit notification sample
|
27 |
-
*
|
28 |
-
* @param OffAmazonPaymentsNotifications_Model_ProviderCreditNotification $notification
|
29 |
-
* notification
|
30 |
-
*
|
31 |
-
* @return void
|
32 |
-
*/
|
33 |
-
public function __construct(OffAmazonPaymentsNotifications_Model_ProviderCreditNotification $notification) {
|
34 |
-
parent::__construct ( $notification );
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Extract the name of the log file based on the notification
|
39 |
-
*
|
40 |
-
* @throws InvalidArgumentException
|
41 |
-
*
|
42 |
-
* @return string
|
43 |
-
*/
|
44 |
-
protected function getLogFileName() {
|
45 |
-
if (! $this->notification->getProviderCreditDetails ()->isSetAmazonProviderCreditId ()) {
|
46 |
-
throw new InvalidArgumentException ( "ProviderCreditId is NULL" );
|
47 |
-
}
|
48 |
-
|
49 |
-
return $this->notification->getProviderCreditDetails ()->getAmazonProviderCreditId () . "_ProviderCreditNotification.txt";
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Log the notification contents
|
54 |
-
*
|
55 |
-
* @return void
|
56 |
-
*/
|
57 |
-
protected function logNotificationContents() {
|
58 |
-
$this->ipnLogFile->writeLine ( "ProviderCredit Notification @ " . date ( "Y-m-d H:i:s" ) . " (GMT)" );
|
59 |
-
$this->ipnLogFile->writeLine ( "=============================================================================" );
|
60 |
-
|
61 |
-
if ($this->notification->isSetProviderCreditDetails ()) {
|
62 |
-
$this->ipnLogFile->writeLine ( " ProviderCreditDetails" );
|
63 |
-
$providerCreditDetails = $this->notification->getProviderCreditDetails ();
|
64 |
-
if ($providerCreditDetails->isSetAmazonProviderCreditId ()) {
|
65 |
-
$this->ipnLogFile->writeLine ( " AmazonProviderCreditId" );
|
66 |
-
$this->ipnLogFile->writeLine ( " " . $providerCreditDetails->getAmazonProviderCreditId () );
|
67 |
-
}
|
68 |
-
if ($providerCreditDetails->isSetCreditAmount ()) {
|
69 |
-
$this->ipnLogFile->writeLine ( " CreditAmount" );
|
70 |
-
$creditAmount = $providerCreditDetails->getCreditAmount ();
|
71 |
-
if ($creditAmount->isSetAmount ()) {
|
72 |
-
$this->ipnLogFile->writeLine ( " Amount" );
|
73 |
-
$this->ipnLogFile->writeLine ( " " . $creditAmount->getAmount () );
|
74 |
-
}
|
75 |
-
if ($creditAmount->isSetCurrencyCode ()) {
|
76 |
-
$this->ipnLogFile->writeLine ( " CurrencyCode" );
|
77 |
-
$this->ipnLogFile->writeLine ( " " . $creditAmount->getCurrencyCode () );
|
78 |
-
}
|
79 |
-
}
|
80 |
-
if ($providerCreditDetails->isSetCreditReversalAmount ()) {
|
81 |
-
$this->ipnLogFile->writeLine ( " CreditReversalAmount" );
|
82 |
-
$creditReversalAmount = $providerCreditDetails->getCreditReversalAmount ();
|
83 |
-
if ($creditReversalAmount->isSetAmount ()) {
|
84 |
-
$this->ipnLogFile->writeLine ( " Amount" );
|
85 |
-
$this->ipnLogFile->writeLine ( " " . $creditReversalAmount->getAmount () );
|
86 |
-
}
|
87 |
-
if ($creditReversalAmount->isSetCurrencyCode ()) {
|
88 |
-
$this->ipnLogFile->writeLine ( " CurrencyCode" );
|
89 |
-
$this->ipnLogFile->writeLine ( " " . $creditReversalAmount->getCurrencyCode () );
|
90 |
-
}
|
91 |
-
}
|
92 |
-
if ($providerCreditDetails->isSetCreditReversalIdList ()) {
|
93 |
-
$this->ipnLogFile->writeLine ( " CreditReversalIdList" );
|
94 |
-
$idList = $providerCreditDetails->getCreditReversalIdList ();
|
95 |
-
foreach ( $idList as $member ) {
|
96 |
-
$this->ipnLogFile->writeLine ( " member" );
|
97 |
-
$this->ipnLogFile->writeLine ( " " . $member );
|
98 |
-
}
|
99 |
-
}
|
100 |
-
if ($providerCreditDetails->isSetCreationTimestamp ()) {
|
101 |
-
$this->ipnLogFile->writeLine ( " CreationTimestamp" );
|
102 |
-
$this->ipnLogFile->writeLine ( " " . $providerCreditDetails->getCreationTimestamp () );
|
103 |
-
}
|
104 |
-
if ($providerCreditDetails->isSetCreditStatus ()) {
|
105 |
-
$this->ipnLogFile->writeLine ( " CreditStatus" );
|
106 |
-
$creditStatus = $providerCreditDetails->getCreditStatus ();
|
107 |
-
if ($creditStatus->isSetState ()) {
|
108 |
-
$this->ipnLogFile->writeLine ( " State" );
|
109 |
-
$this->ipnLogFile->writeLine ( " " . $creditStatus->getState () );
|
110 |
-
}
|
111 |
-
if ($creditStatus->isSetLastUpdateTimestamp ()) {
|
112 |
-
$this->ipnLogFile->writeLine ( " LastUpdateTimestamp" );
|
113 |
-
$this->ipnLogFile->writeLine ( " " . $creditStatus->getLastUpdateTimestamp () );
|
114 |
-
}
|
115 |
-
if ($creditStatus->isSetReasonCode ()) {
|
116 |
-
$this->ipnLogFile->writeLine ( " ReasonCode" );
|
117 |
-
$this->ipnLogFile->writeLine ( " " . $creditStatus->getReasonCode () );
|
118 |
-
}
|
119 |
-
if ($creditStatus->isSetReasonDescription ()) {
|
120 |
-
$this->ipnLogFile->writeLine ( " ReasonDescription" );
|
121 |
-
$this->ipnLogFile->writeLine ( " " . $creditStatus->getReasonDescription () );
|
122 |
-
}
|
123 |
-
}
|
124 |
-
}
|
125 |
-
}
|
126 |
-
}
|
127 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/ProviderCreditReversalNotificationSample.php
DELETED
@@ -1,115 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
require_once realpath ( dirname ( __FILE__ ) . "/.config.inc.php" );
|
17 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/NotificationSample.php';
|
18 |
-
require_once 'OffAmazonPaymentsNotifications/Model/ProviderCreditReversalNotification.php';
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Class for handling an capture notification and $this->ipnLogFile->writeLine( the
|
22 |
-
* contents to the log file
|
23 |
-
*/
|
24 |
-
class OffAmazonPaymentsNotifications_Samples_ProviderCreditReversalNotificationSample extends OffAmazonPaymentsNotifications_Samples_NotificationSample {
|
25 |
-
/**
|
26 |
-
* Create a new instance of the ProviderCreditReversal notification sample
|
27 |
-
*
|
28 |
-
* @param OffAmazonPaymentsNotifications_Model_ProviderCreditReversalNotification $notification
|
29 |
-
* notification
|
30 |
-
*
|
31 |
-
* @return void
|
32 |
-
*/
|
33 |
-
public function __construct(OffAmazonPaymentsNotifications_Model_ProviderCreditReversalNotification $notification) {
|
34 |
-
parent::__construct ( $notification );
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Extract the name of the log file based on the notification
|
39 |
-
*
|
40 |
-
* @throws InvalidArgumentException
|
41 |
-
*
|
42 |
-
* @return string
|
43 |
-
*/
|
44 |
-
protected function getLogFileName() {
|
45 |
-
if (! $this->notification->getProviderCreditReversalDetails ()->isSetAmazonProviderCreditReversalId ()) {
|
46 |
-
throw new InvalidArgumentException ( "ProviderCreditReversalId is NULL" );
|
47 |
-
}
|
48 |
-
|
49 |
-
return $this->notification->getProviderCreditReversalDetails ()->getAmazonProviderCreditReversalId () . "_ProviderCreditReversalNotification.txt";
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Log the notification contents
|
54 |
-
*
|
55 |
-
* @return void
|
56 |
-
*/
|
57 |
-
protected function logNotificationContents() {
|
58 |
-
$this->ipnLogFile->writeLine ( "ProviderCreditReversal Notification @ " . date ( "Y-m-d H:i:s" ) . " (GMT)" );
|
59 |
-
$this->ipnLogFile->writeLine ( "=============================================================================" );
|
60 |
-
|
61 |
-
if ($this->notification->isSetProviderCreditReversalDetails ()) {
|
62 |
-
$this->ipnLogFile->writeLine ( " ProviderCreditReversalDetails" );
|
63 |
-
$providerCreditReversalDetails = $this->notification->getProviderCreditReversalDetails ();
|
64 |
-
if ($providerCreditReversalDetails->isSetAmazonProviderCreditReversalId ()) {
|
65 |
-
$this->ipnLogFile->writeLine ( " AmazonProviderCreditReversalId" );
|
66 |
-
$this->ipnLogFile->writeLine ( " " . $providerCreditReversalDetails->getAmazonProviderCreditReversalId () );
|
67 |
-
}
|
68 |
-
if ($providerCreditReversalDetails->isSetCreditReversalReferenceId ()) {
|
69 |
-
$this->ipnLogFile->writeLine ( " CreditReversalReferenceId" );
|
70 |
-
$this->ipnLogFile->writeLine ( " " . $providerCreditReversalDetails->getCreditReversalReferenceId () );
|
71 |
-
}
|
72 |
-
if ($providerCreditReversalDetails->isSetCreditReversalAmount ()) {
|
73 |
-
$this->ipnLogFile->writeLine ( " CreditReversalAmount" );
|
74 |
-
$creditReversalAmount = $providerCreditReversalDetails->getCreditReversalAmount ();
|
75 |
-
if ($creditReversalAmount->isSetAmount ()) {
|
76 |
-
$this->ipnLogFile->writeLine ( " Amount" );
|
77 |
-
$this->ipnLogFile->writeLine ( " " . $creditReversalAmount->getAmount () );
|
78 |
-
}
|
79 |
-
if ($creditReversalAmount->isSetCurrencyCode ()) {
|
80 |
-
$this->ipnLogFile->writeLine ( " CurrencyCode" );
|
81 |
-
$this->ipnLogFile->writeLine ( " " . $creditReversalAmount->getCurrencyCode () );
|
82 |
-
}
|
83 |
-
}
|
84 |
-
if ($providerCreditReversalDetails->isSetCreationTimestamp ()) {
|
85 |
-
$this->ipnLogFile->writeLine ( " CreationTimestamp" );
|
86 |
-
$this->ipnLogFile->writeLine ( " " . $providerCreditReversalDetails->getCreationTimestamp () );
|
87 |
-
}
|
88 |
-
if ($providerCreditReversalDetails->isSetCreditReversalStatus ()) {
|
89 |
-
$this->ipnLogFile->writeLine ( " CreditReversalStatus" );
|
90 |
-
$creditStatus = $providerCreditReversalDetails->getCreditReversalStatus ();
|
91 |
-
if ($creditStatus->isSetState ()) {
|
92 |
-
$this->ipnLogFile->writeLine ( " State" );
|
93 |
-
$this->ipnLogFile->writeLine ( " " . $creditStatus->getState () );
|
94 |
-
}
|
95 |
-
if ($creditStatus->isSetLastUpdateTimestamp ()) {
|
96 |
-
$this->ipnLogFile->writeLine ( " LastUpdateTimestamp" );
|
97 |
-
$this->ipnLogFile->writeLine ( " " . $creditStatus->getLastUpdateTimestamp () );
|
98 |
-
}
|
99 |
-
if ($creditStatus->isSetReasonCode ()) {
|
100 |
-
$this->ipnLogFile->writeLine ( " ReasonCode" );
|
101 |
-
$this->ipnLogFile->writeLine ( " " . $creditStatus->getReasonCode () );
|
102 |
-
}
|
103 |
-
if ($creditStatus->isSetReasonDescription ()) {
|
104 |
-
$this->ipnLogFile->writeLine ( " ReasonDescription" );
|
105 |
-
$this->ipnLogFile->writeLine ( " " . $creditStatus->getReasonDescription () );
|
106 |
-
}
|
107 |
-
}
|
108 |
-
if ($providerCreditReversalDetails->isSetCreditReversalNote ()) {
|
109 |
-
$this->ipnLogFile->writeLine ( " CreditReversalNote" );
|
110 |
-
$this->ipnLogFile->writeLine ( " " . $providerCreditReversalDetails->getCreditReversalNote () );
|
111 |
-
}
|
112 |
-
}
|
113 |
-
}
|
114 |
-
}
|
115 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/ProviderRefundDataInput.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<html>
|
18 |
-
<head>
|
19 |
-
<title>Provider Refund Example</title>
|
20 |
-
</head>
|
21 |
-
<body>
|
22 |
-
<h1>Provider Refund Example</h1>
|
23 |
-
<br/><br/>
|
24 |
-
<h2>This page demonstrates the scenario where merchant needs
|
25 |
-
to perform a refund on a previously captured amount
|
26 |
-
for a closed order reference, and then reverse the credit from provider</h2>
|
27 |
-
<br/><br/>
|
28 |
-
<form name="input" action="ProviderRefundResult.php">
|
29 |
-
Order Reference Id: <input type="text" name="orderReferenceId"/><br/><br/>
|
30 |
-
Amazon Capture Id: <input type="text" name="amazonCaptureId"/><br/><br/>
|
31 |
-
Refund Amount: <input type="text" name="refundAmount"/><br/><br/>
|
32 |
-
Provider Id:<input type="text" name="providerId"/><br/><br/>
|
33 |
-
ProviderCreditReversal Amount <input type="text" name="creditReversalAmount"/><br/><br/>
|
34 |
-
<br/><br/>
|
35 |
-
<input type="submit" value="Run Sample"/>
|
36 |
-
</form>
|
37 |
-
</body>
|
38 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/ProviderRefundResult.php
DELETED
@@ -1,173 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* *****************************************************************************
|
5 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
6 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
-
*
|
8 |
-
* You may not use this file except in compliance with the License.
|
9 |
-
* You may obtain a copy of the License at:
|
10 |
-
* http://aws.amazon.com/apache2.0
|
11 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
12 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
13 |
-
* for the
|
14 |
-
* specific language governing permissions and limitations under the
|
15 |
-
* License.
|
16 |
-
* *****************************************************************************
|
17 |
-
*/
|
18 |
-
require_once realpath ( dirname ( __FILE__ ) . "/.config.inc.php" );
|
19 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/WebServerExample.php';
|
20 |
-
require_once 'OffAmazonPaymentsService/Client.php';
|
21 |
-
require_once 'OffAmazonPaymentsService/Samples/RefundExample.php';
|
22 |
-
require_once 'OffAmazonPaymentsService/Samples/RefundSample.php';
|
23 |
-
require_once 'OffAmazonPaymentsService/Samples/GetCaptureDetailsSample.php';
|
24 |
-
require_once 'OffAmazonPaymentsService/Samples/GetRefundDetailsSample.php';
|
25 |
-
require_once 'OffAmazonPaymentsService/Samples/GetProviderCreditReversalDetailsSample.php';
|
26 |
-
|
27 |
-
/**
|
28 |
-
* This script simulates a simple checkout example and generates
|
29 |
-
* html for the page
|
30 |
-
*/
|
31 |
-
class ProviderRefundResult extends WebServerExample {
|
32 |
-
/**
|
33 |
-
* Create a new instance of the Simple Checkout Example
|
34 |
-
*
|
35 |
-
* @param string $queryString
|
36 |
-
* url query string
|
37 |
-
*
|
38 |
-
* @return void
|
39 |
-
*/
|
40 |
-
public function __construct($queryString) {
|
41 |
-
parent::__construct ( $queryString );
|
42 |
-
|
43 |
-
$this->exampleClass = new RefundExample ( new OffAmazonPaymentsService_Client (), $this->queryStringParams ['orderReferenceId'], $this->queryStringParams ['amazonCaptureId'] );
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Execute the example
|
48 |
-
*
|
49 |
-
* @return void
|
50 |
-
*/
|
51 |
-
public function run() {
|
52 |
-
$this->_getOrderReferenceDetails ();
|
53 |
-
$refundAmount = $this->queryStringParams ["refundAmount"];
|
54 |
-
$providerCreditReversalInfo = $this->_getProviderCreditReversalInfoFromQueryParams();
|
55 |
-
$amazonRefundReferenceId = $this->_refundOrder ($refundAmount , $this->currencyCode, $providerCreditReversalInfo );
|
56 |
-
$providerCreditReversalSummaryList = $this->_waitUntilRefundProcessingIsCompleted ( $amazonRefundReferenceId );
|
57 |
-
$this->_confirmProviderCreditReversalSummaries ( $providerCreditReversalSummaryList );
|
58 |
-
print HTML_LB . HTML_LB . "Provider Refund Sample is Complete";
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Get the order reference details to find to the state
|
63 |
-
* of the order reference
|
64 |
-
*
|
65 |
-
* @return void
|
66 |
-
*/
|
67 |
-
private function _getOrderReferenceDetails() {
|
68 |
-
$response = $this->callStepAndCheckForException ( 'getOrderReferenceDetails' );
|
69 |
-
echo $this->printResponseToWebpage ( "printGetOrderReferenceDetailsResponse", array (
|
70 |
-
$response
|
71 |
-
) );
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Perform the refund to transfer the amount from seller
|
76 |
-
* to buyer
|
77 |
-
*
|
78 |
-
* @param string $refundAmount
|
79 |
-
* amount to refund to the buyer
|
80 |
-
* @param string $refundCurrency
|
81 |
-
* currency of the refund
|
82 |
-
*/
|
83 |
-
private function _refundOrder($refundAmount, $refundCurrency, $providerCreditReversalInfo = null) {
|
84 |
-
$response = $this->callStepAndCheckForException ( 'refundToBuyer', array (
|
85 |
-
$refundAmount,
|
86 |
-
$refundCurrency,
|
87 |
-
$providerCreditReversalInfo
|
88 |
-
) );
|
89 |
-
|
90 |
-
$this->printResponseToWebpage ( "printRefundResponse", array (
|
91 |
-
$response
|
92 |
-
) );
|
93 |
-
|
94 |
-
return $response->getRefundResult ()->getRefundDetails ()->getAmazonRefundId ();
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Poll the API for the status of the Refund Request, and continue
|
99 |
-
* once the status has been updated
|
100 |
-
* Throw an error if the status is not equal to OPEN
|
101 |
-
*
|
102 |
-
* @param string $amazonRefundReferenceId
|
103 |
-
* refund transaction to query
|
104 |
-
*
|
105 |
-
* @return No value
|
106 |
-
*/
|
107 |
-
private function _waitUntilRefundProcessingIsCompleted($amazonRefundReferenceId) {
|
108 |
-
// Check for the presence of the ipn notification
|
109 |
-
$this->waitForNotificationToBeProcessedBeforeContinuing ( $amazonRefundReferenceId, "RefundNotification" );
|
110 |
-
|
111 |
-
$response = null;
|
112 |
-
$providerCreditReversalSummaryList = null;
|
113 |
-
$maxSleepTime = 60;
|
114 |
-
while ( is_null ( $providerCreditReversalSummaryList ) && $maxSleepTime > 0 ) {
|
115 |
-
sleep ( 5 );
|
116 |
-
$maxSleepTime -= 5;
|
117 |
-
$response = $this->callStepAndCheckForException ( 'getRefundDetails', array (
|
118 |
-
$amazonRefundReferenceId
|
119 |
-
) );
|
120 |
-
|
121 |
-
$providerCreditReversalSummaryList = $response->getGetRefundDetailsResult ()->getRefundDetails ()->getProviderCreditReversalSummaryList ();
|
122 |
-
}
|
123 |
-
|
124 |
-
validateThatRefundIsCompleted ( $response->getGetRefundDetailsResult ()->getRefundDetails () );
|
125 |
-
$this->printResponseToWebpage ( "printGetRefundDetailsResponse", array (
|
126 |
-
$response
|
127 |
-
) );
|
128 |
-
if (is_null($providerCreditReversalSummaryList)) {
|
129 |
-
throw new ErrorException("No providerCreditReversalSummaryList found in getRefundDetails response");
|
130 |
-
}
|
131 |
-
return $providerCreditReversalSummaryList;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
*/
|
136 |
-
private function _confirmProviderCreditReversalSummaries($providerCreditReversalSummaryList) {
|
137 |
-
if (! is_null ( $providerCreditReversalSummaryList ) && $providerCreditReversalSummaryList->isSetmember()) {
|
138 |
-
$values = $providerCreditReversalSummaryList->getmember ();
|
139 |
-
foreach ( $values as $value ) {
|
140 |
-
if ($value->isSetProviderCreditReversalId ()) {
|
141 |
-
$providerCreditReversalId = $value->getProviderCreditReversalId ();
|
142 |
-
// Check for the presence of the ipn notification
|
143 |
-
$this->waitForNotificationToBeProcessedBeforeContinuing ( $providerCreditReversalId, "ProviderCreditReversalNotification" );
|
144 |
-
|
145 |
-
$response = $this->callStepAndCheckForException ( 'getProviderCreditReversalDetails', array (
|
146 |
-
$providerCreditReversalId
|
147 |
-
) );
|
148 |
-
|
149 |
-
$this->printResponseToWebpage ( "printGetProviderCreditReversalDetailsResponse", array (
|
150 |
-
$response
|
151 |
-
) );
|
152 |
-
}
|
153 |
-
}
|
154 |
-
}
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Get provider id and credit amount for this order
|
159 |
-
*/
|
160 |
-
private function _getProviderCreditReversalInfoFromQueryParams() {
|
161 |
-
$providerId = $this->queryStringParams ['providerId'];
|
162 |
-
$providerCreditReversalAmount = $this->queryStringParams ['creditReversalAmount'];
|
163 |
-
if(empty($providerId) || empty($providerCreditReversalAmount))
|
164 |
-
throw new ErrorException("No provider id or provider credit reversal amount empty.");
|
165 |
-
return array($providerId , $providerCreditReversalAmount);
|
166 |
-
}
|
167 |
-
|
168 |
-
}
|
169 |
-
|
170 |
-
$result = new ProviderRefundResult ( $_SERVER ['QUERY_STRING'] );
|
171 |
-
$result->run ();
|
172 |
-
|
173 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/RefundDataInput.php
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<html>
|
18 |
-
<head>
|
19 |
-
<title>Refund Example</title>
|
20 |
-
</head>
|
21 |
-
<body>
|
22 |
-
<h1>Refund Example</h1>
|
23 |
-
<br/><br/>
|
24 |
-
<h2>This page demonstrates the scenario where merchant needs
|
25 |
-
to perform a refund on a previously captured amount
|
26 |
-
for a closed order reference.</h2>
|
27 |
-
<br/><br/>
|
28 |
-
<form name="input" action="RefundResult.php">
|
29 |
-
Order Reference Id: <input type="text" name="orderReferenceId"/><br/><br/>
|
30 |
-
Amazon Capture Id: <input type="text" name="amazonCaptureId"/><br/><br/>
|
31 |
-
Refund Amount: <input type="text" name="refundAmount"/><br/><br/>
|
32 |
-
<br/><br/>
|
33 |
-
<input type="submit" value="Run Sample"/>
|
34 |
-
</form>
|
35 |
-
</body>
|
36 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/RefundNotificationSample.php
DELETED
@@ -1,154 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
|
17 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
18 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/NotificationSample.php';
|
19 |
-
require_once 'OffAmazonPaymentsNotifications/Model/RefundNotification.php';
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Class for handling a refund notification and print the
|
23 |
-
* contents to the log file
|
24 |
-
*
|
25 |
-
*/
|
26 |
-
class OffAmazonPaymentsNotifications_Samples_RefundNotificationSample
|
27 |
-
extends OffAmazonPaymentsNotifications_Samples_NotificationSample
|
28 |
-
{
|
29 |
-
/**
|
30 |
-
* Create a new instance of the Refund notification sample
|
31 |
-
*
|
32 |
-
* @param OffAmazonPaymentsNotifications_Model_RefundNotification $notification notification
|
33 |
-
*
|
34 |
-
* @return void
|
35 |
-
*/
|
36 |
-
public function __construct(
|
37 |
-
OffAmazonPaymentsNotifications_Model_RefundNotification $notification
|
38 |
-
) {
|
39 |
-
parent::__construct($notification);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Extract the name of the log file based on the notification
|
44 |
-
*
|
45 |
-
* @throws InvalidArgumentException
|
46 |
-
*
|
47 |
-
* @return string
|
48 |
-
*/
|
49 |
-
protected function getLogFileName() {
|
50 |
-
if (!$this->notification->getRefundDetails()->isSetAmazonRefundId()) {
|
51 |
-
throw new InvalidArgumentException("RefundId is NULL");
|
52 |
-
}
|
53 |
-
|
54 |
-
return $this->notification->getRefundDetails()->getAmazonRefundId()."_RefundNotification.txt";
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Log the notification contents
|
59 |
-
*
|
60 |
-
* @return void
|
61 |
-
*/
|
62 |
-
protected function logNotificationContents()
|
63 |
-
{
|
64 |
-
$this->ipnLogFile->writeLine("Refund Notification @ ".date("Y-m-d H:i:s") . " (GMT)");
|
65 |
-
$this->ipnLogFile->writeLine("=============================================================================");
|
66 |
-
if ($this->notification->isSetRefundDetails()) {
|
67 |
-
$this->ipnLogFile->writeLine(" RefundDetails");
|
68 |
-
$refundDetails = $this->notification->getRefundDetails();
|
69 |
-
if ($refundDetails->isSetAmazonRefundId()) {
|
70 |
-
$this->ipnLogFile->writeLine(" AmazonRefundId");
|
71 |
-
$this->ipnLogFile->writeLine(" " . $refundDetails->getAmazonRefundId());
|
72 |
-
}
|
73 |
-
if ($refundDetails->isSetRefundReferenceId()) {
|
74 |
-
$this->ipnLogFile->writeLine(" RefundReferenceId");
|
75 |
-
$this->ipnLogFile->writeLine(" " . $refundDetails->getRefundReferenceId());
|
76 |
-
}
|
77 |
-
if ($refundDetails->isSetRefundType()) {
|
78 |
-
$this->ipnLogFile->writeLine(" RefundType");
|
79 |
-
$this->ipnLogFile->writeLine(" " . $refundDetails->getRefundType());
|
80 |
-
}
|
81 |
-
if ($refundDetails->isSetRefundAmount()) {
|
82 |
-
$this->ipnLogFile->writeLine(" RefundAmount");
|
83 |
-
$refundAmount = $refundDetails->getRefundAmount();
|
84 |
-
if ($refundAmount->isSetAmount()) {
|
85 |
-
$this->ipnLogFile->writeLine(" Amount");
|
86 |
-
$this->ipnLogFile->writeLine(" " . $refundAmount->getAmount());
|
87 |
-
}
|
88 |
-
if ($refundAmount->isSetCurrencyCode()) {
|
89 |
-
$this->ipnLogFile->writeLine(" CurrencyCode");
|
90 |
-
$this->ipnLogFile->writeLine(" " . $refundAmount->getCurrencyCode());
|
91 |
-
}
|
92 |
-
}
|
93 |
-
if ($refundDetails->isSetFeeRefunded()) {
|
94 |
-
$this->ipnLogFile->writeLine(" FeeRefunded");
|
95 |
-
$feeRefunded = $refundDetails->getFeeRefunded();
|
96 |
-
if ($feeRefunded->isSetAmount()) {
|
97 |
-
$this->ipnLogFile->writeLine(" Amount");
|
98 |
-
$this->ipnLogFile->writeLine(" " . $feeRefunded->getAmount());
|
99 |
-
}
|
100 |
-
if ($feeRefunded->isSetCurrencyCode()) {
|
101 |
-
$this->ipnLogFile->writeLine(" CurrencyCode");
|
102 |
-
$this->ipnLogFile->writeLine(" " . $feeRefunded->getCurrencyCode());
|
103 |
-
}
|
104 |
-
}
|
105 |
-
if ($refundDetails->isSetCreationTimestamp()) {
|
106 |
-
$this->ipnLogFile->writeLine(" CreationTimestamp");
|
107 |
-
$this->ipnLogFile->writeLine(" " . $refundDetails->getCreationTimestamp());
|
108 |
-
}
|
109 |
-
if ($refundDetails->isSetRefundStatus()) {
|
110 |
-
$this->ipnLogFile->writeLine(" RefundStatus");
|
111 |
-
$refundStatus = $refundDetails->getRefundStatus();
|
112 |
-
if ($refundStatus->isSetState()) {
|
113 |
-
$this->ipnLogFile->writeLine(" State");
|
114 |
-
$this->ipnLogFile->writeLine(" " . $refundStatus->getState());
|
115 |
-
}
|
116 |
-
if ($refundStatus->isSetLastUpdateTimestamp()) {
|
117 |
-
$this->ipnLogFile->writeLine(" LastUpdateTimestamp");
|
118 |
-
$this->ipnLogFile->writeLine(" " . $refundStatus->getLastUpdateTimestamp());
|
119 |
-
}
|
120 |
-
if ($refundStatus->isSetReasonCode()) {
|
121 |
-
$this->ipnLogFile->writeLine(" ReasonCode");
|
122 |
-
$this->ipnLogFile->writeLine(" " . $refundStatus->getReasonCode());
|
123 |
-
}
|
124 |
-
if ($refundStatus->isSetReasonDescription()) {
|
125 |
-
$this->ipnLogFile->writeLine(" ReasonDescription");
|
126 |
-
$this->ipnLogFile->writeLine(" " . $refundStatus->getReasonDescription());
|
127 |
-
}
|
128 |
-
}
|
129 |
-
if($refundDetails->isSetProviderCreditReversalSummaryList()){
|
130 |
-
$this->ipnLogFile->writeLine( " ProviderCreditReversalSummaryList" );
|
131 |
-
$providerCreditReversalSummaryList = $refundDetails->getProviderCreditReversalSummaryList();
|
132 |
-
if($providerCreditReversalSummaryList->isSetProviderCreditReversalSummary()){
|
133 |
-
$values = $providerCreditReversalSummaryList->getProviderCreditReversalSummary();
|
134 |
-
foreach($values as $value){
|
135 |
-
$this->ipnLogFile->writeLine( " ProviderCreditReversalSummary" );
|
136 |
-
if($value->isSetProviderSellerId()){
|
137 |
-
$this->ipnLogFile->writeLine( " ProviderSellerId" );
|
138 |
-
$this->ipnLogFile->writeLine( " ".$value->getProviderSellerId() );
|
139 |
-
}
|
140 |
-
if($value->isSetProviderCreditReversalId()){
|
141 |
-
$this->ipnLogFile->writeLine( " ProviderCreditReversalId" );
|
142 |
-
$this->ipnLogFile->writeLine( " ".$value->getProviderCreditReversalId() );
|
143 |
-
}
|
144 |
-
}
|
145 |
-
}
|
146 |
-
}
|
147 |
-
if ($refundDetails->isSetSoftDescriptor()) {
|
148 |
-
$this->ipnLogFile->writeLine(" SoftDescriptor");
|
149 |
-
$this->ipnLogFile->writeLine(" " . $refundDetails->getSoftDescriptor());
|
150 |
-
}
|
151 |
-
}
|
152 |
-
}
|
153 |
-
}
|
154 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/RefundResult.php
DELETED
@@ -1,161 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* *****************************************************************************
|
5 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
6 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
-
*
|
8 |
-
* You may not use this file except in compliance with the License.
|
9 |
-
* You may obtain a copy of the License at:
|
10 |
-
* http://aws.amazon.com/apache2.0
|
11 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
12 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
13 |
-
* for the
|
14 |
-
* specific language governing permissions and limitations under the
|
15 |
-
* License.
|
16 |
-
* *****************************************************************************
|
17 |
-
*/
|
18 |
-
|
19 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
20 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/WebServerExample.php';
|
21 |
-
require_once 'OffAmazonPaymentsService/Client.php';
|
22 |
-
require_once 'OffAmazonPaymentsService/Samples/RefundExample.php';
|
23 |
-
require_once 'OffAmazonPaymentsService/Samples/RefundSample.php';
|
24 |
-
require_once 'OffAmazonPaymentsService/Samples/GetCaptureDetailsSample.php';
|
25 |
-
require_once 'OffAmazonPaymentsService/Samples/GetRefundDetailsSample.php';
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* This script simulates a simple checkout example and generates
|
30 |
-
* html for the page
|
31 |
-
*
|
32 |
-
*/
|
33 |
-
class RefundResult extends WebServerExample
|
34 |
-
{
|
35 |
-
/**
|
36 |
-
* Create a new instance of the Simple Checkout Example
|
37 |
-
*
|
38 |
-
* @param string $queryString url query string
|
39 |
-
*
|
40 |
-
* @return void
|
41 |
-
*/
|
42 |
-
public function __construct($queryString)
|
43 |
-
{
|
44 |
-
parent::__construct($queryString);
|
45 |
-
|
46 |
-
$this->exampleClass = new RefundExample(
|
47 |
-
new OffAmazonPaymentsService_Client(),
|
48 |
-
$this->queryStringParams['orderReferenceId'],
|
49 |
-
$this->queryStringParams['amazonCaptureId'],
|
50 |
-
);
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Execute the example
|
55 |
-
*
|
56 |
-
* @return void
|
57 |
-
*/
|
58 |
-
public function run()
|
59 |
-
{
|
60 |
-
$this->_getOrderReferenceDetails();
|
61 |
-
$amazonRefundId = $this->_refundToBuyer(
|
62 |
-
$this->queryStringParams["refundAmount"],
|
63 |
-
$this->currencyCode
|
64 |
-
);
|
65 |
-
$this->_waitUntilRefundProcessingIsCompleted($amazonRefundId);
|
66 |
-
$this->_getCaptureDetails();
|
67 |
-
print HTML_LB.HTML_LB."Refund Sample is Complete";
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Get the order reference details to find to the state
|
72 |
-
* of the order reference
|
73 |
-
*
|
74 |
-
* @return void
|
75 |
-
*/
|
76 |
-
private function _getOrderReferenceDetails()
|
77 |
-
{
|
78 |
-
$response = $this->callStepAndCheckForException('getOrderReferenceDetails');
|
79 |
-
echo $this->printResponseToWebpage(
|
80 |
-
"printGetOrderReferenceDetailsResponse",
|
81 |
-
array($response)
|
82 |
-
);
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Get the order reference details to find to the state
|
87 |
-
* of the order reference
|
88 |
-
*
|
89 |
-
* @return void
|
90 |
-
*/
|
91 |
-
private function _getCaptureDetails()
|
92 |
-
{
|
93 |
-
$response = $this->callStepAndCheckForException('getCaptureDetails');
|
94 |
-
echo $this->printResponseToWebpage(
|
95 |
-
"printGetCaptureDetailsResponse",
|
96 |
-
array($response)
|
97 |
-
);
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Perform the refund to transfer the amount from seller
|
102 |
-
* to buyer
|
103 |
-
*
|
104 |
-
* @param string $refundAmount amount to refund to the buyer
|
105 |
-
* @param string $refundCurrency currency of the refund
|
106 |
-
*
|
107 |
-
* @return void
|
108 |
-
*/
|
109 |
-
private function _refundToBuyer($refundAmount, $refundCurrency)
|
110 |
-
{
|
111 |
-
$response = $this->callStepAndCheckForException(
|
112 |
-
'refundToBuyer',
|
113 |
-
array($refundAmount, $refundCurrency)
|
114 |
-
);
|
115 |
-
echo $this->printResponseToWebpage("printRefundResponse", array($response));
|
116 |
-
return $response->getRefundResult()
|
117 |
-
->getRefundDetails()->getAmazonRefundId();
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Check that we have received an IPN notification for the refund
|
122 |
-
*
|
123 |
-
* For PHP, there is an IPN handler that will write the contents of the IPN to
|
124 |
-
* a file in the format of
|
125 |
-
* <amazonReferenceId>_RefundNotification.txt
|
126 |
-
* This method will check for the presence of this file
|
127 |
-
* and will loop/timeout until the notification has been handled.
|
128 |
-
*
|
129 |
-
* Merchants can use alternative approaches such as memory caches,
|
130 |
-
* shared memory or database storage so that scripts serving user
|
131 |
-
* pages are able to check on the status of a notification
|
132 |
-
*
|
133 |
-
* @param string $amazonRefundId refund transaction to query
|
134 |
-
*
|
135 |
-
* @return void
|
136 |
-
*/
|
137 |
-
private function _waitUntilRefundProcessingIsCompleted($amazonRefundId)
|
138 |
-
{
|
139 |
-
// Check for the presence of the ipn notification
|
140 |
-
$this->waitForNotificationToBeProcessedBeforeContinuing(
|
141 |
-
$amazonRefundId,
|
142 |
-
"RefundNotification"
|
143 |
-
);
|
144 |
-
// Notification is present, go and get the full
|
145 |
-
// information for this notification
|
146 |
-
$response = $this->callStepAndCheckForException(
|
147 |
-
'getRefundDetails', array($amazonRefundId)
|
148 |
-
);
|
149 |
-
validateThatRefundIsCompleted($response->getGetRefundDetailsResult()->getRefundDetails());
|
150 |
-
echo $this->printResponseToWebpage(
|
151 |
-
"printGetRefundDetailsResponse",
|
152 |
-
array($response)
|
153 |
-
);
|
154 |
-
|
155 |
-
}
|
156 |
-
|
157 |
-
}
|
158 |
-
$refundResult = new RefundResult($_SERVER['QUERY_STRING']);
|
159 |
-
$refundResult->run();
|
160 |
-
|
161 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/ReverseProviderCreditDataInput.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<html>
|
18 |
-
<head>
|
19 |
-
<title>Reverse Provider Credit Example</title>
|
20 |
-
</head>
|
21 |
-
<body>
|
22 |
-
<h1>Reverse Provider Credit Example</h1>
|
23 |
-
|
24 |
-
<h2>This page will perform a reverse provider credit that demonstrates
|
25 |
-
transaction required to transfer the funds from provider to
|
26 |
-
seller.</h2>
|
27 |
-
|
28 |
-
<form name="input" action="ReverseProviderCreditResult.php">
|
29 |
-
Amazon Provider Credit Id:<input type="text" name="providerCreditId"/><br/>
|
30 |
-
Credit Reversal Amount: <input type="text" name="creditReversalAmount"/><br/>
|
31 |
-
<input type="submit" value="Submit"/>
|
32 |
-
</form>
|
33 |
-
</body>
|
34 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/ReverseProviderCreditResult.php
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* *****************************************************************************
|
5 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
6 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
7 |
-
*
|
8 |
-
* You may not use this file except in compliance with the License.
|
9 |
-
* You may obtain a copy of the License at:
|
10 |
-
* http://aws.amazon.com/apache2.0
|
11 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
12 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
13 |
-
* for the
|
14 |
-
* specific language governing permissions and limitations under the
|
15 |
-
* License.
|
16 |
-
* *****************************************************************************
|
17 |
-
*/
|
18 |
-
require_once realpath ( dirname ( __FILE__ ) . "/.config.inc.php" );
|
19 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/WebServerExample.php';
|
20 |
-
require_once 'OffAmazonPaymentsService/Client.php';
|
21 |
-
require_once 'OffAmazonPaymentsService/Samples/ReverseProviderCreditExample.php';
|
22 |
-
require_once 'OffAmazonPaymentsService/Samples/ReverseProviderCreditSample.php';
|
23 |
-
|
24 |
-
/**
|
25 |
-
* This script simulates a simple checkout example and generates
|
26 |
-
* html for the page
|
27 |
-
*/
|
28 |
-
class ReverseProviderCreditResult extends WebServerExample {
|
29 |
-
/**
|
30 |
-
* Create a new instance of the Simple Checkout Example
|
31 |
-
*
|
32 |
-
* @param string $queryString
|
33 |
-
* url query string
|
34 |
-
*
|
35 |
-
* @return void
|
36 |
-
*/
|
37 |
-
public function __construct($queryString) {
|
38 |
-
parent::__construct ( $queryString );
|
39 |
-
|
40 |
-
$this->exampleClass = new ReverseProviderCreditExample ( new OffAmazonPaymentsService_Client () );
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Execute the example
|
45 |
-
*
|
46 |
-
* @return void
|
47 |
-
*/
|
48 |
-
public function run() {
|
49 |
-
$amazonProviderCreditId = $this->queryStringParams ['providerCreditId'];
|
50 |
-
$creditReversalAmount = $this->queryStringParams ['creditReversalAmount'];
|
51 |
-
$creditReversalReferenceId = str_replace ( "-", "", $amazonProviderCreditId ) . "q" . rand ( 1, 1000 );
|
52 |
-
$this->_reverseToMerchant ( $amazonProviderCreditId, $creditReversalAmount, $creditReversalReferenceId );
|
53 |
-
print "Reverse provider credit completed" . PHP_EOL;
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Perform the reverse to transfer the amount from seller
|
58 |
-
* to merchant
|
59 |
-
*
|
60 |
-
* @param string $creditReversalAmount
|
61 |
-
* amount to reverse to the buyer
|
62 |
-
* @param string $reverseCurrency
|
63 |
-
* currency of the reverse
|
64 |
-
*/
|
65 |
-
private function _reverseToMerchant($amazonProviderCreditId, $creditReversalAmount, $creditReversalReferenceId) {
|
66 |
-
$response = $this->callStepAndCheckForException ( 'reverseToMerchant', array (
|
67 |
-
$amazonProviderCreditId,
|
68 |
-
$creditReversalAmount,
|
69 |
-
$creditReversalReferenceId
|
70 |
-
) );
|
71 |
-
|
72 |
-
$this->printResponseToWebpage ( "printProviderCreditReversalDetailsResponse", array (
|
73 |
-
$response
|
74 |
-
) );
|
75 |
-
}
|
76 |
-
}
|
77 |
-
|
78 |
-
$result = new ReverseProviderCreditResult ( $_SERVER ['QUERY_STRING'] );
|
79 |
-
$result->run ();
|
80 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/Samples.html
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<!DOCTYPE html>
|
18 |
-
<html>
|
19 |
-
<head>
|
20 |
-
<title>Samples Index Page</title>
|
21 |
-
</head>
|
22 |
-
|
23 |
-
<body>
|
24 |
-
|
25 |
-
<h1>Login and Pay with Amazon PHP Sample Code</h1>
|
26 |
-
|
27 |
-
<br/>
|
28 |
-
|
29 |
-
<h2>Order Reference Samples</h2>
|
30 |
-
|
31 |
-
<p>Click <a href="PayWithAmazon/signin.php" target="_blank">here</a> to create a new
|
32 |
-
order reference before running one of the samples below</p>
|
33 |
-
|
34 |
-
<ul>
|
35 |
-
<li><a href="SimpleCheckoutDataInput.php" target="_blank">Simple checkout</a></li>
|
36 |
-
<li><a href="SplitShipmentsCheckoutDataInput_1.php" target="_blank">Split shipments</a></li>
|
37 |
-
<li><a href="RefundDataInput.php" target="_blank">Refund</a></li>
|
38 |
-
<li><a href="CancellationDataInput.php" target="_blank">Cancellation</a></li>
|
39 |
-
<li><a href="AddressConsentSample.php" target="_blank">Address consent usage</a></li>
|
40 |
-
</ul>
|
41 |
-
|
42 |
-
<br/>
|
43 |
-
|
44 |
-
<h2>Billing Agreement Samples</h2>
|
45 |
-
|
46 |
-
<p>Click <a href="AutomaticPayments/signin.php" target="_blank">here</a> to create a new
|
47 |
-
billing agreement before running one of the samples below</p>
|
48 |
-
|
49 |
-
<ul>
|
50 |
-
<li><a href="AutomaticPaymentsSimpleCheckoutDataInput.php" target="_blank">Automatic Payments Simple checkout</a></li>
|
51 |
-
</ul>
|
52 |
-
|
53 |
-
<br/>
|
54 |
-
|
55 |
-
<h2>Solution Provider Samples</h2>
|
56 |
-
|
57 |
-
<p>Click <a href="PayWithAmazon/signin.php" target="_blank">here</a> to create a new
|
58 |
-
orderReference before running one of the samples below</p>
|
59 |
-
|
60 |
-
<ul>
|
61 |
-
<li><a href="ProviderCheckoutDataInput.php" target="_blank">Provider Checkout</a></li>
|
62 |
-
<li><a href="ProviderRefundDataInput.php" target="_blank">Provider Refund</a></li>
|
63 |
-
<li><a href="ReverseProviderCreditDataInput.php" target="_blank">Reverse Provider Credit</a></li>
|
64 |
-
</ul>
|
65 |
-
|
66 |
-
</body>
|
67 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/SimpleCheckoutDataInput.php
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<html>
|
18 |
-
<head>
|
19 |
-
<title>Simple Checkout Example</title>
|
20 |
-
</head>
|
21 |
-
<body>
|
22 |
-
<h1>Simple Checkout Example</h1>
|
23 |
-
|
24 |
-
<h2>This page will perform a simple checkout that demonstrates using a tax
|
25 |
-
calculations based on the buyer address to determine an order cost, and to
|
26 |
-
then perform all transactions required to transfer the funds from buyer to
|
27 |
-
seller.</h2>
|
28 |
-
|
29 |
-
<form name="input" action="SimpleCheckoutResult.php">
|
30 |
-
Order Reference Id: <input type="text" name="orderReferenceId"/><br/>
|
31 |
-
Order total: <input type="text" name="orderTotal"/><br/>
|
32 |
-
Shipping speed:
|
33 |
-
<select name="shipping">
|
34 |
-
<option value="1">Overnight</option>
|
35 |
-
<option value="2">2-day shipping</option>
|
36 |
-
<option value="3">5-day shipping</option>
|
37 |
-
</select><br/>
|
38 |
-
Authorization Type:
|
39 |
-
<select name ="authOption">
|
40 |
-
<option value ="1">Regular Authorization (Asynchronous Response) [Default]</option>
|
41 |
-
<option value ="2">Fast Authorization (Synchronous Response)</option>
|
42 |
-
</select><br/>
|
43 |
-
<input type="submit" value="Submit"/>
|
44 |
-
</form>
|
45 |
-
</body>
|
46 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/SimpleCheckoutResult.php
DELETED
@@ -1,307 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
19 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/WebServerExample.php';
|
20 |
-
require_once 'OffAmazonPaymentsService/Client.php';
|
21 |
-
require_once 'OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php';
|
22 |
-
|
23 |
-
/**
|
24 |
-
* This script simulates a simple checkout example and generates
|
25 |
-
* html for the page
|
26 |
-
*
|
27 |
-
*/
|
28 |
-
class SimpleCheckoutResult extends WebServerExample
|
29 |
-
{
|
30 |
-
/**
|
31 |
-
* Create a new instance of the Simple Checkout Example
|
32 |
-
*
|
33 |
-
* @param string $queryString url query string
|
34 |
-
*
|
35 |
-
* @return void
|
36 |
-
*/
|
37 |
-
public function __construct($queryString)
|
38 |
-
{
|
39 |
-
parent::__construct($queryString);
|
40 |
-
|
41 |
-
$this->exampleClass = new SimpleCheckoutExample(
|
42 |
-
new OffAmazonPaymentsService_Client(),
|
43 |
-
$this->queryStringParams['orderReferenceId']
|
44 |
-
);
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Execute the example
|
49 |
-
*
|
50 |
-
* @return void
|
51 |
-
*/
|
52 |
-
public function run()
|
53 |
-
{
|
54 |
-
$orderTotal = $this->_calculateOrderTotalBasedOnBuyerDestinationAddress();
|
55 |
-
$this->_addOrderTotalAndSellerInformationToOrder($orderTotal);
|
56 |
-
$this->_confirmOrderReference();
|
57 |
-
$amazonAuthorizationId = $this->_authorizeBasedOnOptionSelected($orderTotal);
|
58 |
-
$this->_getAdditionalInformationForProcessedAuthorization($amazonAuthorizationId);
|
59 |
-
$this->_captureOrderAmount($orderTotal, $amazonAuthorizationId);
|
60 |
-
$this->_closeOrderReference();
|
61 |
-
print HTML_LB.HTML_LB."Simple Checkout Sample is Complete";
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Retreive the current information about the order as indicated by the buyer
|
66 |
-
* and calculate the total amount to charge, based on address destination state
|
67 |
-
* and country
|
68 |
-
*
|
69 |
-
* @return string total amount for the order that the merchant will
|
70 |
-
* charge the buyer
|
71 |
-
*/
|
72 |
-
private function _calculateOrderTotalBasedOnBuyerDestinationAddress()
|
73 |
-
{
|
74 |
-
$response = $this->callStepAndCheckForException('getOrderReferenceDetails');
|
75 |
-
|
76 |
-
$this->printResponseToWebpage(
|
77 |
-
"printGetOrderReferenceDetailsResponse", array($response)
|
78 |
-
);
|
79 |
-
|
80 |
-
$orderTotalPreTaxAndShipping
|
81 |
-
= $this->_getPreTaxAndShippingOrderAmountFromQueryParams();
|
82 |
-
$shippingType = $this->_getShippingTypeFromQueryParams();
|
83 |
-
|
84 |
-
return $this->exampleClass->calculateOrderTotalBasedOnBuyerDetails(
|
85 |
-
$response->getGetOrderReferenceDetailsResult()->getOrderReferenceDetails(),
|
86 |
-
$orderTotalPreTaxAndShipping,
|
87 |
-
$shippingType
|
88 |
-
);
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Add order information by making the call to setOrderReferenceDetails with
|
93 |
-
* the total order amount, as well as notes describing the order information
|
94 |
-
*
|
95 |
-
* @param float $orderTotal total value of the order, incl shipping and tax
|
96 |
-
*
|
97 |
-
* @return void
|
98 |
-
*/
|
99 |
-
private function _addOrderTotalAndSellerInformationToOrder($orderTotal)
|
100 |
-
{
|
101 |
-
$response
|
102 |
-
= $this->callStepAndCheckForException(
|
103 |
-
'addOrderTotalAndSellerInformationToOrder',
|
104 |
-
array($orderTotal)
|
105 |
-
);
|
106 |
-
|
107 |
-
$this->printResponseToWebpage(
|
108 |
-
"printSetOrderReferenceDetailsResponse", array($response)
|
109 |
-
);
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Confirm the order reference information, allowing for
|
114 |
-
* authorizations and captures to be created
|
115 |
-
*
|
116 |
-
* @return void
|
117 |
-
*/
|
118 |
-
private function _confirmOrderReference()
|
119 |
-
{
|
120 |
-
$response = $this->callStepAndCheckForException('confirmOrderReference');
|
121 |
-
|
122 |
-
$this->printResponseToWebpage(
|
123 |
-
"printConfirmOrderReferenceResponse", array($response)
|
124 |
-
);
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Perform Authorize using Regular Authorization or Fast Authorization.
|
129 |
-
*
|
130 |
-
* @param float $authorizationAmount amount to authorize from the buyer
|
131 |
-
*
|
132 |
-
* @return string amazonAuthorizationId amazon generated authorization id reference
|
133 |
-
*/
|
134 |
-
private function _authorizeBasedOnOptionSelected($authorizationAmount)
|
135 |
-
{
|
136 |
-
$authOption = $this->_getAuthOptionFromQueryParams();
|
137 |
-
$amazonAuthorizationId = $this->_authorizeOrderAmount($authorizationAmount, $authOption);
|
138 |
-
$this->_waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId);
|
139 |
-
return $amazonAuthorizationId;
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Perform the authorize call for the order
|
144 |
-
*
|
145 |
-
* @param float $authorizationAmount amount to authorize from the buyer
|
146 |
-
*
|
147 |
-
* @return string amazonAuthorizationId amazon generated authorization rest
|
148 |
-
* id reference
|
149 |
-
*/
|
150 |
-
private function _authorizeOrderAmount($authorizationAmount, $authOption = 1)
|
151 |
-
{
|
152 |
-
$response = $this->callStepAndCheckForException(
|
153 |
-
'authorizeOrderAmount',
|
154 |
-
array($authorizationAmount, $authOption)
|
155 |
-
);
|
156 |
-
|
157 |
-
$this->printResponseToWebpage(
|
158 |
-
"printAuthorizeResponse", array($response)
|
159 |
-
);
|
160 |
-
|
161 |
-
return getAmazonAuthorizationIdFromAuthorizeResponse($response);
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Check that we have received an IPN notification for the authorization
|
166 |
-
*
|
167 |
-
* For PHP, there is an IPN handler that will write the contents of the IPN to
|
168 |
-
* a file in the format of
|
169 |
-
* <amazonOrderReferenceId>_<amazonAuthorizationId>_Authorization.
|
170 |
-
* This method will check for the presnece of this file
|
171 |
-
* and will loop/timeout until the notification has been handled.
|
172 |
-
*
|
173 |
-
* Merchants can use alternative approaches such as memory caches,
|
174 |
-
* shared memory or database storage so that scripts serving user
|
175 |
-
* pages are able to check on the status of a notification
|
176 |
-
*
|
177 |
-
* @param string $amazonAuthorizationId authorization transaction to query
|
178 |
-
*
|
179 |
-
* @return GetAuthorizationDetailsResponse
|
180 |
-
*/
|
181 |
-
private function _waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId)
|
182 |
-
{
|
183 |
-
// Check for the presence of the ipn notification
|
184 |
-
$this->waitForNotificationToBeProcessedBeforeContinuing(
|
185 |
-
$amazonAuthorizationId,
|
186 |
-
"AuthorizationNotification"
|
187 |
-
);
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Display additional information about a completed authorization
|
192 |
-
*
|
193 |
-
* Once an IPN has been received to notify the transition of an IPN to
|
194 |
-
* one of the terminal states, the merchant may optionally call
|
195 |
-
* GetAuthorizationDetails to obtain additional information about the authorization.
|
196 |
-
*
|
197 |
-
* In countries which require VAT invoicing, this approach will allow you to obtain
|
198 |
-
* the buyers billing address so that the invocing requirements can be met.
|
199 |
-
*/
|
200 |
-
private function _getAdditionalInformationForProcessedAuthorization($amazonAuthorizationId)
|
201 |
-
{
|
202 |
-
// Notification is present, go and get the full
|
203 |
-
// information for this notification
|
204 |
-
$response
|
205 |
-
= $this->callStepAndCheckForException(
|
206 |
-
'getAuthorizationDetails',
|
207 |
-
array($amazonAuthorizationId)
|
208 |
-
);
|
209 |
-
|
210 |
-
$this->printResponseToWebpage(
|
211 |
-
"printGetAuthorizationDetailsResponse", array($response)
|
212 |
-
);
|
213 |
-
|
214 |
-
validateThatAuthorizationIsOpen($response);
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Perform the capture call for the order
|
219 |
-
* Throw an exception if the capture is not processed, as this is the
|
220 |
-
* expected result
|
221 |
-
*
|
222 |
-
* @param float $captureAmount amount to capture from the buyer
|
223 |
-
* @param string $amazonAuthorizationId auth id to perform the capture on
|
224 |
-
*
|
225 |
-
* @return no response
|
226 |
-
*/
|
227 |
-
private function _captureOrderAmount($captureAmount, $amazonAuthorizationId)
|
228 |
-
{
|
229 |
-
$response = $this->callStepAndCheckForException(
|
230 |
-
'captureOrderAmount',
|
231 |
-
array($captureAmount, $amazonAuthorizationId)
|
232 |
-
);
|
233 |
-
|
234 |
-
$captureId = $response->getCaptureResult()
|
235 |
-
->getCaptureDetails()->getAmazonCaptureId();
|
236 |
-
|
237 |
-
// Check for the presence of the ipn notification
|
238 |
-
$this->waitForNotificationToBeProcessedBeforeContinuing(
|
239 |
-
$captureId,
|
240 |
-
"CaptureNotification"
|
241 |
-
);
|
242 |
-
|
243 |
-
$response = $this->callStepAndCheckForException(
|
244 |
-
'getCaptureDetails',
|
245 |
-
array($captureId)
|
246 |
-
);
|
247 |
-
|
248 |
-
validateThatCaptureIsCompleted($response->getGetCaptureDetailsResult());
|
249 |
-
$this->printResponseToWebpage(
|
250 |
-
"printGetCaptureDetailsResponse", array($response)
|
251 |
-
);
|
252 |
-
}
|
253 |
-
|
254 |
-
/**
|
255 |
-
* Close this order reference to indicate that the order is complete, and
|
256 |
-
* no further authorizations and captures will be performed on this order
|
257 |
-
*
|
258 |
-
* @return no value
|
259 |
-
*/
|
260 |
-
private function _closeOrderReference()
|
261 |
-
{
|
262 |
-
$response = $this->callStepAndCheckForException('closeOrderReference');
|
263 |
-
$this->printResponseToWebpage(
|
264 |
-
"printCloseOrderReferenceResponse", array($response)
|
265 |
-
);
|
266 |
-
}
|
267 |
-
|
268 |
-
/**
|
269 |
-
* Get the authorization type selected from the request params
|
270 |
-
* i.e. Check if fast auth was selected.
|
271 |
-
* @return true for fast authorization, false for regular authorization
|
272 |
-
*/
|
273 |
-
private function _getAuthOptionFromQueryParams()
|
274 |
-
{
|
275 |
-
$authOption = $this->queryStringParams['authOption'];
|
276 |
-
return $authOption;
|
277 |
-
}
|
278 |
-
|
279 |
-
/**
|
280 |
-
* Capture the pre tax order amount from standard input,
|
281 |
-
* making sure that it is a numeric string
|
282 |
-
*
|
283 |
-
* @return string total amount of the order before tax and shipping charges
|
284 |
-
*/
|
285 |
-
private function _getPreTaxAndShippingOrderAmountFromQueryParams()
|
286 |
-
{
|
287 |
-
$orderAmount = $this->queryStringParams['orderTotal'];
|
288 |
-
return $orderAmount;
|
289 |
-
}
|
290 |
-
|
291 |
-
/**
|
292 |
-
* Capture the shipping type for this order, which determines
|
293 |
-
* the shipping charge
|
294 |
-
*
|
295 |
-
* @return number selected shipping type index
|
296 |
-
*/
|
297 |
-
private function _getShippingTypeFromQueryParams()
|
298 |
-
{
|
299 |
-
$shippingType = $this->queryStringParams['shipping'];
|
300 |
-
return $shippingType - 1;
|
301 |
-
}
|
302 |
-
}
|
303 |
-
|
304 |
-
$simpleCheckoutResult = new SimpleCheckoutResult($_SERVER['QUERY_STRING']);
|
305 |
-
$simpleCheckoutResult->run();
|
306 |
-
|
307 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/SolutionProviderMerchantNotificationSample.php
DELETED
@@ -1,89 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
require_once realpath ( dirname ( __FILE__ ) . "/.config.inc.php" );
|
17 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/NotificationSample.php';
|
18 |
-
require_once 'OffAmazonPaymentsNotifications/Model/SolutionProviderMerchantNotification.php';
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Class for handling an capture notification and $this->ipnLogFile->writeLine( the
|
22 |
-
* contents to the log file
|
23 |
-
*/
|
24 |
-
class OffAmazonPaymentsNotifications_Samples_SolutionProviderMerchantNotificationSample extends OffAmazonPaymentsNotifications_Samples_NotificationSample {
|
25 |
-
/**
|
26 |
-
* Create a new instance of the SolutionProviderMerchant notification sample
|
27 |
-
*
|
28 |
-
* @param OffAmazonPaymentsNotifications_Model_SolutionProviderMerchantNotification $notification
|
29 |
-
* notification
|
30 |
-
*
|
31 |
-
* @return void
|
32 |
-
*/
|
33 |
-
public function __construct(OffAmazonPaymentsNotifications_Model_SolutionProviderMerchantNotification $notification) {
|
34 |
-
parent::__construct ( $notification );
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Extract the name of the log file based on the notification
|
39 |
-
*
|
40 |
-
* @throws InvalidArgumentException
|
41 |
-
*
|
42 |
-
* @return string
|
43 |
-
*/
|
44 |
-
protected function getLogFileName() {
|
45 |
-
if (! $this->notification->getMerchantRegistrationDetails()->isSetSellerId()) {
|
46 |
-
throw new InvalidArgumentException ( "SellerId is NULL" );
|
47 |
-
}
|
48 |
-
|
49 |
-
return $this->notification->getMerchantRegistrationDetails()->getSellerId(). "_SolutionProviderMerchantNotification.txt";
|
50 |
-
}
|
51 |
-
|
52 |
-
|
53 |
-
protected function logNotificationContents() {
|
54 |
-
$this->ipnLogFile->writeLine ( "SolutionProviderMerchant Notification @ " . date ( "Y-m-d H:i:s" ) . " (GMT)" );
|
55 |
-
$this->ipnLogFile->writeLine ( "=============================================================================" );
|
56 |
-
|
57 |
-
if ($this->notification->isSetMerchantRegistrationDetails ()) {
|
58 |
-
$this->ipnLogFile->writeLine ( " MerchantRegistrationDetails" );
|
59 |
-
$merchantRegistrationDetails = $this->notification->getMerchantRegistrationDetails ();
|
60 |
-
if ($merchantRegistrationDetails->isSetSellerId()) {
|
61 |
-
$this->ipnLogFile->writeLine ( " SellerId" );
|
62 |
-
$this->ipnLogFile->writeLine ( " ". $merchantRegistrationDetails->getSellerId() );
|
63 |
-
}
|
64 |
-
if ($merchantRegistrationDetails->isSetType()) {
|
65 |
-
$this->ipnLogFile->writeLine ( " Type" );
|
66 |
-
$this->ipnLogFile->writeLine ( " ". $merchantRegistrationDetails->getType() );
|
67 |
-
}
|
68 |
-
if ($merchantRegistrationDetails->isSetOptions()) {
|
69 |
-
$this->ipnLogFile->writeLine ( " Options" );
|
70 |
-
$options = $merchantRegistrationDetails->getOptions();
|
71 |
-
if($options->isSetSolutionProviderOption()){
|
72 |
-
$memberList = $options->getSolutionProviderOption();
|
73 |
-
foreach ( $memberList as $solutionProviderOption ) {
|
74 |
-
$this->ipnLogFile->writeLine ( " SolutionProviderOption" );
|
75 |
-
if($solutionProviderOption->isSetname()){
|
76 |
-
$this->ipnLogFile->writeLine ( " name" );
|
77 |
-
$this->ipnLogFile->writeLine ( " ".$solutionProviderOption->getname());
|
78 |
-
}
|
79 |
-
if($solutionProviderOption->isSetvalue()){
|
80 |
-
$this->ipnLogFile->writeLine ( " value" );
|
81 |
-
$this->ipnLogFile->writeLine ( " ".$solutionProviderOption->getvalue());
|
82 |
-
}
|
83 |
-
}
|
84 |
-
}
|
85 |
-
}
|
86 |
-
}
|
87 |
-
}
|
88 |
-
}
|
89 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/SplitShipmentsCheckoutDataInput_1.php
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<html>
|
18 |
-
<head>
|
19 |
-
<title>Split Shipments Checkout Example</title>
|
20 |
-
</head>
|
21 |
-
<body>
|
22 |
-
<h1>Split Shipments Checkout Example</h1>
|
23 |
-
|
24 |
-
<h2>
|
25 |
-
<br/> This demonstrates a merchant use case where the order needs to be
|
26 |
-
<br/> furfilled in multiple shipments, or where a single item is shipped
|
27 |
-
<br/> in multiple shipments over time.
|
28 |
-
</h2>
|
29 |
-
|
30 |
-
<form name="input" action="SplitShipmentsCheckoutDataInput_2.php" method="post">
|
31 |
-
Order Reference Id: <input type="text" name="orderReferenceId"/><br/><br/>
|
32 |
-
# of Shipments <font size="2"> (To make this sample simple, we have limited # of shipments to 3)</font>:
|
33 |
-
<select name="totalShipments">
|
34 |
-
<option value="1" onselect="alert('selected');">1</option>
|
35 |
-
<option value="2">2</option>
|
36 |
-
<option value="3">3</option>
|
37 |
-
</select><br/><br/><br/>
|
38 |
-
<input type="submit" value="Submit"/>
|
39 |
-
</form>
|
40 |
-
</body>
|
41 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/SplitShipmentsCheckoutDataInput_2.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<html>
|
18 |
-
<head>
|
19 |
-
<title>Split Shipments Checkout Example</title>
|
20 |
-
</head>
|
21 |
-
<body>
|
22 |
-
<h1>Split Shipments Checkout Example Cont...</h1>
|
23 |
-
|
24 |
-
|
25 |
-
<form name="input" action="SplitShipmentsCheckoutResult.php">
|
26 |
-
<input type="hidden" name="orderReferenceId" value = '<?php echo $_REQUEST["orderReferenceId"]?>'/>
|
27 |
-
<input type="hidden" name="totalShipments" value = '<?php echo $_REQUEST["totalShipments"]?>'/>
|
28 |
-
Select an shipment item for each shipment
|
29 |
-
<?php
|
30 |
-
for($i=1; $i<=$_REQUEST["totalShipments"];$i++) {
|
31 |
-
print "<br/> <br/> Item for shipment #$i: ";
|
32 |
-
print <<<itemToSelect
|
33 |
-
<select name="item$i">
|
34 |
-
<option value="0">Apple</option>
|
35 |
-
<option value="1">Pineapple</option>
|
36 |
-
<option value="2">Bannana</option>
|
37 |
-
<option value="3">Orange</option>
|
38 |
-
<option value="4">Pear</option>
|
39 |
-
</select>
|
40 |
-
itemToSelect;
|
41 |
-
}
|
42 |
-
|
43 |
-
?>
|
44 |
-
|
45 |
-
<br/><br/><br/>
|
46 |
-
<input type="submit" value="Run Sample"/>
|
47 |
-
</form>
|
48 |
-
</body>
|
49 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/SplitShipmentsCheckoutResult.php
DELETED
@@ -1,259 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
19 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/WebServerExample.php';
|
20 |
-
require_once 'OffAmazonPaymentsService/Client.php';
|
21 |
-
require_once 'OffAmazonPaymentsService/Samples/SplitShipmentsCheckoutExample.php';
|
22 |
-
|
23 |
-
/**
|
24 |
-
* This script simulates a split shipments checkout example and generates
|
25 |
-
* html for the page
|
26 |
-
*
|
27 |
-
*/
|
28 |
-
class SplitShipmentsCheckoutResult extends WebServerExample
|
29 |
-
{
|
30 |
-
/**
|
31 |
-
* Create a new instance of the Split Shipments Checkout Example
|
32 |
-
*
|
33 |
-
* @param string $queryString url query string
|
34 |
-
*
|
35 |
-
* @return void
|
36 |
-
*/
|
37 |
-
public function __construct($queryString)
|
38 |
-
{
|
39 |
-
parent::__construct($queryString);
|
40 |
-
|
41 |
-
$this->exampleClass = new SplitShipmentsCheckoutExample(
|
42 |
-
new OffAmazonPaymentsService_Client(),
|
43 |
-
$this->queryStringParams['orderReferenceId']
|
44 |
-
);
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Execute the example
|
49 |
-
*
|
50 |
-
* @return void
|
51 |
-
*/
|
52 |
-
public function run()
|
53 |
-
{
|
54 |
-
$this->_addShipmentsToOrder();
|
55 |
-
$this->_addOrderAmountToOrderReference($this->currencyCode);
|
56 |
-
$this->_confirmOrderReference();
|
57 |
-
$this->_performAuthAndCaptureForOrderShipments();
|
58 |
-
$this->_closeOrderReference();
|
59 |
-
print HTML_LB.HTML_LB."Split Shipment Checkout Sample is Complete";
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Fill in the details for a single shipment in the order
|
64 |
-
*
|
65 |
-
* @return void
|
66 |
-
*/
|
67 |
-
private function _addShipmentsToOrder()
|
68 |
-
{
|
69 |
-
for ($i=1; $i<=$this->queryStringParams["totalShipments"];$i++) {
|
70 |
-
$this->exampleClass->addShipmentToOrder(
|
71 |
-
$this->queryStringParams["item".$i]
|
72 |
-
);
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Add the total price of all items in the order and
|
78 |
-
* update the payment contract
|
79 |
-
*
|
80 |
-
* @param string $currencyCode curreny that the order is placed in
|
81 |
-
*
|
82 |
-
* @return void
|
83 |
-
*/
|
84 |
-
private function _addOrderAmountToOrderReference($currencyCode)
|
85 |
-
{
|
86 |
-
$response = $this->callStepAndCheckForException(
|
87 |
-
'addOrderAmountToOrderReference', array($currencyCode)
|
88 |
-
);
|
89 |
-
echo $this->printResponseToWebpage(
|
90 |
-
"printSetOrderReferenceDetailsResponse", array($response)
|
91 |
-
);
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Confirm the order reference information, allowing for
|
96 |
-
* authorizations and captures to be created
|
97 |
-
*
|
98 |
-
* @return OffAmazonPaymentsService_Model_ConfirmOrderReferenceResponse service response
|
99 |
-
*/
|
100 |
-
private function _confirmOrderReference()
|
101 |
-
{
|
102 |
-
$response = $this->callStepAndCheckForException('confirmOrderReference');
|
103 |
-
echo $this->printResponseToWebpage(
|
104 |
-
"printConfirmOrderReferenceResponse", array($response)
|
105 |
-
);
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Perform the authorize and captures for all shipments in this
|
110 |
-
* order
|
111 |
-
*
|
112 |
-
* @return void
|
113 |
-
*/
|
114 |
-
private function _performAuthAndCaptureForOrderShipments()
|
115 |
-
{
|
116 |
-
for ($i = 0; $i < $this->queryStringParams["totalShipments"]; $i++) {
|
117 |
-
$this->_performAuthAndCaptureForOrderShipment($i);
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Perform the authorize and capture for a single shipment in the order
|
123 |
-
*
|
124 |
-
* @param int $shipmentNumber the shipment to perform transactions on
|
125 |
-
*
|
126 |
-
* @return void
|
127 |
-
*/
|
128 |
-
private function _performAuthAndCaptureForOrderShipment($shipmentNumber)
|
129 |
-
{
|
130 |
-
$amazonAuthorizationId
|
131 |
-
= $this->_performAuthorizationForShipment($shipmentNumber);
|
132 |
-
$this->_waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId);
|
133 |
-
$this->_performCaptureForShipment($shipmentNumber, $amazonAuthorizationId);
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Perform the authorization for the shipment at the given index
|
138 |
-
*
|
139 |
-
* @param int $shipmentNumber order item index to authorize
|
140 |
-
*
|
141 |
-
* @return string amazonAuthorizationId for the single auth call
|
142 |
-
*/
|
143 |
-
private function _performAuthorizationForShipment($shipmentNumber)
|
144 |
-
{
|
145 |
-
$response = $this->callStepAndCheckForException(
|
146 |
-
'performAuthorizationForShipment',
|
147 |
-
array($shipmentNumber, $this->currencyCode)
|
148 |
-
);
|
149 |
-
echo $this->printResponseToWebpage(
|
150 |
-
"printAuthorizeResponse",
|
151 |
-
array($response)
|
152 |
-
);
|
153 |
-
|
154 |
-
return $response->getAuthorizeResult()
|
155 |
-
->getAuthorizationDetails()->getAmazonAuthorizationId();
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* Check that we have received an IPN notification for the authorization
|
160 |
-
*
|
161 |
-
* For PHP, there is an IPN handler that will write the contents of the IPN to
|
162 |
-
* a file in the format of
|
163 |
-
* <amazonAuthorizationId>_Authorization.txt
|
164 |
-
* This method will check for the presence of this file
|
165 |
-
* and will loop/timeout until the notification has been handled.
|
166 |
-
*
|
167 |
-
* Merchants can use alternative approaches such as memory caches,
|
168 |
-
* shared memory or database storage so that scripts serving user
|
169 |
-
* pages are able to check on the status of a notification
|
170 |
-
*
|
171 |
-
* @param string $amazonAuthorizationId authorization transaction to query
|
172 |
-
*
|
173 |
-
* @return void
|
174 |
-
*/
|
175 |
-
private function _waitUntilAuthorizationProcessingIsCompleted(
|
176 |
-
$amazonAuthorizationId
|
177 |
-
) {
|
178 |
-
// Check for the presence of the ipn notification
|
179 |
-
$this->waitForNotificationToBeProcessedBeforeContinuing(
|
180 |
-
$amazonAuthorizationId,
|
181 |
-
"AuthorizationNotification"
|
182 |
-
);
|
183 |
-
|
184 |
-
// Notification is present, go and get the full
|
185 |
-
// information for this notification
|
186 |
-
$response
|
187 |
-
= $this->callStepAndCheckForException(
|
188 |
-
'getAuthorizationDetails',
|
189 |
-
array($amazonAuthorizationId)
|
190 |
-
);
|
191 |
-
|
192 |
-
echo $this->printResponseToWebpage(
|
193 |
-
"printGetAuthorizationDetailsResponse", array($response)
|
194 |
-
);
|
195 |
-
|
196 |
-
validateThatAuthorizationIsOpen($response);
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Perform the capture for a single shipment
|
201 |
-
*
|
202 |
-
* @param int $shipmentNumber order item index to capture
|
203 |
-
* @param string $amazonAuthorizationId authorization to capture
|
204 |
-
*
|
205 |
-
* @return void
|
206 |
-
*/
|
207 |
-
private function _performCaptureForShipment(
|
208 |
-
$shipmentNumber,
|
209 |
-
$amazonAuthorizationId
|
210 |
-
) {
|
211 |
-
$captureResponse = $this->callStepAndCheckForException(
|
212 |
-
'performCaptureForShipment',
|
213 |
-
array(
|
214 |
-
$shipmentNumber,
|
215 |
-
$amazonAuthorizationId,
|
216 |
-
$this->currencyCode
|
217 |
-
)
|
218 |
-
);
|
219 |
-
|
220 |
-
echo $this->printResponseToWebpage(
|
221 |
-
"printCaptureResponse", array($captureResponse)
|
222 |
-
);
|
223 |
-
|
224 |
-
$captureId = $captureResponse->getCaptureResult()
|
225 |
-
->getCaptureDetails()->getAmazonCaptureId();
|
226 |
-
|
227 |
-
// Check for the presence of the ipn notification
|
228 |
-
$this->waitForNotificationToBeProcessedBeforeContinuing(
|
229 |
-
$captureId,
|
230 |
-
"CaptureNotification"
|
231 |
-
);
|
232 |
-
|
233 |
-
$getCaptureDetailsresponse = $this->callStepAndCheckForException(
|
234 |
-
'getCaptureDetails',
|
235 |
-
array($captureId)
|
236 |
-
);
|
237 |
-
|
238 |
-
validateThatCaptureIsCompleted($getCaptureDetailsresponse->getGetCaptureDetailsResult());
|
239 |
-
|
240 |
-
echo $this->printResponseToWebpage(
|
241 |
-
"printGetCaptureDetailsResponse", array($getCaptureDetailsresponse)
|
242 |
-
);
|
243 |
-
}
|
244 |
-
|
245 |
-
/**
|
246 |
-
* Close this order reference to indicate that the order is complete, and
|
247 |
-
* no further authorizations and captures will be performed on this order
|
248 |
-
*
|
249 |
-
* @return void
|
250 |
-
*/
|
251 |
-
private function _closeOrderReference()
|
252 |
-
{
|
253 |
-
$response = $this->callStepAndCheckForException('closeOrderReference');
|
254 |
-
}
|
255 |
-
}
|
256 |
-
|
257 |
-
$splitShipmentsCheckoutResult = new SplitShipmentsCheckoutResult($_SERVER['QUERY_STRING']);
|
258 |
-
$splitShipmentsCheckoutResult->run();
|
259 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/WebServerExample.php
DELETED
@@ -1,205 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
19 |
-
require_once 'OffAmazonPaymentsService/Exception.php';
|
20 |
-
require_once 'OffAmazonPaymentsNotifications/Samples/IpnLogFile.php';
|
21 |
-
require_once 'OffAmazonPaymentsService/Samples/GetOrderReferenceDetailsSample.php';
|
22 |
-
require_once 'OffAmazonPaymentsService/Samples/SetOrderReferenceDetailsSample.php';
|
23 |
-
require_once 'OffAmazonPaymentsService/Samples/ConfirmOrderReferenceSample.php';
|
24 |
-
require_once 'OffAmazonPaymentsService/Samples/AuthorizeSample.php';
|
25 |
-
require_once 'OffAmazonPaymentsService/Samples/GetAuthorizationDetailsSample.php';
|
26 |
-
require_once 'OffAmazonPaymentsService/Samples/CaptureSample.php';
|
27 |
-
require_once 'OffAmazonPaymentsService/Samples/CloseOrderReferenceSample.php';
|
28 |
-
require_once 'OffAmazonPaymentsService/Samples/GetCaptureDetailsSample.php';
|
29 |
-
require_once 'OffAmazonPaymentsService/Samples/GetBillingAgreementDetailsSample.php';
|
30 |
-
require_once 'OffAmazonPaymentsService/Samples/SetBillingAgreementDetailsSample.php';
|
31 |
-
require_once 'OffAmazonPaymentsService/Samples/ConfirmBillingAgreementSample.php';
|
32 |
-
require_once 'OffAmazonPaymentsService/Samples/ValidateBillingAgreementSample.php';
|
33 |
-
require_once 'OffAmazonPaymentsService/Samples/AuthorizeOnBillingAgreementSample.php';
|
34 |
-
require_once 'OffAmazonPaymentsService/Samples/CloseBillingAgreementSample.php';
|
35 |
-
require_once 'OffAmazonPaymentsService/Samples/GetProviderCreditDetailsSample.php';
|
36 |
-
require_once 'OffAmazonPaymentsService/Samples/GetProviderCreditReversalDetailsSample.php';
|
37 |
-
require_once 'OffAmazonPaymentsService/Samples/ReverseProviderCreditSample.php';
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
define(HTML_LB, "<br/>");
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Parent class for webserver based samples that contains common
|
45 |
-
* shared code
|
46 |
-
*/
|
47 |
-
abstract class WebServerExample
|
48 |
-
{
|
49 |
-
/**
|
50 |
-
* Query string parameters
|
51 |
-
*
|
52 |
-
* @var assoc array values
|
53 |
-
*/
|
54 |
-
protected $queryStringParams = null;
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Sample class
|
58 |
-
*
|
59 |
-
* @var mixed sample class
|
60 |
-
*/
|
61 |
-
protected $exampleClass = null;
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Curreny code for requests
|
65 |
-
*
|
66 |
-
* @var string
|
67 |
-
*/
|
68 |
-
protected $currencyCode = "USD";
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Log file path location
|
72 |
-
*
|
73 |
-
* @var string
|
74 |
-
*/
|
75 |
-
protected $folderPath = null;
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Construct a new instance of the child class
|
79 |
-
*
|
80 |
-
* @param string $queryString url query string
|
81 |
-
*
|
82 |
-
* @return void
|
83 |
-
*/
|
84 |
-
public function __construct($queryString)
|
85 |
-
{
|
86 |
-
parse_str($queryString, $this->queryStringParams);
|
87 |
-
$this->folderPath = LOG_FILE_LOCATION;
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Check that we have received an IPN notification for the defined event
|
92 |
-
*
|
93 |
-
* For PHP, there is an IPN handler that will write the contents of the IPN to
|
94 |
-
* a file in the format of
|
95 |
-
* <amazonOrderReferenceId>_<amazonAuthorizationId>_Authorization.
|
96 |
-
* This method will check for the presnece of this file
|
97 |
-
* and will loop/timeout until the notification has been handled.
|
98 |
-
*
|
99 |
-
* Merchants can use alternative approaches such as memory caches,
|
100 |
-
* shared memory or database storage so that scripts serving user
|
101 |
-
* pages are able to check on the status of a notification
|
102 |
-
*
|
103 |
-
* @param string $identifier transaction that we are waiting to query
|
104 |
-
* @param string $notificationType notificationType notification type
|
105 |
-
* that we expect
|
106 |
-
*
|
107 |
-
* @return void
|
108 |
-
*/
|
109 |
-
protected function waitForNotificationToBeProcessedBeforeContinuing(
|
110 |
-
$identifier,
|
111 |
-
$notificationType
|
112 |
-
) {
|
113 |
-
$fileName = $this->folderPath . $identifier . "_" . $notificationType . ".txt";
|
114 |
-
// timeout after 1 minute
|
115 |
-
$totalChecks = 0;
|
116 |
-
|
117 |
-
while (!file_exists($fileName) && $totalChecks < 20) {
|
118 |
-
sleep(5);
|
119 |
-
$totalChecks += 1;
|
120 |
-
}
|
121 |
-
|
122 |
-
if ($totalChecks >= 20) {
|
123 |
-
throw new ErrorException(
|
124 |
-
"IPN has not been received within timeout period exiting sample" ."for ".$identifier ." and ".$notificationType
|
125 |
-
);
|
126 |
-
}
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Call the desired step and check that it does not throw an
|
131 |
-
* exception
|
132 |
-
*
|
133 |
-
* @param string $stepName the name of the step to call on the example class
|
134 |
-
* @param array $args optional parameters to function call
|
135 |
-
*
|
136 |
-
* @return mixed the response object from the step, or an exception if thrown
|
137 |
-
*/
|
138 |
-
protected function callStepAndCheckForException($stepName, $args = array())
|
139 |
-
{
|
140 |
-
try {
|
141 |
-
$response = call_user_func_array(
|
142 |
-
array($this->exampleClass, $stepName),
|
143 |
-
$args
|
144 |
-
);
|
145 |
-
} catch (OffAmazonPaymentsService_Exception $ex) {
|
146 |
-
$this->printResponseToWebpage(
|
147 |
-
"printExceptionToWebpage",
|
148 |
-
array($ex, $stepName)
|
149 |
-
);
|
150 |
-
throw $ex;
|
151 |
-
}
|
152 |
-
|
153 |
-
return $response;
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Invoke the passed in function and print the results out in
|
158 |
-
* html format to the output buffer
|
159 |
-
*
|
160 |
-
* @param string $stepName Name of the function to call
|
161 |
-
* @param array $arg Function arguments
|
162 |
-
*
|
163 |
-
* @return void
|
164 |
-
*/
|
165 |
-
protected function printResponseToWebpage($stepName, $arg=array())
|
166 |
-
{
|
167 |
-
ob_start();
|
168 |
-
call_user_func_array($stepName, $arg);
|
169 |
-
$result = ob_get_contents();
|
170 |
-
ob_clean();
|
171 |
-
$result = preg_replace("/(\\n)/", HTML_LB, $result);
|
172 |
-
$result = preg_replace("/(\\s)/", " ", $result);
|
173 |
-
print $result;
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* Execute the example
|
178 |
-
*
|
179 |
-
* @return void
|
180 |
-
*/
|
181 |
-
public abstract function run();
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Output information about the raised exception to standard output
|
186 |
-
*
|
187 |
-
* @param OffAmazonPaymentsService_Exception $ex exception
|
188 |
-
* @param string $stepName step where ex occured
|
189 |
-
*
|
190 |
-
* @return string decription of the exception
|
191 |
-
*/
|
192 |
-
function printExceptionToWebpage(
|
193 |
-
OffAmazonPaymentsService_Exception $ex,
|
194 |
-
$stepName
|
195 |
-
) {
|
196 |
-
print "Error caught executing step " . $stepName . HTML_LB;
|
197 |
-
print "Caught Exception: " . $ex->getMessage() . HTML_LB;
|
198 |
-
print "Response Status Code: " . $ex->getStatusCode() . HTML_LB;
|
199 |
-
print "Error Code: " . $ex->getErrorCode() . HTML_LB;
|
200 |
-
print "Error Type: " . $ex->getErrorType() . HTML_LB;
|
201 |
-
print "Request ID: " . $ex->getRequestId() . HTML_LB;
|
202 |
-
print "XML: " . $ex->getXML() . HTML_LB;
|
203 |
-
print "ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . HTML_LB;
|
204 |
-
}
|
205 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/address.php
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<?php
|
18 |
-
require_once(realpath(dirname(__FILE__) . "/.config.inc.php"));
|
19 |
-
require_once("OffAmazonPaymentsService/Client.php");
|
20 |
-
$client = new OffAmazonPaymentsService_Client();
|
21 |
-
$merchantValues = $client->getMerchantValues();
|
22 |
-
?>
|
23 |
-
|
24 |
-
<!DOCTYPE html>
|
25 |
-
<html>
|
26 |
-
<head>
|
27 |
-
<title>Address page</title>
|
28 |
-
<script type="text/javascript" src=<?php print "'" . $merchantValues->getWidgetUrl() . "'"; ?> ></script>
|
29 |
-
</head>
|
30 |
-
<body>
|
31 |
-
<div id="AmazonAddressWidget"></div>
|
32 |
-
|
33 |
-
<p>Click <a id="WalletLink" href="">here</a> to go to the
|
34 |
-
wallet page once you have completed the signin</p>
|
35 |
-
|
36 |
-
<script type='text/javascript' >
|
37 |
-
var regexS = "[\\?&]" + "orderReferenceId" + "=([^&#]*)";
|
38 |
-
var regex = new RegExp( regexS );
|
39 |
-
var results = regex.exec( window.location.href );
|
40 |
-
if (results != null) {
|
41 |
-
var orderReferenceId = results[1].replace("?orderReferenceId");
|
42 |
-
document.getElementById("WalletLink").href
|
43 |
-
= "wallet.php?orderReferenceId=" + orderReferenceId;
|
44 |
-
}
|
45 |
-
|
46 |
-
new OffAmazonPayments.Widgets.AddressBook({
|
47 |
-
sellerId: <?php print "\"" . $merchantValues->getMerchantId() . "\""; ?>,
|
48 |
-
amazonOrderReferenceId: orderReferenceId,
|
49 |
-
displayMode: 'Edit',
|
50 |
-
design:{size: { width:'400', height:'228' } },
|
51 |
-
onAddressSelect: function(orderReference) {
|
52 |
-
|
53 |
-
},
|
54 |
-
onError: function(error) {
|
55 |
-
alert(error.getErrorCode() + ": " + error.getErrorMessage());
|
56 |
-
}
|
57 |
-
}).bind("AmazonAddressWidget");
|
58 |
-
</script>
|
59 |
-
</body>
|
60 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/signin.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<!DOCTYPE html>
|
18 |
-
<?php
|
19 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
20 |
-
require_once("OffAmazonPaymentsService/Client.php");
|
21 |
-
$client = new OffAmazonPaymentsService_Client();
|
22 |
-
$merchantValues = $client->getMerchantValues();
|
23 |
-
?>
|
24 |
-
|
25 |
-
<html>
|
26 |
-
<head>
|
27 |
-
<title>Login page</title>
|
28 |
-
<script type="text/javascript" src=<?php print "'" . $merchantValues->getWidgetUrl() . "'"; ?> ></script>
|
29 |
-
</head>
|
30 |
-
<body>
|
31 |
-
<script type='text/javascript'>
|
32 |
-
new OffAmazonPayments.Widgets.Button({
|
33 |
-
sellerId: <?php print "\"" . $merchantValues->getMerchantId() . "\""; ?> ,
|
34 |
-
onSignIn: function(orderReference) {
|
35 |
-
window.location = 'address.php?orderReferenceId=' +
|
36 |
-
orderReference.getAmazonOrderReferenceId();
|
37 |
-
},
|
38 |
-
onError: function(error) {
|
39 |
-
alert(error.getErrorCode() + ": " + error.getErrorMessage());
|
40 |
-
}
|
41 |
-
}).bind("AmazonPayButton");
|
42 |
-
</script>
|
43 |
-
|
44 |
-
<div id="AmazonPayButton"></div>
|
45 |
-
|
46 |
-
<p>Sign in with a test buyer account to redirect to the address
|
47 |
-
widget page</p>
|
48 |
-
</body>
|
49 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsNotifications/Samples/wallet.php
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
* *****************************************************************************
|
15 |
-
*/
|
16 |
-
-->
|
17 |
-
<!DOCTYPE html>
|
18 |
-
<?php
|
19 |
-
require_once realpath(dirname(__FILE__) . "/.config.inc.php");
|
20 |
-
require_once("OffAmazonPaymentsService/Client.php");
|
21 |
-
$client = new OffAmazonPaymentsService_Client();
|
22 |
-
$merchantValues = $client->getMerchantValues();
|
23 |
-
?>
|
24 |
-
|
25 |
-
<html>
|
26 |
-
<head>
|
27 |
-
<title>Wallet page</title>
|
28 |
-
<script type="text/javascript" src=<?php print "'" . $merchantValues->getWidgetUrl() . "'"; ?> ></script>
|
29 |
-
</head>
|
30 |
-
<body>
|
31 |
-
<div id="AmazonWalletWidget"></div>
|
32 |
-
<script type='text/javascript' >
|
33 |
-
var regexS = "[\\?&]" + "orderReferenceId" + "=([^&#]*)";
|
34 |
-
var regex = new RegExp( regexS );
|
35 |
-
var results = regex.exec( window.location.href );
|
36 |
-
if (results != null) {
|
37 |
-
var orderReferenceId = results[1].replace("?orderReferenceId");
|
38 |
-
}
|
39 |
-
|
40 |
-
new OffAmazonPayments.Widgets.Wallet({
|
41 |
-
sellerId: <?php print "\"" . $merchantValues->getMerchantId() . "\""; ?>,
|
42 |
-
amazonOrderReferenceId: orderReferenceId,
|
43 |
-
displayMode: 'Edit',
|
44 |
-
design:{size: { width:'400', height:'228' } },
|
45 |
-
onPaymentSelect: function(orderReference) {
|
46 |
-
|
47 |
-
},
|
48 |
-
onError: function(error) {
|
49 |
-
alert(error.getErrorCode() + ": " + error.getErrorMessage());
|
50 |
-
}
|
51 |
-
}).bind("AmazonWalletWidget");
|
52 |
-
</script>
|
53 |
-
</body>
|
54 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Client.php
CHANGED
@@ -15,56 +15,58 @@
|
|
15 |
* *****************************************************************************
|
16 |
*/
|
17 |
|
18 |
-
|
19 |
/**
|
20 |
* @see OffAmazonPaymentsService_Interface
|
21 |
*/
|
22 |
-
|
23 |
-
|
24 |
-
require_once 'OffAmazonPaymentsService/
|
25 |
-
require_once 'OffAmazonPaymentsService/
|
26 |
-
require_once 'OffAmazonPaymentsService/Model/
|
27 |
-
require_once 'OffAmazonPaymentsService/Model/
|
28 |
-
require_once 'OffAmazonPaymentsService/Model/
|
29 |
-
require_once 'OffAmazonPaymentsService/Model/
|
30 |
-
require_once 'OffAmazonPaymentsService/Model/
|
31 |
-
require_once 'OffAmazonPaymentsService/Model/
|
32 |
-
require_once 'OffAmazonPaymentsService/Model/
|
33 |
-
require_once 'OffAmazonPaymentsService/Model/
|
34 |
-
require_once 'OffAmazonPaymentsService/Model/
|
35 |
-
require_once 'OffAmazonPaymentsService/Model/
|
36 |
-
require_once 'OffAmazonPaymentsService/Model/
|
37 |
-
require_once 'OffAmazonPaymentsService/Model/
|
38 |
-
require_once 'OffAmazonPaymentsService/Model/
|
39 |
-
require_once 'OffAmazonPaymentsService/Model/
|
40 |
-
require_once 'OffAmazonPaymentsService/Model/
|
41 |
-
require_once 'OffAmazonPaymentsService/Model/
|
42 |
-
require_once 'OffAmazonPaymentsService/Model/
|
43 |
-
require_once 'OffAmazonPaymentsService/Model/
|
44 |
-
require_once 'OffAmazonPaymentsService/Model/
|
45 |
-
require_once 'OffAmazonPaymentsService/Model/
|
46 |
-
require_once 'OffAmazonPaymentsService/Model/
|
47 |
-
require_once 'OffAmazonPaymentsService/Model/
|
48 |
-
require_once 'OffAmazonPaymentsService/Model/
|
49 |
-
require_once 'OffAmazonPaymentsService/Model/
|
50 |
-
require_once 'OffAmazonPaymentsService/Model/
|
51 |
-
require_once 'OffAmazonPaymentsService/Model/
|
52 |
-
require_once 'OffAmazonPaymentsService/Model/
|
53 |
-
require_once 'OffAmazonPaymentsService/Model/
|
54 |
-
require_once 'OffAmazonPaymentsService/Model/
|
55 |
-
require_once 'OffAmazonPaymentsService/Model/
|
56 |
-
require_once 'OffAmazonPaymentsService/Model/
|
57 |
-
require_once 'OffAmazonPaymentsService/Model/
|
58 |
-
require_once 'OffAmazonPaymentsService/Model/
|
59 |
-
require_once 'OffAmazonPaymentsService/Model/
|
60 |
-
require_once 'OffAmazonPaymentsService/Model/
|
61 |
-
require_once 'OffAmazonPaymentsService/Model/
|
62 |
-
require_once 'OffAmazonPaymentsService/Model/
|
63 |
-
require_once 'OffAmazonPaymentsService/Model/
|
64 |
-
require_once 'OffAmazonPaymentsService/Model/
|
65 |
-
require_once 'OffAmazonPaymentsService/Model/
|
66 |
-
require_once 'OffAmazonPaymentsService/Model/
|
67 |
-
require_once 'OffAmazonPaymentsService/Model/
|
|
|
|
|
|
|
68 |
|
69 |
/**
|
70 |
* Implementation of the OffAmazonPaymentsService interface
|
@@ -149,89 +151,89 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
149 |
CLIENT_ID
|
150 |
);
|
151 |
}
|
152 |
-
|
153 |
$this->_config = array_merge(
|
154 |
-
$this->_config,
|
155 |
array ('ServiceURL' => $this->_merchantValues->getServiceURL())
|
156 |
);
|
157 |
-
|
158 |
$this->setUserAgentHeader(
|
159 |
$this->_merchantValues->getApplicationName(),
|
160 |
$this->_merchantValues->getApplicationVersion(),
|
161 |
array("ApplicationLibraryVersion" => OffAmazonPaymentsService_Client::APPLICATION_LIBRARY_VERSION)
|
162 |
);
|
163 |
}
|
164 |
-
|
165 |
public function getMerchantValues()
|
166 |
{
|
167 |
return $this->_merchantValues;
|
168 |
}
|
169 |
-
|
170 |
private function _checkConfigHasAllRequiredKeys($config)
|
171 |
{
|
172 |
$requiredKeys = array('merchantId',
|
173 |
-
'accessKey',
|
174 |
-
'secretKey',
|
175 |
-
'region',
|
176 |
'environment',
|
177 |
'applicationName',
|
178 |
'applicationVersion'
|
179 |
);
|
180 |
-
|
181 |
$containsSearch = (
|
182 |
count(
|
183 |
array_intersect(
|
184 |
$requiredKeys,
|
185 |
-
array_keys($config)
|
186 |
)
|
187 |
) == count($requiredKeys)
|
188 |
);
|
189 |
-
|
190 |
if (!$containsSearch) {
|
191 |
throw new InvalidArgumentException("config array is missing required values");
|
192 |
}
|
193 |
}
|
194 |
-
|
195 |
-
private function setUserAgentHeader($applicationName, $applicationVersion, $attributes = null)
|
196 |
-
{
|
197 |
if (is_null($attributes)) {
|
198 |
$attributes = array ();
|
199 |
}
|
200 |
-
|
201 |
$this->_config['UserAgent']
|
202 |
= $this->constructUserAgentHeader($applicationName, $applicationVersion, $attributes);
|
203 |
}
|
204 |
-
|
205 |
-
private function constructUserAgentHeader($applicationName, $applicationVersion, $attributes)
|
206 |
{
|
207 |
$userAgent
|
208 |
= $this->quoteApplicationName($applicationName)
|
209 |
. '/'
|
210 |
. $this->quoteApplicationVersion($applicationVersion);
|
211 |
-
|
212 |
$userAgent .= ' (';
|
213 |
$userAgent .= 'Language=PHP/' . phpversion();
|
214 |
$userAgent .= '; ';
|
215 |
$userAgent .= 'Platform=' . php_uname('s') . '/' . php_uname('m') . '/' . php_uname('r');
|
216 |
$userAgent .= '; ';
|
217 |
$userAgent .= 'MWSClientVersion=' . self::MWS_CLIENT_VERSION;
|
218 |
-
|
219 |
foreach ($attributes as $key => $value) {
|
220 |
if (empty($value)) {
|
221 |
throw new InvalidArgumentException("value for $key cannot be null or empty");
|
222 |
}
|
223 |
-
|
224 |
$userAgent .= '; '
|
225 |
. $this->quoteAttributeName($key)
|
226 |
. '='
|
227 |
. $this->quoteAttributeValue($value);
|
228 |
}
|
229 |
-
|
230 |
$userAgent .= ')';
|
231 |
-
|
232 |
return $userAgent;
|
233 |
}
|
234 |
-
|
235 |
/**
|
236 |
* Collapse multiple whitespace characters into a single ' ' character.
|
237 |
* @param $s
|
@@ -251,7 +253,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
251 |
$quotedString = $this->collapseWhitespace($s);
|
252 |
$quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
|
253 |
$quotedString = preg_replace('/\//', '\\/', $quotedString);
|
254 |
-
|
255 |
return $quotedString;
|
256 |
}
|
257 |
|
@@ -266,7 +268,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
266 |
$quotedString = $this->collapseWhitespace($s);
|
267 |
$quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
|
268 |
$quotedString = preg_replace('/\\(/', '\\(', $quotedString);
|
269 |
-
|
270 |
return $quotedString;
|
271 |
}
|
272 |
|
@@ -281,7 +283,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
281 |
$quotedString = $this->collapseWhitespace($s);
|
282 |
$quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
|
283 |
$quotedString = preg_replace('/\\=/', '\\=', $quotedString);
|
284 |
-
|
285 |
return $quotedString;
|
286 |
}
|
287 |
|
@@ -297,16 +299,16 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
297 |
$quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
|
298 |
$quotedString = preg_replace('/\\;/', '\\;', $quotedString);
|
299 |
$quotedString = preg_replace('/\\)/', '\\)', $quotedString);
|
300 |
-
|
301 |
return $quotedString;
|
302 |
}
|
303 |
|
304 |
// Public API ------------------------------------------------------------//
|
305 |
|
306 |
|
307 |
-
|
308 |
/**
|
309 |
-
* Capture
|
310 |
*
|
311 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_CaptureRequest request
|
312 |
* or OffAmazonPaymentsService_Model_CaptureRequest object itself
|
@@ -327,9 +329,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
327 |
}
|
328 |
|
329 |
|
330 |
-
|
331 |
/**
|
332 |
-
* Refund
|
333 |
*
|
334 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_RefundRequest request
|
335 |
* or OffAmazonPaymentsService_Model_RefundRequest object itself
|
@@ -341,7 +343,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
341 |
public function refund($request)
|
342 |
{
|
343 |
if (!$request instanceof OffAmazonPaymentsService_Model_RefundRequest) {
|
344 |
-
|
345 |
$request = new OffAmazonPaymentsService_Model_RefundRequest($request);
|
346 |
}
|
347 |
$httpResponse = $this->_invoke($this->_convertRefund($request));
|
@@ -351,9 +353,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
351 |
}
|
352 |
|
353 |
|
354 |
-
|
355 |
/**
|
356 |
-
* Close Authorization
|
357 |
*
|
358 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_CloseAuthorizationRequest request
|
359 |
* or OffAmazonPaymentsService_Model_CloseAuthorizationRequest object itself
|
@@ -374,9 +376,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
374 |
}
|
375 |
|
376 |
|
377 |
-
|
378 |
/**
|
379 |
-
* Get Refund Details
|
380 |
*
|
381 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_GetRefundDetailsRequest request
|
382 |
* or OffAmazonPaymentsService_Model_GetRefundDetailsRequest object itself
|
@@ -397,9 +399,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
397 |
}
|
398 |
|
399 |
|
400 |
-
|
401 |
/**
|
402 |
-
* Get Capture Details
|
403 |
*
|
404 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_GetCaptureDetailsRequest request
|
405 |
* or OffAmazonPaymentsService_Model_GetCaptureDetailsRequest object itself
|
@@ -420,9 +422,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
420 |
}
|
421 |
|
422 |
|
423 |
-
|
424 |
/**
|
425 |
-
* Close Order Reference
|
426 |
*
|
427 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_CloseOrderReferenceRequest request
|
428 |
* or OffAmazonPaymentsService_Model_CloseOrderReferenceRequest object itself
|
@@ -433,7 +435,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
433 |
*/
|
434 |
public function closeOrderReference($request)
|
435 |
{
|
436 |
-
if (!$request instanceof OffAmazonPaymentsService_Model_CloseOrderReferenceRequest) {
|
437 |
$request = new OffAmazonPaymentsService_Model_CloseOrderReferenceRequest($request);
|
438 |
};
|
439 |
$httpResponse = $this->_invoke($this->_convertCloseOrderReference($request));
|
@@ -443,9 +445,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
443 |
}
|
444 |
|
445 |
|
446 |
-
|
447 |
/**
|
448 |
-
* Confirm Order Reference
|
449 |
*
|
450 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest request
|
451 |
* or OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest object itself
|
@@ -466,9 +468,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
466 |
}
|
467 |
|
468 |
|
469 |
-
|
470 |
/**
|
471 |
-
* Get Order Reference Details
|
472 |
*
|
473 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest request
|
474 |
* or OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest object itself
|
@@ -489,9 +491,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
489 |
}
|
490 |
|
491 |
|
492 |
-
|
493 |
/**
|
494 |
-
* Authorize
|
495 |
*
|
496 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_AuthorizeRequest request
|
497 |
* or OffAmazonPaymentsService_Model_AuthorizeRequest object itself
|
@@ -512,9 +514,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
512 |
}
|
513 |
|
514 |
|
515 |
-
|
516 |
/**
|
517 |
-
* Set Order Reference Details
|
518 |
*
|
519 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_SetOrderReferenceDetailsRequest request
|
520 |
* or OffAmazonPaymentsService_Model_SetOrderReferenceDetailsRequest object itself
|
@@ -535,9 +537,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
535 |
}
|
536 |
|
537 |
|
538 |
-
|
539 |
/**
|
540 |
-
* Get Authorization Details
|
541 |
*
|
542 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_GetAuthorizationDetailsRequest request
|
543 |
* or OffAmazonPaymentsService_Model_GetAuthorizationDetailsRequest object itself
|
@@ -558,9 +560,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
558 |
}
|
559 |
|
560 |
|
561 |
-
|
562 |
/**
|
563 |
-
* Cancel Order Reference
|
564 |
*
|
565 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_CancelOrderReferenceRequest request
|
566 |
* or OffAmazonPaymentsService_Model_CancelOrderReferenceRequest object itself
|
@@ -579,9 +581,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
579 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
580 |
return $response;
|
581 |
}
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
/**
|
586 |
* Create Order Reference For Id
|
587 |
*
|
@@ -602,9 +604,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
602 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
603 |
return $response;
|
604 |
}
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
/**
|
609 |
* Get Billing Agreement Details
|
610 |
*
|
@@ -625,9 +627,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
625 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
626 |
return $response;
|
627 |
}
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
/**
|
632 |
* Set Billing Agreement Details
|
633 |
*
|
@@ -648,9 +650,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
648 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
649 |
return $response;
|
650 |
}
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
/**
|
655 |
* Confirm Billing Agreement
|
656 |
*
|
@@ -671,9 +673,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
671 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
672 |
return $response;
|
673 |
}
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
/**
|
678 |
* Validate Billing Agreement
|
679 |
*
|
@@ -694,9 +696,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
694 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
695 |
return $response;
|
696 |
}
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
/**
|
701 |
* Authorize On Billing Agreement
|
702 |
*
|
@@ -717,9 +719,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
717 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
718 |
return $response;
|
719 |
}
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
/**
|
724 |
* Close Billing Agreement
|
725 |
*
|
@@ -740,7 +742,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
740 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
741 |
return $response;
|
742 |
}
|
743 |
-
|
744 |
/**
|
745 |
* Get Provider Credit Details
|
746 |
* A query API for ProviderCredits. Both Provider and Seller sellerIds are authorized to call this API.
|
@@ -763,7 +765,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
763 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
764 |
return $response;
|
765 |
}
|
766 |
-
|
767 |
/**
|
768 |
* Get Provider Credit Reversal Details
|
769 |
* Activity to query the funds reversed against a given Provider Credit reversal.
|
@@ -786,7 +788,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
786 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
787 |
return $response;
|
788 |
}
|
789 |
-
|
790 |
/**
|
791 |
* Reverse Provider Credit
|
792 |
* Activity to enable the Caller/Provider to reverse the funds credited to Provider.
|
@@ -809,7 +811,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
809 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
810 |
return $response;
|
811 |
}
|
812 |
-
|
813 |
|
814 |
// Private API ------------------------------------------------------------//
|
815 |
|
@@ -844,13 +846,13 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
844 |
$shouldRetry = false;
|
845 |
} else {
|
846 |
if ($response['Status'] === 500 || $response['Status'] === 503) {
|
847 |
-
|
848 |
-
require_once 'OffAmazonPaymentsService/Model/ErrorResponse.php';
|
849 |
$errorResponse = OffAmazonPaymentsService_Model_ErrorResponse::fromXML($response['ResponseBody']);
|
850 |
-
|
851 |
$errors = $errorResponse->getError();
|
852 |
$shouldRetry = ($errors[0]->getCode() === 'RequestThrottled') ? false : true;
|
853 |
-
|
854 |
if ($shouldRetry) {
|
855 |
$this->_pauseOnRetry(++$retries, $response['Status']);
|
856 |
} else {
|
@@ -862,11 +864,11 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
862 |
}
|
863 |
/* Rethrow on deserializer error */
|
864 |
} catch (Exception $e) {
|
865 |
-
require_once 'OffAmazonPaymentsService/Exception.php';
|
866 |
if ($e instanceof OffAmazonPaymentsService_Exception) {
|
867 |
throw $e;
|
868 |
} else {
|
869 |
-
require_once 'OffAmazonPaymentsService/Exception.php';
|
870 |
throw new OffAmazonPaymentsService_Exception(array('Exception' => $e, 'Message' => $e->getMessage()));
|
871 |
}
|
872 |
}
|
@@ -896,7 +898,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
896 |
$code = $errorMatcherOne[2];
|
897 |
$message = $errorMatcherOne[3];
|
898 |
|
899 |
-
require_once 'OffAmazonPaymentsService/Exception.php';
|
900 |
$ex = new OffAmazonPaymentsService_Exception(array ('Message' => $message, 'StatusCode' => $status, 'ErrorCode' => $code,
|
901 |
'ErrorType' => 'Unknown', 'RequestId' => $requestId, 'XML' => $responseBody,
|
902 |
'ResponseHeaderMetadata' => $responseHeaderMetadata));
|
@@ -908,28 +910,28 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
908 |
$code = $errorMatcherThree[2];
|
909 |
$message = $errorMatcherThree[3];
|
910 |
$requestId = $errorMatcherThree[5];
|
911 |
-
require_once 'OffAmazonPaymentsService/Exception.php';
|
912 |
$ex = new OffAmazonPaymentsService_Exception(array ('Message' => $message, 'StatusCode' => $status, 'ErrorCode' => $code,
|
913 |
'ErrorType' => $type, 'RequestId' => $requestId, 'XML' => $responseBody,
|
914 |
'ResponseHeaderMetadata' => $responseHeaderMetadata));
|
915 |
-
|
916 |
} elseif (preg_match('@<Error>.*<Code>(.*)</Code>.*<Message>(.*)</Message>.*</Error>.*(<Error>)?.*<RequestID>(.*)</RequestID>@mis',
|
917 |
$responseBody, $errorMatcherTwo)) {
|
918 |
|
919 |
$code = $errorMatcherTwo[1];
|
920 |
$message = $errorMatcherTwo[2];
|
921 |
$requestId = $errorMatcherTwo[4];
|
922 |
-
require_once 'OffAmazonPaymentsService/Exception.php';
|
923 |
$ex = new OffAmazonPaymentsService_Exception(array ('Message' => $message, 'StatusCode' => $status, 'ErrorCode' => $code,
|
924 |
'ErrorType' => 'Unknown', 'RequestId' => $requestId, 'XML' => $responseBody,
|
925 |
'ResponseHeaderMetadata' => $responseHeaderMetadata));
|
926 |
|
927 |
} else {
|
928 |
-
require_once 'OffAmazonPaymentsService/Exception.php';
|
929 |
$ex = new OffAmazonPaymentsService_Exception(array('Message' => 'Internal Error', 'StatusCode' => $status, 'ResponseHeaderMetadata' => $responseHeaderMetadata));
|
930 |
}
|
931 |
} else {
|
932 |
-
require_once 'OffAmazonPaymentsService/Exception.php';
|
933 |
$ex = new OffAmazonPaymentsService_Exception(array('Message' => 'Internal Error', 'StatusCode' => $status, 'ResponseHeaderMetadata' => $responseHeaderMetadata));
|
934 |
}
|
935 |
return $ex;
|
@@ -967,8 +969,8 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
967 |
curl_setopt($ch, CURLOPT_PORT, $port);
|
968 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
969 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
970 |
-
|
971 |
-
# if a ca bundle is configured, use it as opposed to the default ca
|
972 |
# configured for the server
|
973 |
if (!is_null($this->_merchantValues->getCaBundleFile())) {
|
974 |
curl_setopt($ch, CURLOPT_CAINFO, $this->_merchantValues->getCaBundleFile());
|
@@ -982,14 +984,14 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
982 |
if ($this->_config['ProxyHost'] != null && $this->_config['ProxyPort'] != -1)
|
983 |
{
|
984 |
curl_setopt($ch, CURLOPT_PROXY, $this->_config['ProxyHost'] . ':' . $this->_config['ProxyPort']);
|
985 |
-
}
|
986 |
|
987 |
$response = '';
|
988 |
if (!$response = curl_exec($ch)) {
|
989 |
$error_msg = "Unable to post request, underlying exception of " . curl_error($ch);
|
990 |
curl_close($ch);
|
991 |
-
require_once 'OffAmazonPaymentsService/Exception.php';
|
992 |
-
throw new OffAmazonPaymentsService_Exception(array('Message' => $error_msg));
|
993 |
}
|
994 |
|
995 |
curl_close($ch);
|
@@ -1006,10 +1008,10 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1006 |
} else {
|
1007 |
$headers[$k] = $v;
|
1008 |
}
|
1009 |
-
}
|
1010 |
}
|
1011 |
-
|
1012 |
-
require_once 'OffAmazonPaymentsService/Model/ResponseHeaderMetadata.php';
|
1013 |
$responseHeaderMetadata = new OffAmazonPaymentsService_Model_ResponseHeaderMetadata(
|
1014 |
$headers['x-mws-request-id'],
|
1015 |
$headers['x-mws-response-context'],
|
@@ -1031,7 +1033,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1031 |
$delay = (int) (pow(4, $retries) * 100000) ;
|
1032 |
usleep($delay);
|
1033 |
} else {
|
1034 |
-
require_once 'OffAmazonPaymentsService/Exception.php';
|
1035 |
throw new OffAmazonPaymentsService_Exception (array ('Message' => "Maximum number of retry attempts reached : $retries", 'StatusCode' => $status));
|
1036 |
}
|
1037 |
}
|
@@ -1163,7 +1165,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1163 |
{
|
1164 |
return gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
|
1165 |
}
|
1166 |
-
|
1167 |
/**
|
1168 |
* Formats date as ISO 8601 timestamp
|
1169 |
*/
|
@@ -1174,12 +1176,12 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1174 |
|
1175 |
|
1176 |
|
1177 |
-
|
1178 |
/**
|
1179 |
* Convert CaptureRequest to name value pairs
|
1180 |
*/
|
1181 |
private function _convertCapture($request) {
|
1182 |
-
|
1183 |
$parameters = array();
|
1184 |
$parameters['Action'] = 'Capture';
|
1185 |
if ($request->isSetSellerId()) {
|
@@ -1221,19 +1223,19 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1221 |
$parameters['ProviderCreditList' . '.' . 'member' . '.' . ($memberproviderCreditListIndex + 1) . '.' . 'CreditAmount' . '.' . 'CurrencyCode'] = $creditAmountmember->getCurrencyCode();
|
1222 |
}
|
1223 |
}
|
1224 |
-
|
1225 |
}
|
1226 |
}
|
1227 |
-
|
1228 |
return $parameters;
|
1229 |
}
|
1230 |
-
|
1231 |
-
|
1232 |
/**
|
1233 |
* Convert RefundRequest to name value pairs
|
1234 |
*/
|
1235 |
private function _convertRefund($request) {
|
1236 |
-
|
1237 |
$parameters = array();
|
1238 |
$parameters['Action'] = 'Refund';
|
1239 |
if ($request->isSetSellerId()) {
|
@@ -1275,19 +1277,19 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1275 |
$parameters['ProviderCreditReversalList' . '.' . 'member' . '.' . ($memberproviderCreditReversalListIndex + 1) . '.' . 'CreditReversalAmount' . '.' . 'CurrencyCode'] = $creditReversalAmountmember->getCurrencyCode();
|
1276 |
}
|
1277 |
}
|
1278 |
-
|
1279 |
}
|
1280 |
}
|
1281 |
|
1282 |
return $parameters;
|
1283 |
}
|
1284 |
-
|
1285 |
-
|
1286 |
/**
|
1287 |
* Convert CloseAuthorizationRequest to name value pairs
|
1288 |
*/
|
1289 |
private function _convertCloseAuthorization($request) {
|
1290 |
-
|
1291 |
$parameters = array();
|
1292 |
$parameters['Action'] = 'CloseAuthorization';
|
1293 |
if ($request->isSetSellerId()) {
|
@@ -1302,13 +1304,13 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1302 |
|
1303 |
return $parameters;
|
1304 |
}
|
1305 |
-
|
1306 |
-
|
1307 |
/**
|
1308 |
* Convert GetRefundDetailsRequest to name value pairs
|
1309 |
*/
|
1310 |
private function _convertGetRefundDetails($request) {
|
1311 |
-
|
1312 |
$parameters = array();
|
1313 |
$parameters['Action'] = 'GetRefundDetails';
|
1314 |
if ($request->isSetSellerId()) {
|
@@ -1320,13 +1322,13 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1320 |
|
1321 |
return $parameters;
|
1322 |
}
|
1323 |
-
|
1324 |
-
|
1325 |
/**
|
1326 |
* Convert GetCaptureDetailsRequest to name value pairs
|
1327 |
*/
|
1328 |
private function _convertGetCaptureDetails($request) {
|
1329 |
-
|
1330 |
$parameters = array();
|
1331 |
$parameters['Action'] = 'GetCaptureDetails';
|
1332 |
if ($request->isSetSellerId()) {
|
@@ -1338,13 +1340,13 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1338 |
|
1339 |
return $parameters;
|
1340 |
}
|
1341 |
-
|
1342 |
-
|
1343 |
/**
|
1344 |
* Convert CloseOrderReferenceRequest to name value pairs
|
1345 |
*/
|
1346 |
private function _convertCloseOrderReference($request) {
|
1347 |
-
|
1348 |
$parameters = array();
|
1349 |
$parameters['Action'] = 'CloseOrderReference';
|
1350 |
if ($request->isSetSellerId()) {
|
@@ -1359,13 +1361,13 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1359 |
|
1360 |
return $parameters;
|
1361 |
}
|
1362 |
-
|
1363 |
-
|
1364 |
/**
|
1365 |
* Convert ConfirmOrderReferenceRequest to name value pairs
|
1366 |
*/
|
1367 |
private function _convertConfirmOrderReference($request) {
|
1368 |
-
|
1369 |
$parameters = array();
|
1370 |
$parameters['Action'] = 'ConfirmOrderReference';
|
1371 |
if ($request->isSetAmazonOrderReferenceId()) {
|
@@ -1377,13 +1379,13 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1377 |
|
1378 |
return $parameters;
|
1379 |
}
|
1380 |
-
|
1381 |
-
|
1382 |
/**
|
1383 |
* Convert GetOrderReferenceDetailsRequest to name value pairs
|
1384 |
*/
|
1385 |
private function _convertGetOrderReferenceDetails($request) {
|
1386 |
-
|
1387 |
$parameters = array();
|
1388 |
$parameters['Action'] = 'GetOrderReferenceDetails';
|
1389 |
if ($request->isSetAmazonOrderReferenceId()) {
|
@@ -1398,13 +1400,13 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1398 |
|
1399 |
return $parameters;
|
1400 |
}
|
1401 |
-
|
1402 |
-
|
1403 |
/**
|
1404 |
* Convert AuthorizeRequest to name value pairs
|
1405 |
*/
|
1406 |
private function _convertAuthorize($request) {
|
1407 |
-
|
1408 |
$parameters = array();
|
1409 |
$parameters['Action'] = 'Authorize';
|
1410 |
if ($request->isSetSellerId()) {
|
@@ -1463,13 +1465,13 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1463 |
|
1464 |
return $parameters;
|
1465 |
}
|
1466 |
-
|
1467 |
-
|
1468 |
/**
|
1469 |
* Convert SetOrderReferenceDetailsRequest to name value pairs
|
1470 |
*/
|
1471 |
private function _convertSetOrderReferenceDetails($request) {
|
1472 |
-
|
1473 |
$parameters = array();
|
1474 |
$parameters['Action'] = 'SetOrderReferenceDetails';
|
1475 |
if ($request->isSetSellerId()) {
|
@@ -1517,13 +1519,13 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1517 |
|
1518 |
return $parameters;
|
1519 |
}
|
1520 |
-
|
1521 |
-
|
1522 |
/**
|
1523 |
* Convert GetAuthorizationDetailsRequest to name value pairs
|
1524 |
*/
|
1525 |
private function _convertGetAuthorizationDetails($request) {
|
1526 |
-
|
1527 |
$parameters = array();
|
1528 |
$parameters['Action'] = 'GetAuthorizationDetails';
|
1529 |
if ($request->isSetSellerId()) {
|
@@ -1535,13 +1537,13 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1535 |
|
1536 |
return $parameters;
|
1537 |
}
|
1538 |
-
|
1539 |
-
|
1540 |
/**
|
1541 |
* Convert CancelOrderReferenceRequest to name value pairs
|
1542 |
*/
|
1543 |
private function _convertCancelOrderReference($request) {
|
1544 |
-
|
1545 |
$parameters = array();
|
1546 |
$parameters['Action'] = 'CancelOrderReference';
|
1547 |
if ($request->isSetSellerId()) {
|
@@ -1556,13 +1558,13 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1556 |
|
1557 |
return $parameters;
|
1558 |
}
|
1559 |
-
|
1560 |
-
|
1561 |
/**
|
1562 |
* Convert CreateOrderReferenceForIdRequest to name value pairs
|
1563 |
*/
|
1564 |
private function _convertCreateOrderReferenceForId($request) {
|
1565 |
-
|
1566 |
$parameters = array();
|
1567 |
$parameters['Action'] = 'CreateOrderReferenceForId';
|
1568 |
if ($request->isSetId()) {
|
@@ -1616,16 +1618,16 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1616 |
}
|
1617 |
}
|
1618 |
}
|
1619 |
-
|
1620 |
return $parameters;
|
1621 |
}
|
1622 |
-
|
1623 |
-
|
1624 |
/**
|
1625 |
* Convert GetBillingAgreementDetailsRequest to name value pairs
|
1626 |
*/
|
1627 |
private function _convertGetBillingAgreementDetails($request) {
|
1628 |
-
|
1629 |
$parameters = array();
|
1630 |
$parameters['Action'] = 'GetBillingAgreementDetails';
|
1631 |
if ($request->isSetAmazonBillingAgreementId()) {
|
@@ -1637,16 +1639,16 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1637 |
if ($request->isSetAddressConsentToken()) {
|
1638 |
$parameters['AddressConsentToken'] = $request->getAddressConsentToken();
|
1639 |
}
|
1640 |
-
|
1641 |
return $parameters;
|
1642 |
}
|
1643 |
-
|
1644 |
-
|
1645 |
/**
|
1646 |
* Convert SetBillingAgreementDetailsRequest to name value pairs
|
1647 |
*/
|
1648 |
private function _convertSetBillingAgreementDetails($request) {
|
1649 |
-
|
1650 |
$parameters = array();
|
1651 |
$parameters['Action'] = 'SetBillingAgreementDetails';
|
1652 |
if ($request->isSetSellerId()) {
|
@@ -1676,16 +1678,16 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1676 |
}
|
1677 |
}
|
1678 |
}
|
1679 |
-
|
1680 |
return $parameters;
|
1681 |
}
|
1682 |
-
|
1683 |
-
|
1684 |
/**
|
1685 |
* Convert ConfirmBillingAgreementRequest to name value pairs
|
1686 |
*/
|
1687 |
private function _convertConfirmBillingAgreement($request) {
|
1688 |
-
|
1689 |
$parameters = array();
|
1690 |
$parameters['Action'] = 'ConfirmBillingAgreement';
|
1691 |
if ($request->isSetSellerId()) {
|
@@ -1697,13 +1699,13 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1697 |
|
1698 |
return $parameters;
|
1699 |
}
|
1700 |
-
|
1701 |
-
|
1702 |
/**
|
1703 |
* Convert ValidateBillingAgreementRequest to name value pairs
|
1704 |
*/
|
1705 |
private function _convertValidateBillingAgreement($request) {
|
1706 |
-
|
1707 |
$parameters = array();
|
1708 |
$parameters['Action'] = 'ValidateBillingAgreement';
|
1709 |
if ($request->isSetAmazonBillingAgreementId()) {
|
@@ -1712,16 +1714,16 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1712 |
if ($request->isSetSellerId()) {
|
1713 |
$parameters['SellerId'] = $request->getSellerId();
|
1714 |
}
|
1715 |
-
|
1716 |
return $parameters;
|
1717 |
}
|
1718 |
-
|
1719 |
-
|
1720 |
/**
|
1721 |
* Convert AuthorizeOnBillingAgreementRequest to name value pairs
|
1722 |
*/
|
1723 |
private function _convertAuthorizeOnBillingAgreement($request) {
|
1724 |
-
|
1725 |
$parameters = array();
|
1726 |
$parameters['Action'] = 'AuthorizeOnBillingAgreement';
|
1727 |
if ($request->isSetSellerId()) {
|
@@ -1781,16 +1783,16 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1781 |
if ($request->isSetInheritShippingAddress()) {
|
1782 |
$parameters['InheritShippingAddress'] = $request->getInheritShippingAddress() ? "true" : "false";
|
1783 |
}
|
1784 |
-
|
1785 |
return $parameters;
|
1786 |
}
|
1787 |
-
|
1788 |
-
|
1789 |
/**
|
1790 |
* Convert CloseBillingAgreementRequest to name value pairs
|
1791 |
*/
|
1792 |
private function _convertCloseBillingAgreement($request) {
|
1793 |
-
|
1794 |
$parameters = array();
|
1795 |
$parameters['Action'] = 'CloseBillingAgreement';
|
1796 |
if ($request->isSetAmazonBillingAgreementId()) {
|
@@ -1805,15 +1807,15 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1805 |
if ($request->isSetReasonCode()) {
|
1806 |
$parameters['ReasonCode'] = $request->getReasonCode();
|
1807 |
}
|
1808 |
-
|
1809 |
return $parameters;
|
1810 |
}
|
1811 |
-
|
1812 |
/**
|
1813 |
* Convert GetProviderCreditDetailsRequest to name value pairs
|
1814 |
*/
|
1815 |
private function _convertGetProviderCreditDetails($request) {
|
1816 |
-
|
1817 |
$parameters = array();
|
1818 |
$parameters['Action'] = 'GetProviderCreditDetails';
|
1819 |
if ($request->isSetSellerId()) {
|
@@ -1822,15 +1824,15 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1822 |
if ($request->isSetAmazonProviderCreditId()) {
|
1823 |
$parameters['AmazonProviderCreditId'] = $request->getAmazonProviderCreditId();
|
1824 |
}
|
1825 |
-
|
1826 |
return $parameters;
|
1827 |
}
|
1828 |
-
|
1829 |
/**
|
1830 |
* Convert GetProviderCreditReversalDetailsRequest to name value pairs
|
1831 |
*/
|
1832 |
private function _convertGetProviderCreditReversalDetails($request) {
|
1833 |
-
|
1834 |
$parameters = array();
|
1835 |
$parameters['Action'] = 'GetProviderCreditReversalDetails';
|
1836 |
if ($request->isSetSellerId()) {
|
@@ -1839,7 +1841,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1839 |
if ($request->isSetAmazonProviderCreditReversalId()) {
|
1840 |
$parameters['AmazonProviderCreditReversalId'] = $request->getAmazonProviderCreditReversalId();
|
1841 |
}
|
1842 |
-
|
1843 |
return $parameters;
|
1844 |
}
|
1845 |
|
@@ -1847,7 +1849,7 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1847 |
* Convert ReverseProviderCreditRequest to name value pairs
|
1848 |
*/
|
1849 |
private function _convertReverseProviderCredit($request) {
|
1850 |
-
|
1851 |
$parameters = array();
|
1852 |
$parameters['Action'] = 'ReverseProviderCredit';
|
1853 |
if ($request->isSetSellerId()) {
|
@@ -1871,9 +1873,9 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
|
|
1871 |
if ($request->isSetCreditReversalNote()) {
|
1872 |
$parameters['CreditReversalNote'] = $request->getCreditReversalNote();
|
1873 |
}
|
1874 |
-
|
1875 |
return $parameters;
|
1876 |
}
|
1877 |
-
|
1878 |
}
|
1879 |
?>
|
15 |
* *****************************************************************************
|
16 |
*/
|
17 |
|
|
|
18 |
/**
|
19 |
* @see OffAmazonPaymentsService_Interface
|
20 |
*/
|
21 |
+
|
22 |
+
if (!defined('COMPILER_INCLUDE_PATH')) {
|
23 |
+
require_once 'OffAmazonPaymentsService/Interface.php';
|
24 |
+
require_once 'OffAmazonPaymentsService/MerchantValues.php';
|
25 |
+
require_once 'OffAmazonPaymentsService/Model/CaptureRequest.php';
|
26 |
+
require_once 'OffAmazonPaymentsService/Model/CaptureResponse.php';
|
27 |
+
require_once 'OffAmazonPaymentsService/Model/RefundRequest.php';
|
28 |
+
require_once 'OffAmazonPaymentsService/Model/RefundResponse.php';
|
29 |
+
require_once 'OffAmazonPaymentsService/Model/CloseAuthorizationRequest.php';
|
30 |
+
require_once 'OffAmazonPaymentsService/Model/CloseAuthorizationResponse.php';
|
31 |
+
require_once 'OffAmazonPaymentsService/Model/GetRefundDetailsRequest.php';
|
32 |
+
require_once 'OffAmazonPaymentsService/Model/GetRefundDetailsResponse.php';
|
33 |
+
require_once 'OffAmazonPaymentsService/Model/GetCaptureDetailsRequest.php';
|
34 |
+
require_once 'OffAmazonPaymentsService/Model/GetCaptureDetailsResponse.php';
|
35 |
+
require_once 'OffAmazonPaymentsService/Model/CloseOrderReferenceRequest.php';
|
36 |
+
require_once 'OffAmazonPaymentsService/Model/CloseOrderReferenceResponse.php';
|
37 |
+
require_once 'OffAmazonPaymentsService/Model/ConfirmOrderReferenceRequest.php';
|
38 |
+
require_once 'OffAmazonPaymentsService/Model/ConfirmOrderReferenceResponse.php';
|
39 |
+
require_once 'OffAmazonPaymentsService/Model/GetOrderReferenceDetailsRequest.php';
|
40 |
+
require_once 'OffAmazonPaymentsService/Model/GetOrderReferenceDetailsResponse.php';
|
41 |
+
require_once 'OffAmazonPaymentsService/Model/AuthorizeRequest.php';
|
42 |
+
require_once 'OffAmazonPaymentsService/Model/AuthorizeResponse.php';
|
43 |
+
require_once 'OffAmazonPaymentsService/Model/SetOrderReferenceDetailsRequest.php';
|
44 |
+
require_once 'OffAmazonPaymentsService/Model/SetOrderReferenceDetailsResponse.php';
|
45 |
+
require_once 'OffAmazonPaymentsService/Model/GetAuthorizationDetailsRequest.php';
|
46 |
+
require_once 'OffAmazonPaymentsService/Model/GetAuthorizationDetailsResponse.php';
|
47 |
+
require_once 'OffAmazonPaymentsService/Model/CancelOrderReferenceRequest.php';
|
48 |
+
require_once 'OffAmazonPaymentsService/Model/CancelOrderReferenceResponse.php';
|
49 |
+
require_once 'OffAmazonPaymentsService/Model/AuthorizeOnBillingAgreementRequest.php';
|
50 |
+
require_once 'OffAmazonPaymentsService/Model/AuthorizeOnBillingAgreementResponse.php';
|
51 |
+
require_once 'OffAmazonPaymentsService/Model/CloseBillingAgreementRequest.php';
|
52 |
+
require_once 'OffAmazonPaymentsService/Model/CloseBillingAgreementResponse.php';
|
53 |
+
require_once 'OffAmazonPaymentsService/Model/ConfirmBillingAgreementRequest.php';
|
54 |
+
require_once 'OffAmazonPaymentsService/Model/ConfirmBillingAgreementResponse.php';
|
55 |
+
require_once 'OffAmazonPaymentsService/Model/CreateOrderReferenceForIdRequest.php';
|
56 |
+
require_once 'OffAmazonPaymentsService/Model/CreateOrderReferenceForIdResponse.php';
|
57 |
+
require_once 'OffAmazonPaymentsService/Model/GetBillingAgreementDetailsRequest.php';
|
58 |
+
require_once 'OffAmazonPaymentsService/Model/GetBillingAgreementDetailsResponse.php';
|
59 |
+
require_once 'OffAmazonPaymentsService/Model/SetBillingAgreementDetailsRequest.php';
|
60 |
+
require_once 'OffAmazonPaymentsService/Model/SetBillingAgreementDetailsResponse.php';
|
61 |
+
require_once 'OffAmazonPaymentsService/Model/ValidateBillingAgreementRequest.php';
|
62 |
+
require_once 'OffAmazonPaymentsService/Model/ValidateBillingAgreementResponse.php';
|
63 |
+
require_once 'OffAmazonPaymentsService/Model/GetProviderCreditReversalDetailsRequest.php';
|
64 |
+
require_once 'OffAmazonPaymentsService/Model/GetProviderCreditReversalDetailsResponse.php';
|
65 |
+
require_once 'OffAmazonPaymentsService/Model/GetProviderCreditDetailsRequest.php';
|
66 |
+
require_once 'OffAmazonPaymentsService/Model/GetProviderCreditDetailsResponse.php';
|
67 |
+
require_once 'OffAmazonPaymentsService/Model/ReverseProviderCreditRequest.php';
|
68 |
+
require_once 'OffAmazonPaymentsService/Model/ReverseProviderCreditResponse.php';
|
69 |
+
}
|
70 |
|
71 |
/**
|
72 |
* Implementation of the OffAmazonPaymentsService interface
|
151 |
CLIENT_ID
|
152 |
);
|
153 |
}
|
154 |
+
|
155 |
$this->_config = array_merge(
|
156 |
+
$this->_config,
|
157 |
array ('ServiceURL' => $this->_merchantValues->getServiceURL())
|
158 |
);
|
159 |
+
|
160 |
$this->setUserAgentHeader(
|
161 |
$this->_merchantValues->getApplicationName(),
|
162 |
$this->_merchantValues->getApplicationVersion(),
|
163 |
array("ApplicationLibraryVersion" => OffAmazonPaymentsService_Client::APPLICATION_LIBRARY_VERSION)
|
164 |
);
|
165 |
}
|
166 |
+
|
167 |
public function getMerchantValues()
|
168 |
{
|
169 |
return $this->_merchantValues;
|
170 |
}
|
171 |
+
|
172 |
private function _checkConfigHasAllRequiredKeys($config)
|
173 |
{
|
174 |
$requiredKeys = array('merchantId',
|
175 |
+
'accessKey',
|
176 |
+
'secretKey',
|
177 |
+
'region',
|
178 |
'environment',
|
179 |
'applicationName',
|
180 |
'applicationVersion'
|
181 |
);
|
182 |
+
|
183 |
$containsSearch = (
|
184 |
count(
|
185 |
array_intersect(
|
186 |
$requiredKeys,
|
187 |
+
array_keys($config)
|
188 |
)
|
189 |
) == count($requiredKeys)
|
190 |
);
|
191 |
+
|
192 |
if (!$containsSearch) {
|
193 |
throw new InvalidArgumentException("config array is missing required values");
|
194 |
}
|
195 |
}
|
196 |
+
|
197 |
+
private function setUserAgentHeader($applicationName, $applicationVersion, $attributes = null)
|
198 |
+
{
|
199 |
if (is_null($attributes)) {
|
200 |
$attributes = array ();
|
201 |
}
|
202 |
+
|
203 |
$this->_config['UserAgent']
|
204 |
= $this->constructUserAgentHeader($applicationName, $applicationVersion, $attributes);
|
205 |
}
|
206 |
+
|
207 |
+
private function constructUserAgentHeader($applicationName, $applicationVersion, $attributes)
|
208 |
{
|
209 |
$userAgent
|
210 |
= $this->quoteApplicationName($applicationName)
|
211 |
. '/'
|
212 |
. $this->quoteApplicationVersion($applicationVersion);
|
213 |
+
|
214 |
$userAgent .= ' (';
|
215 |
$userAgent .= 'Language=PHP/' . phpversion();
|
216 |
$userAgent .= '; ';
|
217 |
$userAgent .= 'Platform=' . php_uname('s') . '/' . php_uname('m') . '/' . php_uname('r');
|
218 |
$userAgent .= '; ';
|
219 |
$userAgent .= 'MWSClientVersion=' . self::MWS_CLIENT_VERSION;
|
220 |
+
|
221 |
foreach ($attributes as $key => $value) {
|
222 |
if (empty($value)) {
|
223 |
throw new InvalidArgumentException("value for $key cannot be null or empty");
|
224 |
}
|
225 |
+
|
226 |
$userAgent .= '; '
|
227 |
. $this->quoteAttributeName($key)
|
228 |
. '='
|
229 |
. $this->quoteAttributeValue($value);
|
230 |
}
|
231 |
+
|
232 |
$userAgent .= ')';
|
233 |
+
|
234 |
return $userAgent;
|
235 |
}
|
236 |
+
|
237 |
/**
|
238 |
* Collapse multiple whitespace characters into a single ' ' character.
|
239 |
* @param $s
|
253 |
$quotedString = $this->collapseWhitespace($s);
|
254 |
$quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
|
255 |
$quotedString = preg_replace('/\//', '\\/', $quotedString);
|
256 |
+
|
257 |
return $quotedString;
|
258 |
}
|
259 |
|
268 |
$quotedString = $this->collapseWhitespace($s);
|
269 |
$quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
|
270 |
$quotedString = preg_replace('/\\(/', '\\(', $quotedString);
|
271 |
+
|
272 |
return $quotedString;
|
273 |
}
|
274 |
|
283 |
$quotedString = $this->collapseWhitespace($s);
|
284 |
$quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
|
285 |
$quotedString = preg_replace('/\\=/', '\\=', $quotedString);
|
286 |
+
|
287 |
return $quotedString;
|
288 |
}
|
289 |
|
299 |
$quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
|
300 |
$quotedString = preg_replace('/\\;/', '\\;', $quotedString);
|
301 |
$quotedString = preg_replace('/\\)/', '\\)', $quotedString);
|
302 |
+
|
303 |
return $quotedString;
|
304 |
}
|
305 |
|
306 |
// Public API ------------------------------------------------------------//
|
307 |
|
308 |
|
309 |
+
|
310 |
/**
|
311 |
+
* Capture
|
312 |
*
|
313 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_CaptureRequest request
|
314 |
* or OffAmazonPaymentsService_Model_CaptureRequest object itself
|
329 |
}
|
330 |
|
331 |
|
332 |
+
|
333 |
/**
|
334 |
+
* Refund
|
335 |
*
|
336 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_RefundRequest request
|
337 |
* or OffAmazonPaymentsService_Model_RefundRequest object itself
|
343 |
public function refund($request)
|
344 |
{
|
345 |
if (!$request instanceof OffAmazonPaymentsService_Model_RefundRequest) {
|
346 |
+
|
347 |
$request = new OffAmazonPaymentsService_Model_RefundRequest($request);
|
348 |
}
|
349 |
$httpResponse = $this->_invoke($this->_convertRefund($request));
|
353 |
}
|
354 |
|
355 |
|
356 |
+
|
357 |
/**
|
358 |
+
* Close Authorization
|
359 |
*
|
360 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_CloseAuthorizationRequest request
|
361 |
* or OffAmazonPaymentsService_Model_CloseAuthorizationRequest object itself
|
376 |
}
|
377 |
|
378 |
|
379 |
+
|
380 |
/**
|
381 |
+
* Get Refund Details
|
382 |
*
|
383 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_GetRefundDetailsRequest request
|
384 |
* or OffAmazonPaymentsService_Model_GetRefundDetailsRequest object itself
|
399 |
}
|
400 |
|
401 |
|
402 |
+
|
403 |
/**
|
404 |
+
* Get Capture Details
|
405 |
*
|
406 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_GetCaptureDetailsRequest request
|
407 |
* or OffAmazonPaymentsService_Model_GetCaptureDetailsRequest object itself
|
422 |
}
|
423 |
|
424 |
|
425 |
+
|
426 |
/**
|
427 |
+
* Close Order Reference
|
428 |
*
|
429 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_CloseOrderReferenceRequest request
|
430 |
* or OffAmazonPaymentsService_Model_CloseOrderReferenceRequest object itself
|
435 |
*/
|
436 |
public function closeOrderReference($request)
|
437 |
{
|
438 |
+
if (!$request instanceof OffAmazonPaymentsService_Model_CloseOrderReferenceRequest) {
|
439 |
$request = new OffAmazonPaymentsService_Model_CloseOrderReferenceRequest($request);
|
440 |
};
|
441 |
$httpResponse = $this->_invoke($this->_convertCloseOrderReference($request));
|
445 |
}
|
446 |
|
447 |
|
448 |
+
|
449 |
/**
|
450 |
+
* Confirm Order Reference
|
451 |
*
|
452 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest request
|
453 |
* or OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest object itself
|
468 |
}
|
469 |
|
470 |
|
471 |
+
|
472 |
/**
|
473 |
+
* Get Order Reference Details
|
474 |
*
|
475 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest request
|
476 |
* or OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest object itself
|
491 |
}
|
492 |
|
493 |
|
494 |
+
|
495 |
/**
|
496 |
+
* Authorize
|
497 |
*
|
498 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_AuthorizeRequest request
|
499 |
* or OffAmazonPaymentsService_Model_AuthorizeRequest object itself
|
514 |
}
|
515 |
|
516 |
|
517 |
+
|
518 |
/**
|
519 |
+
* Set Order Reference Details
|
520 |
*
|
521 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_SetOrderReferenceDetailsRequest request
|
522 |
* or OffAmazonPaymentsService_Model_SetOrderReferenceDetailsRequest object itself
|
537 |
}
|
538 |
|
539 |
|
540 |
+
|
541 |
/**
|
542 |
+
* Get Authorization Details
|
543 |
*
|
544 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_GetAuthorizationDetailsRequest request
|
545 |
* or OffAmazonPaymentsService_Model_GetAuthorizationDetailsRequest object itself
|
560 |
}
|
561 |
|
562 |
|
563 |
+
|
564 |
/**
|
565 |
+
* Cancel Order Reference
|
566 |
*
|
567 |
* @param mixed $request array of parameters for OffAmazonPaymentsService_Model_CancelOrderReferenceRequest request
|
568 |
* or OffAmazonPaymentsService_Model_CancelOrderReferenceRequest object itself
|
581 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
582 |
return $response;
|
583 |
}
|
584 |
+
|
585 |
+
|
586 |
+
|
587 |
/**
|
588 |
* Create Order Reference For Id
|
589 |
*
|
604 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
605 |
return $response;
|
606 |
}
|
607 |
+
|
608 |
+
|
609 |
+
|
610 |
/**
|
611 |
* Get Billing Agreement Details
|
612 |
*
|
627 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
628 |
return $response;
|
629 |
}
|
630 |
+
|
631 |
+
|
632 |
+
|
633 |
/**
|
634 |
* Set Billing Agreement Details
|
635 |
*
|
650 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
651 |
return $response;
|
652 |
}
|
653 |
+
|
654 |
+
|
655 |
+
|
656 |
/**
|
657 |
* Confirm Billing Agreement
|
658 |
*
|
673 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
674 |
return $response;
|
675 |
}
|
676 |
+
|
677 |
+
|
678 |
+
|
679 |
/**
|
680 |
* Validate Billing Agreement
|
681 |
*
|
696 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
697 |
return $response;
|
698 |
}
|
699 |
+
|
700 |
+
|
701 |
+
|
702 |
/**
|
703 |
* Authorize On Billing Agreement
|
704 |
*
|
719 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
720 |
return $response;
|
721 |
}
|
722 |
+
|
723 |
+
|
724 |
+
|
725 |
/**
|
726 |
* Close Billing Agreement
|
727 |
*
|
742 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
743 |
return $response;
|
744 |
}
|
745 |
+
|
746 |
/**
|
747 |
* Get Provider Credit Details
|
748 |
* A query API for ProviderCredits. Both Provider and Seller sellerIds are authorized to call this API.
|
765 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
766 |
return $response;
|
767 |
}
|
768 |
+
|
769 |
/**
|
770 |
* Get Provider Credit Reversal Details
|
771 |
* Activity to query the funds reversed against a given Provider Credit reversal.
|
788 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
789 |
return $response;
|
790 |
}
|
791 |
+
|
792 |
/**
|
793 |
* Reverse Provider Credit
|
794 |
* Activity to enable the Caller/Provider to reverse the funds credited to Provider.
|
811 |
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
|
812 |
return $response;
|
813 |
}
|
814 |
+
|
815 |
|
816 |
// Private API ------------------------------------------------------------//
|
817 |
|
846 |
$shouldRetry = false;
|
847 |
} else {
|
848 |
if ($response['Status'] === 500 || $response['Status'] === 503) {
|
849 |
+
|
850 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once 'OffAmazonPaymentsService/Model/ErrorResponse.php';
|
851 |
$errorResponse = OffAmazonPaymentsService_Model_ErrorResponse::fromXML($response['ResponseBody']);
|
852 |
+
|
853 |
$errors = $errorResponse->getError();
|
854 |
$shouldRetry = ($errors[0]->getCode() === 'RequestThrottled') ? false : true;
|
855 |
+
|
856 |
if ($shouldRetry) {
|
857 |
$this->_pauseOnRetry(++$retries, $response['Status']);
|
858 |
} else {
|
864 |
}
|
865 |
/* Rethrow on deserializer error */
|
866 |
} catch (Exception $e) {
|
867 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once 'OffAmazonPaymentsService/Exception.php';
|
868 |
if ($e instanceof OffAmazonPaymentsService_Exception) {
|
869 |
throw $e;
|
870 |
} else {
|
871 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once 'OffAmazonPaymentsService/Exception.php';
|
872 |
throw new OffAmazonPaymentsService_Exception(array('Exception' => $e, 'Message' => $e->getMessage()));
|
873 |
}
|
874 |
}
|
898 |
$code = $errorMatcherOne[2];
|
899 |
$message = $errorMatcherOne[3];
|
900 |
|
901 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once 'OffAmazonPaymentsService/Exception.php';
|
902 |
$ex = new OffAmazonPaymentsService_Exception(array ('Message' => $message, 'StatusCode' => $status, 'ErrorCode' => $code,
|
903 |
'ErrorType' => 'Unknown', 'RequestId' => $requestId, 'XML' => $responseBody,
|
904 |
'ResponseHeaderMetadata' => $responseHeaderMetadata));
|
910 |
$code = $errorMatcherThree[2];
|
911 |
$message = $errorMatcherThree[3];
|
912 |
$requestId = $errorMatcherThree[5];
|
913 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once 'OffAmazonPaymentsService/Exception.php';
|
914 |
$ex = new OffAmazonPaymentsService_Exception(array ('Message' => $message, 'StatusCode' => $status, 'ErrorCode' => $code,
|
915 |
'ErrorType' => $type, 'RequestId' => $requestId, 'XML' => $responseBody,
|
916 |
'ResponseHeaderMetadata' => $responseHeaderMetadata));
|
917 |
+
|
918 |
} elseif (preg_match('@<Error>.*<Code>(.*)</Code>.*<Message>(.*)</Message>.*</Error>.*(<Error>)?.*<RequestID>(.*)</RequestID>@mis',
|
919 |
$responseBody, $errorMatcherTwo)) {
|
920 |
|
921 |
$code = $errorMatcherTwo[1];
|
922 |
$message = $errorMatcherTwo[2];
|
923 |
$requestId = $errorMatcherTwo[4];
|
924 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once 'OffAmazonPaymentsService/Exception.php';
|
925 |
$ex = new OffAmazonPaymentsService_Exception(array ('Message' => $message, 'StatusCode' => $status, 'ErrorCode' => $code,
|
926 |
'ErrorType' => 'Unknown', 'RequestId' => $requestId, 'XML' => $responseBody,
|
927 |
'ResponseHeaderMetadata' => $responseHeaderMetadata));
|
928 |
|
929 |
} else {
|
930 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once 'OffAmazonPaymentsService/Exception.php';
|
931 |
$ex = new OffAmazonPaymentsService_Exception(array('Message' => 'Internal Error', 'StatusCode' => $status, 'ResponseHeaderMetadata' => $responseHeaderMetadata));
|
932 |
}
|
933 |
} else {
|
934 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once 'OffAmazonPaymentsService/Exception.php';
|
935 |
$ex = new OffAmazonPaymentsService_Exception(array('Message' => 'Internal Error', 'StatusCode' => $status, 'ResponseHeaderMetadata' => $responseHeaderMetadata));
|
936 |
}
|
937 |
return $ex;
|
969 |
curl_setopt($ch, CURLOPT_PORT, $port);
|
970 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
971 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
972 |
+
|
973 |
+
# if a ca bundle is configured, use it as opposed to the default ca
|
974 |
# configured for the server
|
975 |
if (!is_null($this->_merchantValues->getCaBundleFile())) {
|
976 |
curl_setopt($ch, CURLOPT_CAINFO, $this->_merchantValues->getCaBundleFile());
|
984 |
if ($this->_config['ProxyHost'] != null && $this->_config['ProxyPort'] != -1)
|
985 |
{
|
986 |
curl_setopt($ch, CURLOPT_PROXY, $this->_config['ProxyHost'] . ':' . $this->_config['ProxyPort']);
|
987 |
+
}
|
988 |
|
989 |
$response = '';
|
990 |
if (!$response = curl_exec($ch)) {
|
991 |
$error_msg = "Unable to post request, underlying exception of " . curl_error($ch);
|
992 |
curl_close($ch);
|
993 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once 'OffAmazonPaymentsService/Exception.php';
|
994 |
+
throw new OffAmazonPaymentsService_Exception(array('Message' => $error_msg));
|
995 |
}
|
996 |
|
997 |
curl_close($ch);
|
1008 |
} else {
|
1009 |
$headers[$k] = $v;
|
1010 |
}
|
1011 |
+
}
|
1012 |
}
|
1013 |
+
|
1014 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once 'OffAmazonPaymentsService/Model/ResponseHeaderMetadata.php';
|
1015 |
$responseHeaderMetadata = new OffAmazonPaymentsService_Model_ResponseHeaderMetadata(
|
1016 |
$headers['x-mws-request-id'],
|
1017 |
$headers['x-mws-response-context'],
|
1033 |
$delay = (int) (pow(4, $retries) * 100000) ;
|
1034 |
usleep($delay);
|
1035 |
} else {
|
1036 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once 'OffAmazonPaymentsService/Exception.php';
|
1037 |
throw new OffAmazonPaymentsService_Exception (array ('Message' => "Maximum number of retry attempts reached : $retries", 'StatusCode' => $status));
|
1038 |
}
|
1039 |
}
|
1165 |
{
|
1166 |
return gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
|
1167 |
}
|
1168 |
+
|
1169 |
/**
|
1170 |
* Formats date as ISO 8601 timestamp
|
1171 |
*/
|
1176 |
|
1177 |
|
1178 |
|
1179 |
+
|
1180 |
/**
|
1181 |
* Convert CaptureRequest to name value pairs
|
1182 |
*/
|
1183 |
private function _convertCapture($request) {
|
1184 |
+
|
1185 |
$parameters = array();
|
1186 |
$parameters['Action'] = 'Capture';
|
1187 |
if ($request->isSetSellerId()) {
|
1223 |
$parameters['ProviderCreditList' . '.' . 'member' . '.' . ($memberproviderCreditListIndex + 1) . '.' . 'CreditAmount' . '.' . 'CurrencyCode'] = $creditAmountmember->getCurrencyCode();
|
1224 |
}
|
1225 |
}
|
1226 |
+
|
1227 |
}
|
1228 |
}
|
1229 |
+
|
1230 |
return $parameters;
|
1231 |
}
|
1232 |
+
|
1233 |
+
|
1234 |
/**
|
1235 |
* Convert RefundRequest to name value pairs
|
1236 |
*/
|
1237 |
private function _convertRefund($request) {
|
1238 |
+
|
1239 |
$parameters = array();
|
1240 |
$parameters['Action'] = 'Refund';
|
1241 |
if ($request->isSetSellerId()) {
|
1277 |
$parameters['ProviderCreditReversalList' . '.' . 'member' . '.' . ($memberproviderCreditReversalListIndex + 1) . '.' . 'CreditReversalAmount' . '.' . 'CurrencyCode'] = $creditReversalAmountmember->getCurrencyCode();
|
1278 |
}
|
1279 |
}
|
1280 |
+
|
1281 |
}
|
1282 |
}
|
1283 |
|
1284 |
return $parameters;
|
1285 |
}
|
1286 |
+
|
1287 |
+
|
1288 |
/**
|
1289 |
* Convert CloseAuthorizationRequest to name value pairs
|
1290 |
*/
|
1291 |
private function _convertCloseAuthorization($request) {
|
1292 |
+
|
1293 |
$parameters = array();
|
1294 |
$parameters['Action'] = 'CloseAuthorization';
|
1295 |
if ($request->isSetSellerId()) {
|
1304 |
|
1305 |
return $parameters;
|
1306 |
}
|
1307 |
+
|
1308 |
+
|
1309 |
/**
|
1310 |
* Convert GetRefundDetailsRequest to name value pairs
|
1311 |
*/
|
1312 |
private function _convertGetRefundDetails($request) {
|
1313 |
+
|
1314 |
$parameters = array();
|
1315 |
$parameters['Action'] = 'GetRefundDetails';
|
1316 |
if ($request->isSetSellerId()) {
|
1322 |
|
1323 |
return $parameters;
|
1324 |
}
|
1325 |
+
|
1326 |
+
|
1327 |
/**
|
1328 |
* Convert GetCaptureDetailsRequest to name value pairs
|
1329 |
*/
|
1330 |
private function _convertGetCaptureDetails($request) {
|
1331 |
+
|
1332 |
$parameters = array();
|
1333 |
$parameters['Action'] = 'GetCaptureDetails';
|
1334 |
if ($request->isSetSellerId()) {
|
1340 |
|
1341 |
return $parameters;
|
1342 |
}
|
1343 |
+
|
1344 |
+
|
1345 |
/**
|
1346 |
* Convert CloseOrderReferenceRequest to name value pairs
|
1347 |
*/
|
1348 |
private function _convertCloseOrderReference($request) {
|
1349 |
+
|
1350 |
$parameters = array();
|
1351 |
$parameters['Action'] = 'CloseOrderReference';
|
1352 |
if ($request->isSetSellerId()) {
|
1361 |
|
1362 |
return $parameters;
|
1363 |
}
|
1364 |
+
|
1365 |
+
|
1366 |
/**
|
1367 |
* Convert ConfirmOrderReferenceRequest to name value pairs
|
1368 |
*/
|
1369 |
private function _convertConfirmOrderReference($request) {
|
1370 |
+
|
1371 |
$parameters = array();
|
1372 |
$parameters['Action'] = 'ConfirmOrderReference';
|
1373 |
if ($request->isSetAmazonOrderReferenceId()) {
|
1379 |
|
1380 |
return $parameters;
|
1381 |
}
|
1382 |
+
|
1383 |
+
|
1384 |
/**
|
1385 |
* Convert GetOrderReferenceDetailsRequest to name value pairs
|
1386 |
*/
|
1387 |
private function _convertGetOrderReferenceDetails($request) {
|
1388 |
+
|
1389 |
$parameters = array();
|
1390 |
$parameters['Action'] = 'GetOrderReferenceDetails';
|
1391 |
if ($request->isSetAmazonOrderReferenceId()) {
|
1400 |
|
1401 |
return $parameters;
|
1402 |
}
|
1403 |
+
|
1404 |
+
|
1405 |
/**
|
1406 |
* Convert AuthorizeRequest to name value pairs
|
1407 |
*/
|
1408 |
private function _convertAuthorize($request) {
|
1409 |
+
|
1410 |
$parameters = array();
|
1411 |
$parameters['Action'] = 'Authorize';
|
1412 |
if ($request->isSetSellerId()) {
|
1465 |
|
1466 |
return $parameters;
|
1467 |
}
|
1468 |
+
|
1469 |
+
|
1470 |
/**
|
1471 |
* Convert SetOrderReferenceDetailsRequest to name value pairs
|
1472 |
*/
|
1473 |
private function _convertSetOrderReferenceDetails($request) {
|
1474 |
+
|
1475 |
$parameters = array();
|
1476 |
$parameters['Action'] = 'SetOrderReferenceDetails';
|
1477 |
if ($request->isSetSellerId()) {
|
1519 |
|
1520 |
return $parameters;
|
1521 |
}
|
1522 |
+
|
1523 |
+
|
1524 |
/**
|
1525 |
* Convert GetAuthorizationDetailsRequest to name value pairs
|
1526 |
*/
|
1527 |
private function _convertGetAuthorizationDetails($request) {
|
1528 |
+
|
1529 |
$parameters = array();
|
1530 |
$parameters['Action'] = 'GetAuthorizationDetails';
|
1531 |
if ($request->isSetSellerId()) {
|
1537 |
|
1538 |
return $parameters;
|
1539 |
}
|
1540 |
+
|
1541 |
+
|
1542 |
/**
|
1543 |
* Convert CancelOrderReferenceRequest to name value pairs
|
1544 |
*/
|
1545 |
private function _convertCancelOrderReference($request) {
|
1546 |
+
|
1547 |
$parameters = array();
|
1548 |
$parameters['Action'] = 'CancelOrderReference';
|
1549 |
if ($request->isSetSellerId()) {
|
1558 |
|
1559 |
return $parameters;
|
1560 |
}
|
1561 |
+
|
1562 |
+
|
1563 |
/**
|
1564 |
* Convert CreateOrderReferenceForIdRequest to name value pairs
|
1565 |
*/
|
1566 |
private function _convertCreateOrderReferenceForId($request) {
|
1567 |
+
|
1568 |
$parameters = array();
|
1569 |
$parameters['Action'] = 'CreateOrderReferenceForId';
|
1570 |
if ($request->isSetId()) {
|
1618 |
}
|
1619 |
}
|
1620 |
}
|
1621 |
+
|
1622 |
return $parameters;
|
1623 |
}
|
1624 |
+
|
1625 |
+
|
1626 |
/**
|
1627 |
* Convert GetBillingAgreementDetailsRequest to name value pairs
|
1628 |
*/
|
1629 |
private function _convertGetBillingAgreementDetails($request) {
|
1630 |
+
|
1631 |
$parameters = array();
|
1632 |
$parameters['Action'] = 'GetBillingAgreementDetails';
|
1633 |
if ($request->isSetAmazonBillingAgreementId()) {
|
1639 |
if ($request->isSetAddressConsentToken()) {
|
1640 |
$parameters['AddressConsentToken'] = $request->getAddressConsentToken();
|
1641 |
}
|
1642 |
+
|
1643 |
return $parameters;
|
1644 |
}
|
1645 |
+
|
1646 |
+
|
1647 |
/**
|
1648 |
* Convert SetBillingAgreementDetailsRequest to name value pairs
|
1649 |
*/
|
1650 |
private function _convertSetBillingAgreementDetails($request) {
|
1651 |
+
|
1652 |
$parameters = array();
|
1653 |
$parameters['Action'] = 'SetBillingAgreementDetails';
|
1654 |
if ($request->isSetSellerId()) {
|
1678 |
}
|
1679 |
}
|
1680 |
}
|
1681 |
+
|
1682 |
return $parameters;
|
1683 |
}
|
1684 |
+
|
1685 |
+
|
1686 |
/**
|
1687 |
* Convert ConfirmBillingAgreementRequest to name value pairs
|
1688 |
*/
|
1689 |
private function _convertConfirmBillingAgreement($request) {
|
1690 |
+
|
1691 |
$parameters = array();
|
1692 |
$parameters['Action'] = 'ConfirmBillingAgreement';
|
1693 |
if ($request->isSetSellerId()) {
|
1699 |
|
1700 |
return $parameters;
|
1701 |
}
|
1702 |
+
|
1703 |
+
|
1704 |
/**
|
1705 |
* Convert ValidateBillingAgreementRequest to name value pairs
|
1706 |
*/
|
1707 |
private function _convertValidateBillingAgreement($request) {
|
1708 |
+
|
1709 |
$parameters = array();
|
1710 |
$parameters['Action'] = 'ValidateBillingAgreement';
|
1711 |
if ($request->isSetAmazonBillingAgreementId()) {
|
1714 |
if ($request->isSetSellerId()) {
|
1715 |
$parameters['SellerId'] = $request->getSellerId();
|
1716 |
}
|
1717 |
+
|
1718 |
return $parameters;
|
1719 |
}
|
1720 |
+
|
1721 |
+
|
1722 |
/**
|
1723 |
* Convert AuthorizeOnBillingAgreementRequest to name value pairs
|
1724 |
*/
|
1725 |
private function _convertAuthorizeOnBillingAgreement($request) {
|
1726 |
+
|
1727 |
$parameters = array();
|
1728 |
$parameters['Action'] = 'AuthorizeOnBillingAgreement';
|
1729 |
if ($request->isSetSellerId()) {
|
1783 |
if ($request->isSetInheritShippingAddress()) {
|
1784 |
$parameters['InheritShippingAddress'] = $request->getInheritShippingAddress() ? "true" : "false";
|
1785 |
}
|
1786 |
+
|
1787 |
return $parameters;
|
1788 |
}
|
1789 |
+
|
1790 |
+
|
1791 |
/**
|
1792 |
* Convert CloseBillingAgreementRequest to name value pairs
|
1793 |
*/
|
1794 |
private function _convertCloseBillingAgreement($request) {
|
1795 |
+
|
1796 |
$parameters = array();
|
1797 |
$parameters['Action'] = 'CloseBillingAgreement';
|
1798 |
if ($request->isSetAmazonBillingAgreementId()) {
|
1807 |
if ($request->isSetReasonCode()) {
|
1808 |
$parameters['ReasonCode'] = $request->getReasonCode();
|
1809 |
}
|
1810 |
+
|
1811 |
return $parameters;
|
1812 |
}
|
1813 |
+
|
1814 |
/**
|
1815 |
* Convert GetProviderCreditDetailsRequest to name value pairs
|
1816 |
*/
|
1817 |
private function _convertGetProviderCreditDetails($request) {
|
1818 |
+
|
1819 |
$parameters = array();
|
1820 |
$parameters['Action'] = 'GetProviderCreditDetails';
|
1821 |
if ($request->isSetSellerId()) {
|
1824 |
if ($request->isSetAmazonProviderCreditId()) {
|
1825 |
$parameters['AmazonProviderCreditId'] = $request->getAmazonProviderCreditId();
|
1826 |
}
|
1827 |
+
|
1828 |
return $parameters;
|
1829 |
}
|
1830 |
+
|
1831 |
/**
|
1832 |
* Convert GetProviderCreditReversalDetailsRequest to name value pairs
|
1833 |
*/
|
1834 |
private function _convertGetProviderCreditReversalDetails($request) {
|
1835 |
+
|
1836 |
$parameters = array();
|
1837 |
$parameters['Action'] = 'GetProviderCreditReversalDetails';
|
1838 |
if ($request->isSetSellerId()) {
|
1841 |
if ($request->isSetAmazonProviderCreditReversalId()) {
|
1842 |
$parameters['AmazonProviderCreditReversalId'] = $request->getAmazonProviderCreditReversalId();
|
1843 |
}
|
1844 |
+
|
1845 |
return $parameters;
|
1846 |
}
|
1847 |
|
1849 |
* Convert ReverseProviderCreditRequest to name value pairs
|
1850 |
*/
|
1851 |
private function _convertReverseProviderCredit($request) {
|
1852 |
+
|
1853 |
$parameters = array();
|
1854 |
$parameters['Action'] = 'ReverseProviderCredit';
|
1855 |
if ($request->isSetSellerId()) {
|
1873 |
if ($request->isSetCreditReversalNote()) {
|
1874 |
$parameters['CreditReversalNote'] = $request->getCreditReversalNote();
|
1875 |
}
|
1876 |
+
|
1877 |
return $parameters;
|
1878 |
}
|
1879 |
+
|
1880 |
}
|
1881 |
?>
|
lib/OffAmazonPaymentsService/MerchantValues.php
CHANGED
@@ -16,8 +16,10 @@
|
|
16 |
*/
|
17 |
|
18 |
|
19 |
-
|
20 |
-
require_once '
|
|
|
|
|
21 |
|
22 |
define('MERCHANT_ID', isset($merchantId) ? $merchantId : null);
|
23 |
define('ACCESS_KEY', isset($accessKey) ? $accessKey : null);
|
@@ -45,12 +47,12 @@ class OffAmazonPaymentsService_MerchantValues
|
|
45 |
private $_caBundleFile;
|
46 |
private $_regionSpecificProperties;
|
47 |
private $_clientId;
|
48 |
-
|
49 |
public function __construct(
|
50 |
-
$merchantId,
|
51 |
-
$accessKey,
|
52 |
-
$secretKey,
|
53 |
-
$applicationName,
|
54 |
$applicationVersion,
|
55 |
$region,
|
56 |
$environment,
|
@@ -79,7 +81,7 @@ class OffAmazonPaymentsService_MerchantValues
|
|
79 |
if ($this->_accessKey == "") {
|
80 |
throw new InvalidArgumentException("accessKey not set in the properties file");
|
81 |
}
|
82 |
-
|
83 |
if ($this->_secretKey == "") {
|
84 |
throw new InvalidArgumentException("secretKey not set in the properties file");
|
85 |
}
|
@@ -95,12 +97,12 @@ class OffAmazonPaymentsService_MerchantValues
|
|
95 |
"applicationVersion not set in the properties file"
|
96 |
);
|
97 |
}
|
98 |
-
|
99 |
if ($this->_region == "") {
|
100 |
throw new InvalidArgumentException("region not set in the properties file");
|
101 |
-
}
|
102 |
$this->_region = $this->_validateRegion($this->_region);
|
103 |
-
|
104 |
if ($this->_environment == "") {
|
105 |
throw new InvalidArgumentException("environment not set in the properties file");
|
106 |
}
|
@@ -130,17 +132,17 @@ class OffAmazonPaymentsService_MerchantValues
|
|
130 |
{
|
131 |
return $this->_regionSpecificProperties->getServiceUrlFor($this->_region, $this->_environment, $this->_serviceUrl);
|
132 |
}
|
133 |
-
|
134 |
public function getWidgetUrl()
|
135 |
{
|
136 |
return $this->_regionSpecificProperties->getWidgetUrlFor($this->_region, $this->_environment, $this->_merchantId, $this->_widgetUrl);
|
137 |
}
|
138 |
-
|
139 |
public function getCurrency()
|
140 |
{
|
141 |
return $this->_regionSpecificProperties->getCurrencyFor($this->_region);
|
142 |
}
|
143 |
-
|
144 |
public function getApplicationName()
|
145 |
{
|
146 |
return $this->_applicationName;
|
@@ -150,12 +152,12 @@ class OffAmazonPaymentsService_MerchantValues
|
|
150 |
{
|
151 |
return $this->_applicationVersion;
|
152 |
}
|
153 |
-
|
154 |
public function getRegion()
|
155 |
{
|
156 |
return $this->_region;
|
157 |
}
|
158 |
-
|
159 |
public function getEnvironment()
|
160 |
{
|
161 |
return $this->_environment;
|
@@ -165,24 +167,24 @@ class OffAmazonPaymentsService_MerchantValues
|
|
165 |
{
|
166 |
return $this->_caBundleFile;
|
167 |
}
|
168 |
-
|
169 |
public function getClientId()
|
170 |
{
|
171 |
return $this->_clientId;
|
172 |
}
|
173 |
-
|
174 |
private function _validateRegion($region)
|
175 |
{
|
176 |
-
include_once 'Regions.php';
|
177 |
return self::_getValueForConstant($region, new OffAmazonPaymentsService_Regions());
|
178 |
}
|
179 |
-
|
180 |
private static function _validateEnvironment($environment)
|
181 |
{
|
182 |
-
include_once 'Environments.php';
|
183 |
return self::_getValueForConstant($environment, new OffAmazonPaymentsService_Environments());
|
184 |
}
|
185 |
-
|
186 |
private static function _getValueForConstant($constant, $valuesClass)
|
187 |
{
|
188 |
$rc = new ReflectionClass($valuesClass);
|
@@ -192,22 +194,22 @@ class OffAmazonPaymentsService_MerchantValues
|
|
192 |
throw new InvalidArgumentException(
|
193 |
"check your property file: " . $constant . " is not a valid option. Available options are: " . $allowedValues
|
194 |
);
|
195 |
-
}
|
196 |
-
|
197 |
return $value;
|
198 |
}
|
199 |
-
|
200 |
public static function withRegionSpecificProperties(
|
201 |
-
$merchantId,
|
202 |
-
$accessKey,
|
203 |
-
$secretKey,
|
204 |
-
$applicationName,
|
205 |
-
$applicationVersion,
|
206 |
-
$region,
|
207 |
-
$environment,
|
208 |
-
$serviceUrl,
|
209 |
$widgetUrl,
|
210 |
-
$caBundleFile,
|
211 |
$regionSpecificProperties,
|
212 |
$clientId)
|
213 |
{
|
16 |
*/
|
17 |
|
18 |
|
19 |
+
if (!defined('COMPILER_INCLUDE_PATH')) {
|
20 |
+
require_once 'OffAmazonPaymentsService.config.inc.php';
|
21 |
+
require_once 'RegionSpecificProperties.php';
|
22 |
+
}
|
23 |
|
24 |
define('MERCHANT_ID', isset($merchantId) ? $merchantId : null);
|
25 |
define('ACCESS_KEY', isset($accessKey) ? $accessKey : null);
|
47 |
private $_caBundleFile;
|
48 |
private $_regionSpecificProperties;
|
49 |
private $_clientId;
|
50 |
+
|
51 |
public function __construct(
|
52 |
+
$merchantId,
|
53 |
+
$accessKey,
|
54 |
+
$secretKey,
|
55 |
+
$applicationName,
|
56 |
$applicationVersion,
|
57 |
$region,
|
58 |
$environment,
|
81 |
if ($this->_accessKey == "") {
|
82 |
throw new InvalidArgumentException("accessKey not set in the properties file");
|
83 |
}
|
84 |
+
|
85 |
if ($this->_secretKey == "") {
|
86 |
throw new InvalidArgumentException("secretKey not set in the properties file");
|
87 |
}
|
97 |
"applicationVersion not set in the properties file"
|
98 |
);
|
99 |
}
|
100 |
+
|
101 |
if ($this->_region == "") {
|
102 |
throw new InvalidArgumentException("region not set in the properties file");
|
103 |
+
}
|
104 |
$this->_region = $this->_validateRegion($this->_region);
|
105 |
+
|
106 |
if ($this->_environment == "") {
|
107 |
throw new InvalidArgumentException("environment not set in the properties file");
|
108 |
}
|
132 |
{
|
133 |
return $this->_regionSpecificProperties->getServiceUrlFor($this->_region, $this->_environment, $this->_serviceUrl);
|
134 |
}
|
135 |
+
|
136 |
public function getWidgetUrl()
|
137 |
{
|
138 |
return $this->_regionSpecificProperties->getWidgetUrlFor($this->_region, $this->_environment, $this->_merchantId, $this->_widgetUrl);
|
139 |
}
|
140 |
+
|
141 |
public function getCurrency()
|
142 |
{
|
143 |
return $this->_regionSpecificProperties->getCurrencyFor($this->_region);
|
144 |
}
|
145 |
+
|
146 |
public function getApplicationName()
|
147 |
{
|
148 |
return $this->_applicationName;
|
152 |
{
|
153 |
return $this->_applicationVersion;
|
154 |
}
|
155 |
+
|
156 |
public function getRegion()
|
157 |
{
|
158 |
return $this->_region;
|
159 |
}
|
160 |
+
|
161 |
public function getEnvironment()
|
162 |
{
|
163 |
return $this->_environment;
|
167 |
{
|
168 |
return $this->_caBundleFile;
|
169 |
}
|
170 |
+
|
171 |
public function getClientId()
|
172 |
{
|
173 |
return $this->_clientId;
|
174 |
}
|
175 |
+
|
176 |
private function _validateRegion($region)
|
177 |
{
|
178 |
+
if (!defined('COMPILER_INCLUDE_PATH')) include_once 'Regions.php';
|
179 |
return self::_getValueForConstant($region, new OffAmazonPaymentsService_Regions());
|
180 |
}
|
181 |
+
|
182 |
private static function _validateEnvironment($environment)
|
183 |
{
|
184 |
+
if (!defined('COMPILER_INCLUDE_PATH')) include_once 'Environments.php';
|
185 |
return self::_getValueForConstant($environment, new OffAmazonPaymentsService_Environments());
|
186 |
}
|
187 |
+
|
188 |
private static function _getValueForConstant($constant, $valuesClass)
|
189 |
{
|
190 |
$rc = new ReflectionClass($valuesClass);
|
194 |
throw new InvalidArgumentException(
|
195 |
"check your property file: " . $constant . " is not a valid option. Available options are: " . $allowedValues
|
196 |
);
|
197 |
+
}
|
198 |
+
|
199 |
return $value;
|
200 |
}
|
201 |
+
|
202 |
public static function withRegionSpecificProperties(
|
203 |
+
$merchantId,
|
204 |
+
$accessKey,
|
205 |
+
$secretKey,
|
206 |
+
$applicationName,
|
207 |
+
$applicationVersion,
|
208 |
+
$region,
|
209 |
+
$environment,
|
210 |
+
$serviceUrl,
|
211 |
$widgetUrl,
|
212 |
+
$caBundleFile,
|
213 |
$regionSpecificProperties,
|
214 |
$clientId)
|
215 |
{
|
lib/OffAmazonPaymentsService/Model.php
CHANGED
@@ -18,17 +18,17 @@
|
|
18 |
|
19 |
/**
|
20 |
* OffAmazonPaymentsService_Model - base class for all model classes
|
21 |
-
*/
|
22 |
abstract class OffAmazonPaymentsService_Model
|
23 |
{
|
24 |
-
|
25 |
/** @var array */
|
26 |
protected $_fields = array ();
|
27 |
-
|
28 |
/**
|
29 |
* Construct new model class
|
30 |
-
*
|
31 |
-
* @param mixed $data - DOMElement or Associative Array to construct from.
|
32 |
*/
|
33 |
public function __construct($data = null)
|
34 |
{
|
@@ -38,43 +38,43 @@ abstract class OffAmazonPaymentsService_Model
|
|
38 |
} elseif ($this->_isDOMElement($data)) {
|
39 |
$this->_fromDOMElement($data);
|
40 |
} else {
|
41 |
-
throw new Exception ("Unable to construct from provided data.
|
42 |
Please be sure to pass associative array or DOMElement");
|
43 |
}
|
44 |
-
|
45 |
}
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
-
* Support for virtual properties getters.
|
50 |
-
*
|
51 |
* Virtual property call example:
|
52 |
-
*
|
53 |
* $action->Property
|
54 |
-
*
|
55 |
-
* Direct getter(preferred):
|
56 |
-
*
|
57 |
-
* $action->getProperty()
|
58 |
-
*
|
59 |
* @param string $propertyName name of the property
|
60 |
*/
|
61 |
public function __get($propertyName)
|
62 |
{
|
63 |
-
$getter = "get$propertyName";
|
64 |
return $this->$getter();
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
-
* Support for virtual properties setters.
|
69 |
-
*
|
70 |
* Virtual property call example:
|
71 |
-
*
|
72 |
* $action->Property = 'ABC'
|
73 |
-
*
|
74 |
* Direct setter (preferred):
|
75 |
-
*
|
76 |
-
* $action->setProperty('ABC')
|
77 |
-
*
|
78 |
* @param string $propertyName name of the property
|
79 |
*/
|
80 |
public function __set($propertyName, $propertyValue)
|
@@ -84,14 +84,14 @@ abstract class OffAmazonPaymentsService_Model
|
|
84 |
return $this;
|
85 |
}
|
86 |
|
87 |
-
|
88 |
/**
|
89 |
* XML fragment representation of this object
|
90 |
-
* Note, name of the root determined by caller
|
91 |
* This fragment returns inner fields representation only
|
92 |
* @return string XML fragment for this object
|
93 |
*/
|
94 |
-
protected function _toXMLFragment()
|
95 |
{
|
96 |
$xml = "";
|
97 |
foreach ($this->_fields as $fieldName => $field) {
|
@@ -133,45 +133,45 @@ abstract class OffAmazonPaymentsService_Model
|
|
133 |
* Escape special XML characters
|
134 |
* @return string with escaped XML characters
|
135 |
*/
|
136 |
-
private function _escapeXML($str)
|
137 |
{
|
138 |
-
$from = array( "&", "<", ">", "'", "\"");
|
139 |
$to = array( "&", "<", ">", "'", """);
|
140 |
-
return str_replace($from, $to, $str);
|
141 |
}
|
142 |
|
143 |
|
144 |
-
|
145 |
/**
|
146 |
-
* Construct from DOMElement
|
147 |
-
*
|
148 |
-
* This function iterates over object fields and queries XML
|
149 |
-
* for corresponding tag value. If query succeeds, value extracted
|
150 |
-
* from xml, and field value properly constructed based on field type.
|
151 |
*
|
152 |
* Field types defined as arrays always constructed as arrays,
|
153 |
* even if XML contains a single element - to make sure that
|
154 |
* data structure is predictable, and no is_array checks are
|
155 |
* required.
|
156 |
-
*
|
157 |
* @param DOMElement $dom XML element to construct from
|
158 |
*/
|
159 |
private function _fromDOMElement(DOMElement $dom)
|
160 |
{
|
161 |
$xpath = new DOMXPath($dom->ownerDocument);
|
162 |
$xpath->registerNamespace('a', 'http://mws.amazonservices.com/schema/OffAmazonPayments/2013-01-01');
|
163 |
-
|
164 |
foreach ($this->_fields as $fieldName => $field) {
|
165 |
-
$fieldType = $field['FieldType'];
|
166 |
if (is_array($fieldType)) {
|
167 |
if ($this->_isComplexType($fieldType[0])) {
|
168 |
$elements = $xpath->query("./a:$fieldName", $dom);
|
169 |
if ($elements->length >= 1) {
|
170 |
-
require_once str_replace('_', DIRECTORY_SEPARATOR, $fieldType[0]) . ".php";
|
171 |
foreach ($elements as $element) {
|
172 |
$this->_fields[$fieldName]['FieldValue'][] = new $fieldType[0]($element);
|
173 |
}
|
174 |
-
}
|
175 |
} else {
|
176 |
$elements = $xpath->query("./a:$fieldName", $dom);
|
177 |
if ($elements->length >= 1) {
|
@@ -179,15 +179,15 @@ abstract class OffAmazonPaymentsService_Model
|
|
179 |
$text = $xpath->query('./text()', $element);
|
180 |
$this->_fields[$fieldName]['FieldValue'][] = $text->item(0)->data;
|
181 |
}
|
182 |
-
}
|
183 |
}
|
184 |
} else {
|
185 |
if ($this->_isComplexType($fieldType)) {
|
186 |
$elements = $xpath->query("./a:$fieldName", $dom);
|
187 |
if ($elements->length == 1) {
|
188 |
-
require_once str_replace('_', DIRECTORY_SEPARATOR, $fieldType) . ".php";
|
189 |
$this->_fields[$fieldName]['FieldValue'] = new $fieldType($elements->item(0));
|
190 |
-
}
|
191 |
} else {
|
192 |
$element = $xpath->query("./a:$fieldName/text()", $dom);
|
193 |
if ($element->length == 1) {
|
@@ -211,47 +211,47 @@ abstract class OffAmazonPaymentsService_Model
|
|
211 |
|
212 |
/**
|
213 |
* Construct from Associative Array
|
214 |
-
*
|
215 |
-
*
|
216 |
* @param array $array associative array to construct from
|
217 |
*/
|
218 |
private function _fromAssociativeArray(array $array)
|
219 |
{
|
220 |
foreach ($this->_fields as $fieldName => $field) {
|
221 |
-
$fieldType = $field['FieldType'];
|
222 |
if (is_array($fieldType)) {
|
223 |
if ($this->_isComplexType($fieldType[0])) {
|
224 |
-
if (array_key_exists($fieldName, $array)) {
|
225 |
$elements = $array[$fieldName];
|
226 |
if (!$this->_isNumericArray($elements)) {
|
227 |
-
$elements = array($elements);
|
228 |
}
|
229 |
if (count ($elements) >= 1) {
|
230 |
-
require_once str_replace('_', DIRECTORY_SEPARATOR, $fieldType[0]) . ".php";
|
231 |
foreach ($elements as $element) {
|
232 |
$this->_fields[$fieldName]['FieldValue'][] = new $fieldType[0]($element);
|
233 |
}
|
234 |
}
|
235 |
-
}
|
236 |
} else {
|
237 |
if (array_key_exists($fieldName, $array)) {
|
238 |
$elements = $array[$fieldName];
|
239 |
if (!$this->_isNumericArray($elements)) {
|
240 |
-
$elements = array($elements);
|
241 |
}
|
242 |
if (count ($elements) >= 1) {
|
243 |
foreach ($elements as $element) {
|
244 |
$this->_fields[$fieldName]['FieldValue'][] = $element;
|
245 |
}
|
246 |
-
}
|
247 |
}
|
248 |
}
|
249 |
} else {
|
250 |
if ($this->_isComplexType($fieldType)) {
|
251 |
if (array_key_exists($fieldName, $array)) {
|
252 |
-
require_once str_replace('_', DIRECTORY_SEPARATOR, $fieldType) . ".php";
|
253 |
$this->_fields[$fieldName]['FieldValue'] = new $fieldType($array[$fieldName]);
|
254 |
-
}
|
255 |
} else {
|
256 |
if (array_key_exists($fieldName, $array)) {
|
257 |
$this->_fields[$fieldName]['FieldValue'] = $array[$fieldName];
|
@@ -265,10 +265,10 @@ abstract class OffAmazonPaymentsService_Model
|
|
265 |
|
266 |
/**
|
267 |
* Determines if field is complex type
|
268 |
-
*
|
269 |
* @param string $fieldType field type name
|
270 |
*/
|
271 |
-
private function _isComplexType ($fieldType)
|
272 |
{
|
273 |
return preg_match('/^OffAmazonPaymentsService_Model_/', $fieldType);
|
274 |
}
|
18 |
|
19 |
/**
|
20 |
* OffAmazonPaymentsService_Model - base class for all model classes
|
21 |
+
*/
|
22 |
abstract class OffAmazonPaymentsService_Model
|
23 |
{
|
24 |
+
|
25 |
/** @var array */
|
26 |
protected $_fields = array ();
|
27 |
+
|
28 |
/**
|
29 |
* Construct new model class
|
30 |
+
*
|
31 |
+
* @param mixed $data - DOMElement or Associative Array to construct from.
|
32 |
*/
|
33 |
public function __construct($data = null)
|
34 |
{
|
38 |
} elseif ($this->_isDOMElement($data)) {
|
39 |
$this->_fromDOMElement($data);
|
40 |
} else {
|
41 |
+
throw new Exception ("Unable to construct from provided data.
|
42 |
Please be sure to pass associative array or DOMElement");
|
43 |
}
|
44 |
+
|
45 |
}
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
+
* Support for virtual properties getters.
|
50 |
+
*
|
51 |
* Virtual property call example:
|
52 |
+
*
|
53 |
* $action->Property
|
54 |
+
*
|
55 |
+
* Direct getter(preferred):
|
56 |
+
*
|
57 |
+
* $action->getProperty()
|
58 |
+
*
|
59 |
* @param string $propertyName name of the property
|
60 |
*/
|
61 |
public function __get($propertyName)
|
62 |
{
|
63 |
+
$getter = "get$propertyName";
|
64 |
return $this->$getter();
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
+
* Support for virtual properties setters.
|
69 |
+
*
|
70 |
* Virtual property call example:
|
71 |
+
*
|
72 |
* $action->Property = 'ABC'
|
73 |
+
*
|
74 |
* Direct setter (preferred):
|
75 |
+
*
|
76 |
+
* $action->setProperty('ABC')
|
77 |
+
*
|
78 |
* @param string $propertyName name of the property
|
79 |
*/
|
80 |
public function __set($propertyName, $propertyValue)
|
84 |
return $this;
|
85 |
}
|
86 |
|
87 |
+
|
88 |
/**
|
89 |
* XML fragment representation of this object
|
90 |
+
* Note, name of the root determined by caller
|
91 |
* This fragment returns inner fields representation only
|
92 |
* @return string XML fragment for this object
|
93 |
*/
|
94 |
+
protected function _toXMLFragment()
|
95 |
{
|
96 |
$xml = "";
|
97 |
foreach ($this->_fields as $fieldName => $field) {
|
133 |
* Escape special XML characters
|
134 |
* @return string with escaped XML characters
|
135 |
*/
|
136 |
+
private function _escapeXML($str)
|
137 |
{
|
138 |
+
$from = array( "&", "<", ">", "'", "\"");
|
139 |
$to = array( "&", "<", ">", "'", """);
|
140 |
+
return str_replace($from, $to, $str);
|
141 |
}
|
142 |
|
143 |
|
144 |
+
|
145 |
/**
|
146 |
+
* Construct from DOMElement
|
147 |
+
*
|
148 |
+
* This function iterates over object fields and queries XML
|
149 |
+
* for corresponding tag value. If query succeeds, value extracted
|
150 |
+
* from xml, and field value properly constructed based on field type.
|
151 |
*
|
152 |
* Field types defined as arrays always constructed as arrays,
|
153 |
* even if XML contains a single element - to make sure that
|
154 |
* data structure is predictable, and no is_array checks are
|
155 |
* required.
|
156 |
+
*
|
157 |
* @param DOMElement $dom XML element to construct from
|
158 |
*/
|
159 |
private function _fromDOMElement(DOMElement $dom)
|
160 |
{
|
161 |
$xpath = new DOMXPath($dom->ownerDocument);
|
162 |
$xpath->registerNamespace('a', 'http://mws.amazonservices.com/schema/OffAmazonPayments/2013-01-01');
|
163 |
+
|
164 |
foreach ($this->_fields as $fieldName => $field) {
|
165 |
+
$fieldType = $field['FieldType'];
|
166 |
if (is_array($fieldType)) {
|
167 |
if ($this->_isComplexType($fieldType[0])) {
|
168 |
$elements = $xpath->query("./a:$fieldName", $dom);
|
169 |
if ($elements->length >= 1) {
|
170 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once str_replace('_', DIRECTORY_SEPARATOR, $fieldType[0]) . ".php";
|
171 |
foreach ($elements as $element) {
|
172 |
$this->_fields[$fieldName]['FieldValue'][] = new $fieldType[0]($element);
|
173 |
}
|
174 |
+
}
|
175 |
} else {
|
176 |
$elements = $xpath->query("./a:$fieldName", $dom);
|
177 |
if ($elements->length >= 1) {
|
179 |
$text = $xpath->query('./text()', $element);
|
180 |
$this->_fields[$fieldName]['FieldValue'][] = $text->item(0)->data;
|
181 |
}
|
182 |
+
}
|
183 |
}
|
184 |
} else {
|
185 |
if ($this->_isComplexType($fieldType)) {
|
186 |
$elements = $xpath->query("./a:$fieldName", $dom);
|
187 |
if ($elements->length == 1) {
|
188 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once str_replace('_', DIRECTORY_SEPARATOR, $fieldType) . ".php";
|
189 |
$this->_fields[$fieldName]['FieldValue'] = new $fieldType($elements->item(0));
|
190 |
+
}
|
191 |
} else {
|
192 |
$element = $xpath->query("./a:$fieldName/text()", $dom);
|
193 |
if ($element->length == 1) {
|
211 |
|
212 |
/**
|
213 |
* Construct from Associative Array
|
214 |
+
*
|
215 |
+
*
|
216 |
* @param array $array associative array to construct from
|
217 |
*/
|
218 |
private function _fromAssociativeArray(array $array)
|
219 |
{
|
220 |
foreach ($this->_fields as $fieldName => $field) {
|
221 |
+
$fieldType = $field['FieldType'];
|
222 |
if (is_array($fieldType)) {
|
223 |
if ($this->_isComplexType($fieldType[0])) {
|
224 |
+
if (array_key_exists($fieldName, $array)) {
|
225 |
$elements = $array[$fieldName];
|
226 |
if (!$this->_isNumericArray($elements)) {
|
227 |
+
$elements = array($elements);
|
228 |
}
|
229 |
if (count ($elements) >= 1) {
|
230 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once str_replace('_', DIRECTORY_SEPARATOR, $fieldType[0]) . ".php";
|
231 |
foreach ($elements as $element) {
|
232 |
$this->_fields[$fieldName]['FieldValue'][] = new $fieldType[0]($element);
|
233 |
}
|
234 |
}
|
235 |
+
}
|
236 |
} else {
|
237 |
if (array_key_exists($fieldName, $array)) {
|
238 |
$elements = $array[$fieldName];
|
239 |
if (!$this->_isNumericArray($elements)) {
|
240 |
+
$elements = array($elements);
|
241 |
}
|
242 |
if (count ($elements) >= 1) {
|
243 |
foreach ($elements as $element) {
|
244 |
$this->_fields[$fieldName]['FieldValue'][] = $element;
|
245 |
}
|
246 |
+
}
|
247 |
}
|
248 |
}
|
249 |
} else {
|
250 |
if ($this->_isComplexType($fieldType)) {
|
251 |
if (array_key_exists($fieldName, $array)) {
|
252 |
+
if (!defined('COMPILER_INCLUDE_PATH')) require_once str_replace('_', DIRECTORY_SEPARATOR, $fieldType) . ".php";
|
253 |
$this->_fields[$fieldName]['FieldValue'] = new $fieldType($array[$fieldName]);
|
254 |
+
}
|
255 |
} else {
|
256 |
if (array_key_exists($fieldName, $array)) {
|
257 |
$this->_fields[$fieldName]['FieldValue'] = $array[$fieldName];
|
265 |
|
266 |
/**
|
267 |
* Determines if field is complex type
|
268 |
+
*
|
269 |
* @param string $fieldType field type name
|
270 |
*/
|
271 |
+
private function _isComplexType ($fieldType)
|
272 |
{
|
273 |
return preg_match('/^OffAmazonPaymentsService_Model_/', $fieldType);
|
274 |
}
|
lib/OffAmazonPaymentsService/RegionSpecificProperties.php
CHANGED
@@ -16,12 +16,14 @@
|
|
16 |
*/
|
17 |
|
18 |
|
19 |
-
|
20 |
-
require_once '
|
|
|
|
|
21 |
|
22 |
/**
|
23 |
* Encapsulation of properties that are tied to a region/environment pairing
|
24 |
-
*
|
25 |
* Provides mappings for:
|
26 |
* - widget url
|
27 |
* - mws service url
|
@@ -38,50 +40,50 @@ class OffAmazonPaymentsService_RegionSpecificProperties
|
|
38 |
'eu' => 'https://mws-eu.amazonservices.com',
|
39 |
'na' => 'https://mws.amazonservices.com'
|
40 |
);
|
41 |
-
|
42 |
private $_currencyCodes = array(
|
43 |
'de' => 'EUR',
|
44 |
'uk' => 'GBP',
|
45 |
'us' => 'USD',
|
46 |
'na' => 'USD'
|
47 |
);
|
48 |
-
|
49 |
private $_regionMappings = array(
|
50 |
'de' => 'eu',
|
51 |
'na' => 'na',
|
52 |
'uk' => 'eu',
|
53 |
'us' => 'na'
|
54 |
);
|
55 |
-
|
56 |
const WIDGET_FORMAT_STRING = '%s/OffAmazonPayments/%s%s/js/Widgets.js?sellerId=%s';
|
57 |
const SERVICE_FORMAT_STRING = '%s/OffAmazonPayments%s/%s';
|
58 |
-
|
59 |
/**
|
60 |
* Return the correct widget url for the javascript widget
|
61 |
-
*
|
62 |
* @param string $region
|
63 |
* @param string $environment
|
64 |
* @param string $merchantId
|
65 |
-
* @param string $overrideUrl
|
66 |
-
*
|
67 |
* @return string widgetUrl
|
68 |
*/
|
69 |
public function getWidgetUrlFor($region, $environment, $merchantId, $overrideUrl)
|
70 |
{
|
71 |
-
return sprintf(self::WIDGET_FORMAT_STRING,
|
72 |
-
$this->_getWidgetHostFor($region, $overrideUrl),
|
73 |
-
$this->_getWidgetRegionFor($region),
|
74 |
$this->_getWidgetEnvironmentFor($environment),
|
75 |
urlencode($merchantId));
|
76 |
}
|
77 |
-
|
78 |
/**
|
79 |
* Return the mws service for this region
|
80 |
-
*
|
81 |
* @param string $region merchant region - us, na, uk, de
|
82 |
* @param string $environment service - live, sandbox
|
83 |
* @param string $overrideUrl override url
|
84 |
-
*
|
85 |
* @return string mws service url
|
86 |
*/
|
87 |
public function getServiceUrlFor($region, $environment, $overrideUrl)
|
@@ -91,12 +93,12 @@ class OffAmazonPaymentsService_RegionSpecificProperties
|
|
91 |
$this->_getSectionNameFor($environment),
|
92 |
OffAmazonPaymentsService_Client::SERVICE_VERSION);
|
93 |
}
|
94 |
-
|
95 |
/**
|
96 |
* Get the currency code for the given region
|
97 |
-
*
|
98 |
* @param string $region us,uk,de,na
|
99 |
-
*
|
100 |
* @return string currency code
|
101 |
*/
|
102 |
public function getCurrencyFor($region)
|
@@ -104,30 +106,30 @@ class OffAmazonPaymentsService_RegionSpecificProperties
|
|
104 |
$this->_validateRegionIsDefined($region, $this->_currencyCodes);
|
105 |
return $this->_currencyCodes[$region];
|
106 |
}
|
107 |
-
|
108 |
/**
|
109 |
* Return the correct host for the widget url based on the region
|
110 |
-
*
|
111 |
* @param string $region us,uk,de,na
|
112 |
* @param string $overrideUrl override string for widget host
|
113 |
-
*
|
114 |
* @return string widget host
|
115 |
*/
|
116 |
-
private function _getWidgetHostFor($region, $overrideUrl)
|
117 |
{
|
118 |
if (empty($overrideUrl)) {
|
119 |
return $this->_getRegionPropertyFor($region, $this->_widgetUrls);
|
120 |
}
|
121 |
-
|
122 |
return $overrideUrl;
|
123 |
}
|
124 |
-
|
125 |
/**
|
126 |
* Return the correct host for the service url based on the region
|
127 |
-
*
|
128 |
* @param string $region us,uk,de,na
|
129 |
* @param string $overrideUrl override string for service host
|
130 |
-
*
|
131 |
* @return string mws host
|
132 |
*/
|
133 |
private function _getServiceHostFor($region, $overrideUrl)
|
@@ -135,32 +137,32 @@ class OffAmazonPaymentsService_RegionSpecificProperties
|
|
135 |
if (empty($overrideUrl)) {
|
136 |
return $this->_getRegionPropertyFor($region, $this->_serviceUrls);
|
137 |
}
|
138 |
-
|
139 |
return $overrideUrl;
|
140 |
}
|
141 |
-
|
142 |
/**
|
143 |
* Return the correct value for this region from an
|
144 |
* associate array keyed by realms
|
145 |
-
*
|
146 |
* @param string $region us,uk,de,na
|
147 |
* @param array $properties associate array of realms to property values
|
148 |
-
*
|
149 |
* @return string property for region
|
150 |
*/
|
151 |
private function _getRegionPropertyFor($region, $properties)
|
152 |
{
|
153 |
-
$this->_validateRegionIsDefined($region, $this->_regionMappings);
|
154 |
return $properties[$this->_regionMappings[$region]];
|
155 |
}
|
156 |
-
|
157 |
/**
|
158 |
* Throw an exception if the region does not hold a valid mapping
|
159 |
* in an array
|
160 |
-
*
|
161 |
* @param string $region defined region - us,na,uk,de
|
162 |
* @param array $array array to validate
|
163 |
-
*
|
164 |
* @return void
|
165 |
*/
|
166 |
private function _validateRegionIsDefined($region, $array)
|
@@ -169,36 +171,36 @@ class OffAmazonPaymentsService_RegionSpecificProperties
|
|
169 |
throw new InvalidArgumentException("No region mapping defined for region " . $region);
|
170 |
}
|
171 |
}
|
172 |
-
|
173 |
/**
|
174 |
* Return the correct region if it requires additional mapping
|
175 |
-
*
|
176 |
* @param string $region configured region
|
177 |
-
*
|
178 |
* @return string url region param
|
179 |
*/
|
180 |
private function _getWidgetRegionFor($region)
|
181 |
{
|
182 |
// Since na was a go live region, we maintain special handling so that compatablity is not broken
|
183 |
if (strcasecmp($region, 'na') == 0) {
|
184 |
-
return 'us';
|
185 |
-
}
|
186 |
-
|
187 |
return strtolower($region);
|
188 |
}
|
189 |
-
|
190 |
/**
|
191 |
* Generate the correct widget environment string, based on the environement
|
192 |
-
*
|
193 |
* @param string $environment currently configured environment
|
194 |
-
*
|
195 |
* @return string postfix for widget url string
|
196 |
*/
|
197 |
private function _getWidgetEnvironmentFor($environment)
|
198 |
{
|
199 |
return ( $this->_isSandbox($environment) ? '/sandbox' : '');
|
200 |
}
|
201 |
-
|
202 |
/**
|
203 |
* Return the correct section name postfix for the
|
204 |
* given environment
|
@@ -211,12 +213,12 @@ class OffAmazonPaymentsService_RegionSpecificProperties
|
|
211 |
{
|
212 |
return ( $this->_isSandbox($environment) ? '_Sandbox' : '');
|
213 |
}
|
214 |
-
|
215 |
/**
|
216 |
* Check if the environment is sandbox
|
217 |
-
*
|
218 |
* @param string environment name
|
219 |
-
*
|
220 |
* @return bool true if environment is sandbox
|
221 |
*/
|
222 |
private function _isSandbox($environment)
|
16 |
*/
|
17 |
|
18 |
|
19 |
+
if (!defined('COMPILER_INCLUDE_PATH')) {
|
20 |
+
require_once 'OffAmazonPaymentsService.config.inc.php';
|
21 |
+
require_once 'Client.php';
|
22 |
+
}
|
23 |
|
24 |
/**
|
25 |
* Encapsulation of properties that are tied to a region/environment pairing
|
26 |
+
*
|
27 |
* Provides mappings for:
|
28 |
* - widget url
|
29 |
* - mws service url
|
40 |
'eu' => 'https://mws-eu.amazonservices.com',
|
41 |
'na' => 'https://mws.amazonservices.com'
|
42 |
);
|
43 |
+
|
44 |
private $_currencyCodes = array(
|
45 |
'de' => 'EUR',
|
46 |
'uk' => 'GBP',
|
47 |
'us' => 'USD',
|
48 |
'na' => 'USD'
|
49 |
);
|
50 |
+
|
51 |
private $_regionMappings = array(
|
52 |
'de' => 'eu',
|
53 |
'na' => 'na',
|
54 |
'uk' => 'eu',
|
55 |
'us' => 'na'
|
56 |
);
|
57 |
+
|
58 |
const WIDGET_FORMAT_STRING = '%s/OffAmazonPayments/%s%s/js/Widgets.js?sellerId=%s';
|
59 |
const SERVICE_FORMAT_STRING = '%s/OffAmazonPayments%s/%s';
|
60 |
+
|
61 |
/**
|
62 |
* Return the correct widget url for the javascript widget
|
63 |
+
*
|
64 |
* @param string $region
|
65 |
* @param string $environment
|
66 |
* @param string $merchantId
|
67 |
+
* @param string $overrideUrl
|
68 |
+
*
|
69 |
* @return string widgetUrl
|
70 |
*/
|
71 |
public function getWidgetUrlFor($region, $environment, $merchantId, $overrideUrl)
|
72 |
{
|
73 |
+
return sprintf(self::WIDGET_FORMAT_STRING,
|
74 |
+
$this->_getWidgetHostFor($region, $overrideUrl),
|
75 |
+
$this->_getWidgetRegionFor($region),
|
76 |
$this->_getWidgetEnvironmentFor($environment),
|
77 |
urlencode($merchantId));
|
78 |
}
|
79 |
+
|
80 |
/**
|
81 |
* Return the mws service for this region
|
82 |
+
*
|
83 |
* @param string $region merchant region - us, na, uk, de
|
84 |
* @param string $environment service - live, sandbox
|
85 |
* @param string $overrideUrl override url
|
86 |
+
*
|
87 |
* @return string mws service url
|
88 |
*/
|
89 |
public function getServiceUrlFor($region, $environment, $overrideUrl)
|
93 |
$this->_getSectionNameFor($environment),
|
94 |
OffAmazonPaymentsService_Client::SERVICE_VERSION);
|
95 |
}
|
96 |
+
|
97 |
/**
|
98 |
* Get the currency code for the given region
|
99 |
+
*
|
100 |
* @param string $region us,uk,de,na
|
101 |
+
*
|
102 |
* @return string currency code
|
103 |
*/
|
104 |
public function getCurrencyFor($region)
|
106 |
$this->_validateRegionIsDefined($region, $this->_currencyCodes);
|
107 |
return $this->_currencyCodes[$region];
|
108 |
}
|
109 |
+
|
110 |
/**
|
111 |
* Return the correct host for the widget url based on the region
|
112 |
+
*
|
113 |
* @param string $region us,uk,de,na
|
114 |
* @param string $overrideUrl override string for widget host
|
115 |
+
*
|
116 |
* @return string widget host
|
117 |
*/
|
118 |
+
private function _getWidgetHostFor($region, $overrideUrl)
|
119 |
{
|
120 |
if (empty($overrideUrl)) {
|
121 |
return $this->_getRegionPropertyFor($region, $this->_widgetUrls);
|
122 |
}
|
123 |
+
|
124 |
return $overrideUrl;
|
125 |
}
|
126 |
+
|
127 |
/**
|
128 |
* Return the correct host for the service url based on the region
|
129 |
+
*
|
130 |
* @param string $region us,uk,de,na
|
131 |
* @param string $overrideUrl override string for service host
|
132 |
+
*
|
133 |
* @return string mws host
|
134 |
*/
|
135 |
private function _getServiceHostFor($region, $overrideUrl)
|
137 |
if (empty($overrideUrl)) {
|
138 |
return $this->_getRegionPropertyFor($region, $this->_serviceUrls);
|
139 |
}
|
140 |
+
|
141 |
return $overrideUrl;
|
142 |
}
|
143 |
+
|
144 |
/**
|
145 |
* Return the correct value for this region from an
|
146 |
* associate array keyed by realms
|
147 |
+
*
|
148 |
* @param string $region us,uk,de,na
|
149 |
* @param array $properties associate array of realms to property values
|
150 |
+
*
|
151 |
* @return string property for region
|
152 |
*/
|
153 |
private function _getRegionPropertyFor($region, $properties)
|
154 |
{
|
155 |
+
$this->_validateRegionIsDefined($region, $this->_regionMappings);
|
156 |
return $properties[$this->_regionMappings[$region]];
|
157 |
}
|
158 |
+
|
159 |
/**
|
160 |
* Throw an exception if the region does not hold a valid mapping
|
161 |
* in an array
|
162 |
+
*
|
163 |
* @param string $region defined region - us,na,uk,de
|
164 |
* @param array $array array to validate
|
165 |
+
*
|
166 |
* @return void
|
167 |
*/
|
168 |
private function _validateRegionIsDefined($region, $array)
|
171 |
throw new InvalidArgumentException("No region mapping defined for region " . $region);
|
172 |
}
|
173 |
}
|
174 |
+
|
175 |
/**
|
176 |
* Return the correct region if it requires additional mapping
|
177 |
+
*
|
178 |
* @param string $region configured region
|
179 |
+
*
|
180 |
* @return string url region param
|
181 |
*/
|
182 |
private function _getWidgetRegionFor($region)
|
183 |
{
|
184 |
// Since na was a go live region, we maintain special handling so that compatablity is not broken
|
185 |
if (strcasecmp($region, 'na') == 0) {
|
186 |
+
return 'us';
|
187 |
+
}
|
188 |
+
|
189 |
return strtolower($region);
|
190 |
}
|
191 |
+
|
192 |
/**
|
193 |
* Generate the correct widget environment string, based on the environement
|
194 |
+
*
|
195 |
* @param string $environment currently configured environment
|
196 |
+
*
|
197 |
* @return string postfix for widget url string
|
198 |
*/
|
199 |
private function _getWidgetEnvironmentFor($environment)
|
200 |
{
|
201 |
return ( $this->_isSandbox($environment) ? '/sandbox' : '');
|
202 |
}
|
203 |
+
|
204 |
/**
|
205 |
* Return the correct section name postfix for the
|
206 |
* given environment
|
213 |
{
|
214 |
return ( $this->_isSandbox($environment) ? '_Sandbox' : '');
|
215 |
}
|
216 |
+
|
217 |
/**
|
218 |
* Check if the environment is sandbox
|
219 |
+
*
|
220 |
* @param string environment name
|
221 |
+
*
|
222 |
* @return bool true if environment is sandbox
|
223 |
*/
|
224 |
private function _isSandbox($environment)
|
lib/OffAmazonPaymentsService/Samples/.config.inc.php
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/************************************************************************
|
4 |
-
* OPTIONAL ON SOME INSTALLATIONS
|
5 |
-
*
|
6 |
-
* Set include path to root of library, relative to Samples directory.
|
7 |
-
* Only needed when running library from local directory.
|
8 |
-
* If library is installed in PHP include path, this is not needed
|
9 |
-
***********************************************************************/
|
10 |
-
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . "/../../."));
|
11 |
-
|
12 |
-
require_once "OffAmazonPayments/.autoloader.php";
|
13 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/AddressConsentSample.php
DELETED
@@ -1,78 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
4 |
-
|
5 |
-
/**
|
6 |
-
* AddressConsentSample shows how to use an
|
7 |
-
* access token in order to return additional information about the buyer
|
8 |
-
* attached to a payment contract.
|
9 |
-
*
|
10 |
-
* This example is for US based customers only.
|
11 |
-
*
|
12 |
-
* Note that the token requires needs to be decoded before it can be passed
|
13 |
-
* into the service call
|
14 |
-
*
|
15 |
-
* The sample is run by passing in a draft order reference and the access token
|
16 |
-
* assocaited with this order reference object..
|
17 |
-
*/
|
18 |
-
class AddressConsentSample
|
19 |
-
{
|
20 |
-
private $_sellerId;
|
21 |
-
private $_service;
|
22 |
-
private $_amazonOrderReferenceId;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Create a new instance of the Address consent sample
|
26 |
-
*
|
27 |
-
* @param OffAmazonPaymentsService_Client $service instance of the service
|
28 |
-
* client
|
29 |
-
* @param string $amazonOrderReferenceId an order reference object in
|
30 |
-
* draft state to use in
|
31 |
-
* the example
|
32 |
-
*
|
33 |
-
* @return new PayWithAmazonAddressConsentSample
|
34 |
-
*/
|
35 |
-
public function __construct($service, $amazonOrderReferenceId)
|
36 |
-
{
|
37 |
-
$this->_service = $service;
|
38 |
-
$this->_amazonOrderReferenceId = $amazonOrderReferenceId;
|
39 |
-
$this->_sellerId = $this->_service->getMerchantValues()->getMerchantId();
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Validate that the order reference is in the draft state
|
44 |
-
*
|
45 |
-
* @param OffAmazonPayments_Model_GetOrderReferenceDetailsResponse in an unverified state
|
46 |
-
*
|
47 |
-
* @return void
|
48 |
-
* @throws ErrorException if the state does not match the expected state
|
49 |
-
*/
|
50 |
-
public function validateOrderReferenceIsInACorrectState($getOrderReferenceDetailsResponse)
|
51 |
-
{
|
52 |
-
validateOrderReferenceIsInACorrectState(
|
53 |
-
$getOrderReferenceDetailsResponse->getGetOrderReferenceDetailsResult()->getOrderReferenceDetails(),
|
54 |
-
"DRAFT"
|
55 |
-
);
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Use the order reference object to query the order information, including
|
60 |
-
* the current physical delivery address as selected by the buyer
|
61 |
-
*
|
62 |
-
* @return OffAmazonPaymentsService_Model_GetOrderReferenceDetailsResponse service response
|
63 |
-
*/
|
64 |
-
public function getOrderReferenceDetails($addressConsentToken = null)
|
65 |
-
{
|
66 |
-
$getOrderReferenceDetailsRequest = new OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest();
|
67 |
-
$getOrderReferenceDetailsRequest->setSellerId($this->_sellerId);
|
68 |
-
$getOrderReferenceDetailsRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
69 |
-
|
70 |
-
if (is_null($addressConsentToken) == FALSE) {
|
71 |
-
$decodedToken = urldecode($addressConsentToken);
|
72 |
-
$getOrderReferenceDetailsRequest->setAddressConsentToken($decodedToken);
|
73 |
-
}
|
74 |
-
|
75 |
-
return $this->_service->getOrderReferenceDetails($getOrderReferenceDetailsRequest);
|
76 |
-
}
|
77 |
-
}
|
78 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/AuthorizeOnBillingAgreementSample.php
DELETED
@@ -1,258 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Checks that the Authorize Response has all objects initialized, and returns
|
21 |
-
* the amazon authorization id
|
22 |
-
*
|
23 |
-
* @param OffAmazonPaymentsService_Model_AuthorizeResult $response response
|
24 |
-
* object
|
25 |
-
*
|
26 |
-
* @throws ErrorException
|
27 |
-
*
|
28 |
-
* @return AmazonAuthorizationId
|
29 |
-
*/
|
30 |
-
function getAmazonAuthorizationIdFromAuthorizeOnBillingAgreementResponse ($response)
|
31 |
-
{
|
32 |
-
if (is_null($response) || ! $response->isSetAuthorizeOnBillingAgreementResult() ||
|
33 |
-
! $response->getAuthorizeOnBillingAgreementResult()->isSetAuthorizationDetails() ||
|
34 |
-
! $response->getAuthorizeOnBillingAgreementResult()
|
35 |
-
->getAuthorizationDetails()
|
36 |
-
->isSetAmazonAuthorizationId()) {
|
37 |
-
throw new ErrorException("Error with AuthorizeResponse - missing required fields");
|
38 |
-
}
|
39 |
-
|
40 |
-
return $response->getAuthorizeOnBillingAgreementResult()
|
41 |
-
->getAuthorizationDetails()
|
42 |
-
->getAmazonAuthorizationId();
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Print the AuthorizeOnBillingAgreement response to the console
|
47 |
-
*
|
48 |
-
* @param OffAmazonPaymentsService_Model_AuthorizeOnBillingAgreementResponse $response
|
49 |
-
* response object
|
50 |
-
*
|
51 |
-
* @return void
|
52 |
-
*/
|
53 |
-
function printAuthorizeOnBillingAgreementResponse ($response)
|
54 |
-
{
|
55 |
-
echo ("Service Response\n");
|
56 |
-
echo ("=============================================================================\n");
|
57 |
-
|
58 |
-
echo (" AuthorizeOnBillingAgreementResponse\n");
|
59 |
-
if ($response->isSetAuthorizeOnBillingAgreementResult()) {
|
60 |
-
echo (" AuthorizeOnBillingAgreementResult\n");
|
61 |
-
$authorizeOnBillingAgreementResult = $response->getAuthorizeOnBillingAgreementResult();
|
62 |
-
if ($authorizeOnBillingAgreementResult->isSetAuthorizationDetails()) {
|
63 |
-
echo (" AuthorizationDetails\n");
|
64 |
-
$authorizationDetails = $authorizeOnBillingAgreementResult->getAuthorizationDetails();
|
65 |
-
if ($authorizationDetails->isSetAmazonAuthorizationId()) {
|
66 |
-
echo (" AmazonAuthorizationId\n");
|
67 |
-
echo (" " . $authorizationDetails->getAmazonAuthorizationId() .
|
68 |
-
"\n");
|
69 |
-
}
|
70 |
-
if ($authorizationDetails->isSetAuthorizationReferenceId()) {
|
71 |
-
echo (" AuthorizationReferenceId\n");
|
72 |
-
echo (" " .
|
73 |
-
$authorizationDetails->getAuthorizationReferenceId() . "\n");
|
74 |
-
}
|
75 |
-
if ($authorizationDetails->isSetAuthorizationBillingAddress()) {
|
76 |
-
echo (" AuthorizationBillingAddress\n");
|
77 |
-
$authorizationBillingAddress = $authorizationDetails->getAuthorizationBillingAddress();
|
78 |
-
if ($authorizationBillingAddress->isSetName()) {
|
79 |
-
echo (" Name\n");
|
80 |
-
echo (" " . $authorizationBillingAddress->getName() .
|
81 |
-
"\n");
|
82 |
-
}
|
83 |
-
if ($authorizationBillingAddress->isSetAddressLine1()) {
|
84 |
-
echo (" AddressLine1\n");
|
85 |
-
echo (" " .
|
86 |
-
$authorizationBillingAddress->getAddressLine1() . "\n");
|
87 |
-
}
|
88 |
-
if ($authorizationBillingAddress->isSetAddressLine2()) {
|
89 |
-
echo (" AddressLine2\n");
|
90 |
-
echo (" " .
|
91 |
-
$authorizationBillingAddress->getAddressLine2() . "\n");
|
92 |
-
}
|
93 |
-
if ($authorizationBillingAddress->isSetAddressLine3()) {
|
94 |
-
echo (" AddressLine3\n");
|
95 |
-
echo (" " .
|
96 |
-
$authorizationBillingAddress->getAddressLine3() . "\n");
|
97 |
-
}
|
98 |
-
if ($authorizationBillingAddress->isSetCity()) {
|
99 |
-
echo (" City\n");
|
100 |
-
echo (" " . $authorizationBillingAddress->getCity() .
|
101 |
-
"\n");
|
102 |
-
}
|
103 |
-
if ($authorizationBillingAddress->isSetCounty()) {
|
104 |
-
echo (" County\n");
|
105 |
-
echo (" " . $authorizationBillingAddress->getCounty() .
|
106 |
-
"\n");
|
107 |
-
}
|
108 |
-
if ($authorizationBillingAddress->isSetDistrict()) {
|
109 |
-
echo (" District\n");
|
110 |
-
echo (" " .
|
111 |
-
$authorizationBillingAddress->getDistrict() . "\n");
|
112 |
-
}
|
113 |
-
if ($authorizationBillingAddress->isSetStateOrRegion()) {
|
114 |
-
echo (" StateOrRegion\n");
|
115 |
-
echo (" " .
|
116 |
-
$authorizationBillingAddress->getStateOrRegion() . "\n");
|
117 |
-
}
|
118 |
-
if ($authorizationBillingAddress->isSetPostalCode()) {
|
119 |
-
echo (" PostalCode\n");
|
120 |
-
echo (" " .
|
121 |
-
$authorizationBillingAddress->getPostalCode() . "\n");
|
122 |
-
}
|
123 |
-
if ($authorizationBillingAddress->isSetCountryCode()) {
|
124 |
-
echo (" CountryCode\n");
|
125 |
-
echo (" " .
|
126 |
-
$authorizationBillingAddress->getCountryCode() . "\n");
|
127 |
-
}
|
128 |
-
if ($authorizationBillingAddress->isSetPhone()) {
|
129 |
-
echo (" Phone\n");
|
130 |
-
echo (" " . $authorizationBillingAddress->getPhone() .
|
131 |
-
"\n");
|
132 |
-
}
|
133 |
-
}
|
134 |
-
if ($authorizationDetails->isSetSellerAuthorizationNote()) {
|
135 |
-
echo (" SellerAuthorizationNote\n");
|
136 |
-
echo (" " .
|
137 |
-
$authorizationDetails->getSellerAuthorizationNote() . "\n");
|
138 |
-
}
|
139 |
-
if ($authorizationDetails->isSetAuthorizationAmount()) {
|
140 |
-
echo (" AuthorizationAmount\n");
|
141 |
-
$authorizationAmount = $authorizationDetails->getAuthorizationAmount();
|
142 |
-
if ($authorizationAmount->isSetAmount()) {
|
143 |
-
echo (" Amount\n");
|
144 |
-
echo (" " . $authorizationAmount->getAmount() . "\n");
|
145 |
-
}
|
146 |
-
if ($authorizationAmount->isSetCurrencyCode()) {
|
147 |
-
echo (" CurrencyCode\n");
|
148 |
-
echo (" " . $authorizationAmount->getCurrencyCode() .
|
149 |
-
"\n");
|
150 |
-
}
|
151 |
-
}
|
152 |
-
if ($authorizationDetails->isSetCapturedAmount()) {
|
153 |
-
echo (" CapturedAmount\n");
|
154 |
-
$capturedAmount = $authorizationDetails->getCapturedAmount();
|
155 |
-
if ($capturedAmount->isSetAmount()) {
|
156 |
-
echo (" Amount\n");
|
157 |
-
echo (" " . $capturedAmount->getAmount() . "\n");
|
158 |
-
}
|
159 |
-
if ($capturedAmount->isSetCurrencyCode()) {
|
160 |
-
echo (" CurrencyCode\n");
|
161 |
-
echo (" " . $capturedAmount->getCurrencyCode() . "\n");
|
162 |
-
}
|
163 |
-
}
|
164 |
-
if ($authorizationDetails->isSetAuthorizationFee()) {
|
165 |
-
echo (" AuthorizationFee\n");
|
166 |
-
$authorizationFee = $authorizationDetails->getAuthorizationFee();
|
167 |
-
if ($authorizationFee->isSetAmount()) {
|
168 |
-
echo (" Amount\n");
|
169 |
-
echo (" " . $authorizationFee->getAmount() . "\n");
|
170 |
-
}
|
171 |
-
if ($authorizationFee->isSetCurrencyCode()) {
|
172 |
-
echo (" CurrencyCode\n");
|
173 |
-
echo (" " . $authorizationFee->getCurrencyCode() .
|
174 |
-
"\n");
|
175 |
-
}
|
176 |
-
}
|
177 |
-
if ($authorizationDetails->isSetIdList()) {
|
178 |
-
echo (" IdList\n");
|
179 |
-
$idList = $authorizationDetails->getIdList();
|
180 |
-
$memberList = $idList->getmember();
|
181 |
-
foreach ($memberList as $member) {
|
182 |
-
echo (" member\n");
|
183 |
-
echo (" " . $member . "\n");
|
184 |
-
}
|
185 |
-
}
|
186 |
-
if ($authorizationDetails->isSetCreationTimestamp()) {
|
187 |
-
echo (" CreationTimestamp\n");
|
188 |
-
echo (" " . $authorizationDetails->getCreationTimestamp() .
|
189 |
-
"\n");
|
190 |
-
}
|
191 |
-
if ($authorizationDetails->isSetExpirationTimestamp()) {
|
192 |
-
echo (" ExpirationTimestamp\n");
|
193 |
-
echo (" " . $authorizationDetails->getExpirationTimestamp() .
|
194 |
-
"\n");
|
195 |
-
}
|
196 |
-
if ($authorizationDetails->isSetAuthorizationStatus()) {
|
197 |
-
echo (" AuthorizationStatus\n");
|
198 |
-
$authorizationStatus = $authorizationDetails->getAuthorizationStatus();
|
199 |
-
if ($authorizationStatus->isSetState()) {
|
200 |
-
echo (" State\n");
|
201 |
-
echo (" " . $authorizationStatus->getState() . "\n");
|
202 |
-
}
|
203 |
-
if ($authorizationStatus->isSetLastUpdateTimestamp()) {
|
204 |
-
echo (" LastUpdateTimestamp\n");
|
205 |
-
echo (" " .
|
206 |
-
$authorizationStatus->getLastUpdateTimestamp() . "\n");
|
207 |
-
}
|
208 |
-
if ($authorizationStatus->isSetReasonCode()) {
|
209 |
-
echo (" ReasonCode\n");
|
210 |
-
echo (" " . $authorizationStatus->getReasonCode() .
|
211 |
-
"\n");
|
212 |
-
}
|
213 |
-
if ($authorizationStatus->isSetReasonDescription()) {
|
214 |
-
echo (" ReasonDescription\n");
|
215 |
-
echo (" " .
|
216 |
-
$authorizationStatus->getReasonDescription() . "\n");
|
217 |
-
}
|
218 |
-
}
|
219 |
-
if ($authorizationDetails->isSetOrderItemCategories()) {
|
220 |
-
echo (" OrderItemCategories\n");
|
221 |
-
$orderItemCategories = $authorizationDetails->getOrderItemCategories();
|
222 |
-
$orderItemCategoryList = $orderItemCategories->getOrderItemCategory();
|
223 |
-
foreach ($orderItemCategoryList as $orderItemCategory) {
|
224 |
-
echo (" OrderItemCategory\n");
|
225 |
-
echo (" " . $orderItemCategory);
|
226 |
-
}
|
227 |
-
}
|
228 |
-
if ($authorizationDetails->isSetCaptureNow()) {
|
229 |
-
echo (" CaptureNow\n");
|
230 |
-
echo (" " . $authorizationDetails->getCaptureNow() . "\n");
|
231 |
-
}
|
232 |
-
if ($authorizationDetails->isSetSoftDescriptor()) {
|
233 |
-
echo (" SoftDescriptor\n");
|
234 |
-
echo (" " . $authorizationDetails->getSoftDescriptor() . "\n");
|
235 |
-
}
|
236 |
-
if ($authorizationDetails->isSetAddressVerificationCode()) {
|
237 |
-
echo (" AddressVerificationCode\n");
|
238 |
-
echo (" " . $authorizationDetails->getAddressVerificationCode() . "\n");
|
239 |
-
}
|
240 |
-
}
|
241 |
-
if ($authorizeOnBillingAgreementResult->isSetAmazonOrderReferenceId()) {
|
242 |
-
echo (" AmazonOrderReferenceId\n");
|
243 |
-
echo (" " .
|
244 |
-
$authorizeOnBillingAgreementResult->getAmazonOrderReferenceId() . "\n");
|
245 |
-
}
|
246 |
-
}
|
247 |
-
if ($response->isSetResponseMetadata()) {
|
248 |
-
echo (" ResponseMetadata\n");
|
249 |
-
$responseMetadata = $response->getResponseMetadata();
|
250 |
-
if ($responseMetadata->isSetRequestId()) {
|
251 |
-
echo (" RequestId\n");
|
252 |
-
echo (" " . $responseMetadata->getRequestId() . "\n");
|
253 |
-
}
|
254 |
-
}
|
255 |
-
|
256 |
-
echo (" ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");
|
257 |
-
}
|
258 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/AuthorizeSample.php
DELETED
@@ -1,271 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Authorize Sample
|
21 |
-
*/
|
22 |
-
|
23 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Checks that the Authorize Response has all objects initialized, and returns
|
27 |
-
* the amazon authorization id
|
28 |
-
*
|
29 |
-
* @param OffAmazonPaymentsService_Model_AuthorizeResult $response response
|
30 |
-
* object
|
31 |
-
*
|
32 |
-
* @throws ErrorException
|
33 |
-
*
|
34 |
-
* @return AmazonAuthorizationId
|
35 |
-
*/
|
36 |
-
function getAmazonAuthorizationIdFromAuthorizeResponse($response)
|
37 |
-
{
|
38 |
-
if (is_null($response)
|
39 |
-
|| !$response->isSetAuthorizeResult()
|
40 |
-
|| !$response->getAuthorizeResult()->isSetAuthorizationDetails()
|
41 |
-
|| !$response->getAuthorizeResult()->getAuthorizationDetails()->isSetAmazonAuthorizationId()
|
42 |
-
) {
|
43 |
-
throw new ErrorException("Error with AuthorizeResponse - missing required fields");
|
44 |
-
}
|
45 |
-
|
46 |
-
return $response->getAuthorizeResult()->getAuthorizationDetails()->getAmazonAuthorizationId();
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Print the authorize response to the console
|
51 |
-
*
|
52 |
-
* @param OffAmazonPaymentsService_Model_AuthorizeResult $response response
|
53 |
-
* object
|
54 |
-
*
|
55 |
-
* @return void
|
56 |
-
*/
|
57 |
-
function printAuthorizeResponse($response)
|
58 |
-
{
|
59 |
-
|
60 |
-
print "Service Response" . PHP_EOL;
|
61 |
-
print "=============================================================================" . PHP_EOL;
|
62 |
-
|
63 |
-
print " AuthorizeResponse" . PHP_EOL;
|
64 |
-
if ($response->isSetAuthorizeResult()) {
|
65 |
-
print " AuthorizeResult" . PHP_EOL;
|
66 |
-
$authorizeResult = $response->getAuthorizeResult();
|
67 |
-
if ($authorizeResult->isSetAuthorizationDetails()) {
|
68 |
-
print " AuthorizationDetails" . PHP_EOL;
|
69 |
-
$authorizationDetails = $authorizeResult->getAuthorizationDetails();
|
70 |
-
if ($authorizationDetails->isSetAmazonAuthorizationId())
|
71 |
-
{
|
72 |
-
print " AmazonAuthorizationId" . PHP_EOL;
|
73 |
-
print " " . $authorizationDetails->getAmazonAuthorizationId() . PHP_EOL;
|
74 |
-
}
|
75 |
-
if ($authorizationDetails->isSetAuthorizationReferenceId())
|
76 |
-
{
|
77 |
-
print " AuthorizationReferenceId" . PHP_EOL;
|
78 |
-
print " " . $authorizationDetails->getAuthorizationReferenceId() . PHP_EOL;
|
79 |
-
}
|
80 |
-
if ($authorizationDetails->isSetAuthorizationBillingAddress())
|
81 |
-
{
|
82 |
-
print " AuthorizationBillingAddress" . PHP_EOL;
|
83 |
-
$authorizationBillingAddress = $authorizationDetails->getAuthorizationBillingAddress();
|
84 |
-
if ($authorizationBillingAddress->isSetName())
|
85 |
-
{
|
86 |
-
print " Name" . PHP_EOL;
|
87 |
-
print " " . $authorizationBillingAddress->getName() . PHP_EOL;
|
88 |
-
}
|
89 |
-
if ($authorizationBillingAddress->isSetAddressLine1())
|
90 |
-
{
|
91 |
-
print " AddressLine1" . PHP_EOL;
|
92 |
-
print " " . $authorizationBillingAddress->getAddressLine1() . PHP_EOL;
|
93 |
-
}
|
94 |
-
if ($authorizationBillingAddress->isSetAddressLine2())
|
95 |
-
{
|
96 |
-
print " AddressLine2" . PHP_EOL;
|
97 |
-
print " " . $authorizationBillingAddress->getAddressLine2() . PHP_EOL;
|
98 |
-
}
|
99 |
-
if ($authorizationBillingAddress->isSetAddressLine3())
|
100 |
-
{
|
101 |
-
print " AddressLine3" . PHP_EOL;
|
102 |
-
print " " . $authorizationBillingAddress->getAddressLine3() . PHP_EOL;
|
103 |
-
}
|
104 |
-
if ($authorizationBillingAddress->isSetCity())
|
105 |
-
{
|
106 |
-
print " City" . PHP_EOL;
|
107 |
-
print " " . $authorizationBillingAddress->getCity() . PHP_EOL;
|
108 |
-
}
|
109 |
-
if ($authorizationBillingAddress->isSetCounty())
|
110 |
-
{
|
111 |
-
print " County" . PHP_EOL;
|
112 |
-
print " " . $authorizationBillingAddress->getCounty() . PHP_EOL;
|
113 |
-
}
|
114 |
-
if ($authorizationBillingAddress->isSetDistrict())
|
115 |
-
{
|
116 |
-
print " District" . PHP_EOL;
|
117 |
-
print " " . $authorizationBillingAddress->getDistrict() . PHP_EOL;
|
118 |
-
}
|
119 |
-
if ($authorizationBillingAddress->isSetStateOrRegion())
|
120 |
-
{
|
121 |
-
print " StateOrRegion" . PHP_EOL;
|
122 |
-
print " " . $authorizationBillingAddress->getStateOrRegion() . PHP_EOL;
|
123 |
-
}
|
124 |
-
if ($authorizationBillingAddress->isSetPostalCode())
|
125 |
-
{
|
126 |
-
print " PostalCode" . PHP_EOL;
|
127 |
-
print " " . $authorizationBillingAddress->getPostalCode() . PHP_EOL;
|
128 |
-
}
|
129 |
-
if ($authorizationBillingAddress->isSetCountryCode())
|
130 |
-
{
|
131 |
-
print " CountryCode" . PHP_EOL;
|
132 |
-
print " " . $authorizationBillingAddress->getCountryCode() . PHP_EOL;
|
133 |
-
}
|
134 |
-
if ($authorizationBillingAddress->isSetPhone())
|
135 |
-
{
|
136 |
-
print " Phone" . PHP_EOL;
|
137 |
-
print " " . $authorizationBillingAddress->getPhone() . PHP_EOL;
|
138 |
-
}
|
139 |
-
}
|
140 |
-
if ($authorizationDetails->isSetSellerAuthorizationNote())
|
141 |
-
{
|
142 |
-
print " SellerAuthorizationNote" . PHP_EOL;
|
143 |
-
print " " . $authorizationDetails->getSellerAuthorizationNote() . PHP_EOL;
|
144 |
-
}
|
145 |
-
if ($authorizationDetails->isSetAuthorizationAmount()) {
|
146 |
-
print " AuthorizationAmount" . PHP_EOL;
|
147 |
-
$authorizationAmount = $authorizationDetails->getAuthorizationAmount();
|
148 |
-
if ($authorizationAmount->isSetAmount())
|
149 |
-
{
|
150 |
-
print " Amount" . PHP_EOL;
|
151 |
-
print " " . $authorizationAmount->getAmount() . PHP_EOL;
|
152 |
-
}
|
153 |
-
if ($authorizationAmount->isSetCurrencyCode())
|
154 |
-
{
|
155 |
-
print " CurrencyCode" . PHP_EOL;
|
156 |
-
print " " . $authorizationAmount->getCurrencyCode() . PHP_EOL;
|
157 |
-
}
|
158 |
-
}
|
159 |
-
if ($authorizationDetails->isSetCapturedAmount()) {
|
160 |
-
print " CapturedAmount" . PHP_EOL;
|
161 |
-
$capturedAmount = $authorizationDetails->getCapturedAmount();
|
162 |
-
if ($capturedAmount->isSetAmount())
|
163 |
-
{
|
164 |
-
print " Amount" . PHP_EOL;
|
165 |
-
print " " . $capturedAmount->getAmount() . PHP_EOL;
|
166 |
-
}
|
167 |
-
if ($capturedAmount->isSetCurrencyCode())
|
168 |
-
{
|
169 |
-
print " CurrencyCode" . PHP_EOL;
|
170 |
-
print " " . $capturedAmount->getCurrencyCode() . PHP_EOL;
|
171 |
-
}
|
172 |
-
}
|
173 |
-
if ($authorizationDetails->isSetAuthorizationFee()) {
|
174 |
-
print " AuthorizationFee" . PHP_EOL;
|
175 |
-
$authorizationFee = $authorizationDetails->getAuthorizationFee();
|
176 |
-
if ($authorizationFee->isSetAmount())
|
177 |
-
{
|
178 |
-
print " Amount" . PHP_EOL;
|
179 |
-
print " " . $authorizationFee->getAmount() . PHP_EOL;
|
180 |
-
}
|
181 |
-
if ($authorizationFee->isSetCurrencyCode())
|
182 |
-
{
|
183 |
-
print " CurrencyCode" . PHP_EOL;
|
184 |
-
print " " . $authorizationFee->getCurrencyCode() . PHP_EOL;
|
185 |
-
}
|
186 |
-
}
|
187 |
-
if ($authorizationDetails->isSetIdList()) {
|
188 |
-
print " IdList" . PHP_EOL;
|
189 |
-
$idList = $authorizationDetails->getIdList();
|
190 |
-
$memberList = $idList->getmember();
|
191 |
-
foreach ($memberList as $member) {
|
192 |
-
print " member" . PHP_EOL;
|
193 |
-
print " " . $member;
|
194 |
-
}
|
195 |
-
}
|
196 |
-
if ($authorizationDetails->isSetCreationTimestamp())
|
197 |
-
{
|
198 |
-
print " CreationTimestamp" . PHP_EOL;
|
199 |
-
print " " . $authorizationDetails->getCreationTimestamp() . PHP_EOL;
|
200 |
-
}
|
201 |
-
if ($authorizationDetails->isSetExpirationTimestamp())
|
202 |
-
{
|
203 |
-
print " ExpirationTimestamp" . PHP_EOL;
|
204 |
-
print " " . $authorizationDetails->getExpirationTimestamp() . PHP_EOL;
|
205 |
-
}
|
206 |
-
if ($authorizationDetails->isSetAuthorizationStatus()) {
|
207 |
-
print " AuthorizationStatus" . PHP_EOL;
|
208 |
-
$authorizationStatus = $authorizationDetails->getAuthorizationStatus();
|
209 |
-
if ($authorizationStatus->isSetState())
|
210 |
-
{
|
211 |
-
print " State" . PHP_EOL;
|
212 |
-
print " " . $authorizationStatus->getState() . PHP_EOL;
|
213 |
-
}
|
214 |
-
if ($authorizationStatus->isSetLastUpdateTimestamp())
|
215 |
-
{
|
216 |
-
print " LastUpdateTimestamp" . PHP_EOL;
|
217 |
-
print " " . $authorizationStatus->getLastUpdateTimestamp() . PHP_EOL;
|
218 |
-
}
|
219 |
-
if ($authorizationStatus->isSetReasonCode())
|
220 |
-
{
|
221 |
-
print " ReasonCode" . PHP_EOL;
|
222 |
-
print " " . $authorizationStatus->getReasonCode() . PHP_EOL;
|
223 |
-
}
|
224 |
-
if ($authorizationStatus->isSetReasonDescription())
|
225 |
-
{
|
226 |
-
print " ReasonDescription" . PHP_EOL;
|
227 |
-
print " " . $authorizationStatus->getReasonDescription() . PHP_EOL;
|
228 |
-
}
|
229 |
-
}
|
230 |
-
if ($authorizationDetails->isSetOrderItemCategories()) {
|
231 |
-
print " OrderItemCategories" . PHP_EOL;
|
232 |
-
$orderItemCategories = $authorizationDetails->getOrderItemCategories();
|
233 |
-
$orderItemCategoryList = $orderItemCategories->getOrderItemCategory();
|
234 |
-
foreach ($orderItemCategoryList as $orderItemCategory) {
|
235 |
-
print " OrderItemCategory" . PHP_EOL;
|
236 |
-
print " " . $orderItemCategory;
|
237 |
-
}
|
238 |
-
}
|
239 |
-
if ($authorizationDetails->isSetCaptureNow())
|
240 |
-
{
|
241 |
-
print " CaptureNow" . PHP_EOL;
|
242 |
-
print " " . $authorizationDetails->getCaptureNow() . PHP_EOL;
|
243 |
-
}
|
244 |
-
if ($authorizationDetails->isSetSoftDescriptor())
|
245 |
-
{
|
246 |
-
print " SoftDescriptor" . PHP_EOL;
|
247 |
-
print " " . $authorizationDetails->getSoftDescriptor() . PHP_EOL;
|
248 |
-
}
|
249 |
-
if ($authorizationDetails->isSetAddressVerificationCode())
|
250 |
-
{
|
251 |
-
print " AddressVerificationCode" . PHP_EOL;
|
252 |
-
print " " . $authorizationDetails->getAddressVerificationCode() . PHP_EOL;
|
253 |
-
}
|
254 |
-
}
|
255 |
-
}
|
256 |
-
if ($response->isSetResponseMetadata()) {
|
257 |
-
print " ResponseMetadata" . PHP_EOL;
|
258 |
-
$responseMetadata = $response->getResponseMetadata();
|
259 |
-
if ($responseMetadata->isSetRequestId())
|
260 |
-
{
|
261 |
-
print " RequestId" . PHP_EOL;
|
262 |
-
print " " . $responseMetadata->getRequestId() . PHP_EOL;
|
263 |
-
}
|
264 |
-
}
|
265 |
-
|
266 |
-
print " ResponseHeaderMetadata: " .
|
267 |
-
$response->getResponseHeaderMetadata() . PHP_EOL;
|
268 |
-
|
269 |
-
return $response;
|
270 |
-
}
|
271 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/AutomaticPaymentsSimpleCheckoutExample.php
DELETED
@@ -1,366 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
/*
|
19 |
-
* Automatic payments simple checkout example
|
20 |
-
*
|
21 |
-
* This demonstrates a merchant use case where the item is in stock, and
|
22 |
-
* the billing agreement creation is immediately followed by the order
|
23 |
-
* confirmation and capture of funds for the merchant
|
24 |
-
*
|
25 |
-
* This use case makes the assumption that the merchant is using the billing
|
26 |
-
* agreement address capture widget to capture the destination address for the
|
27 |
-
* order, and uses the address information to calculate a tax and shipping rate
|
28 |
-
*
|
29 |
-
* This example will show the following service calls:
|
30 |
-
* - GetBillingAgreementDetails
|
31 |
-
* - SetBillingAgreementDetails
|
32 |
-
* - ConfirmBillingAgreement
|
33 |
-
* - AuthorizeOnBillingAgreement
|
34 |
-
* - GetAuthorizeDetails
|
35 |
-
* - Capture
|
36 |
-
* - GetCaptureDetails
|
37 |
-
* - CloseBillingAgreement
|
38 |
-
*/
|
39 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
40 |
-
require_once realpath(dirname(__FILE__)) . '/Utils/ShippingAndTaxCostHelper.php';
|
41 |
-
|
42 |
-
/**
|
43 |
-
* AutomaticPaymentsSimpleCheckoutExample includes the logic required to capture
|
44 |
-
* an order and perform all actions to capture the order amount fromthe buyer.
|
45 |
-
*/
|
46 |
-
class AutomaticPaymentsSimpleCheckoutExample
|
47 |
-
{
|
48 |
-
|
49 |
-
private $_sellerId;
|
50 |
-
|
51 |
-
private $_service;
|
52 |
-
|
53 |
-
private $_amazonBillingAgreementId;
|
54 |
-
|
55 |
-
private $_shippingAndTaxCostHelper;
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Create a new instance of the automatic payment simple checkout example
|
59 |
-
* case
|
60 |
-
*
|
61 |
-
* @param OffAmazonPaymentsService_Client $service
|
62 |
-
* instance of the service client
|
63 |
-
* @param string $amazonBillingAgreementId
|
64 |
-
* an billing agreement object in draft state
|
65 |
-
*
|
66 |
-
* @return new AutomaticPaymentsSimpleCheckoutExample
|
67 |
-
*/
|
68 |
-
public function __construct ($service, $amazonBillingAgreementId)
|
69 |
-
{
|
70 |
-
$this->_service = $service;
|
71 |
-
|
72 |
-
$this->_amazonBillingAgreementId = $amazonBillingAgreementId;
|
73 |
-
|
74 |
-
$this->_sellerId = $this->_service->getMerchantValues()->getMerchantId();
|
75 |
-
|
76 |
-
$this->_shippingAndTaxCostHelper = new ShippingAndTaxCostHelper();
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Use the billing agreement object to query the automatic payment
|
81 |
-
* information, including the current physical delivery address as selected
|
82 |
-
* by the buyer
|
83 |
-
*
|
84 |
-
* @return OffAmazonPaymentsService_Model_GetBillingAgreementDetailsResponse
|
85 |
-
* service response
|
86 |
-
*/
|
87 |
-
public function getBillingAgreementDetails ()
|
88 |
-
{
|
89 |
-
$getBillingAgreementDetailsRequest = new OffAmazonPaymentsService_Model_GetBillingAgreementDetailsRequest();
|
90 |
-
$getBillingAgreementDetailsRequest->setSellerId($this->_sellerId);
|
91 |
-
$getBillingAgreementDetailsRequest->setAmazonBillingAgreementId(
|
92 |
-
$this->_amazonBillingAgreementId);
|
93 |
-
|
94 |
-
return $this->_service->getBillingAgreementDetails($getBillingAgreementDetailsRequest);
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Calculate the amount to charge the buyer for each payment, based on the
|
99 |
-
* buyer destination
|
100 |
-
*
|
101 |
-
* Note that until the billing agreement is confirmed, the name & address
|
102 |
-
* fields will not be returned to the client.
|
103 |
-
*
|
104 |
-
* @param OffAmazonPaymentsService_Model_BillingAgreementDetails $BillingAgreementDetails
|
105 |
-
* response
|
106 |
-
* @param string $orderAmountPreTaxAndShipping
|
107 |
-
* order amount
|
108 |
-
* @param int $shippingType
|
109 |
-
* shipping type
|
110 |
-
*
|
111 |
-
* @return float total amount for the order, with shipping and tax included
|
112 |
-
*/
|
113 |
-
public function calculatePaymentAmountBasedOnBuyerDetails ($BillingAgreementDetails,
|
114 |
-
$orderAmountPreTaxAndShipping, $shippingType)
|
115 |
-
{
|
116 |
-
return $this->_shippingAndTaxCostHelper->calculateTotalAmount($BillingAgreementDetails,
|
117 |
-
$orderAmountPreTaxAndShipping, $shippingType);
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Set seller specific information to the billing agreement details.
|
122 |
-
*
|
123 |
-
* @return OffAmazonPaymentsService_Model_SetBillingAgreementDetailsResponse
|
124 |
-
* service response
|
125 |
-
*/
|
126 |
-
public function addSellerInformationToBillingAgreement ()
|
127 |
-
{
|
128 |
-
$sellerBillingAgreementAttributes = new OffAmazonPaymentsService_Model_SellerBillingAgreementAttributes();
|
129 |
-
$sellerBillingAgreementAttributes->setSellerBillingAgreementId(
|
130 |
-
$this->_amazonBillingAgreementId);
|
131 |
-
$sellerBillingAgreementAttributes->setStoreName("Your store name here");
|
132 |
-
$sellerBillingAgreementAttributes->setCustomInformation(
|
133 |
-
"Additional information you wish to include with this billing agreement.");
|
134 |
-
|
135 |
-
$billingAgreementAttributes = new OffAmazonPaymentsService_Model_BillingAgreementAttributes();
|
136 |
-
$billingAgreementAttributes->setSellerNote(
|
137 |
-
"Description of the billing agreement that is displayed to the buyer in the emails.");
|
138 |
-
$billingAgreementAttributes->setSellerBillingAgreementAttributes(
|
139 |
-
$sellerBillingAgreementAttributes);
|
140 |
-
|
141 |
-
$setBillingAgreementDetailsRequest = new OffAmazonPaymentsService_Model_SetBillingAgreementDetailsRequest();
|
142 |
-
$setBillingAgreementDetailsRequest->setAmazonBillingAgreementId(
|
143 |
-
$this->_amazonBillingAgreementId);
|
144 |
-
$setBillingAgreementDetailsRequest->setSellerId($this->_sellerId);
|
145 |
-
$setBillingAgreementDetailsRequest->setBillingAgreementAttributes(
|
146 |
-
$billingAgreementAttributes);
|
147 |
-
return $this->_service->setBillingAgreementDetails($setBillingAgreementDetailsRequest);
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Confirm the billing agreement information, allowing for authorizations
|
152 |
-
* and captures to be created
|
153 |
-
*
|
154 |
-
* @return OffAmazonPaymentsService_Model_ConfirmBillingAgreementResponse
|
155 |
-
* service response
|
156 |
-
*/
|
157 |
-
public function confirmBillingAgreement ()
|
158 |
-
{
|
159 |
-
$confirmBillingAgreementRequest = new OffAmazonPaymentsService_Model_ConfirmBillingAgreementRequest();
|
160 |
-
$confirmBillingAgreementRequest->setAmazonBillingAgreementId(
|
161 |
-
$this->_amazonBillingAgreementId);
|
162 |
-
$confirmBillingAgreementRequest->setSellerId($this->_sellerId);
|
163 |
-
|
164 |
-
return $this->_service->confirmBillingAgreement($confirmBillingAgreementRequest);
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Check that the billing agreement is in valid status and the selected payment
|
169 |
-
* method is also valid.
|
170 |
-
*
|
171 |
-
* @return OffAmazonPaymentsService_Model_ValidateBillingAgreementResponse
|
172 |
-
* service response
|
173 |
-
*/
|
174 |
-
public function validateBillingAgreement ()
|
175 |
-
{
|
176 |
-
$validateBillingAgreementRequest = new OffAmazonPaymentsService_Model_ValidateBillingAgreementRequest();
|
177 |
-
$validateBillingAgreementRequest->setAmazonBillingAgreementId(
|
178 |
-
$this->_amazonBillingAgreementId);
|
179 |
-
$validateBillingAgreementRequest->setSellerId($this->_sellerId);
|
180 |
-
|
181 |
-
return $this->_service->validateBillingAgreement($validateBillingAgreementRequest);
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Perform the authorize call on the billing agreement
|
186 |
-
*
|
187 |
-
* @param float $authorizationAmount
|
188 |
-
* amount to authorize from the buyer
|
189 |
-
*
|
190 |
-
* @param string $authorizationReferenceId
|
191 |
-
* seller provided authorization reference id
|
192 |
-
*
|
193 |
-
* @return OffAmazonPaymentsService_Model_AuthorizeOnBillingAgreementResponse
|
194 |
-
* service response
|
195 |
-
*/
|
196 |
-
public function authorizePaymentAmount ($authorizationAmount, $authorizationReferenceId)
|
197 |
-
{
|
198 |
-
$authorizeOnBillingAgreementRequest = $this->_createAuthorizeOnBillingAgreementRequest(
|
199 |
-
$authorizationAmount, $authorizationReferenceId, false);
|
200 |
-
return $this->_service->authorizeOnBillingAgreement($authorizeOnBillingAgreementRequest);
|
201 |
-
}
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Authorize on the billing agreement with auto capture
|
205 |
-
*
|
206 |
-
* @param float $authorizationAmount
|
207 |
-
* amount to authorize from the buyer
|
208 |
-
*
|
209 |
-
* @param string $authorizationReferenceId
|
210 |
-
* seller provided authorization reference id
|
211 |
-
*
|
212 |
-
* @return OffAmazonPaymentsService_Model_AuthorizeOnBillingAgreementResponse
|
213 |
-
* service response
|
214 |
-
*/
|
215 |
-
public function authorizePaymentAmountWithCaptureNow ($authorizationAmount,
|
216 |
-
$authorizationReferenceId)
|
217 |
-
{
|
218 |
-
$authorizeOnBillingAgreementRequest = $this->_createAuthorizeOnBillingAgreementRequest(
|
219 |
-
$authorizationAmount, $authorizationReferenceId, true);
|
220 |
-
return $this->_service->authorizeOnBillingAgreement($authorizeOnBillingAgreementRequest);
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Create AuthorizeOnBillingAgreement request
|
225 |
-
*
|
226 |
-
* @param float $authorizationAmount
|
227 |
-
* @param string $authorizationReferenceId
|
228 |
-
* @param bool $CaptureNow
|
229 |
-
*
|
230 |
-
* @return OffAmazonPaymentsService_Model_AuthorizeOnBillingAgreementRequest
|
231 |
-
*/
|
232 |
-
private function _createAuthorizeOnBillingAgreementRequest ($authorizationAmount,
|
233 |
-
$authorizationReferenceId, $CaptureNow)
|
234 |
-
{
|
235 |
-
$authorizeOnBillingAgreementRequest = new OffAmazonPaymentsService_Model_AuthorizeOnBillingAgreementRequest();
|
236 |
-
$authorizeOnBillingAgreementRequest->setAmazonBillingAgreementId(
|
237 |
-
$this->_amazonBillingAgreementId);
|
238 |
-
$authorizeOnBillingAgreementRequest->setSellerId($this->_sellerId);
|
239 |
-
$authorizeOnBillingAgreementRequest->setAuthorizationReferenceId($authorizationReferenceId);
|
240 |
-
$authorizeOnBillingAgreementRequest->setAuthorizationAmount(
|
241 |
-
new OffAmazonPaymentsService_Model_Price());
|
242 |
-
$authorizeOnBillingAgreementRequest->getAuthorizationAmount()->setAmount(
|
243 |
-
$authorizationAmount);
|
244 |
-
$authorizeOnBillingAgreementRequest->getAuthorizationAmount()->setCurrencyCode(
|
245 |
-
$this->_service->getMerchantValues()
|
246 |
-
->getCurrency());
|
247 |
-
$authorizeOnBillingAgreementRequest->setCaptureNow($CaptureNow);
|
248 |
-
return $authorizeOnBillingAgreementRequest;
|
249 |
-
}
|
250 |
-
|
251 |
-
/**
|
252 |
-
* Poll the API for the status of the Authorization Request, and continue
|
253 |
-
* once the status has been updated.
|
254 |
-
* WARNING: This is not the way to integrate for production systems,
|
255 |
-
* instead merchants should use IPN to receive a callback once the
|
256 |
-
* processing has been completed.
|
257 |
-
* Note that Amazon reserves the right to throttle requests that
|
258 |
-
* ignore this advice and poll for a response
|
259 |
-
*
|
260 |
-
* @param string $amazonAuthorizationReferenceId
|
261 |
-
* authorization transaction to query
|
262 |
-
*
|
263 |
-
* @return OffAmazonPaymentsService_Model_GetAuthorizationDetailsResponse
|
264 |
-
* service response
|
265 |
-
*/
|
266 |
-
public function waitUntilAuthorizationProcessingIsCompleted ($amazonAuthorizationId)
|
267 |
-
{
|
268 |
-
$getAuthorizationDetailsResponse = null;
|
269 |
-
do {
|
270 |
-
sleep(5);
|
271 |
-
$getAuthorizationDetailsResponse = $this->getAuthorizationDetails(
|
272 |
-
$amazonAuthorizationId);
|
273 |
-
} while ((isset($getAuthorizationDetailsResponse)) and (strcasecmp(
|
274 |
-
$getAuthorizationDetailsResponse->getGetAuthorizationDetailsResult()
|
275 |
-
->getAuthorizationDetails()
|
276 |
-
->getAuthorizationStatus()
|
277 |
-
->getState(), "Pending") == 0));
|
278 |
-
|
279 |
-
if (is_null($getAuthorizationDetailsResponse)) {
|
280 |
-
throw new ErrorException("No valid response from getAuthorizationDetails request");
|
281 |
-
}
|
282 |
-
|
283 |
-
return $getAuthorizationDetailsResponse;
|
284 |
-
}
|
285 |
-
|
286 |
-
/**
|
287 |
-
* Perform the getAuthroizationDetails request for the order
|
288 |
-
*
|
289 |
-
* @param string $amazonAuthorizationReferenceId
|
290 |
-
* authorization transaction
|
291 |
-
* to query
|
292 |
-
*
|
293 |
-
* @return OffAmazonPaymentsService_Model_GetAuthorizationDetailsResponse
|
294 |
-
* service response
|
295 |
-
*/
|
296 |
-
public function getAuthorizationDetails ($amazonAuthorizationReferenceId)
|
297 |
-
{
|
298 |
-
$getAuthorizationDetailsRequest = new OffAmazonPaymentsService_Model_GetAuthorizationDetailsRequest();
|
299 |
-
$getAuthorizationDetailsRequest->setSellerId($this->_sellerId);
|
300 |
-
$getAuthorizationDetailsRequest->setAmazonAuthorizationId($amazonAuthorizationReferenceId);
|
301 |
-
|
302 |
-
return $this->_service->getAuthorizationDetails($getAuthorizationDetailsRequest);
|
303 |
-
}
|
304 |
-
|
305 |
-
/**
|
306 |
-
* Perform the capture call for the order
|
307 |
-
*
|
308 |
-
* @param float $captureAmount
|
309 |
-
* amount to capture from the buyer
|
310 |
-
* @param string $amazonAuthorizationId
|
311 |
-
* auth id to perform the capture on
|
312 |
-
*
|
313 |
-
* @return OffAmazonPaymentsService_Model_CaptureResponse service response
|
314 |
-
*/
|
315 |
-
public function captureOrderAmount ($captureAmount, $amazonAuthorizationId)
|
316 |
-
{
|
317 |
-
$captureRequest = new OffAmazonPaymentsService_Model_CaptureRequest();
|
318 |
-
$captureRequest->setSellerId($this->_sellerId);
|
319 |
-
$captureRequest->setAmazonAuthorizationId($amazonAuthorizationId);
|
320 |
-
$captureRequest->setCaptureReferenceId($amazonAuthorizationId . "-c01");
|
321 |
-
$captureRequest->setCaptureAmount(new OffAmazonPaymentsService_Model_Price());
|
322 |
-
$captureRequest->getCaptureAmount()->setAmount($captureAmount);
|
323 |
-
$captureRequest->getCaptureAmount()->setCurrencyCode(
|
324 |
-
$this->_service->getMerchantValues()
|
325 |
-
->getCurrency());
|
326 |
-
|
327 |
-
return $this->_service->capture($captureRequest);
|
328 |
-
}
|
329 |
-
|
330 |
-
/**
|
331 |
-
* Perform the get capture details call for the order
|
332 |
-
*
|
333 |
-
* @param string $amazonCaptureId
|
334 |
-
* capture it to get details for
|
335 |
-
*
|
336 |
-
* @return OffAmazonPaymentsService_Model_CaptureResponse service response
|
337 |
-
*/
|
338 |
-
public function getCaptureDetails ($amazonCaptureId)
|
339 |
-
{
|
340 |
-
$captureDetailsRequest = new OffAmazonPaymentsService_Model_GetCaptureDetailsRequest();
|
341 |
-
$captureDetailsRequest->setSellerId($this->_sellerId);
|
342 |
-
$captureDetailsRequest->setAmazonCaptureId($amazonCaptureId);
|
343 |
-
|
344 |
-
return $this->_service->getCaptureDetails($captureDetailsRequest);
|
345 |
-
}
|
346 |
-
|
347 |
-
/**
|
348 |
-
* Close this billing agreement to indicate that the billing agreement is
|
349 |
-
* complete, and
|
350 |
-
* no further authorizations and captures will be performed on this billing
|
351 |
-
* agreement.
|
352 |
-
*
|
353 |
-
* @return OffAmazonPaymentsService_Model_CloseBillingAgreementResponse
|
354 |
-
* service response
|
355 |
-
*/
|
356 |
-
public function closeBillingAgreement ()
|
357 |
-
{
|
358 |
-
$closeBillingAgreementRequest = new OffAmazonPaymentsService_Model_CloseBillingAgreementRequest();
|
359 |
-
$closeBillingAgreementRequest->setSellerId($this->_sellerId);
|
360 |
-
$closeBillingAgreementRequest->setAmazonBillingAgreementId($this->_amazonBillingAgreementId);
|
361 |
-
$closeBillingAgreementRequest->setClosureReason("Automatic payment complete");
|
362 |
-
|
363 |
-
return $this->_service->closeBillingAgreement($closeBillingAgreementRequest);
|
364 |
-
}
|
365 |
-
}
|
366 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/AutomaticPaymentsSimpleCheckoutExampleCLI.php
DELETED
@@ -1,319 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
/*
|
19 |
-
* Automatic payments simple checkout example command line example
|
20 |
-
*
|
21 |
-
* This class drives the automatic payment simple checkout example from a command
|
22 |
-
* line interface. See AutomaticPaymentsSimpleCheckoutExample.php for more information
|
23 |
-
*/
|
24 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
25 |
-
require_once realpath(dirname(__FILE__)) . '/GetBillingAgreementDetailsSample.php';
|
26 |
-
require_once realpath(dirname(__FILE__)) . '/SetBillingAgreementDetailsSample.php';
|
27 |
-
require_once realpath(dirname(__FILE__)) . '/ConfirmBillingAgreementSample.php';
|
28 |
-
require_once realpath(dirname(__FILE__)) . '/ValidateBillingAgreementSample.php';
|
29 |
-
require_once realpath(dirname(__FILE__)) . '/AuthorizeOnBillingAgreementSample.php';
|
30 |
-
require_once realpath(dirname(__FILE__)) . '/GetAuthorizationDetailsSample.php';
|
31 |
-
require_once realpath(dirname(__FILE__)) . '/CaptureSample.php';
|
32 |
-
require_once realpath(dirname(__FILE__)) . '/GetCaptureDetailsSample.php';
|
33 |
-
require_once realpath(dirname(__FILE__)) . '/CloseBillingAgreementSample.php';
|
34 |
-
require_once realpath(dirname(__FILE__)) . '/CLIExample.php';
|
35 |
-
require_once realpath(dirname(__FILE__)) . '/AutomaticPaymentsSimpleCheckoutExample.php';
|
36 |
-
|
37 |
-
/**
|
38 |
-
* AutomaticPaymentsSimpleCheckoutExampleCLI class captures input from stdin and
|
39 |
-
* prints to stdout, and drives the automatic payment simple checkout example
|
40 |
-
*/
|
41 |
-
class AutomaticPaymentsSimpleCheckoutExampleCLI extends CLIExample
|
42 |
-
{
|
43 |
-
|
44 |
-
private $_amazonBillingAgreementId;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Create a new instance of the cli example and
|
48 |
-
* validate command line arguments
|
49 |
-
*
|
50 |
-
* @param array $argv
|
51 |
-
* arguments to the appplication passed from the command line
|
52 |
-
*/
|
53 |
-
public function __construct ($argv)
|
54 |
-
{
|
55 |
-
if (count($argv) < 1) {
|
56 |
-
print "Missing mandatory argument: " . "please provide an amazonBillingAgreementId";
|
57 |
-
exit(0);
|
58 |
-
}
|
59 |
-
|
60 |
-
/*
|
61 |
-
* Instantiate Implementation of OffAmazonPaymentsService client
|
62 |
-
* Merchant ids and access keys are defined in the constants are defined
|
63 |
-
* in the OffAmazonPaymentsService.config.inc.php file in the parent
|
64 |
-
* directory of this server
|
65 |
-
*/
|
66 |
-
$this->exampleClass = new AutomaticPaymentsSimpleCheckoutExample(
|
67 |
-
new OffAmazonPaymentsService_Client(), $argv[1]);
|
68 |
-
$this->_amazonBillingAgreementId = $argv[1];
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Run all the steps for the sample in sequence
|
73 |
-
*/
|
74 |
-
public function runSample ()
|
75 |
-
{
|
76 |
-
// Calculate payment amount based on buyer selected shipping address
|
77 |
-
$paymentTotal = $this->_calculatePaymentAmountBasedOnBuyerDestinationAddress();
|
78 |
-
|
79 |
-
// Added custom information and seller note to the billing agreement
|
80 |
-
$this->_addSellerInformationToBillingAgreement();
|
81 |
-
|
82 |
-
/*
|
83 |
-
* Confirm billing agreement. The billing agreement has to be consented
|
84 |
-
* by buyer before you confirm the billing agreement.
|
85 |
-
*/
|
86 |
-
$this->_confirmBillingAgreement();
|
87 |
-
|
88 |
-
// Validate billing agreement (optional)
|
89 |
-
$this->_validateBillingAgreement();
|
90 |
-
|
91 |
-
// First payment
|
92 |
-
$amazonAuthorizationId1 = $this->_authorizePaymentAmount($paymentTotal,
|
93 |
-
$this->_amazonBillingAgreementId . "-A01");
|
94 |
-
$this->_waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId1);
|
95 |
-
$this->_captureOrderAmount($paymentTotal, $amazonAuthorizationId1);
|
96 |
-
|
97 |
-
// Second payment with capture now
|
98 |
-
$this->_authorizePaymentAmountWithCaptureNow($paymentTotal,
|
99 |
-
$this->_amazonBillingAgreementId . "-A02");
|
100 |
-
|
101 |
-
// More payments here ...
|
102 |
-
|
103 |
-
/*
|
104 |
-
* Confirm the billing agreement again if the buyer changes the shipping
|
105 |
-
* address or payments method through widgets. For details on how to render
|
106 |
-
* widgets for existing billing agreements, please see integration guide
|
107 |
-
* for details.
|
108 |
-
*/
|
109 |
-
$this->_confirmBillingAgreement();
|
110 |
-
|
111 |
-
// Validate billing agreement (optional)
|
112 |
-
$this->_validateBillingAgreement();
|
113 |
-
|
114 |
-
// Another payment here
|
115 |
-
$this->_authorizePaymentAmountWithCaptureNow($paymentTotal,
|
116 |
-
$this->_amazonBillingAgreementId . "-A03");
|
117 |
-
|
118 |
-
// More payments here ...
|
119 |
-
|
120 |
-
// Close the billing agreement when this automatic payment is no longer
|
121 |
-
// needed
|
122 |
-
$this->_closeBillingAgreement();
|
123 |
-
|
124 |
-
print "Automatic payment simple checkout example completed" . PHP_EOL;
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Retreive the current information about the billing agreement as indicated
|
129 |
-
* by the buyer and calculate amount for each payment to charge, based on
|
130 |
-
* address destination state and country
|
131 |
-
*
|
132 |
-
* @return string total amount for the order that the merchant will charge
|
133 |
-
* the buyer
|
134 |
-
*/
|
135 |
-
private function _calculatePaymentAmountBasedOnBuyerDestinationAddress ()
|
136 |
-
{
|
137 |
-
$response = $this->callStepAndCheckForException('getBillingAgreementDetails');
|
138 |
-
printGetBillingAgreementDetailsResponse($response);
|
139 |
-
|
140 |
-
$orderTotalPreTaxAndShipping = $this->_getPreTaxAndShippingOrderAmountFromStdIn();
|
141 |
-
$shippingType = $this->_getShippingTypeFromStdIn();
|
142 |
-
|
143 |
-
return $this->exampleClass->calculatePaymentAmountBasedOnBuyerDetails(
|
144 |
-
$response->getGetBillingAgreementDetailsResult()
|
145 |
-
->getBillingAgreementDetails(), $orderTotalPreTaxAndShipping, $shippingType);
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Add seller information by making the call to setBillingAgreementDetails
|
150 |
-
* with seller notes and custom information.
|
151 |
-
*
|
152 |
-
*/
|
153 |
-
private function _addSellerInformationToBillingAgreement ()
|
154 |
-
{
|
155 |
-
$response = $this->callStepAndCheckForException('addSellerInformationToBillingAgreement');
|
156 |
-
printSetBillingAgreementDetailsResponse($response);
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Confirm the order reference information, allowing for authorizations and
|
161 |
-
* captures to be created.
|
162 |
-
*/
|
163 |
-
private function _confirmBillingAgreement ()
|
164 |
-
{
|
165 |
-
$response = $this->callStepAndCheckForException('confirmBillingAgreement');
|
166 |
-
printConfirmBillingAgreementResponse($response);
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Check that the billing agreement is in valid status and the selected payment
|
171 |
-
* method is also valid.
|
172 |
-
*/
|
173 |
-
private function _validateBillingAgreement ()
|
174 |
-
{
|
175 |
-
$response = $this->callStepAndCheckForException('validateBillingAgreement');
|
176 |
-
printValidateBillingAgreementResponse($response);
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Perform the authorize call for the billing agreement
|
181 |
-
*
|
182 |
-
* @param float $authorizationAmount
|
183 |
-
* amount to authorize from the buyer
|
184 |
-
*
|
185 |
-
* @return string amazonAuthorizationId amazon generated authorization id
|
186 |
-
* reference
|
187 |
-
*/
|
188 |
-
private function _authorizePaymentAmount ($authorizationAmount, $authorizationReferenceId)
|
189 |
-
{
|
190 |
-
$response = $this->callStepAndCheckForException('authorizePaymentAmount',
|
191 |
-
array(
|
192 |
-
$authorizationAmount,
|
193 |
-
$authorizationReferenceId
|
194 |
-
));
|
195 |
-
printAuthorizeOnBillingAgreementResponse($response);
|
196 |
-
return $response->getAuthorizeOnBillingAgreementResult()
|
197 |
-
->getAuthorizationDetails()
|
198 |
-
->getAmazonAuthorizationId();
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Perform the authorize call with auto capture for the billing agreement
|
203 |
-
*
|
204 |
-
* @param unknown $authorizationAmount
|
205 |
-
* @param unknown $authorizationReferenceId
|
206 |
-
*/
|
207 |
-
private function _authorizePaymentAmountWithCaptureNow ($authorizationAmount,
|
208 |
-
$authorizationReferenceId)
|
209 |
-
{
|
210 |
-
$response = $this->callStepAndCheckForException('authorizePaymentAmountWithCaptureNow',
|
211 |
-
array(
|
212 |
-
$authorizationAmount,
|
213 |
-
$authorizationReferenceId
|
214 |
-
));
|
215 |
-
printAuthorizeOnBillingAgreementResponse($response);
|
216 |
-
return $response->getAuthorizeOnBillingAgreementResult()
|
217 |
-
->getAuthorizationDetails()
|
218 |
-
->getAmazonAuthorizationId();
|
219 |
-
}
|
220 |
-
|
221 |
-
/**
|
222 |
-
* Poll the API for the status of the Authorization Request, and continue
|
223 |
-
* once the status has been updated
|
224 |
-
* Throw an error if the status is not equal to Open
|
225 |
-
*
|
226 |
-
* @param string $amazonAuthorizationId
|
227 |
-
* authorization transaction to query
|
228 |
-
*
|
229 |
-
*/
|
230 |
-
private function _waitUntilAuthorizationProcessingIsCompleted ($amazonAuthorizationId)
|
231 |
-
{
|
232 |
-
$response = $this->callStepAndCheckForException(
|
233 |
-
'waitUntilAuthorizationProcessingIsCompleted',
|
234 |
-
array(
|
235 |
-
$amazonAuthorizationId
|
236 |
-
));
|
237 |
-
printGetAuthorizationDetailsResponse($response);
|
238 |
-
validateThatAuthorizationIsOpen($response);
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Perform the capture call for the order
|
243 |
-
* Throw an exception if the capture is not processed, as this is the
|
244 |
-
* expected result
|
245 |
-
*
|
246 |
-
* @param float $captureAmount
|
247 |
-
* amount to capture from the buyer
|
248 |
-
* @param string $amazonAuthorizationId
|
249 |
-
* auth id to perform the capture on
|
250 |
-
*
|
251 |
-
* @return no response
|
252 |
-
*/
|
253 |
-
private function _captureOrderAmount ($captureAmount, $amazonAuthorizationId)
|
254 |
-
{
|
255 |
-
$response = $this->callStepAndCheckForException('captureOrderAmount',
|
256 |
-
array(
|
257 |
-
$captureAmount,
|
258 |
-
$amazonAuthorizationId
|
259 |
-
));
|
260 |
-
|
261 |
-
validateThatCaptureIsCompleted($response->getCaptureResult());
|
262 |
-
printCaptureResponse($response);
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Close this order reference to indicate that the order is complete, and
|
267 |
-
* no further authorizations and captures will be performed on this order
|
268 |
-
*
|
269 |
-
* @return no value
|
270 |
-
*/
|
271 |
-
private function _closeBillingAgreement ()
|
272 |
-
{
|
273 |
-
$response = $this->callStepAndCheckForException('closeBillingAgreement');
|
274 |
-
}
|
275 |
-
|
276 |
-
/**
|
277 |
-
* Capture the pre tax order amount from standard input,
|
278 |
-
* making sure that it is a numeric string
|
279 |
-
*
|
280 |
-
* @return string total amount of the order before tax and shipping charges
|
281 |
-
*/
|
282 |
-
private function _getPreTaxAndShippingOrderAmountFromStdIn ()
|
283 |
-
{
|
284 |
-
print PHP_EOL . "-------------------------------------------" . PHP_EOL;
|
285 |
-
print "Enter the pre tax amount to charge for the order" . "as a number (to 2 decimal places): ";
|
286 |
-
do {
|
287 |
-
$orderAmount = trim(fgets(STDIN));
|
288 |
-
} while (! is_numeric($orderAmount));
|
289 |
-
|
290 |
-
return $orderAmount;
|
291 |
-
}
|
292 |
-
|
293 |
-
/**
|
294 |
-
* Capture the shipping type for this order, which determines
|
295 |
-
* the shipping charge
|
296 |
-
*
|
297 |
-
* @return number selected shipping type index
|
298 |
-
*/
|
299 |
-
private function _getShippingTypeFromStdIn ()
|
300 |
-
{
|
301 |
-
print PHP_EOL . "Select a shipping option for the order:" . PHP_EOL;
|
302 |
-
print "\t 1 - Overnight shipping" . PHP_EOL;
|
303 |
-
print "\t 2 - 2-day shipping" . PHP_EOL;
|
304 |
-
print "\t 3 - 5-day shipping" . PHP_EOL;
|
305 |
-
print ">>";
|
306 |
-
|
307 |
-
do {
|
308 |
-
$shippingType = trim(fgets(STDIN));
|
309 |
-
} while (! is_numeric($shippingType) and ($shippingType < 1 or $shippingType > 3));
|
310 |
-
|
311 |
-
return $shippingType - 1;
|
312 |
-
}
|
313 |
-
}
|
314 |
-
;
|
315 |
-
|
316 |
-
$AutomaticPaymentsSimpleCheckoutExample = new AutomaticPaymentsSimpleCheckoutExampleCLI($argv);
|
317 |
-
$AutomaticPaymentsSimpleCheckoutExample->runSample();
|
318 |
-
|
319 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/CLIExample.php
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
*/
|
15 |
-
|
16 |
-
require_once realpath(dirname(__FILE__) . '/.config.inc.php');
|
17 |
-
require_once 'OffAmazonPaymentsService/Exception.php';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Helper class to print out the exception to the command line
|
21 |
-
*/
|
22 |
-
abstract class CLIExample
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* Store an instance of the example class that this CLI class executes
|
26 |
-
*/
|
27 |
-
protected $exampleClass;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Call the desired setp and check that it does not throw an
|
31 |
-
* exception
|
32 |
-
*
|
33 |
-
* @param string $stepName the name of the step to call on the example class
|
34 |
-
*
|
35 |
-
* @return mixed the response object from the step, or an exception if thrown
|
36 |
-
*/
|
37 |
-
protected function callStepAndCheckForException($stepName, $args = array())
|
38 |
-
{
|
39 |
-
try {
|
40 |
-
$response = call_user_func_array(array($this->exampleClass, $stepName), $args);
|
41 |
-
} catch (OffAmazonPaymentsService_Exception $ex) {
|
42 |
-
$this->printExceptionToCLI($ex, $stepName);
|
43 |
-
throw $ex;
|
44 |
-
}
|
45 |
-
|
46 |
-
return $response;
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Output information about the raised exception to standard output
|
51 |
-
*
|
52 |
-
* @param OffAmazonPaymentsService_Exception $ex exception
|
53 |
-
* @param string $stepName step where ex occured
|
54 |
-
*
|
55 |
-
* @return no value
|
56 |
-
*/
|
57 |
-
protected function printExceptionToCLI(
|
58 |
-
OffAmazonPaymentsService_Exception $ex,
|
59 |
-
$stepName
|
60 |
-
) {
|
61 |
-
print "Error caught executing step " . $stepName . PHP_EOL;
|
62 |
-
print "Caught Exception: " . $ex->getMessage() . PHP_EOL;
|
63 |
-
print "Response Status Code: " . $ex->getStatusCode() . PHP_EOL;
|
64 |
-
print "Error Code: " . $ex->getErrorCode() . PHP_EOL;
|
65 |
-
print "Error Type: " . $ex->getErrorType() . PHP_EOL;
|
66 |
-
print "Request ID: " . $ex->getRequestId() . PHP_EOL;
|
67 |
-
print "XML: " . $ex->getXML() . PHP_EOL;
|
68 |
-
print "ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . PHP_EOL;
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Populate the steps required to execute the sample code scenario
|
73 |
-
*/
|
74 |
-
public abstract function runSample();
|
75 |
-
}
|
76 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/CancelOrderReferenceSample.php
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Cancel Order Reference Sample
|
21 |
-
*/
|
22 |
-
|
23 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
24 |
-
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Cancel Order Reference Action Sample
|
28 |
-
|
29 |
-
* @param OffAmazonPaymentsService_Interface $service instance of OffAmazonPaymentsService_Interface
|
30 |
-
* @param mixed $request OffAmazonPaymentsService_Model_CancelOrderReference or array of parameters
|
31 |
-
*/
|
32 |
-
function printCancelOrderReferenceResponse($response)
|
33 |
-
{
|
34 |
-
|
35 |
-
print "Service Response" . PHP_EOL;
|
36 |
-
print "=============================================================================" . PHP_EOL;
|
37 |
-
|
38 |
-
print " CancelOrderReferenceResponse" . PHP_EOL;
|
39 |
-
if ($response->isSetResponseMetadata()) {
|
40 |
-
print " ResponseMetadata" . PHP_EOL;
|
41 |
-
$responseMetadata = $response->getResponseMetadata();
|
42 |
-
if ($responseMetadata->isSetRequestId())
|
43 |
-
{
|
44 |
-
print " RequestId" . PHP_EOL;
|
45 |
-
print " " . $responseMetadata->getRequestId() . PHP_EOL;
|
46 |
-
}
|
47 |
-
}
|
48 |
-
|
49 |
-
print " ResponseHeaderMetadata: " .
|
50 |
-
$response->getResponseHeaderMetadata() . PHP_EOL;
|
51 |
-
|
52 |
-
return $response;
|
53 |
-
}
|
54 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/CancellationExample.php
DELETED
@@ -1,263 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
*/
|
15 |
-
|
16 |
-
/*
|
17 |
-
* Cancellation example
|
18 |
-
*
|
19 |
-
* This demonstrates a merchant use case where the order needs to be
|
20 |
-
* cancelled before the first cancelOrderReference has been performed
|
21 |
-
*
|
22 |
-
* This is done using the CancelOrderReference call to cancel to order,
|
23 |
-
* and can be called prior to the first cancelOrderReference has been performed.
|
24 |
-
*
|
25 |
-
* If a cancelOrderReference has been performed, then the merchant will need to
|
26 |
-
* close the order reference if there is an outstanding total and perform a
|
27 |
-
* refund on existing cancelOrderReferenced amounts if required.
|
28 |
-
*
|
29 |
-
* This example will show the following service calls:
|
30 |
-
* - SetOrderReferenceDetails
|
31 |
-
* - ConfirmOrderReference
|
32 |
-
* - Authorize
|
33 |
-
* - GetAuthorizeDetails
|
34 |
-
* - CancelOrderReference
|
35 |
-
* - GetOrderReferenceDetails
|
36 |
-
*/
|
37 |
-
|
38 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
39 |
-
|
40 |
-
/**
|
41 |
-
* CancellationExample includes the logic
|
42 |
-
* requiere to cancel an order with open
|
43 |
-
* authorizations
|
44 |
-
*
|
45 |
-
*/
|
46 |
-
class CancellationExample
|
47 |
-
{
|
48 |
-
|
49 |
-
private $_sellerId;
|
50 |
-
private $_service;
|
51 |
-
private $_amazonOrderReferenceId;
|
52 |
-
private $_authorizationReferenceId;
|
53 |
-
private $_orderTotalAmount;
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Create a new instance of the simple checkout example
|
57 |
-
* case
|
58 |
-
*
|
59 |
-
* @param OffAmazonPaymentsService_Client $service instance of the
|
60 |
-
* service client
|
61 |
-
* @param string $amazonOrderReferenceId an order reference
|
62 |
-
* object in draft
|
63 |
-
* state to use in the example
|
64 |
-
* @param string $orderTotalAmount amount to authorize
|
65 |
-
* from the buyer
|
66 |
-
*
|
67 |
-
* @return new CancellationExample
|
68 |
-
*/
|
69 |
-
public function __construct($service, $amazonOrderReferenceId, $orderTotalAmount)
|
70 |
-
{
|
71 |
-
$this->_service = $service;
|
72 |
-
$this->_amazonOrderReferenceId = $amazonOrderReferenceId;
|
73 |
-
|
74 |
-
/*
|
75 |
-
* Setup shared identifiers for the series of transaction requests
|
76 |
-
*/
|
77 |
-
$this->_authorizationReferenceId
|
78 |
-
= str_replace("-", "", $this->_amazonOrderReferenceId) . "a01";
|
79 |
-
|
80 |
-
$this->_sellerId
|
81 |
-
= $this->_service->getMerchantValues()->getMerchantId();
|
82 |
-
|
83 |
-
$this->_orderTotalAmount = $orderTotalAmount;
|
84 |
-
$this->_currencyCode = $service->getMerchantValues()->getCurrency();
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Add information to the payment contract so that it can be confirmed
|
89 |
-
* in a later step
|
90 |
-
* Simulates a merchant adding the order details to the payment contract
|
91 |
-
*
|
92 |
-
* @return OffAmazonPaymentsService_Model_SetOrderReferenceDetailsResponse
|
93 |
-
* response
|
94 |
-
*/
|
95 |
-
public function setupOrderReference()
|
96 |
-
{
|
97 |
-
$orderTotal = new OffAmazonPaymentsService_Model_OrderTotal();
|
98 |
-
$orderTotal->setCurrencyCode($this->_currencyCode);
|
99 |
-
$orderTotal->setAmount($this->_orderTotalAmount);
|
100 |
-
|
101 |
-
$setOrderReferenceDetailsRequest
|
102 |
-
= new OffAmazonPaymentsService_Model_SetOrderReferenceDetailsRequest();
|
103 |
-
$setOrderReferenceDetailsRequest->setSellerId($this->_sellerId);
|
104 |
-
$setOrderReferenceDetailsRequest
|
105 |
-
->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
106 |
-
$setOrderReferenceDetailsRequest
|
107 |
-
->setOrderReferenceAttributes(
|
108 |
-
new OffAmazonPaymentsService_Model_OrderReferenceAttributes()
|
109 |
-
);
|
110 |
-
$setOrderReferenceDetailsRequest
|
111 |
-
->getOrderReferenceAttributes()->setOrderTotal($orderTotal);
|
112 |
-
|
113 |
-
return $this->_service->setOrderReferenceDetails(
|
114 |
-
$setOrderReferenceDetailsRequest
|
115 |
-
);
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Confirm the order reference information, allowing for
|
120 |
-
* authorizations and captures to be created
|
121 |
-
*
|
122 |
-
* @return OffAmazonPaymentsService_Model_ConfirmOrderReferenceResponse response
|
123 |
-
*/
|
124 |
-
public function confirmOrderReference()
|
125 |
-
{
|
126 |
-
$confirmOrderReferenceRequest
|
127 |
-
= new OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest();
|
128 |
-
$confirmOrderReferenceRequest
|
129 |
-
->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
130 |
-
$confirmOrderReferenceRequest->setSellerId($this->_sellerId);
|
131 |
-
|
132 |
-
return $this->_service->confirmOrderReference($confirmOrderReferenceRequest);
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Perform the authorize call for the order
|
137 |
-
*
|
138 |
-
* Cancel order reference can now be called at any point between a
|
139 |
-
* ConfirmOrderReference call and a cancelOrderReference call
|
140 |
-
* In this example we will call it following a single authorization for
|
141 |
-
* half of the order total
|
142 |
-
*
|
143 |
-
* @return OffAmazonPaymentsService_Model_AuthorizeResponse service response
|
144 |
-
*/
|
145 |
-
public function performAuthorization()
|
146 |
-
{
|
147 |
-
$authorizationAmountPrice = new OffAmazonPaymentsService_Model_Price();
|
148 |
-
$authorizationAmountPrice->setCurrencyCode($this->_currencyCode);
|
149 |
-
$authorizationAmountPrice->setAmount($this->_orderTotalAmount);
|
150 |
-
|
151 |
-
$authorizeRequest = new OffAmazonPaymentsService_Model_AuthorizeRequest();
|
152 |
-
$authorizeRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
153 |
-
$authorizeRequest->setSellerId($this->_sellerId);
|
154 |
-
$authorizeRequest->setAuthorizationReferenceId(
|
155 |
-
$this->_authorizationReferenceId
|
156 |
-
);
|
157 |
-
$authorizeRequest->setAuthorizationAmount($authorizationAmountPrice);
|
158 |
-
|
159 |
-
return $this->_service->authorize($authorizeRequest);
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* Poll the API for the status of the Authorization Request, and continue
|
164 |
-
* once the status has been updated
|
165 |
-
* WARNING: This is not the way to integrate for production systems,
|
166 |
-
* instead merchants should use IPN to receive a callback once the
|
167 |
-
* processing has been completed.
|
168 |
-
* Note that Amazon reserves the right to throttle requests that
|
169 |
-
* ignore this advice and poll for a response
|
170 |
-
*
|
171 |
-
* @param string $amazonAuthorizationId authorization transaction to query
|
172 |
-
*
|
173 |
-
* @return OffAmazonPaymentsService_Model_GetAuthorizationDetailsResponse
|
174 |
-
* response
|
175 |
-
*/
|
176 |
-
public function waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId)
|
177 |
-
{
|
178 |
-
$getAuthorizationDetailsResponse = null;
|
179 |
-
do {
|
180 |
-
sleep(5);
|
181 |
-
$getAuthorizationDetailsResponse
|
182 |
-
= $this->getAuthorizationDetails($amazonAuthorizationId);
|
183 |
-
} while ((isset($getAuthorizationDetailsResponse)) and
|
184 |
-
(strcasecmp(
|
185 |
-
$getAuthorizationDetailsResponse
|
186 |
-
->getGetAuthorizationDetailsResult()
|
187 |
-
->getAuthorizationDetails()->getAuthorizationStatus()
|
188 |
-
->getState(),
|
189 |
-
"Pending"
|
190 |
-
) == 0));
|
191 |
-
|
192 |
-
if (is_null($getAuthorizationDetailsResponse)) {
|
193 |
-
throw new ErrorException(
|
194 |
-
"No valid response from getAuthorizationDetails request"
|
195 |
-
);
|
196 |
-
}
|
197 |
-
|
198 |
-
return $getAuthorizationDetailsResponse;
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Perform the getAuthroizationDetails request for the order
|
203 |
-
*
|
204 |
-
* @param string $amazonAuthorizationReferenceId authorization transaction
|
205 |
-
* to query
|
206 |
-
*
|
207 |
-
* @return OffAmazonPaymentsService_Model_GetAuthorizationDetailsResponse
|
208 |
-
* response
|
209 |
-
*/
|
210 |
-
public function getAuthorizationDetails($amazonAuthorizationReferenceId)
|
211 |
-
{
|
212 |
-
$getAuthorizationDetailsRequest
|
213 |
-
= new OffAmazonPaymentsService_Model_GetAuthorizationDetailsRequest();
|
214 |
-
$getAuthorizationDetailsRequest
|
215 |
-
->setSellerId($this->_sellerId);
|
216 |
-
$getAuthorizationDetailsRequest
|
217 |
-
->setAmazonAuthorizationId($amazonAuthorizationReferenceId);
|
218 |
-
|
219 |
-
return $this->_service->getAuthorizationDetails(
|
220 |
-
$getAuthorizationDetailsRequest
|
221 |
-
);
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* Cancel the payment contract - this can be performed on any order reference
|
226 |
-
* that does not have a completed transaction
|
227 |
-
*
|
228 |
-
* @return OffAmazonPaymentsService_Model_CancelOrderReferenceResponse response
|
229 |
-
*/
|
230 |
-
public function cancelOrderReference()
|
231 |
-
{
|
232 |
-
$cancelOrderReferenceRequest
|
233 |
-
= new OffAmazonPaymentsService_Model_CancelOrderReferenceRequest();
|
234 |
-
$cancelOrderReferenceRequest->setSellerId($this->_sellerId);
|
235 |
-
$cancelOrderReferenceRequest
|
236 |
-
->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
237 |
-
|
238 |
-
return $this->_service->cancelOrderReference($cancelOrderReferenceRequest);
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Get the status of the order reference request object to show that it
|
243 |
-
* now cancelled
|
244 |
-
*
|
245 |
-
* @return OffAmazonPaymentsService_Model_GetOrderReferenceDetailsResponse
|
246 |
-
* response
|
247 |
-
*/
|
248 |
-
public function getOrderReferenceDetails()
|
249 |
-
{
|
250 |
-
$getOrderReferenceDetailsRequest
|
251 |
-
= new OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest();
|
252 |
-
$getOrderReferenceDetailsRequest
|
253 |
-
->setSellerId($this->_sellerId);
|
254 |
-
$getOrderReferenceDetailsRequest
|
255 |
-
->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
256 |
-
|
257 |
-
return $this->_service->getOrderReferenceDetails(
|
258 |
-
$getOrderReferenceDetailsRequest
|
259 |
-
);
|
260 |
-
}
|
261 |
-
|
262 |
-
}
|
263 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/CancellationExampleCLI.php
DELETED
@@ -1,164 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
******************************************************************************/
|
16 |
-
|
17 |
-
/*******************************************************************************
|
18 |
-
* Cancellation command line example
|
19 |
-
*
|
20 |
-
* This class drives the cancellation example from a command line iterface
|
21 |
-
* See CancellationExample.php for more information
|
22 |
-
******************************************************************************/
|
23 |
-
|
24 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
25 |
-
require_once realpath(dirname(__FILE__)) . '/SetOrderReferenceDetailsSample.php';
|
26 |
-
require_once realpath(dirname(__FILE__)) . '/GetOrderReferenceDetailsSample.php';
|
27 |
-
require_once realpath(dirname(__FILE__)) . '/AuthorizeSample.php';
|
28 |
-
require_once realpath(dirname(__FILE__)) . '/ConfirmOrderReferenceSample.php';
|
29 |
-
require_once realpath(dirname(__FILE__)) . '/CancelOrderReferenceSample.php';
|
30 |
-
require_once realpath(dirname(__FILE__)) . '/GetAuthorizationDetailsSample.php';
|
31 |
-
require_once realpath(dirname(__FILE__)) . '/CLIExample.php';
|
32 |
-
require_once realpath(dirname(__FILE__)) . '/CancellationExample.php';
|
33 |
-
|
34 |
-
/**
|
35 |
-
* CancellationExampleCLI class captures input from stdin and prints to stdout,
|
36 |
-
* and drives the cancellation example
|
37 |
-
*
|
38 |
-
*/
|
39 |
-
class CancellationExampleCLI extends CLIExample
|
40 |
-
{
|
41 |
-
/**
|
42 |
-
* Create a new instance of the cli example and validate command line arguments
|
43 |
-
*
|
44 |
-
* @param array $argv arguments to the application passed from the command line
|
45 |
-
*/
|
46 |
-
public function __construct($argv)
|
47 |
-
{
|
48 |
-
if (count($argv) < 1) {
|
49 |
-
print "Missing mandatory argument: " .
|
50 |
-
"please provide an amazonOrderReferenceId";
|
51 |
-
exit(0);
|
52 |
-
}
|
53 |
-
|
54 |
-
/*
|
55 |
-
* Instantiate Implementation of OffAmazonPaymentsService client
|
56 |
-
*
|
57 |
-
* Merchant ids and access keys are defined in the constants
|
58 |
-
* are defined in the OffAmazonPaymentsService.config.inc.php file in
|
59 |
-
* the parent directory of this server
|
60 |
-
*/
|
61 |
-
$this->exampleClass
|
62 |
-
= new CancellationExample(
|
63 |
-
new OffAmazonPaymentsService_Client(),
|
64 |
-
$argv[1],
|
65 |
-
"100.00"
|
66 |
-
);
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Run all the steps for the sample in sequence
|
71 |
-
*/
|
72 |
-
public function runSample()
|
73 |
-
{
|
74 |
-
$this->_setupOrderReference();
|
75 |
-
$this->_confirmOrderReference();
|
76 |
-
$amazonAuthorizationId = $this->_performAuthorization();
|
77 |
-
$this->_waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId);
|
78 |
-
$this->_cancelOrder();
|
79 |
-
$this->_getOrderReferenceDetails();
|
80 |
-
|
81 |
-
print "Cancellation completed" . PHP_EOL;
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Add information to the payment contract so that it can be confirmed
|
86 |
-
* in a later step
|
87 |
-
* Simulates a merchant adding the order details to the payment contract
|
88 |
-
*
|
89 |
-
*/
|
90 |
-
private function _setupOrderReference()
|
91 |
-
{
|
92 |
-
$response = $this->callStepAndCheckForException('setupOrderReference');
|
93 |
-
printSetOrderReferenceDetailsResponse($response);
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Confirm the order reference information, allowing for
|
98 |
-
* authorizations and captures to be created
|
99 |
-
*
|
100 |
-
*/
|
101 |
-
private function _confirmOrderReference()
|
102 |
-
{
|
103 |
-
$response = $this->callStepAndCheckForException('confirmOrderReference');
|
104 |
-
printConfirmOrderReferenceResponse($response);
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Perform the authorize call for the order
|
109 |
-
*
|
110 |
-
* @return string amazonAuthorizationId amazon generated authorization id reference
|
111 |
-
*/
|
112 |
-
private function _performAuthorization()
|
113 |
-
{
|
114 |
-
$response = $this->callStepAndCheckForException('performAuthorization');
|
115 |
-
printAuthorizeResponse($response);
|
116 |
-
return $response->getAuthorizeResult()->getAuthorizationDetails()->getAmazonAuthorizationId();
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Poll the API for the status of the Authorization Request, and continue
|
121 |
-
* once the status has been updated
|
122 |
-
* Throw an error if the status is not equal to OPEN
|
123 |
-
*
|
124 |
-
* @param string $amazonAuthorizationId authorization transaction to query
|
125 |
-
*
|
126 |
-
* @return No value
|
127 |
-
*/
|
128 |
-
private function _waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId)
|
129 |
-
{
|
130 |
-
$response = $this->callStepAndCheckForException(
|
131 |
-
'waitUntilAuthorizationProcessingIsCompleted',
|
132 |
-
array($amazonAuthorizationId)
|
133 |
-
);
|
134 |
-
|
135 |
-
printGetAuthorizationDetailsResponse($response);
|
136 |
-
validateThatAuthorizationIsOpen($response);
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Cancel the payment contract - this can be performed on any order reference
|
141 |
-
* that does not have a completed transaction
|
142 |
-
*
|
143 |
-
*/
|
144 |
-
private function _cancelOrder()
|
145 |
-
{
|
146 |
-
$response = $this->callStepAndCheckForException('cancelOrderReference');
|
147 |
-
printCancelOrderReferenceResponse($response);
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Get the status of the order reference request object to show that it
|
152 |
-
* now cancelled
|
153 |
-
*
|
154 |
-
*/
|
155 |
-
private function _getOrderReferenceDetails()
|
156 |
-
{
|
157 |
-
$response = $this->callStepAndCheckForException('getOrderReferenceDetails');
|
158 |
-
printGetOrderReferenceDetailsResponse($response);
|
159 |
-
}
|
160 |
-
}
|
161 |
-
|
162 |
-
$cancellationExample = new CancellationExampleCLI($argv);
|
163 |
-
$cancellationExample->runSample();
|
164 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/CaptureSample.php
DELETED
@@ -1,162 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Capture Sample
|
21 |
-
*/
|
22 |
-
|
23 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Capture Action Sample
|
27 |
-
|
28 |
-
* @param OffAmazonPaymentsService_Interface $service instance of OffAmazonPaymentsService_Interface
|
29 |
-
* @param mixed $request OffAmazonPaymentsService_Model_Capture or array of parameters
|
30 |
-
*/
|
31 |
-
function printCaptureResponse($response)
|
32 |
-
{
|
33 |
-
|
34 |
-
print "Service Response" . PHP_EOL;
|
35 |
-
print "=============================================================================" . PHP_EOL;
|
36 |
-
|
37 |
-
print " CaptureResponse" . PHP_EOL;
|
38 |
-
if ($response->isSetCaptureResult()) {
|
39 |
-
print " CaptureResult" . PHP_EOL;
|
40 |
-
$captureResult = $response->getCaptureResult();
|
41 |
-
if ($captureResult->isSetCaptureDetails()) {
|
42 |
-
print " CaptureDetails" . PHP_EOL;
|
43 |
-
$captureDetails = $captureResult->getCaptureDetails();
|
44 |
-
if ($captureDetails->isSetAmazonCaptureId()) {
|
45 |
-
print " AmazonCaptureId" . PHP_EOL;
|
46 |
-
print " " . $captureDetails->getAmazonCaptureId() . PHP_EOL;
|
47 |
-
}
|
48 |
-
if ($captureDetails->isSetCaptureReferenceId()) {
|
49 |
-
print " CaptureReferenceId" . PHP_EOL;
|
50 |
-
print " " . $captureDetails->getCaptureReferenceId() . PHP_EOL;
|
51 |
-
}
|
52 |
-
if ($captureDetails->isSetSellerCaptureNote()) {
|
53 |
-
print " SellerCaptureNote" . PHP_EOL;
|
54 |
-
print " " . $captureDetails->getSellerCaptureNote() . PHP_EOL;
|
55 |
-
}
|
56 |
-
if ($captureDetails->isSetCaptureAmount()) {
|
57 |
-
print " CaptureAmount" . PHP_EOL;
|
58 |
-
$captureAmount = $captureDetails->getCaptureAmount();
|
59 |
-
if ($captureAmount->isSetAmount()) {
|
60 |
-
print " Amount" . PHP_EOL;
|
61 |
-
print " " . $captureAmount->getAmount() . PHP_EOL;
|
62 |
-
}
|
63 |
-
if ($captureAmount->isSetCurrencyCode()) {
|
64 |
-
print " CurrencyCode" . PHP_EOL;
|
65 |
-
print " " . $captureAmount->getCurrencyCode() . PHP_EOL;
|
66 |
-
}
|
67 |
-
}
|
68 |
-
if ($captureDetails->isSetRefundedAmount()) {
|
69 |
-
print " RefundedAmount" . PHP_EOL;
|
70 |
-
$refundedAmount = $captureDetails->getRefundedAmount();
|
71 |
-
if ($refundedAmount->isSetAmount()) {
|
72 |
-
print " Amount" . PHP_EOL;
|
73 |
-
print " " . $refundedAmount->getAmount() . PHP_EOL;
|
74 |
-
}
|
75 |
-
if ($refundedAmount->isSetCurrencyCode()) {
|
76 |
-
print " CurrencyCode" . PHP_EOL;
|
77 |
-
print " " . $refundedAmount->getCurrencyCode() . PHP_EOL;
|
78 |
-
}
|
79 |
-
}
|
80 |
-
if ($captureDetails->isSetCaptureFee()) {
|
81 |
-
print " CaptureFee" . PHP_EOL;
|
82 |
-
$captureFee = $captureDetails->getCaptureFee();
|
83 |
-
if ($captureFee->isSetAmount()) {
|
84 |
-
print " Amount" . PHP_EOL;
|
85 |
-
print " " . $captureFee->getAmount() . PHP_EOL;
|
86 |
-
}
|
87 |
-
if ($captureFee->isSetCurrencyCode()) {
|
88 |
-
print " CurrencyCode" . PHP_EOL;
|
89 |
-
print " " . $captureFee->getCurrencyCode() . PHP_EOL;
|
90 |
-
}
|
91 |
-
}
|
92 |
-
if ($captureDetails->isSetIdList()) {
|
93 |
-
print " IdList" . PHP_EOL;
|
94 |
-
$idList = $captureDetails->getIdList();
|
95 |
-
$memberList = $idList->getmember();
|
96 |
-
foreach ($memberList as $member) {
|
97 |
-
print " member" . PHP_EOL;
|
98 |
-
print " " . $member;
|
99 |
-
}
|
100 |
-
}
|
101 |
-
if ($captureDetails->isSetCreationTimestamp()) {
|
102 |
-
print " CreationTimestamp" . PHP_EOL;
|
103 |
-
print " " . $captureDetails->getCreationTimestamp() . PHP_EOL;
|
104 |
-
}
|
105 |
-
if ($captureDetails->isSetCaptureStatus()) {
|
106 |
-
print " CaptureStatus" . PHP_EOL;
|
107 |
-
$captureStatus = $captureDetails->getCaptureStatus();
|
108 |
-
if ($captureStatus->isSetState()) {
|
109 |
-
print " State" . PHP_EOL;
|
110 |
-
print " " . $captureStatus->getState() . PHP_EOL;
|
111 |
-
}
|
112 |
-
if ($captureStatus->isSetLastUpdateTimestamp()) {
|
113 |
-
print " LastUpdateTimestamp" . PHP_EOL;
|
114 |
-
print " " . $captureStatus->getLastUpdateTimestamp() . PHP_EOL;
|
115 |
-
}
|
116 |
-
if ($captureStatus->isSetReasonCode()) {
|
117 |
-
print " ReasonCode" . PHP_EOL;
|
118 |
-
print " " . $captureStatus->getReasonCode() . PHP_EOL;
|
119 |
-
}
|
120 |
-
if ($captureStatus->isSetReasonDescription()) {
|
121 |
-
print " ReasonDescription" . PHP_EOL;
|
122 |
-
print " " . $captureStatus->getReasonDescription() . PHP_EOL;
|
123 |
-
}
|
124 |
-
if ($captureDetails->isSetSoftDescriptor()) {
|
125 |
-
print " SoftDescriptor" . PHP_EOL;
|
126 |
-
print " " . $captureDetails->getSoftDescriptor() . PHP_EOL;
|
127 |
-
}
|
128 |
-
}
|
129 |
-
if($captureDetails->isSetProviderCreditSummaryList()){
|
130 |
-
print " ProviderCreditSummaryList" . PHP_EOL;
|
131 |
-
$providerCreditSummaryList = $captureDetails->getProviderCreditSummaryList();
|
132 |
-
if($providerCreditSummaryList->isSetmember()){
|
133 |
-
$values = $providerCreditSummaryList->getmember();
|
134 |
-
foreach($values as $value){
|
135 |
-
print " ProviderCreditSummary" . PHP_EOL;
|
136 |
-
if($value->isSetProviderId()){
|
137 |
-
print " ProviderId" . PHP_EOL;
|
138 |
-
print " ".$value->getProviderId() . PHP_EOL;
|
139 |
-
}
|
140 |
-
if($value->isSetProviderCreditId()){
|
141 |
-
print " ProviderCreditId" . PHP_EOL;
|
142 |
-
print " ".$value->getProviderCreditId() . PHP_EOL;
|
143 |
-
}
|
144 |
-
}
|
145 |
-
}
|
146 |
-
}
|
147 |
-
}
|
148 |
-
}
|
149 |
-
if ($response->isSetResponseMetadata()) {
|
150 |
-
print " ResponseMetadata" . PHP_EOL;
|
151 |
-
$responseMetadata = $response->getResponseMetadata();
|
152 |
-
if ($responseMetadata->isSetRequestId()) {
|
153 |
-
print " RequestId" . PHP_EOL;
|
154 |
-
print " " . $responseMetadata->getRequestId() . PHP_EOL;
|
155 |
-
}
|
156 |
-
}
|
157 |
-
|
158 |
-
print " ResponseHeaderMetadata: " .
|
159 |
-
$response->getResponseHeaderMetadata() . PHP_EOL;
|
160 |
-
return $response;
|
161 |
-
}
|
162 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/CloseAuthorizationSample.php
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Close Authorization Sample
|
21 |
-
*/
|
22 |
-
|
23 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
24 |
-
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Close Authorization Action Sample
|
28 |
-
|
29 |
-
* @param OffAmazonPaymentsService_Interface $service instance of OffAmazonPaymentsService_Interface
|
30 |
-
* @param mixed $request OffAmazonPaymentsService_Model_CloseAuthorization or array of parameters
|
31 |
-
*/
|
32 |
-
function printCloseAuthorizationResponse($response)
|
33 |
-
{
|
34 |
-
|
35 |
-
print "Service Response" . PHP_EOL;
|
36 |
-
print "=============================================================================" . PHP_EOL;
|
37 |
-
|
38 |
-
print " CloseAuthorizationResponse" . PHP_EOL;
|
39 |
-
if ($response->isSetResponseMetadata()) {
|
40 |
-
print " ResponseMetadata" . PHP_EOL;
|
41 |
-
$responseMetadata = $response->getResponseMetadata();
|
42 |
-
if ($responseMetadata->isSetRequestId())
|
43 |
-
{
|
44 |
-
print " RequestId" . PHP_EOL;
|
45 |
-
print " " . $responseMetadata->getRequestId() . PHP_EOL;
|
46 |
-
}
|
47 |
-
}
|
48 |
-
|
49 |
-
print " ResponseHeaderMetadata: " .
|
50 |
-
$response->getResponseHeaderMetadata() . PHP_EOL;
|
51 |
-
|
52 |
-
return $response;
|
53 |
-
}
|
54 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/CloseBillingAgreementSample.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Print the CloseBillingAgreement response to the console
|
21 |
-
*
|
22 |
-
* @param OffAmazonPaymentsService_Model_CloseBillingAgreementResponse $response
|
23 |
-
* response object
|
24 |
-
*
|
25 |
-
* @return void
|
26 |
-
*/
|
27 |
-
function printCloseBillingAgreementResponse ($response)
|
28 |
-
{
|
29 |
-
echo ("Service Response\n");
|
30 |
-
echo ("=============================================================================\n");
|
31 |
-
|
32 |
-
echo (" CloseBillingAgreementResponse\n");
|
33 |
-
if ($response->isSetResponseMetadata()) {
|
34 |
-
echo (" ResponseMetadata\n");
|
35 |
-
$responseMetadata = $response->getResponseMetadata();
|
36 |
-
if ($responseMetadata->isSetRequestId()) {
|
37 |
-
echo (" RequestId\n");
|
38 |
-
echo (" " . $responseMetadata->getRequestId() . "\n");
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
echo (" ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");
|
43 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/CloseOrderReferenceSample.php
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Close Order Reference Sample
|
21 |
-
*/
|
22 |
-
|
23 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
24 |
-
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Close Order Reference Action Sample
|
28 |
-
|
29 |
-
* @param OffAmazonPaymentsService_Interface $service instance of OffAmazonPaymentsService_Interface
|
30 |
-
* @param mixed $request OffAmazonPaymentsService_Model_CloseOrderReference or array of parameters
|
31 |
-
*/
|
32 |
-
function printCloseOrderReferenceResponse($response)
|
33 |
-
{
|
34 |
-
|
35 |
-
print "Service Response" . PHP_EOL;
|
36 |
-
print "=============================================================================" . PHP_EOL;
|
37 |
-
|
38 |
-
print " CloseOrderReferenceResponse" . PHP_EOL;
|
39 |
-
if ($response->isSetResponseMetadata()) {
|
40 |
-
print " ResponseMetadata" . PHP_EOL;
|
41 |
-
$responseMetadata = $response->getResponseMetadata();
|
42 |
-
if ($responseMetadata->isSetRequestId())
|
43 |
-
{
|
44 |
-
print " RequestId" . PHP_EOL;
|
45 |
-
print " " . $responseMetadata->getRequestId() . PHP_EOL;
|
46 |
-
}
|
47 |
-
}
|
48 |
-
|
49 |
-
print " ResponseHeaderMetadata: " .
|
50 |
-
$response->getResponseHeaderMetadata() . PHP_EOL;
|
51 |
-
|
52 |
-
return $response;
|
53 |
-
}
|
54 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/ConfirmBillingAgreementSample.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Print the ConfirmBillingAgreement response to the console
|
21 |
-
*
|
22 |
-
* @param OffAmazonPaymentsService_Model_ConfirmBillingAgreementResponse $response
|
23 |
-
* response object
|
24 |
-
*
|
25 |
-
* @return void
|
26 |
-
*/
|
27 |
-
function printConfirmBillingAgreementResponse ($response)
|
28 |
-
{
|
29 |
-
echo ("Service Response\n");
|
30 |
-
echo ("=============================================================================\n");
|
31 |
-
|
32 |
-
echo (" ConfirmBillingAgreementResponse\n");
|
33 |
-
if ($response->isSetResponseMetadata()) {
|
34 |
-
echo (" ResponseMetadata\n");
|
35 |
-
$responseMetadata = $response->getResponseMetadata();
|
36 |
-
if ($responseMetadata->isSetRequestId()) {
|
37 |
-
echo (" RequestId\n");
|
38 |
-
echo (" " . $responseMetadata->getRequestId() . "\n");
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
echo (" ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");
|
43 |
-
}
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/ConfirmOrderReferenceSample.php
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Confirm Order Reference Sample
|
21 |
-
*/
|
22 |
-
|
23 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
24 |
-
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Confirm Order Reference Action Sample
|
28 |
-
|
29 |
-
* @param OffAmazonPaymentsService_Interface $service instance of OffAmazonPaymentsService_Interface
|
30 |
-
* @param mixed $request OffAmazonPaymentsService_Model_ConfirmOrderReference or array of parameters
|
31 |
-
*/
|
32 |
-
function printConfirmOrderReferenceResponse($response)
|
33 |
-
{
|
34 |
-
|
35 |
-
print "Service Response" . PHP_EOL;
|
36 |
-
print "=============================================================================" . PHP_EOL;
|
37 |
-
|
38 |
-
print " ConfirmOrderReferenceResponse" . PHP_EOL;
|
39 |
-
if ($response->isSetResponseMetadata()) {
|
40 |
-
print " ResponseMetadata" . PHP_EOL;
|
41 |
-
$responseMetadata = $response->getResponseMetadata();
|
42 |
-
if ($responseMetadata->isSetRequestId())
|
43 |
-
{
|
44 |
-
print " RequestId" . PHP_EOL;
|
45 |
-
print " " . $responseMetadata->getRequestId() . PHP_EOL;
|
46 |
-
}
|
47 |
-
}
|
48 |
-
|
49 |
-
print " ResponseHeaderMetadata: " .
|
50 |
-
$response->getResponseHeaderMetadata() . PHP_EOL;
|
51 |
-
|
52 |
-
return $response;
|
53 |
-
}
|
54 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/CreateOrderReferenceForIdSample.php
DELETED
@@ -1,333 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Print the CreateOrderReferenceForId response to the console
|
21 |
-
*
|
22 |
-
* @param OffAmazonPaymentsService_Model_CreateOrderReferenceForIdResponse $response
|
23 |
-
* response object
|
24 |
-
*
|
25 |
-
* @return void
|
26 |
-
*/
|
27 |
-
function printCreateOrderReferenceForIdResponse ($response)
|
28 |
-
{
|
29 |
-
echo ("Service Response\n");
|
30 |
-
echo ("=============================================================================\n");
|
31 |
-
|
32 |
-
echo (" CreateOrderReferenceForIdResponse\n");
|
33 |
-
if ($response->isSetCreateOrderReferenceForIdResult()) {
|
34 |
-
echo (" CreateOrderReferenceForIdResult\n");
|
35 |
-
$createOrderReferenceForIdResult = $response->getCreateOrderReferenceForIdResult();
|
36 |
-
if ($createOrderReferenceForIdResult->isSetOrderReferenceDetails()) {
|
37 |
-
echo (" OrderReferenceDetails\n");
|
38 |
-
$orderReferenceDetails = $createOrderReferenceForIdResult->getOrderReferenceDetails();
|
39 |
-
if ($orderReferenceDetails->isSetAmazonOrderReferenceId()) {
|
40 |
-
echo (" AmazonOrderReferenceId\n");
|
41 |
-
echo (" " .
|
42 |
-
$orderReferenceDetails->getAmazonOrderReferenceId() . "\n");
|
43 |
-
}
|
44 |
-
if ($orderReferenceDetails->isSetBuyer()) {
|
45 |
-
echo (" Buyer\n");
|
46 |
-
$buyer = $orderReferenceDetails->getBuyer();
|
47 |
-
if ($buyer->isSetName()) {
|
48 |
-
echo (" Name\n");
|
49 |
-
echo (" " . $buyer->getName() . "\n");
|
50 |
-
}
|
51 |
-
if ($buyer->isSetEmail()) {
|
52 |
-
echo (" Email\n");
|
53 |
-
echo (" " . $buyer->getEmail() . "\n");
|
54 |
-
}
|
55 |
-
if ($buyer->isSetPhone()) {
|
56 |
-
echo (" Phone\n");
|
57 |
-
echo (" " . $buyer->getPhone() . "\n");
|
58 |
-
}
|
59 |
-
}
|
60 |
-
if ($orderReferenceDetails->isSetOrderTotal()) {
|
61 |
-
echo (" OrderTotal\n");
|
62 |
-
$orderTotal = $orderReferenceDetails->getOrderTotal();
|
63 |
-
if ($orderTotal->isSetCurrencyCode()) {
|
64 |
-
echo (" CurrencyCode\n");
|
65 |
-
echo (" " . $orderTotal->getCurrencyCode() . "\n");
|
66 |
-
}
|
67 |
-
if ($orderTotal->isSetAmount()) {
|
68 |
-
echo (" Amount\n");
|
69 |
-
echo (" " . $orderTotal->getAmount() . "\n");
|
70 |
-
}
|
71 |
-
}
|
72 |
-
if ($orderReferenceDetails->isSetSellerNote()) {
|
73 |
-
echo (" SellerNote\n");
|
74 |
-
echo (" " . $orderReferenceDetails->getSellerNote() . "\n");
|
75 |
-
}
|
76 |
-
if ($orderReferenceDetails->isSetPlatformId()) {
|
77 |
-
echo (" PlatformId\n");
|
78 |
-
echo (" " . $orderReferenceDetails->getPlatformId() . "\n");
|
79 |
-
}
|
80 |
-
if ($orderReferenceDetails->isSetDestination()) {
|
81 |
-
echo (" Destination\n");
|
82 |
-
$destination = $orderReferenceDetails->getDestination();
|
83 |
-
if ($destination->isSetDestinationType()) {
|
84 |
-
echo (" DestinationType\n");
|
85 |
-
echo (" " . $destination->getDestinationType() . "\n");
|
86 |
-
}
|
87 |
-
if ($destination->isSetPhysicalDestination()) {
|
88 |
-
echo (" PhysicalDestination\n");
|
89 |
-
$physicalDestination = $destination->getPhysicalDestination();
|
90 |
-
if ($physicalDestination->isSetName()) {
|
91 |
-
echo (" Name\n");
|
92 |
-
echo (" " . $physicalDestination->getName() .
|
93 |
-
"\n");
|
94 |
-
}
|
95 |
-
if ($physicalDestination->isSetAddressLine1()) {
|
96 |
-
echo (" AddressLine1\n");
|
97 |
-
echo (" " .
|
98 |
-
$physicalDestination->getAddressLine1() . "\n");
|
99 |
-
}
|
100 |
-
if ($physicalDestination->isSetAddressLine2()) {
|
101 |
-
echo (" AddressLine2\n");
|
102 |
-
echo (" " .
|
103 |
-
$physicalDestination->getAddressLine2() . "\n");
|
104 |
-
}
|
105 |
-
if ($physicalDestination->isSetAddressLine3()) {
|
106 |
-
echo (" AddressLine3\n");
|
107 |
-
echo (" " .
|
108 |
-
$physicalDestination->getAddressLine3() . "\n");
|
109 |
-
}
|
110 |
-
if ($physicalDestination->isSetCity()) {
|
111 |
-
echo (" City\n");
|
112 |
-
echo (" " . $physicalDestination->getCity() .
|
113 |
-
"\n");
|
114 |
-
}
|
115 |
-
if ($physicalDestination->isSetCounty()) {
|
116 |
-
echo (" County\n");
|
117 |
-
echo (" " . $physicalDestination->getCounty() .
|
118 |
-
"\n");
|
119 |
-
}
|
120 |
-
if ($physicalDestination->isSetDistrict()) {
|
121 |
-
echo (" District\n");
|
122 |
-
echo (" " .
|
123 |
-
$physicalDestination->getDistrict() . "\n");
|
124 |
-
}
|
125 |
-
if ($physicalDestination->isSetStateOrRegion()) {
|
126 |
-
echo (" StateOrRegion\n");
|
127 |
-
echo (" " .
|
128 |
-
$physicalDestination->getStateOrRegion() . "\n");
|
129 |
-
}
|
130 |
-
if ($physicalDestination->isSetPostalCode()) {
|
131 |
-
echo (" PostalCode\n");
|
132 |
-
echo (" " .
|
133 |
-
$physicalDestination->getPostalCode() . "\n");
|
134 |
-
}
|
135 |
-
if ($physicalDestination->isSetCountryCode()) {
|
136 |
-
echo (" CountryCode\n");
|
137 |
-
echo (" " .
|
138 |
-
$physicalDestination->getCountryCode() . "\n");
|
139 |
-
}
|
140 |
-
if ($physicalDestination->isSetPhone()) {
|
141 |
-
echo (" Phone\n");
|
142 |
-
echo (" " . $physicalDestination->getPhone() .
|
143 |
-
"\n");
|
144 |
-
}
|
145 |
-
}
|
146 |
-
}
|
147 |
-
if ($orderReferenceDetails->isSetBillingAddress()) {
|
148 |
-
echo (" BillingAddress\n");
|
149 |
-
$billingAddress = $orderReferenceDetails->getBillingAddress();
|
150 |
-
if ($billingAddress->isSetAddressType()) {
|
151 |
-
echo (" AddressType\n");
|
152 |
-
echo (" " . $billingAddress->getAddressType() . "\n");
|
153 |
-
}
|
154 |
-
if ($billingAddress->isSetPhysicalAddress()) {
|
155 |
-
echo (" PhysicalAddress\n");
|
156 |
-
$physicalAddress = $billingAddress->getPhysicalAddress();
|
157 |
-
if ($physicalAddress->isSetName()) {
|
158 |
-
echo (" Name\n");
|
159 |
-
echo (" " . $physicalAddress->getName() .
|
160 |
-
"\n");
|
161 |
-
}
|
162 |
-
if ($physicalAddress->isSetAddressLine1()) {
|
163 |
-
echo (" AddressLine1\n");
|
164 |
-
echo (" " .
|
165 |
-
$physicalAddress->getAddressLine1() . "\n");
|
166 |
-
}
|
167 |
-
if ($physicalAddress->isSetAddressLine2()) {
|
168 |
-
echo (" AddressLine2\n");
|
169 |
-
echo (" " .
|
170 |
-
$physicalAddress->getAddressLine2() . "\n");
|
171 |
-
}
|
172 |
-
if ($physicalAddress->isSetAddressLine3()) {
|
173 |
-
echo (" AddressLine3\n");
|
174 |
-
echo (" " .
|
175 |
-
$physicalAddress->getAddressLine3() . "\n");
|
176 |
-
}
|
177 |
-
if ($physicalAddress->isSetCity()) {
|
178 |
-
echo (" City\n");
|
179 |
-
echo (" " . $physicalAddress->getCity() .
|
180 |
-
"\n");
|
181 |
-
}
|
182 |
-
if ($physicalAddress->isSetCounty()) {
|
183 |
-
echo (" County\n");
|
184 |
-
echo (" " . $physicalAddress->getCounty() .
|
185 |
-
"\n");
|
186 |
-
}
|
187 |
-
if ($physicalAddress->isSetDistrict()) {
|
188 |
-
echo (" District\n");
|
189 |
-
echo (" " .
|
190 |
-
$physicalAddress->getDistrict() . "\n");
|
191 |
-
}
|
192 |
-
if ($physicalAddress->isSetStateOrRegion()) {
|
193 |
-
echo (" StateOrRegion\n");
|
194 |
-
echo (" " .
|
195 |
-
$physicalAddress->getStateOrRegion() . "\n");
|
196 |
-
}
|
197 |
-
if ($physicalAddress->isSetPostalCode()) {
|
198 |
-
echo (" PostalCode\n");
|
199 |
-
echo (" " .
|
200 |
-
$physicalAddress->getPostalCode() . "\n");
|
201 |
-
}
|
202 |
-
if ($physicalAddress->isSetCountryCode()) {
|
203 |
-
echo (" CountryCode\n");
|
204 |
-
echo (" " .
|
205 |
-
$physicalAddress->getCountryCode() . "\n");
|
206 |
-
}
|
207 |
-
if ($physicalAddress->isSetPhone()) {
|
208 |
-
echo (" Phone\n");
|
209 |
-
echo (" " . $physicalAddress->getPhone() .
|
210 |
-
"\n");
|
211 |
-
}
|
212 |
-
}
|
213 |
-
}
|
214 |
-
if ($orderReferenceDetails->isSetReleaseEnvironment()) {
|
215 |
-
echo (" ReleaseEnvironment\n");
|
216 |
-
echo (" " . $orderReferenceDetails->getReleaseEnvironment() .
|
217 |
-
"\n");
|
218 |
-
}
|
219 |
-
if ($orderReferenceDetails->isSetIdList())
|
220 |
-
{
|
221 |
-
print " IdList" . PHP_EOL;
|
222 |
-
$idList = $orderReferenceDetails->getIdList();
|
223 |
-
$memberList = $idList->getmember();
|
224 |
-
foreach ($memberList as $member) {
|
225 |
-
print " member" . PHP_EOL;
|
226 |
-
print " " . $member . PHP_EOL;;
|
227 |
-
}
|
228 |
-
}
|
229 |
-
if ($orderReferenceDetails->isSetSellerOrderAttributes()) {
|
230 |
-
echo (" SellerOrderAttributes\n");
|
231 |
-
$sellerOrderAttributes = $orderReferenceDetails->getSellerOrderAttributes();
|
232 |
-
if ($sellerOrderAttributes->isSetSellerOrderId()) {
|
233 |
-
echo (" SellerOrderId\n");
|
234 |
-
echo (" " . $sellerOrderAttributes->getSellerOrderId() .
|
235 |
-
"\n");
|
236 |
-
}
|
237 |
-
if ($sellerOrderAttributes->isSetStoreName()) {
|
238 |
-
echo (" StoreName\n");
|
239 |
-
echo (" " . $sellerOrderAttributes->getStoreName() .
|
240 |
-
"\n");
|
241 |
-
}
|
242 |
-
if ($sellerOrderAttributes->isSetOrderItemCategories()) {
|
243 |
-
echo (" OrderItemCategories\n");
|
244 |
-
$orderItemCategories = $sellerOrderAttributes->getOrderItemCategories();
|
245 |
-
$orderItemCategoryList = $orderItemCategories->getOrderItemCategory();
|
246 |
-
foreach ($orderItemCategoryList as $orderItemCategory) {
|
247 |
-
echo (" OrderItemCategory\n");
|
248 |
-
echo (" " . $orderItemCategory);
|
249 |
-
}
|
250 |
-
}
|
251 |
-
if ($sellerOrderAttributes->isSetCustomInformation()) {
|
252 |
-
echo (" CustomInformation\n");
|
253 |
-
echo (" " .
|
254 |
-
$sellerOrderAttributes->getCustomInformation() . "\n");
|
255 |
-
}
|
256 |
-
}
|
257 |
-
if ($orderReferenceDetails->isSetOrderReferenceStatus()) {
|
258 |
-
echo (" OrderReferenceStatus\n");
|
259 |
-
$orderReferenceStatus = $orderReferenceDetails->getOrderReferenceStatus();
|
260 |
-
if ($orderReferenceStatus->isSetState()) {
|
261 |
-
echo (" State\n");
|
262 |
-
echo (" " . $orderReferenceStatus->getState() . "\n");
|
263 |
-
}
|
264 |
-
if ($orderReferenceStatus->isSetLastUpdateTimestamp()) {
|
265 |
-
echo (" LastUpdateTimestamp\n");
|
266 |
-
echo (" " .
|
267 |
-
$orderReferenceStatus->getLastUpdateTimestamp() . "\n");
|
268 |
-
}
|
269 |
-
if ($orderReferenceStatus->isSetReasonCode()) {
|
270 |
-
echo (" ReasonCode\n");
|
271 |
-
echo (" " . $orderReferenceStatus->getReasonCode() .
|
272 |
-
"\n");
|
273 |
-
}
|
274 |
-
if ($orderReferenceStatus->isSetReasonDescription()) {
|
275 |
-
echo (" ReasonDescription\n");
|
276 |
-
echo (" " .
|
277 |
-
$orderReferenceStatus->getReasonDescription() . "\n");
|
278 |
-
}
|
279 |
-
}
|
280 |
-
if ($orderReferenceDetails->isSetConstraints()) {
|
281 |
-
echo (" Constraints\n");
|
282 |
-
$constraints = $orderReferenceDetails->getConstraints();
|
283 |
-
$constraintList = $constraints->getConstraint();
|
284 |
-
foreach ($constraintList as $constraint) {
|
285 |
-
echo (" Constraint\n");
|
286 |
-
if ($constraint->isSetConstraintID()) {
|
287 |
-
echo (" ConstraintID\n");
|
288 |
-
echo (" " . $constraint->getConstraintID() .
|
289 |
-
"\n");
|
290 |
-
}
|
291 |
-
if ($constraint->isSetDescription()) {
|
292 |
-
echo (" Description\n");
|
293 |
-
echo (" " . $constraint->getDescription() .
|
294 |
-
"\n");
|
295 |
-
}
|
296 |
-
}
|
297 |
-
}
|
298 |
-
if ($orderReferenceDetails->isSetCreationTimestamp()) {
|
299 |
-
echo (" CreationTimestamp\n");
|
300 |
-
echo (" " . $orderReferenceDetails->getCreationTimestamp() .
|
301 |
-
"\n");
|
302 |
-
}
|
303 |
-
if ($orderReferenceDetails->isSetExpirationTimestamp()) {
|
304 |
-
echo (" ExpirationTimestamp\n");
|
305 |
-
echo (" " . $orderReferenceDetails->getExpirationTimestamp() .
|
306 |
-
"\n");
|
307 |
-
}
|
308 |
-
if ($orderReferenceDetails->isSetParentDetails()) {
|
309 |
-
echo (" ParentDetails\n");
|
310 |
-
$parentDetails = $orderReferenceDetails->getParentDetails();
|
311 |
-
if ($parentDetails->isSetId()) {
|
312 |
-
echo (" Id\n");
|
313 |
-
echo (" " . $parentDetails->getId() . "\n");
|
314 |
-
}
|
315 |
-
if ($parentDetails->isSetType()) {
|
316 |
-
echo (" Type\n");
|
317 |
-
echo (" " . $parentDetails->getType() . "\n");
|
318 |
-
}
|
319 |
-
}
|
320 |
-
}
|
321 |
-
}
|
322 |
-
if ($response->isSetResponseMetadata()) {
|
323 |
-
echo (" ResponseMetadata\n");
|
324 |
-
$responseMetadata = $response->getResponseMetadata();
|
325 |
-
if ($responseMetadata->isSetRequestId()) {
|
326 |
-
echo (" RequestId\n");
|
327 |
-
echo (" " . $responseMetadata->getRequestId() . "\n");
|
328 |
-
}
|
329 |
-
}
|
330 |
-
|
331 |
-
echo (" ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");
|
332 |
-
}
|
333 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/GetAuthorizationDetailsSample.php
DELETED
@@ -1,266 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Get Authorization Details Sample
|
21 |
-
*/
|
22 |
-
|
23 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Throw an error if the response does not have an authorization status
|
27 |
-
* of open
|
28 |
-
*
|
29 |
-
* @param OffAmazonPaymentsService_Model_GetAuthorizationDetails response
|
30 |
-
* @throws ErrorException
|
31 |
-
*/
|
32 |
-
function validateThatAuthorizationIsOpen($response)
|
33 |
-
{
|
34 |
-
$authorizationDetails = $response->getGetAuthorizationDetailsResult()
|
35 |
-
->getAuthorizationDetails();
|
36 |
-
|
37 |
-
if (strcasecmp($authorizationDetails->getAuthorizationStatus()->getState(), "Open") != 0) {
|
38 |
-
throw new ErrorException(
|
39 |
-
"Error with authorization " .
|
40 |
-
$amazonAuthorizationReferenceId . " - state is " .
|
41 |
-
$authorizationDetails->getAuthorizationStatus()->getState() . PHP_EOL
|
42 |
-
);
|
43 |
-
}
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Get Authorization Details Action Sample
|
48 |
-
|
49 |
-
* @param OffAmazonPaymentsService_Interface $service instance of OffAmazonPaymentsService_Interface
|
50 |
-
* @param mixed $request OffAmazonPaymentsService_Model_GetAuthorizationDetails or array of parameters
|
51 |
-
*/
|
52 |
-
function printGetAuthorizationDetailsResponse($response)
|
53 |
-
{
|
54 |
-
|
55 |
-
print "Service Response" . PHP_EOL;
|
56 |
-
print "=============================================================================" . PHP_EOL;
|
57 |
-
|
58 |
-
print " GetAuthorizationDetailsResponse" . PHP_EOL;
|
59 |
-
if ($response->isSetGetAuthorizationDetailsResult()) {
|
60 |
-
print " GetAuthorizationDetailsResult" . PHP_EOL;
|
61 |
-
$getAuthorizationDetailsResult = $response->getGetAuthorizationDetailsResult();
|
62 |
-
if ($getAuthorizationDetailsResult->isSetAuthorizationDetails()) {
|
63 |
-
print " AuthorizationDetails" . PHP_EOL;
|
64 |
-
$authorizationDetails = $getAuthorizationDetailsResult->getAuthorizationDetails();
|
65 |
-
if ($authorizationDetails->isSetAmazonAuthorizationId())
|
66 |
-
{
|
67 |
-
print " AmazonAuthorizationId" . PHP_EOL;
|
68 |
-
print " " . $authorizationDetails->getAmazonAuthorizationId() . PHP_EOL;
|
69 |
-
}
|
70 |
-
if ($authorizationDetails->isSetAuthorizationReferenceId())
|
71 |
-
{
|
72 |
-
print " AuthorizationReferenceId" . PHP_EOL;
|
73 |
-
print " " . $authorizationDetails->getAuthorizationReferenceId() . PHP_EOL;
|
74 |
-
}
|
75 |
-
if ($authorizationDetails->isSetAuthorizationBillingAddress())
|
76 |
-
{
|
77 |
-
print " AuthorizationBillingAddress" . PHP_EOL;
|
78 |
-
$authorizationBillingAddress = $authorizationDetails->getAuthorizationBillingAddress();
|
79 |
-
if ($authorizationBillingAddress->isSetName())
|
80 |
-
{
|
81 |
-
print " Name" . PHP_EOL;
|
82 |
-
print " " . $authorizationBillingAddress->getName() . PHP_EOL;
|
83 |
-
}
|
84 |
-
if ($authorizationBillingAddress->isSetAddressLine1())
|
85 |
-
{
|
86 |
-
print " AddressLine1" . PHP_EOL;
|
87 |
-
print " " . $authorizationBillingAddress->getAddressLine1() . PHP_EOL;
|
88 |
-
}
|
89 |
-
if ($authorizationBillingAddress->isSetAddressLine2())
|
90 |
-
{
|
91 |
-
print " AddressLine2" . PHP_EOL;
|
92 |
-
print " " . $authorizationBillingAddress->getAddressLine2() . PHP_EOL;
|
93 |
-
}
|
94 |
-
if ($authorizationBillingAddress->isSetAddressLine3())
|
95 |
-
{
|
96 |
-
print " AddressLine3" . PHP_EOL;
|
97 |
-
print " " . $authorizationBillingAddress->getAddressLine3() . PHP_EOL;
|
98 |
-
}
|
99 |
-
if ($authorizationBillingAddress->isSetCity())
|
100 |
-
{
|
101 |
-
print " City" . PHP_EOL;
|
102 |
-
print " " . $authorizationBillingAddress->getCity() . PHP_EOL;
|
103 |
-
}
|
104 |
-
if ($authorizationBillingAddress->isSetCounty())
|
105 |
-
{
|
106 |
-
print " County" . PHP_EOL;
|
107 |
-
print " " . $authorizationBillingAddress->getCounty() . PHP_EOL;
|
108 |
-
}
|
109 |
-
if ($authorizationBillingAddress->isSetDistrict())
|
110 |
-
{
|
111 |
-
print " District" . PHP_EOL;
|
112 |
-
print " " . $authorizationBillingAddress->getDistrict() . PHP_EOL;
|
113 |
-
}
|
114 |
-
if ($authorizationBillingAddress->isSetStateOrRegion())
|
115 |
-
{
|
116 |
-
print " StateOrRegion" . PHP_EOL;
|
117 |
-
print " " . $authorizationBillingAddress->getStateOrRegion() . PHP_EOL;
|
118 |
-
}
|
119 |
-
if ($authorizationBillingAddress->isSetPostalCode())
|
120 |
-
{
|
121 |
-
print " PostalCode" . PHP_EOL;
|
122 |
-
print " " . $authorizationBillingAddress->getPostalCode() . PHP_EOL;
|
123 |
-
}
|
124 |
-
if ($authorizationBillingAddress->isSetCountryCode())
|
125 |
-
{
|
126 |
-
print " CountryCode" . PHP_EOL;
|
127 |
-
print " " . $authorizationBillingAddress->getCountryCode() . PHP_EOL;
|
128 |
-
}
|
129 |
-
if ($authorizationBillingAddress->isSetPhone())
|
130 |
-
{
|
131 |
-
print " Phone" . PHP_EOL;
|
132 |
-
print " " . $authorizationBillingAddress->getPhone() . PHP_EOL;
|
133 |
-
}
|
134 |
-
}
|
135 |
-
if ($authorizationDetails->isSetSellerAuthorizationNote())
|
136 |
-
{
|
137 |
-
print " SellerAuthorizationNote" . PHP_EOL;
|
138 |
-
print " " . $authorizationDetails->getSellerAuthorizationNote() . PHP_EOL;
|
139 |
-
}
|
140 |
-
if ($authorizationDetails->isSetAuthorizationAmount()) {
|
141 |
-
print " AuthorizationAmount" . PHP_EOL;
|
142 |
-
$authorizationAmount = $authorizationDetails->getAuthorizationAmount();
|
143 |
-
if ($authorizationAmount->isSetAmount())
|
144 |
-
{
|
145 |
-
print " Amount" . PHP_EOL;
|
146 |
-
print " " . $authorizationAmount->getAmount() . PHP_EOL;
|
147 |
-
}
|
148 |
-
if ($authorizationAmount->isSetCurrencyCode())
|
149 |
-
{
|
150 |
-
print " CurrencyCode" . PHP_EOL;
|
151 |
-
print " " . $authorizationAmount->getCurrencyCode() . PHP_EOL;
|
152 |
-
}
|
153 |
-
}
|
154 |
-
if ($authorizationDetails->isSetCapturedAmount()) {
|
155 |
-
print " CapturedAmount" . PHP_EOL;
|
156 |
-
$capturedAmount = $authorizationDetails->getCapturedAmount();
|
157 |
-
if ($capturedAmount->isSetAmount())
|
158 |
-
{
|
159 |
-
print " Amount" . PHP_EOL;
|
160 |
-
print " " . $capturedAmount->getAmount() . PHP_EOL;
|
161 |
-
}
|
162 |
-
if ($capturedAmount->isSetCurrencyCode())
|
163 |
-
{
|
164 |
-
print " CurrencyCode" . PHP_EOL;
|
165 |
-
print " " . $capturedAmount->getCurrencyCode() . PHP_EOL;
|
166 |
-
}
|
167 |
-
}
|
168 |
-
if ($authorizationDetails->isSetAuthorizationFee()) {
|
169 |
-
print " AuthorizationFee" . PHP_EOL;
|
170 |
-
$authorizationFee = $authorizationDetails->getAuthorizationFee();
|
171 |
-
if ($authorizationFee->isSetAmount())
|
172 |
-
{
|
173 |
-
print " Amount" . PHP_EOL;
|
174 |
-
print " " . $authorizationFee->getAmount() . PHP_EOL;
|
175 |
-
}
|
176 |
-
if ($authorizationFee->isSetCurrencyCode())
|
177 |
-
{
|
178 |
-
print " CurrencyCode" . PHP_EOL;
|
179 |
-
print " " . $authorizationFee->getCurrencyCode() . PHP_EOL;
|
180 |
-
}
|
181 |
-
}
|
182 |
-
if ($authorizationDetails->isSetIdList()) {
|
183 |
-
print " IdList" . PHP_EOL;
|
184 |
-
$idList = $authorizationDetails->getIdList();
|
185 |
-
$memberList = $idList->getmember();
|
186 |
-
foreach ($memberList as $member) {
|
187 |
-
print " member" . PHP_EOL;
|
188 |
-
print " " . $member;
|
189 |
-
}
|
190 |
-
}
|
191 |
-
if ($authorizationDetails->isSetCreationTimestamp())
|
192 |
-
{
|
193 |
-
print " CreationTimestamp" . PHP_EOL;
|
194 |
-
print " " . $authorizationDetails->getCreationTimestamp() . PHP_EOL;
|
195 |
-
}
|
196 |
-
if ($authorizationDetails->isSetExpirationTimestamp())
|
197 |
-
{
|
198 |
-
print " ExpirationTimestamp" . PHP_EOL;
|
199 |
-
print " " . $authorizationDetails->getExpirationTimestamp() . PHP_EOL;
|
200 |
-
}
|
201 |
-
if ($authorizationDetails->isSetAuthorizationStatus()) {
|
202 |
-
print " AuthorizationStatus" . PHP_EOL;
|
203 |
-
$authorizationStatus = $authorizationDetails->getAuthorizationStatus();
|
204 |
-
if ($authorizationStatus->isSetState())
|
205 |
-
{
|
206 |
-
print " State" . PHP_EOL;
|
207 |
-
print " " . $authorizationStatus->getState() . PHP_EOL;
|
208 |
-
}
|
209 |
-
if ($authorizationStatus->isSetLastUpdateTimestamp())
|
210 |
-
{
|
211 |
-
print " LastUpdateTimestamp" . PHP_EOL;
|
212 |
-
print " " . $authorizationStatus->getLastUpdateTimestamp() . PHP_EOL;
|
213 |
-
}
|
214 |
-
if ($authorizationStatus->isSetReasonCode())
|
215 |
-
{
|
216 |
-
print " ReasonCode" . PHP_EOL;
|
217 |
-
print " " . $authorizationStatus->getReasonCode() . PHP_EOL;
|
218 |
-
}
|
219 |
-
if ($authorizationStatus->isSetReasonDescription())
|
220 |
-
{
|
221 |
-
print " ReasonDescription" . PHP_EOL;
|
222 |
-
print " " . $authorizationStatus->getReasonDescription() . PHP_EOL;
|
223 |
-
}
|
224 |
-
}
|
225 |
-
if ($authorizationDetails->isSetOrderItemCategories()) {
|
226 |
-
print " OrderItemCategories" . PHP_EOL;
|
227 |
-
$orderItemCategories = $authorizationDetails->getOrderItemCategories();
|
228 |
-
$orderItemCategoryList = $orderItemCategories->getOrderItemCategory();
|
229 |
-
foreach ($orderItemCategoryList as $orderItemCategory) {
|
230 |
-
print " OrderItemCategory" . PHP_EOL;
|
231 |
-
print " " . $orderItemCategory;
|
232 |
-
}
|
233 |
-
}
|
234 |
-
if ($authorizationDetails->isSetCaptureNow())
|
235 |
-
{
|
236 |
-
print " CaptureNow" . PHP_EOL;
|
237 |
-
print " " . $authorizationDetails->getCaptureNow() . PHP_EOL;
|
238 |
-
}
|
239 |
-
if ($authorizationDetails->isSetSoftDescriptor())
|
240 |
-
{
|
241 |
-
print " SoftDescriptor" . PHP_EOL;
|
242 |
-
print " " . $authorizationDetails->getSoftDescriptor() . PHP_EOL;
|
243 |
-
}
|
244 |
-
if($authorizationDetails->isSetAddressVerificationCode())
|
245 |
-
{
|
246 |
-
print " AddressVerificationCode" . PHP_EOL;
|
247 |
-
print " " . $authorizationDetails->getAddressVerificationCode() . PHP_EOL;
|
248 |
-
}
|
249 |
-
}
|
250 |
-
}
|
251 |
-
if ($response->isSetResponseMetadata()) {
|
252 |
-
print " ResponseMetadata" . PHP_EOL;
|
253 |
-
$responseMetadata = $response->getResponseMetadata();
|
254 |
-
if ($responseMetadata->isSetRequestId())
|
255 |
-
{
|
256 |
-
print " RequestId" . PHP_EOL;
|
257 |
-
print " " . $responseMetadata->getRequestId() . PHP_EOL;
|
258 |
-
}
|
259 |
-
}
|
260 |
-
|
261 |
-
print " ResponseHeaderMetadata: " .
|
262 |
-
$response->getResponseHeaderMetadata() . PHP_EOL;
|
263 |
-
|
264 |
-
return $response;
|
265 |
-
}
|
266 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/GetBillingAgreementDetailsSample.php
DELETED
@@ -1,337 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Print the GetBillingAgreementDetails response to the console
|
21 |
-
*
|
22 |
-
* @param OffAmazonPaymentsService_Model_GetBillingAgreementDetailsResponse $response
|
23 |
-
* response object
|
24 |
-
*
|
25 |
-
* @return void
|
26 |
-
*/
|
27 |
-
function printGetBillingAgreementDetailsResponse ($response)
|
28 |
-
{
|
29 |
-
echo ("Service Response\n");
|
30 |
-
echo ("=============================================================================\n");
|
31 |
-
|
32 |
-
echo (" GetBillingAgreementDetailsResponse\n");
|
33 |
-
if ($response->isSetGetBillingAgreementDetailsResult()) {
|
34 |
-
echo (" GetBillingAgreementDetailsResult\n");
|
35 |
-
$getBillingAgreementDetailsResult = $response->getGetBillingAgreementDetailsResult();
|
36 |
-
if ($getBillingAgreementDetailsResult->isSetBillingAgreementDetails()) {
|
37 |
-
echo (" BillingAgreementDetails\n");
|
38 |
-
$billingAgreementDetails = $getBillingAgreementDetailsResult->getBillingAgreementDetails();
|
39 |
-
if ($billingAgreementDetails->isSetAmazonBillingAgreementId()) {
|
40 |
-
echo (" AmazonBillingAgreementId\n");
|
41 |
-
echo (" " .
|
42 |
-
$billingAgreementDetails->getAmazonBillingAgreementId() . "\n");
|
43 |
-
}
|
44 |
-
if ($billingAgreementDetails->isSetBillingAgreementLimits()) {
|
45 |
-
echo (" BillingAgreementLimits\n");
|
46 |
-
$billingAgreementLimits = $billingAgreementDetails->getBillingAgreementLimits();
|
47 |
-
if ($billingAgreementLimits->isSetAmountLimitPerTimePeriod()) {
|
48 |
-
echo (" AmountLimitPerTimePeriod\n");
|
49 |
-
$amountLimitPerTimePeriod = $billingAgreementLimits->getAmountLimitPerTimePeriod();
|
50 |
-
if ($amountLimitPerTimePeriod->isSetAmount()) {
|
51 |
-
echo (" Amount\n");
|
52 |
-
echo (" " .
|
53 |
-
$amountLimitPerTimePeriod->getAmount() . "\n");
|
54 |
-
}
|
55 |
-
if ($amountLimitPerTimePeriod->isSetCurrencyCode()) {
|
56 |
-
echo (" CurrencyCode\n");
|
57 |
-
echo (" " .
|
58 |
-
$amountLimitPerTimePeriod->getCurrencyCode() . "\n");
|
59 |
-
}
|
60 |
-
}
|
61 |
-
if ($billingAgreementLimits->isSetTimePeriodStartDate()) {
|
62 |
-
echo (" TimePeriodStartDate\n");
|
63 |
-
echo (" " .
|
64 |
-
$billingAgreementLimits->getTimePeriodStartDate() . "\n");
|
65 |
-
}
|
66 |
-
if ($billingAgreementLimits->isSetTimePeriodEndDate()) {
|
67 |
-
echo (" TimePeriodEndDate\n");
|
68 |
-
echo (" " .
|
69 |
-
$billingAgreementLimits->getTimePeriodEndDate() . "\n");
|
70 |
-
}
|
71 |
-
if ($billingAgreementLimits->isSetCurrentRemainingBalance()) {
|
72 |
-
echo (" CurrentRemainingBalance\n");
|
73 |
-
$currentRemainingBalance = $billingAgreementLimits->getCurrentRemainingBalance();
|
74 |
-
if ($currentRemainingBalance->isSetAmount()) {
|
75 |
-
echo (" Amount\n");
|
76 |
-
echo (" " .
|
77 |
-
$currentRemainingBalance->getAmount() . "\n");
|
78 |
-
}
|
79 |
-
if ($currentRemainingBalance->isSetCurrencyCode()) {
|
80 |
-
echo (" CurrencyCode\n");
|
81 |
-
echo (" " .
|
82 |
-
$currentRemainingBalance->getCurrencyCode() . "\n");
|
83 |
-
}
|
84 |
-
}
|
85 |
-
}
|
86 |
-
if ($billingAgreementDetails->isSetBuyer()) {
|
87 |
-
echo (" Buyer\n");
|
88 |
-
$buyer = $billingAgreementDetails->getBuyer();
|
89 |
-
if ($buyer->isSetName()) {
|
90 |
-
echo (" Name\n");
|
91 |
-
echo (" " . $buyer->getName() . "\n");
|
92 |
-
}
|
93 |
-
if ($buyer->isSetEmail()) {
|
94 |
-
echo (" Email\n");
|
95 |
-
echo (" " . $buyer->getEmail() . "\n");
|
96 |
-
}
|
97 |
-
if ($buyer->isSetPhone()) {
|
98 |
-
echo (" Phone\n");
|
99 |
-
echo (" " . $buyer->getPhone() . "\n");
|
100 |
-
}
|
101 |
-
}
|
102 |
-
if ($billingAgreementDetails->isSetSellerNote()) {
|
103 |
-
echo (" SellerNote\n");
|
104 |
-
echo (" " . $billingAgreementDetails->getSellerNote() . "\n");
|
105 |
-
}
|
106 |
-
if ($billingAgreementDetails->isSetPlatformId()) {
|
107 |
-
echo (" PlatformId\n");
|
108 |
-
echo (" " . $billingAgreementDetails->getPlatformId() . "\n");
|
109 |
-
}
|
110 |
-
if ($billingAgreementDetails->isSetDestination()) {
|
111 |
-
echo (" Destination\n");
|
112 |
-
$destination = $billingAgreementDetails->getDestination();
|
113 |
-
if ($destination->isSetDestinationType()) {
|
114 |
-
echo (" DestinationType\n");
|
115 |
-
echo (" " . $destination->getDestinationType() . "\n");
|
116 |
-
}
|
117 |
-
if ($destination->isSetPhysicalDestination()) {
|
118 |
-
echo (" PhysicalDestination\n");
|
119 |
-
$physicalDestination = $destination->getPhysicalDestination();
|
120 |
-
if ($physicalDestination->isSetName()) {
|
121 |
-
echo (" Name\n");
|
122 |
-
echo (" " . $physicalDestination->getName() .
|
123 |
-
"\n");
|
124 |
-
}
|
125 |
-
if ($physicalDestination->isSetAddressLine1()) {
|
126 |
-
echo (" AddressLine1\n");
|
127 |
-
echo (" " .
|
128 |
-
$physicalDestination->getAddressLine1() . "\n");
|
129 |
-
}
|
130 |
-
if ($physicalDestination->isSetAddressLine2()) {
|
131 |
-
echo (" AddressLine2\n");
|
132 |
-
echo (" " .
|
133 |
-
$physicalDestination->getAddressLine2() . "\n");
|
134 |
-
}
|
135 |
-
if ($physicalDestination->isSetAddressLine3()) {
|
136 |
-
echo (" AddressLine3\n");
|
137 |
-
echo (" " .
|
138 |
-
$physicalDestination->getAddressLine3() . "\n");
|
139 |
-
}
|
140 |
-
if ($physicalDestination->isSetCity()) {
|
141 |
-
echo (" City\n");
|
142 |
-
echo (" " . $physicalDestination->getCity() .
|
143 |
-
"\n");
|
144 |
-
}
|
145 |
-
if ($physicalDestination->isSetCounty()) {
|
146 |
-
echo (" County\n");
|
147 |
-
echo (" " . $physicalDestination->getCounty() .
|
148 |
-
"\n");
|
149 |
-
}
|
150 |
-
if ($physicalDestination->isSetDistrict()) {
|
151 |
-
echo (" District\n");
|
152 |
-
echo (" " .
|
153 |
-
$physicalDestination->getDistrict() . "\n");
|
154 |
-
}
|
155 |
-
if ($physicalDestination->isSetStateOrRegion()) {
|
156 |
-
echo (" StateOrRegion\n");
|
157 |
-
echo (" " .
|
158 |
-
$physicalDestination->getStateOrRegion() . "\n");
|
159 |
-
}
|
160 |
-
if ($physicalDestination->isSetPostalCode()) {
|
161 |
-
echo (" PostalCode\n");
|
162 |
-
echo (" " .
|
163 |
-
$physicalDestination->getPostalCode() . "\n");
|
164 |
-
}
|
165 |
-
if ($physicalDestination->isSetCountryCode()) {
|
166 |
-
echo (" CountryCode\n");
|
167 |
-
echo (" " .
|
168 |
-
$physicalDestination->getCountryCode() . "\n");
|
169 |
-
}
|
170 |
-
if ($physicalDestination->isSetPhone()) {
|
171 |
-
echo (" Phone\n");
|
172 |
-
echo (" " . $physicalDestination->getPhone() .
|
173 |
-
"\n");
|
174 |
-
}
|
175 |
-
}
|
176 |
-
}
|
177 |
-
if ($billingAgreementDetails->isSetBillingAddress()) {
|
178 |
-
echo (" BillingAddress\n");
|
179 |
-
$billingAddress = $billingAgreementDetails->getBillingAddress();
|
180 |
-
if ($billingAddress->isSetAddressType()) {
|
181 |
-
echo (" AddressType\n");
|
182 |
-
echo (" " . $billingAddress->getAddressType() . "\n");
|
183 |
-
}
|
184 |
-
if ($billingAddress->isSetPhysicalAddress()) {
|
185 |
-
echo (" PhysicalAddress\n");
|
186 |
-
$physicalAddress = $billingAddress->getPhysicalAddress();
|
187 |
-
if ($physicalAddress->isSetName()) {
|
188 |
-
echo (" Name\n");
|
189 |
-
echo (" " . $physicalAddress->getName() .
|
190 |
-
"\n");
|
191 |
-
}
|
192 |
-
if ($physicalAddress->isSetAddressLine1()) {
|
193 |
-
echo (" AddressLine1\n");
|
194 |
-
echo (" " .
|
195 |
-
$physicalAddress->getAddressLine1() . "\n");
|
196 |
-
}
|
197 |
-
if ($physicalAddress->isSetAddressLine2()) {
|
198 |
-
echo (" AddressLine2\n");
|
199 |
-
echo (" " .
|
200 |
-
$physicalAddress->getAddressLine2() . "\n");
|
201 |
-
}
|
202 |
-
if ($physicalAddress->isSetAddressLine3()) {
|
203 |
-
echo (" AddressLine3\n");
|
204 |
-
echo (" " .
|
205 |
-
$physicalAddress->getAddressLine3() . "\n");
|
206 |
-
}
|
207 |
-
if ($physicalAddress->isSetCity()) {
|
208 |
-
echo (" City\n");
|
209 |
-
echo (" " . $physicalAddress->getCity() .
|
210 |
-
"\n");
|
211 |
-
}
|
212 |
-
if ($physicalAddress->isSetCounty()) {
|
213 |
-
echo (" County\n");
|
214 |
-
echo (" " . $physicalAddress->getCounty() .
|
215 |
-
"\n");
|
216 |
-
}
|
217 |
-
if ($physicalAddress->isSetDistrict()) {
|
218 |
-
echo (" District\n");
|
219 |
-
echo (" " .
|
220 |
-
$physicalAddress->getDistrict() . "\n");
|
221 |
-
}
|
222 |
-
if ($physicalAddress->isSetStateOrRegion()) {
|
223 |
-
echo (" StateOrRegion\n");
|
224 |
-
echo (" " .
|
225 |
-
$physicalAddress->getStateOrRegion() . "\n");
|
226 |
-
}
|
227 |
-
if ($physicalAddress->isSetPostalCode()) {
|
228 |
-
echo (" PostalCode\n");
|
229 |
-
echo (" " .
|
230 |
-
$physicalAddress->getPostalCode() . "\n");
|
231 |
-
}
|
232 |
-
if ($physicalAddress->isSetCountryCode()) {
|
233 |
-
echo (" CountryCode\n");
|
234 |
-
echo (" " .
|
235 |
-
$physicalAddress->getCountryCode() . "\n");
|
236 |
-
}
|
237 |
-
if ($physicalAddress->isSetPhone()) {
|
238 |
-
echo (" Phone\n");
|
239 |
-
echo (" " . $physicalAddress->getPhone() .
|
240 |
-
"\n");
|
241 |
-
}
|
242 |
-
}
|
243 |
-
}
|
244 |
-
if ($billingAgreementDetails->isSetReleaseEnvironment()) {
|
245 |
-
echo (" ReleaseEnvironment\n");
|
246 |
-
echo (" " . $billingAgreementDetails->getReleaseEnvironment() .
|
247 |
-
"\n");
|
248 |
-
}
|
249 |
-
if ($billingAgreementDetails->isSetSellerBillingAgreementAttributes()) {
|
250 |
-
echo (" SellerBillingAgreementAttributes\n");
|
251 |
-
$sellerBillingAgreementAttributes = $billingAgreementDetails->getSellerBillingAgreementAttributes();
|
252 |
-
if ($sellerBillingAgreementAttributes->isSetSellerBillingAgreementId()) {
|
253 |
-
echo (" SellerBillingAgreementId\n");
|
254 |
-
echo (" " .
|
255 |
-
$sellerBillingAgreementAttributes->getSellerBillingAgreementId() . "\n");
|
256 |
-
}
|
257 |
-
if ($sellerBillingAgreementAttributes->isSetStoreName()) {
|
258 |
-
echo (" StoreName\n");
|
259 |
-
echo (" " .
|
260 |
-
$sellerBillingAgreementAttributes->getStoreName() . "\n");
|
261 |
-
}
|
262 |
-
if ($sellerBillingAgreementAttributes->isSetCustomInformation()) {
|
263 |
-
echo (" CustomInformation\n");
|
264 |
-
echo (" " .
|
265 |
-
$sellerBillingAgreementAttributes->getCustomInformation() . "\n");
|
266 |
-
}
|
267 |
-
}
|
268 |
-
if ($billingAgreementDetails->isSetBillingAgreementStatus()) {
|
269 |
-
echo (" BillingAgreementStatus\n");
|
270 |
-
$billingAgreementStatus = $billingAgreementDetails->getBillingAgreementStatus();
|
271 |
-
if ($billingAgreementStatus->isSetState()) {
|
272 |
-
echo (" State\n");
|
273 |
-
echo (" " . $billingAgreementStatus->getState() . "\n");
|
274 |
-
}
|
275 |
-
if ($billingAgreementStatus->isSetLastUpdatedTimestamp()) {
|
276 |
-
echo (" LastUpdatedTimestamp\n");
|
277 |
-
echo (" " .
|
278 |
-
$billingAgreementStatus->getLastUpdatedTimestamp() . "\n");
|
279 |
-
}
|
280 |
-
if ($billingAgreementStatus->isSetReasonCode()) {
|
281 |
-
echo (" ReasonCode\n");
|
282 |
-
echo (" " . $billingAgreementStatus->getReasonCode() .
|
283 |
-
"\n");
|
284 |
-
}
|
285 |
-
if ($billingAgreementStatus->isSetReasonDescription()) {
|
286 |
-
echo (" ReasonDescription\n");
|
287 |
-
echo (" " .
|
288 |
-
$billingAgreementStatus->getReasonDescription() . "\n");
|
289 |
-
}
|
290 |
-
}
|
291 |
-
if ($billingAgreementDetails->isSetConstraints()) {
|
292 |
-
echo (" Constraints\n");
|
293 |
-
$constraints = $billingAgreementDetails->getConstraints();
|
294 |
-
$constraintList = $constraints->getConstraint();
|
295 |
-
foreach ($constraintList as $constraint) {
|
296 |
-
echo (" Constraint\n");
|
297 |
-
if ($constraint->isSetConstraintID()) {
|
298 |
-
echo (" ConstraintID\n");
|
299 |
-
echo (" " . $constraint->getConstraintID() .
|
300 |
-
"\n");
|
301 |
-
}
|
302 |
-
if ($constraint->isSetDescription()) {
|
303 |
-
echo (" Description\n");
|
304 |
-
echo (" " . $constraint->getDescription() .
|
305 |
-
"\n");
|
306 |
-
}
|
307 |
-
}
|
308 |
-
}
|
309 |
-
if ($billingAgreementDetails->isSetCreationTimestamp()) {
|
310 |
-
echo (" CreationTimestamp\n");
|
311 |
-
echo (" " . $billingAgreementDetails->getCreationTimestamp() .
|
312 |
-
"\n");
|
313 |
-
}
|
314 |
-
if ($billingAgreementDetails->isSetExpirationTimestamp()) {
|
315 |
-
echo (" ExpirationTimestamp\n");
|
316 |
-
echo (" " . $billingAgreementDetails->getExpirationTimestamp() .
|
317 |
-
"\n");
|
318 |
-
}
|
319 |
-
if ($billingAgreementDetails->isSetBillingAgreementConsent()) {
|
320 |
-
echo (" BillingAgreementConsent\n");
|
321 |
-
echo (" " .
|
322 |
-
$billingAgreementDetails->getBillingAgreementConsent() . "\n");
|
323 |
-
}
|
324 |
-
}
|
325 |
-
}
|
326 |
-
if ($response->isSetResponseMetadata()) {
|
327 |
-
echo (" ResponseMetadata\n");
|
328 |
-
$responseMetadata = $response->getResponseMetadata();
|
329 |
-
if ($responseMetadata->isSetRequestId()) {
|
330 |
-
echo (" RequestId\n");
|
331 |
-
echo (" " . $responseMetadata->getRequestId() . "\n");
|
332 |
-
}
|
333 |
-
}
|
334 |
-
|
335 |
-
echo (" ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");
|
336 |
-
}
|
337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/GetCaptureDetailsSample.php
DELETED
@@ -1,203 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Get Capture Details Sample
|
21 |
-
*/
|
22 |
-
|
23 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Throw an error if the capture is not in the
|
27 |
-
* completed status
|
28 |
-
*
|
29 |
-
* @param OffAmazonPaymentsService_Model_CaptureResult $result service response
|
30 |
-
*
|
31 |
-
* @throws ErrorException
|
32 |
-
*
|
33 |
-
* @return void
|
34 |
-
*/
|
35 |
-
function validateThatCaptureIsCompleted($result)
|
36 |
-
{
|
37 |
-
if (strcasecmp(
|
38 |
-
$result->getCaptureDetails()->getCaptureStatus()->getState(),
|
39 |
-
"Completed"
|
40 |
-
) != 0) {
|
41 |
-
throw new ErrorException(
|
42 |
-
"Error with capture - state is " .
|
43 |
-
$result->getCaptureDetails()->getCaptureStatus()->getState() . PHP_EOL
|
44 |
-
);
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Get Capture Details Action Sample
|
50 |
-
|
51 |
-
* @param OffAmazonPaymentsService_Interface $service instance of OffAmazonPaymentsService_Interface
|
52 |
-
* @param mixed $request OffAmazonPaymentsService_Model_GetCaptureDetails or array of parameters
|
53 |
-
*/
|
54 |
-
function printGetCaptureDetailsResponse($response)
|
55 |
-
{
|
56 |
-
|
57 |
-
print "Service Response" . PHP_EOL;
|
58 |
-
print "=============================================================================" . PHP_EOL;
|
59 |
-
|
60 |
-
print " GetCaptureDetailsResponse" . PHP_EOL;
|
61 |
-
if ($response->isSetGetCaptureDetailsResult()) {
|
62 |
-
print " GetCaptureDetailsResult" . PHP_EOL;
|
63 |
-
$getCaptureDetailsResult = $response->getGetCaptureDetailsResult();
|
64 |
-
if ($getCaptureDetailsResult->isSetCaptureDetails()) {
|
65 |
-
print " CaptureDetails" . PHP_EOL;
|
66 |
-
$captureDetails = $getCaptureDetailsResult->getCaptureDetails();
|
67 |
-
if ($captureDetails->isSetAmazonCaptureId())
|
68 |
-
{
|
69 |
-
print " AmazonCaptureId" . PHP_EOL;
|
70 |
-
print " " . $captureDetails->getAmazonCaptureId() . PHP_EOL;
|
71 |
-
}
|
72 |
-
if ($captureDetails->isSetCaptureReferenceId())
|
73 |
-
{
|
74 |
-
print " CaptureReferenceId" . PHP_EOL;
|
75 |
-
print " " . $captureDetails->getCaptureReferenceId() . PHP_EOL;
|
76 |
-
}
|
77 |
-
if ($captureDetails->isSetSellerCaptureNote())
|
78 |
-
{
|
79 |
-
print " SellerCaptureNote" . PHP_EOL;
|
80 |
-
print " " . $captureDetails->getSellerCaptureNote() . PHP_EOL;
|
81 |
-
}
|
82 |
-
if ($captureDetails->isSetCaptureAmount()) {
|
83 |
-
print " CaptureAmount" . PHP_EOL;
|
84 |
-
$captureAmount = $captureDetails->getCaptureAmount();
|
85 |
-
if ($captureAmount->isSetAmount())
|
86 |
-
{
|
87 |
-
print " Amount" . PHP_EOL;
|
88 |
-
print " " . $captureAmount->getAmount() . PHP_EOL;
|
89 |
-
}
|
90 |
-
if ($captureAmount->isSetCurrencyCode())
|
91 |
-
{
|
92 |
-
print " CurrencyCode" . PHP_EOL;
|
93 |
-
print " " . $captureAmount->getCurrencyCode() . PHP_EOL;
|
94 |
-
}
|
95 |
-
}
|
96 |
-
if ($captureDetails->isSetRefundedAmount()) {
|
97 |
-
print " RefundedAmount" . PHP_EOL;
|
98 |
-
$refundedAmount = $captureDetails->getRefundedAmount();
|
99 |
-
if ($refundedAmount->isSetAmount())
|
100 |
-
{
|
101 |
-
print " Amount" . PHP_EOL;
|
102 |
-
print " " . $refundedAmount->getAmount() . PHP_EOL;
|
103 |
-
}
|
104 |
-
if ($refundedAmount->isSetCurrencyCode())
|
105 |
-
{
|
106 |
-
print " CurrencyCode" . PHP_EOL;
|
107 |
-
print " " . $refundedAmount->getCurrencyCode() . PHP_EOL;
|
108 |
-
}
|
109 |
-
}
|
110 |
-
if ($captureDetails->isSetCaptureFee()) {
|
111 |
-
print " CaptureFee" . PHP_EOL;
|
112 |
-
$captureFee = $captureDetails->getCaptureFee();
|
113 |
-
if ($captureFee->isSetAmount())
|
114 |
-
{
|
115 |
-
print " Amount" . PHP_EOL;
|
116 |
-
print " " . $captureFee->getAmount() . PHP_EOL;
|
117 |
-
}
|
118 |
-
if ($captureFee->isSetCurrencyCode())
|
119 |
-
{
|
120 |
-
print " CurrencyCode" . PHP_EOL;
|
121 |
-
print " " . $captureFee->getCurrencyCode() . PHP_EOL;
|
122 |
-
}
|
123 |
-
}
|
124 |
-
if ($captureDetails->isSetIdList()) {
|
125 |
-
print " IdList" . PHP_EOL;
|
126 |
-
$idList = $captureDetails->getIdList();
|
127 |
-
$memberList = $idList->getmember();
|
128 |
-
foreach ($memberList as $member) {
|
129 |
-
print " member" . PHP_EOL;
|
130 |
-
print " " . $member;
|
131 |
-
}
|
132 |
-
}
|
133 |
-
if ($captureDetails->isSetCreationTimestamp())
|
134 |
-
{
|
135 |
-
print " CreationTimestamp" . PHP_EOL;
|
136 |
-
print " " . $captureDetails->getCreationTimestamp() . PHP_EOL;
|
137 |
-
}
|
138 |
-
if ($captureDetails->isSetCaptureStatus()) {
|
139 |
-
print " CaptureStatus" . PHP_EOL;
|
140 |
-
$captureStatus = $captureDetails->getCaptureStatus();
|
141 |
-
if ($captureStatus->isSetState())
|
142 |
-
{
|
143 |
-
print " State" . PHP_EOL;
|
144 |
-
print " " . $captureStatus->getState() . PHP_EOL;
|
145 |
-
}
|
146 |
-
if ($captureStatus->isSetLastUpdateTimestamp())
|
147 |
-
{
|
148 |
-
print " LastUpdateTimestamp" . PHP_EOL;
|
149 |
-
print " " . $captureStatus->getLastUpdateTimestamp() . PHP_EOL;
|
150 |
-
}
|
151 |
-
if ($captureStatus->isSetReasonCode())
|
152 |
-
{
|
153 |
-
print " ReasonCode" . PHP_EOL;
|
154 |
-
print " " . $captureStatus->getReasonCode() . PHP_EOL;
|
155 |
-
}
|
156 |
-
if ($captureStatus->isSetReasonDescription())
|
157 |
-
{
|
158 |
-
print " ReasonDescription" . PHP_EOL;
|
159 |
-
print " " . $captureStatus->getReasonDescription() . PHP_EOL;
|
160 |
-
}
|
161 |
-
}
|
162 |
-
if ($captureDetails->isSetSoftDescriptor())
|
163 |
-
{
|
164 |
-
print " SoftDescriptor" . PHP_EOL;
|
165 |
-
print " " . $captureDetails->getSoftDescriptor() . PHP_EOL;
|
166 |
-
}
|
167 |
-
if($captureDetails->isSetProviderCreditSummaryList())
|
168 |
-
{
|
169 |
-
print " ProviderCreditSummaryList" . PHP_EOL;
|
170 |
-
$providerCreditSummaryList = $captureDetails->getProviderCreditSummaryList();
|
171 |
-
if($providerCreditSummaryList->isSetmember()){
|
172 |
-
$values = $providerCreditSummaryList->getmember();
|
173 |
-
foreach($values as $value){
|
174 |
-
print " ProviderCreditSummary" . PHP_EOL;
|
175 |
-
if($value->isSetProviderId()){
|
176 |
-
print " ProviderId" . PHP_EOL;
|
177 |
-
print " ".$value->getProviderId() . PHP_EOL;
|
178 |
-
}
|
179 |
-
if($value->isSetProviderCreditId()){
|
180 |
-
print " ProviderCreditId" . PHP_EOL;
|
181 |
-
print " ".$value->getProviderCreditId() . PHP_EOL;
|
182 |
-
}
|
183 |
-
}
|
184 |
-
}
|
185 |
-
}
|
186 |
-
}
|
187 |
-
}
|
188 |
-
if ($response->isSetResponseMetadata()) {
|
189 |
-
print " ResponseMetadata" . PHP_EOL;
|
190 |
-
$responseMetadata = $response->getResponseMetadata();
|
191 |
-
if ($responseMetadata->isSetRequestId())
|
192 |
-
{
|
193 |
-
print " RequestId" . PHP_EOL;
|
194 |
-
print " " . $responseMetadata->getRequestId() . PHP_EOL;
|
195 |
-
}
|
196 |
-
}
|
197 |
-
|
198 |
-
print " ResponseHeaderMetadata: " .
|
199 |
-
$response->getResponseHeaderMetadata() . PHP_EOL;
|
200 |
-
|
201 |
-
return $response;
|
202 |
-
}
|
203 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/GetOrderReferenceDetailsSample.php
DELETED
@@ -1,368 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Get Order Reference Details Sample
|
21 |
-
*/
|
22 |
-
|
23 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Verify that the order reference detail is in the expected state
|
27 |
-
*
|
28 |
-
* @param OffAmazonPayments_Model_OrderReferenceDetails in an unverified state
|
29 |
-
* @param string expected state of the object
|
30 |
-
*
|
31 |
-
* @return void
|
32 |
-
* @throws ErrorException if the state does not match the expected state
|
33 |
-
*/
|
34 |
-
function validateOrderReferenceIsInACorrectState($orderReferenceDetails, $expectedState)
|
35 |
-
{
|
36 |
-
$state = $orderReferenceDetails->getOrderReferenceStatus()->getState();
|
37 |
-
if (strcasecmp($state, $expectedState) != 0) {
|
38 |
-
throw new ErrorException(
|
39 |
-
"Error with order reference " .
|
40 |
-
$orderReferenceDetails->getAmazonOrderReferenceId() . " - state is " .
|
41 |
-
$state . " ,expected " . $expectedState . PHP_EOL
|
42 |
-
);
|
43 |
-
}
|
44 |
-
}
|
45 |
-
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Get Order Reference Details Action Sample
|
49 |
-
|
50 |
-
* @param OffAmazonPaymentsService_Interface $service instance of OffAmazonPaymentsService_Interface
|
51 |
-
* @param mixed $request OffAmazonPaymentsService_Model_GetOrderReferenceDetails or array of parameters
|
52 |
-
*/
|
53 |
-
function printGetOrderReferenceDetailsResponse($response)
|
54 |
-
{
|
55 |
-
|
56 |
-
print "Service Response" . PHP_EOL;
|
57 |
-
print "=============================================================================" . PHP_EOL;
|
58 |
-
|
59 |
-
print " GetOrderReferenceDetailsResponse" . PHP_EOL;
|
60 |
-
if ($response->isSetGetOrderReferenceDetailsResult()) {
|
61 |
-
print " GetOrderReferenceDetailsResult" . PHP_EOL;
|
62 |
-
$getOrderReferenceDetailsResult = $response->getGetOrderReferenceDetailsResult();
|
63 |
-
if ($getOrderReferenceDetailsResult->isSetOrderReferenceDetails()) {
|
64 |
-
print " OrderReferenceDetails" . PHP_EOL;
|
65 |
-
$orderReferenceDetails = $getOrderReferenceDetailsResult->getOrderReferenceDetails();
|
66 |
-
if ($orderReferenceDetails->isSetAmazonOrderReferenceId())
|
67 |
-
{
|
68 |
-
print " AmazonOrderReferenceId" . PHP_EOL;
|
69 |
-
print " " . $orderReferenceDetails->getAmazonOrderReferenceId() . PHP_EOL;
|
70 |
-
}
|
71 |
-
if ($orderReferenceDetails->isSetBuyer()) {
|
72 |
-
print " Buyer" . PHP_EOL;
|
73 |
-
$buyer = $orderReferenceDetails->getBuyer();
|
74 |
-
if ($buyer->isSetName())
|
75 |
-
{
|
76 |
-
print " Name" . PHP_EOL;
|
77 |
-
print " " . $buyer->getName() . PHP_EOL;
|
78 |
-
}
|
79 |
-
if ($buyer->isSetEmail())
|
80 |
-
{
|
81 |
-
print " Email" . PHP_EOL;
|
82 |
-
print " " . $buyer->getEmail() . PHP_EOL;
|
83 |
-
}
|
84 |
-
if ($buyer->isSetPhone())
|
85 |
-
{
|
86 |
-
print " Phone" . PHP_EOL;
|
87 |
-
print " " . $buyer->getPhone() . PHP_EOL;
|
88 |
-
}
|
89 |
-
}
|
90 |
-
if ($orderReferenceDetails->isSetOrderTotal()) {
|
91 |
-
print " OrderTotal" . PHP_EOL;
|
92 |
-
$orderTotal = $orderReferenceDetails->getOrderTotal();
|
93 |
-
if ($orderTotal->isSetCurrencyCode())
|
94 |
-
{
|
95 |
-
print " CurrencyCode" . PHP_EOL;
|
96 |
-
print " " . $orderTotal->getCurrencyCode() . PHP_EOL;
|
97 |
-
}
|
98 |
-
if ($orderTotal->isSetAmount())
|
99 |
-
{
|
100 |
-
print " Amount" . PHP_EOL;
|
101 |
-
print " " . $orderTotal->getAmount() . PHP_EOL;
|
102 |
-
}
|
103 |
-
}
|
104 |
-
if ($orderReferenceDetails->isSetSellerNote())
|
105 |
-
{
|
106 |
-
print " SellerNote" . PHP_EOL;
|
107 |
-
print " " . $orderReferenceDetails->getSellerNote() . PHP_EOL;
|
108 |
-
}
|
109 |
-
if ($orderReferenceDetails->isSetDestination()) {
|
110 |
-
print " Destination" . PHP_EOL;
|
111 |
-
$destination = $orderReferenceDetails->getDestination();
|
112 |
-
if ($destination->isSetDestinationType())
|
113 |
-
{
|
114 |
-
print " DestinationType" . PHP_EOL;
|
115 |
-
print " " . $destination->getDestinationType() . PHP_EOL;
|
116 |
-
}
|
117 |
-
if ($destination->isSetPhysicalDestination()) {
|
118 |
-
print " PhysicalDestination" . PHP_EOL;
|
119 |
-
$physicalDestination = $destination->getPhysicalDestination();
|
120 |
-
if ($physicalDestination->isSetName())
|
121 |
-
{
|
122 |
-
print " Name" . PHP_EOL;
|
123 |
-
print " " . $physicalDestination->getName() . PHP_EOL;
|
124 |
-
}
|
125 |
-
if ($physicalDestination->isSetAddressLine1())
|
126 |
-
{
|
127 |
-
print " AddressLine1" . PHP_EOL;
|
128 |
-
print " " . $physicalDestination->getAddressLine1() . PHP_EOL;
|
129 |
-
}
|
130 |
-
if ($physicalDestination->isSetAddressLine2())
|
131 |
-
{
|
132 |
-
print " AddressLine2" . PHP_EOL;
|
133 |
-
print " " . $physicalDestination->getAddressLine2() . PHP_EOL;
|
134 |
-
}
|
135 |
-
if ($physicalDestination->isSetAddressLine3())
|
136 |
-
{
|
137 |
-
print " AddressLine3" . PHP_EOL;
|
138 |
-
print " " . $physicalDestination->getAddressLine3() . PHP_EOL;
|
139 |
-
}
|
140 |
-
if ($physicalDestination->isSetCity())
|
141 |
-
{
|
142 |
-
print " City" . PHP_EOL;
|
143 |
-
print " " . $physicalDestination->getCity() . PHP_EOL;
|
144 |
-
}
|
145 |
-
if ($physicalDestination->isSetCounty())
|
146 |
-
{
|
147 |
-
print " County" . PHP_EOL;
|
148 |
-
print " " . $physicalDestination->getCounty() . PHP_EOL;
|
149 |
-
}
|
150 |
-
if ($physicalDestination->isSetDistrict())
|
151 |
-
{
|
152 |
-
print " District" . PHP_EOL;
|
153 |
-
print " " . $physicalDestination->getDistrict() . PHP_EOL;
|
154 |
-
}
|
155 |
-
if ($physicalDestination->isSetStateOrRegion())
|
156 |
-
{
|
157 |
-
print " StateOrRegion" . PHP_EOL;
|
158 |
-
print " " . $physicalDestination->getStateOrRegion() . PHP_EOL;
|
159 |
-
}
|
160 |
-
if ($physicalDestination->isSetPostalCode())
|
161 |
-
{
|
162 |
-
print " PostalCode" . PHP_EOL;
|
163 |
-
print " " . $physicalDestination->getPostalCode() . PHP_EOL;
|
164 |
-
}
|
165 |
-
if ($physicalDestination->isSetCountryCode())
|
166 |
-
{
|
167 |
-
print " CountryCode" . PHP_EOL;
|
168 |
-
print " " . $physicalDestination->getCountryCode() . PHP_EOL;
|
169 |
-
}
|
170 |
-
if ($physicalDestination->isSetPhone())
|
171 |
-
{
|
172 |
-
print " Phone" . PHP_EOL;
|
173 |
-
print " " . $physicalDestination->getPhone() . PHP_EOL;
|
174 |
-
}
|
175 |
-
}
|
176 |
-
}
|
177 |
-
if ($orderReferenceDetails->isSetBillingAddress()) {
|
178 |
-
echo (" BillingAddress\n");
|
179 |
-
$billingAddress = $orderReferenceDetails->getBillingAddress();
|
180 |
-
if ($billingAddress->isSetAddressType()) {
|
181 |
-
echo (" AddressType\n");
|
182 |
-
echo (" " . $billingAddress->getAddressType() . "\n");
|
183 |
-
}
|
184 |
-
if ($billingAddress->isSetPhysicalAddress()) {
|
185 |
-
echo (" PhysicalAddress\n");
|
186 |
-
$physicalAddress = $billingAddress->getPhysicalAddress();
|
187 |
-
if ($physicalAddress->isSetName()) {
|
188 |
-
echo (" Name\n");
|
189 |
-
echo (" " . $physicalAddress->getName() .
|
190 |
-
"\n");
|
191 |
-
}
|
192 |
-
if ($physicalAddress->isSetAddressLine1()) {
|
193 |
-
echo (" AddressLine1\n");
|
194 |
-
echo (" " .
|
195 |
-
$physicalAddress->getAddressLine1() . "\n");
|
196 |
-
}
|
197 |
-
if ($physicalAddress->isSetAddressLine2()) {
|
198 |
-
echo (" AddressLine2\n");
|
199 |
-
echo (" " .
|
200 |
-
$physicalAddress->getAddressLine2() . "\n");
|
201 |
-
}
|
202 |
-
if ($physicalAddress->isSetAddressLine3()) {
|
203 |
-
echo (" AddressLine3\n");
|
204 |
-
echo (" " .
|
205 |
-
$physicalAddress->getAddressLine3() . "\n");
|
206 |
-
}
|
207 |
-
if ($physicalAddress->isSetCity()) {
|
208 |
-
echo (" City\n");
|
209 |
-
echo (" " . $physicalAddress->getCity() .
|
210 |
-
"\n");
|
211 |
-
}
|
212 |
-
if ($physicalAddress->isSetCounty()) {
|
213 |
-
echo (" County\n");
|
214 |
-
echo (" " . $physicalAddress->getCounty() .
|
215 |
-
"\n");
|
216 |
-
}
|
217 |
-
if ($physicalAddress->isSetDistrict()) {
|
218 |
-
echo (" District\n");
|
219 |
-
echo (" " .
|
220 |
-
$physicalAddress->getDistrict() . "\n");
|
221 |
-
}
|
222 |
-
if ($physicalAddress->isSetStateOrRegion()) {
|
223 |
-
echo (" StateOrRegion\n");
|
224 |
-
echo (" " .
|
225 |
-
$physicalAddress->getStateOrRegion() . "\n");
|
226 |
-
}
|
227 |
-
if ($physicalAddress->isSetPostalCode()) {
|
228 |
-
echo (" PostalCode\n");
|
229 |
-
echo (" " .
|
230 |
-
$physicalAddress->getPostalCode() . "\n");
|
231 |
-
}
|
232 |
-
if ($physicalAddress->isSetCountryCode()) {
|
233 |
-
echo (" CountryCode\n");
|
234 |
-
echo (" " .
|
235 |
-
$physicalAddress->getCountryCode() . "\n");
|
236 |
-
}
|
237 |
-
if ($physicalAddress->isSetPhone()) {
|
238 |
-
echo (" Phone\n");
|
239 |
-
echo (" " . $physicalAddress->getPhone() .
|
240 |
-
"\n");
|
241 |
-
}
|
242 |
-
}
|
243 |
-
}
|
244 |
-
if ($orderReferenceDetails->isSetReleaseEnvironment())
|
245 |
-
{
|
246 |
-
print " ReleaseEnvironment" . PHP_EOL;
|
247 |
-
print " " . $orderReferenceDetails->getReleaseEnvironment() . PHP_EOL;
|
248 |
-
}
|
249 |
-
if ($orderReferenceDetails->isSetSellerOrderAttributes()) {
|
250 |
-
print " SellerOrderAttributes" . PHP_EOL;
|
251 |
-
$sellerOrderAttributes = $orderReferenceDetails->getSellerOrderAttributes();
|
252 |
-
if ($sellerOrderAttributes->isSetSellerOrderId())
|
253 |
-
{
|
254 |
-
print " SellerOrderId" . PHP_EOL;
|
255 |
-
print " " . $sellerOrderAttributes->getSellerOrderId() . PHP_EOL;
|
256 |
-
}
|
257 |
-
if ($sellerOrderAttributes->isSetStoreName())
|
258 |
-
{
|
259 |
-
print " StoreName" . PHP_EOL;
|
260 |
-
print " " . $sellerOrderAttributes->getStoreName() . PHP_EOL;
|
261 |
-
}
|
262 |
-
if ($sellerOrderAttributes->isSetOrderItemCategories()) {
|
263 |
-
print " OrderItemCategories" . PHP_EOL;
|
264 |
-
$orderItemCategories = $sellerOrderAttributes->getOrderItemCategories();
|
265 |
-
$orderItemCategoryList = $orderItemCategories->getOrderItemCategory();
|
266 |
-
foreach ($orderItemCategoryList as $orderItemCategory) {
|
267 |
-
print " OrderItemCategory" . PHP_EOL;
|
268 |
-
print " " . $orderItemCategory;
|
269 |
-
}
|
270 |
-
}
|
271 |
-
if ($sellerOrderAttributes->isSetCustomInformation())
|
272 |
-
{
|
273 |
-
print " CustomInformation" . PHP_EOL;
|
274 |
-
print " " . $sellerOrderAttributes->getCustomInformation() . PHP_EOL;
|
275 |
-
}
|
276 |
-
}
|
277 |
-
if ($orderReferenceDetails->isSetIdList())
|
278 |
-
{
|
279 |
-
print " IdList" . PHP_EOL;
|
280 |
-
$idList = $orderReferenceDetails->getIdList();
|
281 |
-
$memberList = $idList->getmember();
|
282 |
-
foreach ($memberList as $member) {
|
283 |
-
print " member" . PHP_EOL;
|
284 |
-
print " " . $member . PHP_EOL;;
|
285 |
-
}
|
286 |
-
}
|
287 |
-
if ($orderReferenceDetails->isSetOrderReferenceStatus()) {
|
288 |
-
print " OrderReferenceStatus" . PHP_EOL;
|
289 |
-
$orderReferenceStatus = $orderReferenceDetails->getOrderReferenceStatus();
|
290 |
-
if ($orderReferenceStatus->isSetState())
|
291 |
-
{
|
292 |
-
print " State" . PHP_EOL;
|
293 |
-
print " " . $orderReferenceStatus->getState() . PHP_EOL;
|
294 |
-
}
|
295 |
-
if ($orderReferenceStatus->isSetLastUpdateTimestamp())
|
296 |
-
{
|
297 |
-
print " LastUpdateTimestamp" . PHP_EOL;
|
298 |
-
print " " . $orderReferenceStatus->getLastUpdateTimestamp() . PHP_EOL;
|
299 |
-
}
|
300 |
-
if ($orderReferenceStatus->isSetReasonCode())
|
301 |
-
{
|
302 |
-
print " ReasonCode" . PHP_EOL;
|
303 |
-
print " " . $orderReferenceStatus->getReasonCode() . PHP_EOL;
|
304 |
-
}
|
305 |
-
if ($orderReferenceStatus->isSetReasonDescription())
|
306 |
-
{
|
307 |
-
print " ReasonDescription" . PHP_EOL;
|
308 |
-
print " " . $orderReferenceStatus->getReasonDescription() . PHP_EOL;
|
309 |
-
}
|
310 |
-
}
|
311 |
-
if ($orderReferenceDetails->isSetConstraints()) {
|
312 |
-
print " Constraints" . PHP_EOL;
|
313 |
-
$constraints = $orderReferenceDetails->getConstraints();
|
314 |
-
$constraintList = $constraints->getConstraint();
|
315 |
-
foreach ($constraintList as $constraint) {
|
316 |
-
print " Constraint" . PHP_EOL;
|
317 |
-
if ($constraint->isSetConstraintID())
|
318 |
-
{
|
319 |
-
print " ConstraintID" . PHP_EOL;
|
320 |
-
print " " . $constraint->getConstraintID() . PHP_EOL;
|
321 |
-
}
|
322 |
-
if ($constraint->isSetDescription())
|
323 |
-
{
|
324 |
-
print " Description" . PHP_EOL;
|
325 |
-
print " " . $constraint->getDescription() . PHP_EOL;
|
326 |
-
}
|
327 |
-
}
|
328 |
-
}
|
329 |
-
if ($orderReferenceDetails->isSetCreationTimestamp())
|
330 |
-
{
|
331 |
-
print " CreationTimestamp" . PHP_EOL;
|
332 |
-
print " " . $orderReferenceDetails->getCreationTimestamp() . PHP_EOL;
|
333 |
-
}
|
334 |
-
if ($orderReferenceDetails->isSetExpirationTimestamp())
|
335 |
-
{
|
336 |
-
print " ExpirationTimestamp" . PHP_EOL;
|
337 |
-
print " " . $orderReferenceDetails->getExpirationTimestamp() . PHP_EOL;
|
338 |
-
}
|
339 |
-
if ($orderReferenceDetails->isSetParentDetails()) {
|
340 |
-
print " ParentDetails" . PHP_EOL;
|
341 |
-
$parentDetails = $orderReferenceDetails->getParentDetails();
|
342 |
-
if ($parentDetails->isSetId()) {
|
343 |
-
print " Id" . PHP_EOL;
|
344 |
-
print " " . $parentDetails->getId() . PHP_EOL;
|
345 |
-
}
|
346 |
-
if ($parentDetails->isSetType()) {
|
347 |
-
print " Type" . PHP_EOL;
|
348 |
-
print " " . $parentDetails->getType() . PHP_EOL;
|
349 |
-
}
|
350 |
-
}
|
351 |
-
}
|
352 |
-
}
|
353 |
-
if ($response->isSetResponseMetadata()) {
|
354 |
-
print " ResponseMetadata" . PHP_EOL;
|
355 |
-
$responseMetadata = $response->getResponseMetadata();
|
356 |
-
if ($responseMetadata->isSetRequestId())
|
357 |
-
{
|
358 |
-
print " RequestId" . PHP_EOL;
|
359 |
-
print " " . $responseMetadata->getRequestId() . PHP_EOL;
|
360 |
-
}
|
361 |
-
}
|
362 |
-
|
363 |
-
print " ResponseHeaderMetadata: " .
|
364 |
-
$response->getResponseHeaderMetadata() . PHP_EOL;
|
365 |
-
|
366 |
-
return $response;
|
367 |
-
}
|
368 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/GetProviderCreditDetailsSample.php
DELETED
@@ -1,115 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
/**
|
19 |
-
* GetProviderCreditDetails Sample
|
20 |
-
*/
|
21 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/.config.inc.php';
|
22 |
-
|
23 |
-
/**
|
24 |
-
* GetProviderCreditDetails Sample
|
25 |
-
*/
|
26 |
-
function printProviderCreditDetailsResponse($response) {
|
27 |
-
print "Service Response" . PHP_EOL;
|
28 |
-
print "=============================================================================" . PHP_EOL;
|
29 |
-
if ($response->isSetGetProviderCreditDetailsResult ()) {
|
30 |
-
print " GetProviderCreditDetailsResult" . PHP_EOL;
|
31 |
-
$getProviderCreditDetailsResult = $response->getGetProviderCreditDetailsResult ();
|
32 |
-
if ($getProviderCreditDetailsResult->isSetProviderCreditDetails ()) {
|
33 |
-
print " ProviderCreditDetails" . PHP_EOL;
|
34 |
-
$providerCreditDetails = $getProviderCreditDetailsResult->getProviderCreditDetails ();
|
35 |
-
if ($providerCreditDetails->isSetAmazonProviderCreditId ()) {
|
36 |
-
print " AmazonProviderCreditId" . PHP_EOL;
|
37 |
-
print " " . $providerCreditDetails->getAmazonProviderCreditId () . PHP_EOL;
|
38 |
-
}
|
39 |
-
if ($providerCreditDetails->isSetCreditReferenceId ()) {
|
40 |
-
print " CreditReferenceId" . PHP_EOL;
|
41 |
-
print " " . $providerCreditDetails->getCreditReferenceId () . PHP_EOL;
|
42 |
-
}
|
43 |
-
if ($providerCreditDetails->isSetCreditAmount ()) {
|
44 |
-
print " CreditAmount" . PHP_EOL;
|
45 |
-
$creditAmount = $providerCreditDetails->getCreditAmount ();
|
46 |
-
if ($creditAmount->isSetAmount ()) {
|
47 |
-
print " Amount" . PHP_EOL;
|
48 |
-
print " " . $creditAmount->getAmount () . PHP_EOL;
|
49 |
-
}
|
50 |
-
if ($creditAmount->isSetCurrencyCode ()) {
|
51 |
-
print " CurrencyCode" . PHP_EOL;
|
52 |
-
print " " . $creditAmount->getCurrencyCode () . PHP_EOL;
|
53 |
-
}
|
54 |
-
}
|
55 |
-
if ($providerCreditDetails->isSetCreditReversalAmount ()) {
|
56 |
-
print " CreditReversalAmount" . PHP_EOL;
|
57 |
-
$creditReversalAmount = $providerCreditDetails->getCreditReversalAmount ();
|
58 |
-
if ($creditReversalAmount->isSetAmount ()) {
|
59 |
-
print " Amount" . PHP_EOL;
|
60 |
-
print " " . $creditReversalAmount->getAmount () . PHP_EOL;
|
61 |
-
}
|
62 |
-
if ($creditReversalAmount->isSetCurrencyCode ()) {
|
63 |
-
print " CurrencyCode" . PHP_EOL;
|
64 |
-
print " " . $creditReversalAmount->getCurrencyCode () . PHP_EOL;
|
65 |
-
}
|
66 |
-
}
|
67 |
-
if ($providerCreditDetails->isSetCreditReversalIdList ()) {
|
68 |
-
print " CreditReversalIdList" . PHP_EOL;
|
69 |
-
$idList = $providerCreditDetails->getCreditReversalIdList ();
|
70 |
-
$memberList = $idList->getmember ();
|
71 |
-
foreach ( $memberList as $member ) {
|
72 |
-
print " member" . PHP_EOL;
|
73 |
-
print " " . $member . PHP_EOL;
|
74 |
-
}
|
75 |
-
}
|
76 |
-
if ($providerCreditDetails->isSetCreationTimestamp ()) {
|
77 |
-
print " CreationTimestamp" . PHP_EOL;
|
78 |
-
print " " . $providerCreditDetails->getCreationTimestamp () . PHP_EOL;
|
79 |
-
}
|
80 |
-
if ($providerCreditDetails->isSetCreditStatus ()) {
|
81 |
-
print " CreditStatus" . PHP_EOL;
|
82 |
-
$creditStatus = $providerCreditDetails->getCreditStatus ();
|
83 |
-
if ($creditStatus->isSetState ()) {
|
84 |
-
print " State" . PHP_EOL;
|
85 |
-
print " " . $creditStatus->getState () . PHP_EOL;
|
86 |
-
}
|
87 |
-
if ($creditStatus->isSetLastUpdateTimestamp ()) {
|
88 |
-
print " LastUpdateTimestamp" . PHP_EOL;
|
89 |
-
print " " . $creditStatus->getLastUpdateTimestamp () . PHP_EOL;
|
90 |
-
}
|
91 |
-
if ($creditStatus->isSetReasonCode ()) {
|
92 |
-
print " ReasonCode" . PHP_EOL;
|
93 |
-
print " " . $creditStatus->getReasonCode () . PHP_EOL;
|
94 |
-
}
|
95 |
-
if ($creditStatus->isSetReasonDescription ()) {
|
96 |
-
print " ReasonDescription" . PHP_EOL;
|
97 |
-
print " " . $creditStatus->getReasonDescription () . PHP_EOL;
|
98 |
-
}
|
99 |
-
}
|
100 |
-
}
|
101 |
-
}
|
102 |
-
if ($response->isSetResponseMetadata ()) {
|
103 |
-
print " ResponseMetadata" . PHP_EOL;
|
104 |
-
$responseMetadata = $response->getResponseMetadata ();
|
105 |
-
if ($responseMetadata->isSetRequestId ()) {
|
106 |
-
print " RequestId" . PHP_EOL;
|
107 |
-
print " " . $responseMetadata->getRequestId () . PHP_EOL;
|
108 |
-
}
|
109 |
-
}
|
110 |
-
|
111 |
-
print " ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata () . PHP_EOL;
|
112 |
-
|
113 |
-
return $response;
|
114 |
-
}
|
115 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/GetProviderCreditReversalDetailsSample.php
DELETED
@@ -1,99 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
/**
|
19 |
-
* GetProviderCreditReversalDetails Sample
|
20 |
-
*/
|
21 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/.config.inc.php';
|
22 |
-
|
23 |
-
/**
|
24 |
-
* GetProviderCreditReversalDetails Sample
|
25 |
-
*/
|
26 |
-
function printGetProviderCreditReversalDetailsResponse($response) {
|
27 |
-
print "Service Response" . PHP_EOL;
|
28 |
-
print "=============================================================================" . PHP_EOL;
|
29 |
-
|
30 |
-
if ($response->isSetGetProviderCreditReversalDetailsResult ()) {
|
31 |
-
print " GetProviderCreditReversalDetailsResult" . PHP_EOL;
|
32 |
-
$getProviderCreditReversalDetailsResult = $response->getGetProviderCreditReversalDetailsResult ();
|
33 |
-
if ($getProviderCreditReversalDetailsResult->isSetProviderCreditReversalDetails ()) {
|
34 |
-
print " ProviderCreditReversalDetails" . PHP_EOL;
|
35 |
-
$providerCreditReversalDetails = $getProviderCreditReversalDetailsResult->getProviderCreditReversalDetails ();
|
36 |
-
if ($providerCreditReversalDetails->isSetAmazonProviderCreditReversalId ()) {
|
37 |
-
print " AmazonProviderCreditReversalId" . PHP_EOL;
|
38 |
-
print " " . $providerCreditReversalDetails->getAmazonProviderCreditReversalId () . PHP_EOL;
|
39 |
-
}
|
40 |
-
if ($providerCreditReversalDetails->isSetCreditReversalReferenceId ()) {
|
41 |
-
print " CreditReversalReferenceId" . PHP_EOL;
|
42 |
-
print " " . $providerCreditReversalDetails->getCreditReversalReferenceId () . PHP_EOL;
|
43 |
-
}
|
44 |
-
if ($providerCreditReversalDetails->isSetCreditReversalAmount ()) {
|
45 |
-
print " CreditReversalAmount" . PHP_EOL;
|
46 |
-
$creditReversalAmount = $providerCreditReversalDetails->getCreditReversalAmount ();
|
47 |
-
if ($creditReversalAmount->isSetAmount ()) {
|
48 |
-
print " Amount" . PHP_EOL;
|
49 |
-
print " " . $creditReversalAmount->getAmount () . PHP_EOL;
|
50 |
-
}
|
51 |
-
if ($creditReversalAmount->isSetCurrencyCode ()) {
|
52 |
-
print " CurrencyCode" . PHP_EOL;
|
53 |
-
print " " . $creditReversalAmount->getCurrencyCode () . PHP_EOL;
|
54 |
-
}
|
55 |
-
}
|
56 |
-
if ($providerCreditReversalDetails->isSetCreationTimestamp ()) {
|
57 |
-
print " CreationTimestamp" . PHP_EOL;
|
58 |
-
print " " . $providerCreditReversalDetails->getCreationTimestamp () . PHP_EOL;
|
59 |
-
}
|
60 |
-
if ($providerCreditReversalDetails->isSetCreditReversalStatus ()) {
|
61 |
-
print " CreditReversalStatus" . PHP_EOL;
|
62 |
-
$creditStatus = $providerCreditReversalDetails->getCreditReversalStatus ();
|
63 |
-
if ($creditStatus->isSetState ()) {
|
64 |
-
print " State" . PHP_EOL;
|
65 |
-
print " " . $creditStatus->getState () . PHP_EOL;
|
66 |
-
}
|
67 |
-
if ($creditStatus->isSetLastUpdateTimestamp ()) {
|
68 |
-
print " LastUpdateTimestamp" . PHP_EOL;
|
69 |
-
print " " . $creditStatus->getLastUpdateTimestamp () . PHP_EOL;
|
70 |
-
}
|
71 |
-
if ($creditStatus->isSetReasonCode ()) {
|
72 |
-
print " ReasonCode" . PHP_EOL;
|
73 |
-
print " " . $creditStatus->getReasonCode () . PHP_EOL;
|
74 |
-
}
|
75 |
-
if ($creditStatus->isSetReasonDescription ()) {
|
76 |
-
print " ReasonDescription" . PHP_EOL;
|
77 |
-
print " " . $creditStatus->getReasonDescription () . PHP_EOL;
|
78 |
-
}
|
79 |
-
}
|
80 |
-
if ($providerCreditReversalDetails->isSetCreditReversalNote()) {
|
81 |
-
print " CreditReversalNote" . PHP_EOL;
|
82 |
-
print " " . $providerCreditReversalDetails->getCreditReversalNote() . PHP_EOL;
|
83 |
-
}
|
84 |
-
}
|
85 |
-
}
|
86 |
-
if ($response->isSetResponseMetadata ()) {
|
87 |
-
print " ResponseMetadata" . PHP_EOL;
|
88 |
-
$responseMetadata = $response->getResponseMetadata ();
|
89 |
-
if ($responseMetadata->isSetRequestId ()) {
|
90 |
-
print " RequestId" . PHP_EOL;
|
91 |
-
print " " . $responseMetadata->getRequestId () . PHP_EOL;
|
92 |
-
}
|
93 |
-
}
|
94 |
-
|
95 |
-
print " ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata () . PHP_EOL;
|
96 |
-
|
97 |
-
return $response;
|
98 |
-
}
|
99 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/GetRefundDetailsSample.php
DELETED
@@ -1,162 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Get Refund Details Sample
|
21 |
-
*/
|
22 |
-
|
23 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Get Refund Details Action Sample
|
27 |
-
|
28 |
-
* @param OffAmazonPaymentsService_Interface $service instance of OffAmazonPaymentsService_Interface
|
29 |
-
* @param mixed $request OffAmazonPaymentsService_Model_GetRefundDetails or array of parameters
|
30 |
-
*/
|
31 |
-
function printGetRefundDetailsResponse($response)
|
32 |
-
{
|
33 |
-
|
34 |
-
print "Service Response" . PHP_EOL;
|
35 |
-
print "=============================================================================" . PHP_EOL;
|
36 |
-
|
37 |
-
print " GetRefundDetailsResponse" . PHP_EOL;
|
38 |
-
if ($response->isSetGetRefundDetailsResult()) {
|
39 |
-
print " GetRefundDetailsResult" . PHP_EOL;
|
40 |
-
$getRefundDetailsResult = $response->getGetRefundDetailsResult();
|
41 |
-
if ($getRefundDetailsResult->isSetRefundDetails()) {
|
42 |
-
print " RefundDetails" . PHP_EOL;
|
43 |
-
$refundDetails = $getRefundDetailsResult->getRefundDetails();
|
44 |
-
if ($refundDetails->isSetAmazonRefundId())
|
45 |
-
{
|
46 |
-
print " AmazonRefundId" . PHP_EOL;
|
47 |
-
print " " . $refundDetails->getAmazonRefundId() . PHP_EOL;
|
48 |
-
}
|
49 |
-
if ($refundDetails->isSetRefundReferenceId())
|
50 |
-
{
|
51 |
-
print " RefundReferenceId" . PHP_EOL;
|
52 |
-
print " " . $refundDetails->getRefundReferenceId() . PHP_EOL;
|
53 |
-
}
|
54 |
-
if ($refundDetails->isSetSellerRefundNote())
|
55 |
-
{
|
56 |
-
print " SellerRefundNote" . PHP_EOL;
|
57 |
-
print " " . $refundDetails->getSellerRefundNote() . PHP_EOL;
|
58 |
-
}
|
59 |
-
if ($refundDetails->isSetRefundType())
|
60 |
-
{
|
61 |
-
print " RefundType" . PHP_EOL;
|
62 |
-
print " " . $refundDetails->getRefundType() . PHP_EOL;
|
63 |
-
}
|
64 |
-
if ($refundDetails->isSetRefundAmount()) {
|
65 |
-
print " RefundAmount" . PHP_EOL;
|
66 |
-
$refundAmount = $refundDetails->getRefundAmount();
|
67 |
-
if ($refundAmount->isSetAmount())
|
68 |
-
{
|
69 |
-
print " Amount" . PHP_EOL;
|
70 |
-
print " " . $refundAmount->getAmount() . PHP_EOL;
|
71 |
-
}
|
72 |
-
if ($refundAmount->isSetCurrencyCode())
|
73 |
-
{
|
74 |
-
print " CurrencyCode" . PHP_EOL;
|
75 |
-
print " " . $refundAmount->getCurrencyCode() . PHP_EOL;
|
76 |
-
}
|
77 |
-
}
|
78 |
-
if ($refundDetails->isSetFeeRefunded()) {
|
79 |
-
print " FeeRefunded" . PHP_EOL;
|
80 |
-
$feeRefunded = $refundDetails->getFeeRefunded();
|
81 |
-
if ($feeRefunded->isSetAmount())
|
82 |
-
{
|
83 |
-
print " Amount" . PHP_EOL;
|
84 |
-
print " " . $feeRefunded->getAmount() . PHP_EOL;
|
85 |
-
}
|
86 |
-
if ($feeRefunded->isSetCurrencyCode())
|
87 |
-
{
|
88 |
-
print " CurrencyCode" . PHP_EOL;
|
89 |
-
print " " . $feeRefunded->getCurrencyCode() . PHP_EOL;
|
90 |
-
}
|
91 |
-
}
|
92 |
-
if ($refundDetails->isSetCreationTimestamp())
|
93 |
-
{
|
94 |
-
print " CreationTimestamp" . PHP_EOL;
|
95 |
-
print " " . $refundDetails->getCreationTimestamp() . PHP_EOL;
|
96 |
-
}
|
97 |
-
if ($refundDetails->isSetRefundStatus()) {
|
98 |
-
print " RefundStatus" . PHP_EOL;
|
99 |
-
$refundStatus = $refundDetails->getRefundStatus();
|
100 |
-
if ($refundStatus->isSetState())
|
101 |
-
{
|
102 |
-
print " State" . PHP_EOL;
|
103 |
-
print " " . $refundStatus->getState() . PHP_EOL;
|
104 |
-
}
|
105 |
-
if ($refundStatus->isSetLastUpdateTimestamp())
|
106 |
-
{
|
107 |
-
print " LastUpdateTimestamp" . PHP_EOL;
|
108 |
-
print " " . $refundStatus->getLastUpdateTimestamp() . PHP_EOL;
|
109 |
-
}
|
110 |
-
if ($refundStatus->isSetReasonCode())
|
111 |
-
{
|
112 |
-
print " ReasonCode" . PHP_EOL;
|
113 |
-
print " " . $refundStatus->getReasonCode() . PHP_EOL;
|
114 |
-
}
|
115 |
-
if ($refundStatus->isSetReasonDescription())
|
116 |
-
{
|
117 |
-
print " ReasonDescription" . PHP_EOL;
|
118 |
-
print " " . $refundStatus->getReasonDescription() . PHP_EOL;
|
119 |
-
}
|
120 |
-
}
|
121 |
-
if ($refundDetails->isSetSoftDescriptor())
|
122 |
-
{
|
123 |
-
print " SoftDescriptor" . PHP_EOL;
|
124 |
-
print " " . $refundDetails->getSoftDescriptor() . PHP_EOL;
|
125 |
-
}
|
126 |
-
if($refundDetails->isSetProviderCreditReversalSummaryList())
|
127 |
-
{
|
128 |
-
print " ProviderCreditReversalSummaryList" . PHP_EOL;
|
129 |
-
$providerCreditReversalSummaryList = $refundDetails->getProviderCreditReversalSummaryList();
|
130 |
-
if($providerCreditReversalSummaryList->isSetmember()){
|
131 |
-
$values = $providerCreditReversalSummaryList->getmember();
|
132 |
-
foreach($values as $value){
|
133 |
-
print " ProviderCreditReversalSummary" . PHP_EOL;
|
134 |
-
if($value->isSetProviderId()){
|
135 |
-
print " ProviderId" . PHP_EOL;
|
136 |
-
print " ".$value->getProviderId() . PHP_EOL;
|
137 |
-
}
|
138 |
-
if($value->isSetProviderCreditReversalId()){
|
139 |
-
print " ProviderCreditReversalId" . PHP_EOL;
|
140 |
-
print " ".$value->getProviderCreditReversalId() . PHP_EOL;
|
141 |
-
}
|
142 |
-
}
|
143 |
-
}
|
144 |
-
}
|
145 |
-
}
|
146 |
-
}
|
147 |
-
if ($response->isSetResponseMetadata()) {
|
148 |
-
print " ResponseMetadata" . PHP_EOL;
|
149 |
-
$responseMetadata = $response->getResponseMetadata();
|
150 |
-
if ($responseMetadata->isSetRequestId())
|
151 |
-
{
|
152 |
-
print " RequestId" . PHP_EOL;
|
153 |
-
print " " . $responseMetadata->getRequestId() . PHP_EOL;
|
154 |
-
}
|
155 |
-
}
|
156 |
-
|
157 |
-
print " ResponseHeaderMetadata: " .
|
158 |
-
$response->getResponseHeaderMetadata() . PHP_EOL;
|
159 |
-
|
160 |
-
return $response;
|
161 |
-
}
|
162 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/ProviderCheckoutExampleCLI.php
DELETED
@@ -1,322 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at: http://aws.amazon.com/apache2.0 This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
4 |
-
*/
|
5 |
-
|
6 |
-
/*
|
7 |
-
* Straight checkout example command line example
|
8 |
-
*
|
9 |
-
* This class drives the simple checkout example from a command line interface
|
10 |
-
* See SimpleCheckoutExample.php for more information
|
11 |
-
*/
|
12 |
-
|
13 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/.config.inc.php';
|
14 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/GetOrderReferenceDetailsSample.php';
|
15 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/SetOrderReferenceDetailsSample.php';
|
16 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/ConfirmOrderReferenceSample.php';
|
17 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/AuthorizeSample.php';
|
18 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/GetAuthorizationDetailsSample.php';
|
19 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/GetCaptureDetailsSample.php';
|
20 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/CaptureSample.php';
|
21 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/CloseOrderReferenceSample.php';
|
22 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/GetProviderCreditDetailsSample.php';
|
23 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/CLIExample.php';
|
24 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/SimpleCheckoutExample.php';
|
25 |
-
|
26 |
-
/*
|
27 |
-
* ProviderCheckoutExampleCLI class captures input from stdin and prints to stdout, and drives the simple checkout example
|
28 |
-
*/
|
29 |
-
class ProviderCheckoutExampleCLI extends CLIExample {
|
30 |
-
/**
|
31 |
-
* Create a new instance of the cli example and
|
32 |
-
* validate command line arguments
|
33 |
-
*
|
34 |
-
* @param array $argv
|
35 |
-
* arguments to the appplication passed from the command line
|
36 |
-
*/
|
37 |
-
public function __construct($argv) {
|
38 |
-
if (count ( $argv ) < 1) {
|
39 |
-
print "Missing mandatory argument: " . "please provide an amazonOrderReferenceId";
|
40 |
-
exit ( 0 );
|
41 |
-
}
|
42 |
-
|
43 |
-
/*
|
44 |
-
* Instantiate Implementation of OffAmazonPaymentsService client Merchant ids and access keys are defined in the constants are defined in the OffAmazonPaymentsService.config.inc.php file in the parent directory of this server
|
45 |
-
*/
|
46 |
-
$this->exampleClass = new SimpleCheckoutExample ( new OffAmazonPaymentsService_Client (), $argv [1] );
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Run all the steps for the sample in sequence
|
51 |
-
*/
|
52 |
-
public function runSample() {
|
53 |
-
$orderTotal = $this->_calculateOrderTotalBasedOnBuyerDestinationAddress ();
|
54 |
-
$this->_addOrderTotalAndSellerInformationToOrder($orderTotal);
|
55 |
-
$this->_confirmOrderReference();
|
56 |
-
$amazonAuthorizationId = $this->_authorizeBasedOnOptionSelected($orderTotal);
|
57 |
-
$amazonCaptureId = $this->_captureOrderAmount($orderTotal, $amazonAuthorizationId);
|
58 |
-
$providerCreditSummaryList = $this->_waitForProviderCreditSummaryList($amazonCaptureId);
|
59 |
-
$this->_getProviderCreditDetails($providerCreditSummaryList);
|
60 |
-
$this->_closeOrderReference();
|
61 |
-
print "Provider Checkout Completed" . PHP_EOL;
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Retreive the current information about the order as indicated by the buyer
|
66 |
-
* and calculate the total amount to charge, based on address destination state
|
67 |
-
* and country
|
68 |
-
*
|
69 |
-
* @return string total amount for the order that the merchant will
|
70 |
-
* charge the buyer
|
71 |
-
*/
|
72 |
-
private function _calculateOrderTotalBasedOnBuyerDestinationAddress()
|
73 |
-
{
|
74 |
-
$response = $this->callStepAndCheckForException('getOrderReferenceDetails');
|
75 |
-
printGetOrderReferenceDetailsResponse($response);
|
76 |
-
|
77 |
-
$orderTotalPreTaxAndShipping
|
78 |
-
= $this->_getPreTaxAndShippingOrderAmountFromStdIn();
|
79 |
-
$shippingType = $this->_getShippingTypeFromStdIn();
|
80 |
-
return $this->exampleClass->calculateOrderTotalBasedOnBuyerDetails(
|
81 |
-
$response->getGetOrderReferenceDetailsResult()->getOrderReferenceDetails(),
|
82 |
-
$orderTotalPreTaxAndShipping,
|
83 |
-
$shippingType
|
84 |
-
);
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Add order information by making the call to setOrderReferenceDetails with
|
89 |
-
* the total order amount, as well as notes describing the order information
|
90 |
-
*
|
91 |
-
* @param float $orderTotal total value of the order, incl shipping and tax
|
92 |
-
*
|
93 |
-
*/
|
94 |
-
private function _addOrderTotalAndSellerInformationToOrder($orderTotal)
|
95 |
-
{
|
96 |
-
$response
|
97 |
-
= $this->callStepAndCheckForException(
|
98 |
-
'addOrderTotalAndSellerInformationToOrder',
|
99 |
-
array($orderTotal)
|
100 |
-
);
|
101 |
-
printSetOrderReferenceDetailsResponse($response);
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Confirm the order reference information, allowing for
|
106 |
-
* authorizations and captures to be created
|
107 |
-
*
|
108 |
-
*
|
109 |
-
*/
|
110 |
-
private function _confirmOrderReference()
|
111 |
-
{
|
112 |
-
$response = $this->callStepAndCheckForException('confirmOrderReference');
|
113 |
-
printConfirmOrderReferenceResponse($response);
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Perform Authorize using Regular Authorization or Fast Authorization
|
118 |
-
*
|
119 |
-
* @param float $authorizationAmount amount to authorize from the buyer
|
120 |
-
*
|
121 |
-
* @return string amazonAuthorizationId amazon generated authorization id reference
|
122 |
-
*/
|
123 |
-
private function _authorizeBasedOnOptionSelected($authorizationAmount)
|
124 |
-
{
|
125 |
-
$authOption = $this->_getAuthOptionFromStdIn();
|
126 |
-
$amazonAuthorizationId = $this->_authorizeOrderAmount($authorizationAmount, $authOption);
|
127 |
-
if($authOption != 2){
|
128 |
-
//When Asynchronous Authorization is used, wait until the Authorization is completed.
|
129 |
-
//After the Authorization is out of the Pending state, we can continue.
|
130 |
-
//This is not needed for Fast Authorization since it has a synchronous response.
|
131 |
-
$this->_waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId);
|
132 |
-
}
|
133 |
-
return $amazonAuthorizationId;
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Perform the authorize call for the order
|
138 |
-
*
|
139 |
-
* @param float $authorizationAmount amount to authorize from the buyer
|
140 |
-
*
|
141 |
-
* @return string amazonAuthorizationId amazon generated authorization id reference
|
142 |
-
*/
|
143 |
-
private function _authorizeOrderAmount($authorizationAmount, $authOption = 1)
|
144 |
-
{
|
145 |
-
$response = $this->callStepAndCheckForException(
|
146 |
-
'authorizeOrderAmount',
|
147 |
-
array($authorizationAmount, $authOption)
|
148 |
-
);
|
149 |
-
printAuthorizeResponse($response);
|
150 |
-
return $response->getAuthorizeResult()->getAuthorizationDetails()->getAmazonAuthorizationId();
|
151 |
-
}
|
152 |
-
|
153 |
-
/**
|
154 |
-
* Poll the API for the status of the Authorization Request, and continue
|
155 |
-
* once the status has been updated
|
156 |
-
* Throw an error if the status is not equal to Open
|
157 |
-
*
|
158 |
-
* @param string $amazonAuthorizationId authorization transaction to query
|
159 |
-
*
|
160 |
-
*/
|
161 |
-
private function _waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId)
|
162 |
-
{
|
163 |
-
$response
|
164 |
-
= $this->callStepAndCheckForException(
|
165 |
-
'waitUntilAuthorizationProcessingIsCompleted',
|
166 |
-
array($amazonAuthorizationId)
|
167 |
-
);
|
168 |
-
printGetAuthorizationDetailsResponse($response);
|
169 |
-
validateThatAuthorizationIsOpen($response);
|
170 |
-
}
|
171 |
-
|
172 |
-
/**
|
173 |
-
* Perform the capture call for the order
|
174 |
-
* Throw an exception if the capture is not processed, as this is the
|
175 |
-
* expected result
|
176 |
-
*
|
177 |
-
* @param float $captureAmount amount to capture from the buyer
|
178 |
-
* @param string $amazonAuthorizationId auth id to perform the capture on
|
179 |
-
*
|
180 |
-
* @return no response
|
181 |
-
*/
|
182 |
-
private function _captureOrderAmount($captureAmount, $amazonAuthorizationId)
|
183 |
-
{ $providerCreditInfo = $this->_getProviderIdAndCreditAmountFromStdIn();
|
184 |
-
$response = $this->callStepAndCheckForException(
|
185 |
-
'captureOrderAmount',
|
186 |
-
array($captureAmount, $amazonAuthorizationId, $providerCreditInfo)
|
187 |
-
);
|
188 |
-
|
189 |
-
validateThatCaptureIsCompleted($response->getCaptureResult());
|
190 |
-
printCaptureResponse($response);
|
191 |
-
return $response->getCaptureResult()->getCaptureDetails()->getAmazonCaptureId();
|
192 |
-
}
|
193 |
-
|
194 |
-
|
195 |
-
private function _waitForProviderCreditSummaryList($amazonCaptureId){
|
196 |
-
|
197 |
-
$maxSleepTime = 60;
|
198 |
-
$getCaptureDetailsResponse = null;
|
199 |
-
$providerCreditSummaryList = null;
|
200 |
-
$providerCreditSummaryMember = null;
|
201 |
-
while (is_null($providerCreditSummaryList) && $maxSleepTime>0 ) {
|
202 |
-
sleep(5);
|
203 |
-
$maxSleepTime -= 5;
|
204 |
-
$getCaptureDetailsResponse = $this->callStepAndCheckForException('getCaptureDetails',array($amazonCaptureId));
|
205 |
-
$providerCreditSummaryList = $getCaptureDetailsResponse->getGetCaptureDetailsResult()->getCaptureDetails()->getProviderCreditSummaryList();
|
206 |
-
}
|
207 |
-
validateThatCaptureIsCompleted($getCaptureDetailsResponse->getGetCaptureDetailsResult());
|
208 |
-
printGetCaptureDetailsResponse($getCaptureDetailsResponse);
|
209 |
-
if (is_null($providerCreditSummaryList)) {
|
210 |
-
throw new ErrorException("No providerCreditSummaryList found in getCaptureDetails response");
|
211 |
-
}
|
212 |
-
return $providerCreditSummaryList;
|
213 |
-
}
|
214 |
-
|
215 |
-
/**
|
216 |
-
*/
|
217 |
-
private function _getProviderCreditDetails($providerCreditSummaryList) {
|
218 |
-
if (! is_null ( $providerCreditSummaryList ) && $providerCreditSummaryList->isSetmember ()) {
|
219 |
-
$values = $providerCreditSummaryList->getmember ();
|
220 |
-
foreach ( $values as $value ) {
|
221 |
-
if ($value->isSetProviderCreditId ()) {
|
222 |
-
$providerCreditId = $value->getProviderCreditId ();
|
223 |
-
$response = $this->callStepAndCheckForException ( 'getProviderCreditDetails', array (
|
224 |
-
$providerCreditId
|
225 |
-
) );
|
226 |
-
printProviderCreditDetailsResponse ( $response );
|
227 |
-
}
|
228 |
-
}
|
229 |
-
}
|
230 |
-
}
|
231 |
-
|
232 |
-
/**
|
233 |
-
* Close this order reference to indicate that the order is complete, and
|
234 |
-
* no further authorizations and captures will be performed on this order
|
235 |
-
*
|
236 |
-
* @return no value
|
237 |
-
*/
|
238 |
-
private function _closeOrderReference()
|
239 |
-
{
|
240 |
-
$response = $this->callStepAndCheckForException('closeOrderReference');
|
241 |
-
}
|
242 |
-
|
243 |
-
/**
|
244 |
-
* Capture the pre tax order amount from standard input,
|
245 |
-
* making sure that it is a numeric string
|
246 |
-
*
|
247 |
-
* @return string total amount of the order before tax and shipping charges
|
248 |
-
*/
|
249 |
-
private function _getPreTaxAndShippingOrderAmountFromStdIn()
|
250 |
-
{
|
251 |
-
print PHP_EOL . "-------------------------------------------" . PHP_EOL;
|
252 |
-
print "Enter the pre tax amount to charge for the order as a number (to 2 decimal places): ";
|
253 |
-
do {
|
254 |
-
$orderAmount = trim(fgets(STDIN));
|
255 |
-
} while (!is_numeric($orderAmount));
|
256 |
-
|
257 |
-
return $orderAmount;
|
258 |
-
}
|
259 |
-
|
260 |
-
/**
|
261 |
-
* Capture the shipping type for this order, which determines
|
262 |
-
* the shipping charge
|
263 |
-
*
|
264 |
-
* @return number selected shipping type index
|
265 |
-
*/
|
266 |
-
private function _getShippingTypeFromStdIn()
|
267 |
-
{
|
268 |
-
print PHP_EOL . "Select a shipping option for the order:" . PHP_EOL;
|
269 |
-
print "\t 1 - Overnight shipping" . PHP_EOL;
|
270 |
-
print "\t 2 - 2-day shipping" . PHP_EOL;
|
271 |
-
print "\t 3 - 5-day shipping" . PHP_EOL;
|
272 |
-
print ">>";
|
273 |
-
|
274 |
-
do {
|
275 |
-
$shippingType = trim(fgets(STDIN));
|
276 |
-
} while (!is_numeric($shippingType) and
|
277 |
-
($shippingType < 1 or $shippingType > 3));
|
278 |
-
|
279 |
-
return $shippingType - 1;
|
280 |
-
}
|
281 |
-
|
282 |
-
|
283 |
-
/**
|
284 |
-
* Get providerIdList for this order
|
285 |
-
*/
|
286 |
-
private function _getProviderIdAndCreditAmountFromStdIn() {
|
287 |
-
print PHP_EOL . "Enter provider id >>";
|
288 |
-
do {
|
289 |
-
$providerId = trim(fgets(STDIN));
|
290 |
-
} while (!isset($providerId) || $providerId === '');
|
291 |
-
|
292 |
-
print PHP_EOL . "Enter provider credit amount >>";
|
293 |
-
do {
|
294 |
-
$providerCreditAmount = trim(fgets(STDIN));
|
295 |
-
} while (!is_numeric($providerCreditAmount));
|
296 |
-
|
297 |
-
return array($providerId, $providerCreditAmount);
|
298 |
-
}
|
299 |
-
|
300 |
-
/**
|
301 |
-
* Use Regular Authorization or Fast Authorization?
|
302 |
-
*
|
303 |
-
* @return number , 1 for regular authorization and 2 for fast authorization.
|
304 |
-
*/
|
305 |
-
private function _getAuthOptionFromStdIn() {
|
306 |
-
print PHP_EOL . "-------------------------------------------" . PHP_EOL;
|
307 |
-
print "\t 1 - Use Regular Authorization (Asynchronous Response) [Default]" . PHP_EOL;
|
308 |
-
print "\t 2 - Use Fast Authorization (Synchronous Response)" . PHP_EOL;
|
309 |
-
print ">>";
|
310 |
-
do {
|
311 |
-
$authOption = trim ( fgets ( STDIN ) );
|
312 |
-
} while (!is_numeric($authOption) and
|
313 |
-
($authOption < 1 or $authOption > 2));
|
314 |
-
|
315 |
-
return $authOption;
|
316 |
-
}
|
317 |
-
|
318 |
-
};
|
319 |
-
$providerCheckoutExample = new ProviderCheckoutExampleCLI($argv);
|
320 |
-
$providerCheckoutExample->runSample();
|
321 |
-
|
322 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/ProviderRefundExampleCLI.php
DELETED
@@ -1,189 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at: http://aws.amazon.com/apache2.0 This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /* Refund command line example This demonstrates the scenario where merchant a merchant needs to perform a refund on a previously captured amount for a closed order reference See RefundExample.php for further information
|
5 |
-
*/
|
6 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/.config.inc.php';
|
7 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/GetOrderReferenceDetailsSample.php';
|
8 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/GetCaptureDetailsSample.php';
|
9 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/RefundExample.php';
|
10 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/GetRefundDetailsSample.php';
|
11 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/GetProviderCreditReversalDetailsSample.php';
|
12 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/CLIExample.php';
|
13 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/RefundSample.php';
|
14 |
-
|
15 |
-
/**
|
16 |
-
* ProviderRefundExampleCLI class captures input from stdin and prints to stdout,
|
17 |
-
* and drives the refund example
|
18 |
-
*/
|
19 |
-
class ProviderRefundExampleCLI extends CLIExample {
|
20 |
-
/**
|
21 |
-
* Create a new instance of the cli example and validate command line arguments
|
22 |
-
*
|
23 |
-
* @param array $argv
|
24 |
-
* arguments to the application passed from the command line
|
25 |
-
*/
|
26 |
-
public function __construct($argv) {
|
27 |
-
if (count ( $argv ) < 2) {
|
28 |
-
print PHP_EOL."Missing mandatory argument: " . "please provide an amazonOrderReferenceId, a " . "captureId that you want to refund";
|
29 |
-
exit ( 0 );
|
30 |
-
}
|
31 |
-
|
32 |
-
/*
|
33 |
-
* Instantiate Implementation of OffAmazonPaymentsService client Merchant ids and access keys are defined in the constants are defined in the OffAmazonPaymentsService.config.inc.php file in the parent directory of this server
|
34 |
-
*/
|
35 |
-
$this->exampleClass = new RefundExample ( new OffAmazonPaymentsService_Client (), $argv [1], $argv [2] );
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Run all the steps for the sample in sequence
|
40 |
-
*/
|
41 |
-
public function runSample() {
|
42 |
-
$this->_getOrderReferenceDetails ();
|
43 |
-
$this->_getAmountToRefund ();
|
44 |
-
$refundAmount = $this->_getRefundAmount ();
|
45 |
-
$refundCurrency = $this->_getRefundCurrency ();
|
46 |
-
$providerCreditReversalInfo = $this->_getProviderIdAndCreditReversalAmountFromStdIn ();
|
47 |
-
$amazonRefundReferenceId = $this->_refundToBuyer ( $refundAmount, $refundCurrency, $providerCreditReversalInfo);
|
48 |
-
$providerCreditReversalSummaryList = $this->_waitForProviderCreditReversalSummaryList ( $amazonRefundReferenceId );
|
49 |
-
$this->_getProviderCreditReversalDetails ( $providerCreditReversalSummaryList );
|
50 |
-
print "Provider Refund completed" . PHP_EOL;
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Get the order reference details to find to the state
|
55 |
-
* of the order reference
|
56 |
-
*/
|
57 |
-
private function _getOrderReferenceDetails() {
|
58 |
-
$response = $this->callStepAndCheckForException ( 'getOrderReferenceDetails' );
|
59 |
-
printGetOrderReferenceDetailsResponse ( $response );
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Get the capture details to find out the
|
64 |
-
* maximum amount that can be refunded
|
65 |
-
*/
|
66 |
-
private function _getAmountToRefund() {
|
67 |
-
$response = $this->callStepAndCheckForException ( 'getCaptureDetailsRequest' );
|
68 |
-
printGetCaptureDetailsResponse ( $response );
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Get the amount to refund
|
73 |
-
*
|
74 |
-
* @return string refund amount, as a numeric string`
|
75 |
-
*/
|
76 |
-
private function _getRefundAmount() {
|
77 |
-
print PHP_EOL . "----------------------------------------------------------------------------" . PHP_EOL;
|
78 |
-
|
79 |
-
print "Enter the amount to refund the customer (to 2 decimal places) >> ";
|
80 |
-
do {
|
81 |
-
$refundAmount = trim ( fgets ( STDIN ) );
|
82 |
-
} while ( ! is_numeric ( $refundAmount ) );
|
83 |
-
|
84 |
-
return $refundAmount;
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Get the currency to perform the refund in
|
89 |
-
*
|
90 |
-
* @return the curreny to perform the refund in
|
91 |
-
*/
|
92 |
-
private function _getRefundCurrency() {
|
93 |
-
print "Enter the currency for the refund >> ";
|
94 |
-
do {
|
95 |
-
$refundCurrency = trim ( fgets ( STDIN ) );
|
96 |
-
} while ( ! is_string ( $refundCurrency ) );
|
97 |
-
|
98 |
-
return $refundCurrency;
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Perform the refund to transfer the amount from seller
|
103 |
-
* to buyer
|
104 |
-
*
|
105 |
-
* @param string $refundAmount
|
106 |
-
* amount to refund to the buyer
|
107 |
-
* @param string $refundCurrency
|
108 |
-
* currency of the refund
|
109 |
-
*/
|
110 |
-
private function _refundToBuyer($refundAmount, $refundCurrency, $providerCreditReversalInfo) {
|
111 |
-
$response = $this->callStepAndCheckForException ( 'refundToBuyer', array (
|
112 |
-
$refundAmount,
|
113 |
-
$refundCurrency,
|
114 |
-
$providerCreditReversalInfo
|
115 |
-
) );
|
116 |
-
printRefundResponse ( $response );
|
117 |
-
return $response->getRefundResult ()->getRefundDetails ()->getAmazonRefundId ();
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Poll the API for the status of the Refund Request, and continue
|
122 |
-
* once the status has been updated
|
123 |
-
* Throw an error if the status is not equal to OPEN
|
124 |
-
*
|
125 |
-
* @param string $amazonRefundReferenceId
|
126 |
-
* refund transaction to query
|
127 |
-
*
|
128 |
-
* @return No value
|
129 |
-
*/
|
130 |
-
private function _waitForProviderCreditReversalSummaryList($amazonRefundReferenceId) {
|
131 |
-
$response = null;
|
132 |
-
$providerCreditReversalSummaryList = null;
|
133 |
-
$maxSleepTime = 60;
|
134 |
-
while ( is_null ( $providerCreditReversalSummaryList ) && $maxSleepTime > 0 ) {
|
135 |
-
sleep(5);
|
136 |
-
$maxSleepTime -= 5;
|
137 |
-
$response = $this->callStepAndCheckForException ( 'getRefundDetails', array (
|
138 |
-
$amazonRefundReferenceId
|
139 |
-
) );
|
140 |
-
$providerCreditReversalSummaryList = $response->getGetRefundDetailsResult ()->getRefundDetails ()->getProviderCreditReversalSummaryList ();
|
141 |
-
}
|
142 |
-
printGetRefundDetailsResponse ( $response );
|
143 |
-
validateThatRefundIsCompleted ( $response->getGetRefundDetailsResult ()->getRefundDetails () );
|
144 |
-
if (is_null($providerCreditReversalSummaryList)) {
|
145 |
-
throw new ErrorException("No providerCreditReversalSummaryList found in getRefundDetails response");
|
146 |
-
}
|
147 |
-
|
148 |
-
return $providerCreditReversalSummaryList;
|
149 |
-
}
|
150 |
-
|
151 |
-
/**
|
152 |
-
*/
|
153 |
-
private function _getProviderCreditReversalDetails($providerCreditReversalSummaryList) {
|
154 |
-
if (! is_null ( $providerCreditReversalSummaryList ) && $providerCreditReversalSummaryList->isSetmember()) {
|
155 |
-
$values = $providerCreditReversalSummaryList->getmember ();
|
156 |
-
foreach ( $values as $value ) {
|
157 |
-
if ($value->isSetProviderCreditReversalId ()) {
|
158 |
-
$providerCreditReversalId = $value->getProviderCreditReversalId ();
|
159 |
-
$response = $this->callStepAndCheckForException ( 'getProviderCreditReversalDetails', array (
|
160 |
-
$providerCreditReversalId
|
161 |
-
) );
|
162 |
-
printGetProviderCreditReversalDetailsResponse ( $response );
|
163 |
-
}
|
164 |
-
}
|
165 |
-
}
|
166 |
-
}
|
167 |
-
|
168 |
-
/**
|
169 |
-
* Get provider id and credit reversal amount.
|
170 |
-
*/
|
171 |
-
private function _getProviderIdAndCreditReversalAmountFromStdIn() {
|
172 |
-
print PHP_EOL . "Enter provider id >> ";
|
173 |
-
do {
|
174 |
-
$providerId = trim(fgets(STDIN));
|
175 |
-
} while (!isset($providerId) || $providerId === '');
|
176 |
-
|
177 |
-
print PHP_EOL . "Enter provider credit reversal amount >> ";
|
178 |
-
do {
|
179 |
-
$providerCreditReversalAmount = trim(fgets(STDIN));
|
180 |
-
} while (!is_numeric($providerCreditReversalAmount));
|
181 |
-
|
182 |
-
return array($providerId, $providerCreditReversalAmount);
|
183 |
-
}
|
184 |
-
}
|
185 |
-
|
186 |
-
$refundExample = new ProviderRefundExampleCLI ( $argv );
|
187 |
-
$refundExample->runSample ();
|
188 |
-
|
189 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/RefundExample.php
DELETED
@@ -1,223 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
*/
|
16 |
-
|
17 |
-
/*
|
18 |
-
* Refund example
|
19 |
-
*
|
20 |
-
* This demonstrates the scenario where merchant a merchant
|
21 |
-
* needs to perform a refund on a previously captured amount
|
22 |
-
* for a closed order reference
|
23 |
-
*
|
24 |
-
* This example will show the following service calls:
|
25 |
-
* - GetOrderReferenceDetails
|
26 |
-
* - GetCaptureDetails
|
27 |
-
* - Refund
|
28 |
-
* - GetRefundDetails
|
29 |
-
*/
|
30 |
-
|
31 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
32 |
-
|
33 |
-
/**
|
34 |
-
* RefundExample includes the logic
|
35 |
-
* required to refund a capture,
|
36 |
-
* which transfers the funds from
|
37 |
-
* the merchant back to the buyer
|
38 |
-
*
|
39 |
-
*/
|
40 |
-
class RefundExample
|
41 |
-
{
|
42 |
-
private $_sellerId;
|
43 |
-
private $_service;
|
44 |
-
private $_amazonOrderReferenceId;
|
45 |
-
private $_amazonCaptureId;
|
46 |
-
private $_refundReferenceId;
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Create a new instance of the refund example case
|
50 |
-
*
|
51 |
-
* @param OffAmazonPaymentsService_Client $service instance of the service
|
52 |
-
* client
|
53 |
-
* @param string $amazonOrderReferenceId an order reference object in
|
54 |
-
* open or closed state to use in
|
55 |
-
* the example
|
56 |
-
* @param string $amazonCaptureId a completed capture that was
|
57 |
-
* performed on the order reference id
|
58 |
-
* @param string $refundIdSuffix suffixForTheRefundIdentifier
|
59 |
-
*
|
60 |
-
* @return new RefundExample
|
61 |
-
*/
|
62 |
-
public function __construct($service, $amazonOrderReferenceId, $amazonCaptureId)
|
63 |
-
{
|
64 |
-
$this->_service = $service;
|
65 |
-
$this->_amazonOrderReferenceId = $amazonOrderReferenceId;
|
66 |
-
$this->_amazonCaptureId = $amazonCaptureId;
|
67 |
-
$this->_refundReferenceId
|
68 |
-
= str_replace("-", "", $amazonCaptureId) . "r" . rand(1, 1000);
|
69 |
-
|
70 |
-
$this->_sellerId
|
71 |
-
= $this->_service->getMerchantValues()->getMerchantId();
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Get the order reference details to find to the state
|
76 |
-
* of the order reference
|
77 |
-
*
|
78 |
-
* @return OffAmazonPaymentsService_Model_GetOrderReferenceDetailsResponse response
|
79 |
-
*/
|
80 |
-
public function getOrderReferenceDetails()
|
81 |
-
{
|
82 |
-
$getOrderReferenceDetailsRequest
|
83 |
-
= new OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest();
|
84 |
-
$getOrderReferenceDetailsRequest->setSellerId($this->_sellerId);
|
85 |
-
$getOrderReferenceDetailsRequest->setAmazonOrderReferenceId(
|
86 |
-
$this->_amazonOrderReferenceId
|
87 |
-
);
|
88 |
-
|
89 |
-
return $this->_service->getOrderReferenceDetails(
|
90 |
-
$getOrderReferenceDetailsRequest
|
91 |
-
);
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Get the capture details to find out the
|
96 |
-
* maximum amount that can be refunded
|
97 |
-
*
|
98 |
-
* @return OffAmazonPaymentsService_Model_GetCaptureDetailsResponse response
|
99 |
-
*/
|
100 |
-
public function getCaptureDetailsRequest()
|
101 |
-
{
|
102 |
-
$getCaptureDetailsRequest
|
103 |
-
= new OffAmazonPaymentsService_Model_GetCaptureDetailsRequest();
|
104 |
-
$getCaptureDetailsRequest->setSellerId($this->_sellerId);
|
105 |
-
$getCaptureDetailsRequest->setAmazonCaptureId($this->_amazonCaptureId);
|
106 |
-
|
107 |
-
return $this->_service->getCaptureDetails($getCaptureDetailsRequest);
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Perform the refund to transfer the amount from seller
|
112 |
-
* to buyer
|
113 |
-
*
|
114 |
-
* @param string $refundAmount amount to refund to the buyer
|
115 |
-
* @param string $refundCurrency currency of the refund
|
116 |
-
*
|
117 |
-
* @return void
|
118 |
-
*/
|
119 |
-
public function refundToBuyer($refundAmount, $refundCurrency, $providerCreditReversalInfo=null)
|
120 |
-
{
|
121 |
-
$refund = new OffAmazonPaymentsService_Model_Price();
|
122 |
-
$refund->setCurrencyCode($refundCurrency);
|
123 |
-
$refund->setAmount($refundAmount);
|
124 |
-
|
125 |
-
$refundRequest = new OffAmazonPaymentsService_Model_RefundRequest();
|
126 |
-
$refundRequest->setSellerId($this->_sellerId);
|
127 |
-
$refundRequest->setAmazonCaptureId($this->_amazonCaptureId);
|
128 |
-
$refundRequest->setRefundReferenceId($this->_refundReferenceId);
|
129 |
-
$refundRequest->setRefundAmount($refund);
|
130 |
-
|
131 |
-
if($providerCreditReversalInfo != null){
|
132 |
-
$refundRequest->setProviderCreditReversalList(new OffAmazonPaymentsService_Model_ProviderCreditReversalList());
|
133 |
-
$values = array();
|
134 |
-
$providerCreditReversal = new OffAmazonPaymentsService_Model_ProviderCreditReversal();
|
135 |
-
$providerCreditReversal->setProviderId($providerCreditReversalInfo[0]);
|
136 |
-
$creditReversalAmount = new OffAmazonPaymentsService_Model_Price();
|
137 |
-
$creditReversalAmount->setAmount($providerCreditReversalInfo[1]);
|
138 |
-
$creditReversalAmount->setCurrencyCode($refundCurrency);
|
139 |
-
$providerCreditReversal->setCreditReversalAmount($creditReversalAmount);
|
140 |
-
array_push($values, $providerCreditReversal);
|
141 |
-
$refundRequest->getProviderCreditReversalList()->setmember($values);
|
142 |
-
}
|
143 |
-
return $this->_service->refund($refundRequest);
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Poll the API for the status of the Refund Request, and continue
|
148 |
-
* once the status has been updated
|
149 |
-
* WARNING: This is not the way to integrate for production systems,
|
150 |
-
* instead merchants should use IOPN to receive a callback once the
|
151 |
-
* processing has been completed.
|
152 |
-
* Note that Amazon reserves the right to throttle requests that
|
153 |
-
* ignore this advice and poll for a response
|
154 |
-
*
|
155 |
-
* @param string $amazonRefundId refund id to query status of
|
156 |
-
*
|
157 |
-
* @return OffAmazonPaymentsService_Model_GetRefundDetailsResponse response
|
158 |
-
*/
|
159 |
-
public function waitUntilRefundProcessingIsCompleted($amazonRefundId)
|
160 |
-
{
|
161 |
-
$getRefundDetailsResponse = null;
|
162 |
-
do {
|
163 |
-
sleep(5);
|
164 |
-
$getRefundDetailsResponse
|
165 |
-
= $this->getRefundDetails($amazonRefundId);
|
166 |
-
} while ((isset($getRefundDetailsResponse)) and
|
167 |
-
(strcasecmp(
|
168 |
-
$getRefundDetailsResponse->getGetRefundDetailsResult()
|
169 |
-
->getRefundDetails()->getRefundStatus()->getState(),
|
170 |
-
"Pending"
|
171 |
-
)== 0
|
172 |
-
)
|
173 |
-
);
|
174 |
-
|
175 |
-
if (is_null($getRefundDetailsResponse)) {
|
176 |
-
throw new ErrorException(
|
177 |
-
"No valid response from getRefundDetails request"
|
178 |
-
);
|
179 |
-
}
|
180 |
-
|
181 |
-
return $getRefundDetailsResponse;
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Perform the getRefundDetails request for the order
|
186 |
-
*
|
187 |
-
* @param string $amazonRefundId authorization transaction
|
188 |
-
* to query
|
189 |
-
*
|
190 |
-
* @return OffAmazonPaymentsService_Model_GetRefundDetailsResponse response
|
191 |
-
*/
|
192 |
-
public function getRefundDetails($amazonRefundId)
|
193 |
-
{
|
194 |
-
$getRefundDetailsRequest
|
195 |
-
= new OffAmazonPaymentsService_Model_GetRefundDetailsRequest();
|
196 |
-
$getRefundDetailsRequest->setSellerId($this->_sellerId);
|
197 |
-
$getRefundDetailsRequest->setAmazonRefundId($amazonRefundId);
|
198 |
-
return $this->_service->getRefundDetails($getRefundDetailsRequest);
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Perform the get capture details call for the order
|
203 |
-
*
|
204 |
-
* @return OffAmazonPaymentsService_Model_CaptureResponse service response
|
205 |
-
*/
|
206 |
-
public function getCaptureDetails()
|
207 |
-
{
|
208 |
-
$captureDetailsRequest
|
209 |
-
= new OffAmazonPaymentsService_Model_GetCaptureDetailsRequest();
|
210 |
-
$captureDetailsRequest->setSellerId($this->_sellerId);
|
211 |
-
$captureDetailsRequest->setAmazonCaptureId($this->_amazonCaptureId);
|
212 |
-
|
213 |
-
return $this->_service->getCaptureDetails($captureDetailsRequest);
|
214 |
-
}
|
215 |
-
|
216 |
-
public function getProviderCreditReversalDetails($providerCreditReversalId){
|
217 |
-
$providerCreditReversalDetailsRequest = new OffAmazonPaymentsService_Model_GetProviderCreditReversalDetailsRequest();
|
218 |
-
$providerCreditReversalDetailsRequest->setSellerId($this->_sellerId);
|
219 |
-
$providerCreditReversalDetailsRequest->setAmazonProviderCreditReversalId($providerCreditReversalId);
|
220 |
-
return $this->_service->getProviderCreditReversalDetails($providerCreditReversalDetailsRequest);
|
221 |
-
}
|
222 |
-
}
|
223 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/RefundExampleCLI.php
DELETED
@@ -1,182 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
*
|
16 |
-
|
17 |
-
/*
|
18 |
-
* Refund command line example
|
19 |
-
*
|
20 |
-
* This demonstrates the scenario where merchant a merchant
|
21 |
-
* needs to perform a refund on a previously captured amount
|
22 |
-
* for a closed order reference
|
23 |
-
*
|
24 |
-
* See RefundExample.php for further information
|
25 |
-
*/
|
26 |
-
|
27 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
28 |
-
require_once realpath(dirname(__FILE__)) . '/GetOrderReferenceDetailsSample.php';
|
29 |
-
require_once realpath(dirname(__FILE__)) . '/GetCaptureDetailsSample.php';
|
30 |
-
require_once realpath(dirname(__FILE__)) . '/RefundExample.php';
|
31 |
-
require_once realpath(dirname(__FILE__)) . '/GetRefundDetailsSample.php';
|
32 |
-
require_once realpath(dirname(__FILE__)) . '/CLIExample.php';
|
33 |
-
require_once realpath(dirname(__FILE__)) . '/RefundSample.php';
|
34 |
-
|
35 |
-
/**
|
36 |
-
* RefundExampleCLI class captures input from stdin and prints to stdout,
|
37 |
-
* and drives the refund example
|
38 |
-
*
|
39 |
-
*/
|
40 |
-
class RefundExampleCLI extends CLIExample
|
41 |
-
{
|
42 |
-
/**
|
43 |
-
* Create a new instance of the cli example and validate command line arguments
|
44 |
-
*
|
45 |
-
* @param array $argv arguments to the application passed from the command line
|
46 |
-
*/
|
47 |
-
public function __construct($argv)
|
48 |
-
{
|
49 |
-
if (count($argv) < 2) {
|
50 |
-
print "Missing mandatory argument: " .
|
51 |
-
"please provide an amazonOrderReferenceId, a" .
|
52 |
-
"captureId that you want to refund";
|
53 |
-
exit(0);
|
54 |
-
}
|
55 |
-
|
56 |
-
/*
|
57 |
-
* Instantiate Implementation of OffAmazonPaymentsService client
|
58 |
-
*
|
59 |
-
* Merchant ids and access keys are defined in the constants
|
60 |
-
* are defined in the OffAmazonPaymentsService.config.inc.php file in
|
61 |
-
* the parent directory of this server
|
62 |
-
*/
|
63 |
-
$this->exampleClass
|
64 |
-
= new RefundExample(
|
65 |
-
new OffAmazonPaymentsService_Client(),
|
66 |
-
$argv[1],
|
67 |
-
$argv[2]
|
68 |
-
);
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Run all the steps for the sample in sequence
|
73 |
-
*
|
74 |
-
*/
|
75 |
-
public function runSample()
|
76 |
-
{
|
77 |
-
$this->_getOrderReferenceDetails();
|
78 |
-
$this->_getAmountToRefund();
|
79 |
-
$refundAmount = $this->_getRefundAmount();
|
80 |
-
$refundCurrency = $this->_getRefundCurrency();
|
81 |
-
$amazonRefundReferenceId = $this->_refundToBuyer($refundAmount, $refundCurrency);
|
82 |
-
$this->_waitUntilRefundProcessingIsCompleted($amazonRefundReferenceId);
|
83 |
-
|
84 |
-
print "Refund completed" . PHP_EOL;
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Get the order reference details to find to the state
|
89 |
-
* of the order reference
|
90 |
-
*
|
91 |
-
*/
|
92 |
-
private function _getOrderReferenceDetails()
|
93 |
-
{
|
94 |
-
$response = $this->callStepAndCheckForException('getOrderReferenceDetails');
|
95 |
-
printGetOrderReferenceDetailsResponse($response);
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Get the capture details to find out the
|
100 |
-
* maximum amount that can be refunded
|
101 |
-
*
|
102 |
-
*/
|
103 |
-
private function _getAmountToRefund()
|
104 |
-
{
|
105 |
-
$response = $this->callStepAndCheckForException('getCaptureDetailsRequest');
|
106 |
-
printGetCaptureDetailsResponse($response);
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Get the amount to refund
|
111 |
-
*
|
112 |
-
* @return string refund amount, as a numeric string`
|
113 |
-
*/
|
114 |
-
private function _getRefundAmount()
|
115 |
-
{
|
116 |
-
print PHP_EOL . "----------------------------------------------------------------------------" . PHP_EOL;
|
117 |
-
|
118 |
-
print "Enter the amount to refund the customer (to 2 decimal places): ";
|
119 |
-
do {
|
120 |
-
$refundAmount = trim(fgets(STDIN));
|
121 |
-
} while (!is_numeric($refundAmount));
|
122 |
-
|
123 |
-
return $refundAmount;
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Get the currency to perform the refund in
|
128 |
-
*
|
129 |
-
* @return the curreny to perform the refund in
|
130 |
-
*/
|
131 |
-
private function _getRefundCurrency()
|
132 |
-
{
|
133 |
-
print "Enter the currency for the refund: ";
|
134 |
-
do {
|
135 |
-
$refundCurrency = trim(fgets(STDIN));
|
136 |
-
} while (!is_string($refundCurrency));
|
137 |
-
|
138 |
-
return $refundCurrency;
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Perform the refund to transfer the amount from seller
|
143 |
-
* to buyer
|
144 |
-
*
|
145 |
-
* @param string $refundAmount amount to refund to the buyer
|
146 |
-
* @param string $refundCurrency currency of the refund
|
147 |
-
*/
|
148 |
-
private function _refundToBuyer($refundAmount, $refundCurrency)
|
149 |
-
{
|
150 |
-
$response = $this->callStepAndCheckForException(
|
151 |
-
'refundToBuyer',
|
152 |
-
array($refundAmount, $refundCurrency)
|
153 |
-
);
|
154 |
-
printRefundResponse($response);
|
155 |
-
return $response->getRefundResult()->getRefundDetails()->getAmazonRefundId();
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* Poll the API for the status of the Refund Request, and continue
|
160 |
-
* once the status has been updated
|
161 |
-
* Throw an error if the status is not equal to OPEN
|
162 |
-
*
|
163 |
-
* @param string $amazonRefundReferenceId refund transaction to query
|
164 |
-
*
|
165 |
-
* @return No value
|
166 |
-
*/
|
167 |
-
private function _waitUntilRefundProcessingIsCompleted($amazonRefundReferenceId)
|
168 |
-
{
|
169 |
-
$response = $this->callStepAndCheckForException(
|
170 |
-
'waitUntilRefundProcessingIsCompleted',
|
171 |
-
array($amazonRefundReferenceId)
|
172 |
-
);
|
173 |
-
|
174 |
-
printGetRefundDetailsResponse($response);
|
175 |
-
validateThatRefundIsCompleted($response->getGetRefundDetailsResult()->getRefundDetails());
|
176 |
-
}
|
177 |
-
}
|
178 |
-
|
179 |
-
$refundExample = new RefundExampleCLI($argv);
|
180 |
-
$refundExample->runSample();
|
181 |
-
|
182 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/RefundSample.php
DELETED
@@ -1,180 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Refund Sample
|
21 |
-
*/
|
22 |
-
|
23 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Throw an error if the refund is not in the
|
27 |
-
* completed status
|
28 |
-
*
|
29 |
-
* @param OffAmazonPaymentsService_Model_RefundDetails $response service response
|
30 |
-
* @throws ErrorException
|
31 |
-
*/
|
32 |
-
function validateThatRefundIsCompleted($refundDetails)
|
33 |
-
{
|
34 |
-
if (strcasecmp($refundDetails->getRefundStatus()->getState(),"Completed") != 0) {
|
35 |
-
throw new ErrorException(
|
36 |
-
"Error with refund " .
|
37 |
-
$refundDetails->getRefundReferenceId() . " - state is " .
|
38 |
-
$refundDetails->getRefundStatus()->getState() . PHP_EOL
|
39 |
-
);
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Refund Action Sample
|
45 |
-
|
46 |
-
* @param OffAmazonPaymentsService_Interface $service instance of OffAmazonPaymentsService_Interface
|
47 |
-
* @param mixed $request OffAmazonPaymentsService_Model_Refund or array of parameters
|
48 |
-
*/
|
49 |
-
function printRefundResponse($response)
|
50 |
-
{
|
51 |
-
|
52 |
-
print "Service Response" . PHP_EOL;
|
53 |
-
print "=============================================================================" . PHP_EOL;
|
54 |
-
|
55 |
-
print " RefundResponse" . PHP_EOL;
|
56 |
-
if ($response->isSetRefundResult()) {
|
57 |
-
print " RefundResult" . PHP_EOL;
|
58 |
-
$refundResult = $response->getRefundResult();
|
59 |
-
if ($refundResult->isSetRefundDetails()) {
|
60 |
-
print " RefundDetails" . PHP_EOL;
|
61 |
-
$refundDetails = $refundResult->getRefundDetails();
|
62 |
-
if ($refundDetails->isSetAmazonRefundId())
|
63 |
-
{
|
64 |
-
print " AmazonRefundId" . PHP_EOL;
|
65 |
-
print " " . $refundDetails->getAmazonRefundId() . PHP_EOL;
|
66 |
-
}
|
67 |
-
if ($refundDetails->isSetRefundReferenceId())
|
68 |
-
{
|
69 |
-
print " RefundReferenceId" . PHP_EOL;
|
70 |
-
print " " . $refundDetails->getRefundReferenceId() . PHP_EOL;
|
71 |
-
}
|
72 |
-
if ($refundDetails->isSetSellerRefundNote())
|
73 |
-
{
|
74 |
-
print " SellerRefundNote" . PHP_EOL;
|
75 |
-
print " " . $refundDetails->getSellerRefundNote() . PHP_EOL;
|
76 |
-
}
|
77 |
-
if ($refundDetails->isSetRefundType())
|
78 |
-
{
|
79 |
-
print " RefundType" . PHP_EOL;
|
80 |
-
print " " . $refundDetails->getRefundType() . PHP_EOL;
|
81 |
-
}
|
82 |
-
if ($refundDetails->isSetRefundAmount()) {
|
83 |
-
print " RefundAmount" . PHP_EOL;
|
84 |
-
$refundAmount = $refundDetails->getRefundAmount();
|
85 |
-
if ($refundAmount->isSetAmount())
|
86 |
-
{
|
87 |
-
print " Amount" . PHP_EOL;
|
88 |
-
print " " . $refundAmount->getAmount() . PHP_EOL;
|
89 |
-
}
|
90 |
-
if ($refundAmount->isSetCurrencyCode())
|
91 |
-
{
|
92 |
-
print " CurrencyCode" . PHP_EOL;
|
93 |
-
print " " . $refundAmount->getCurrencyCode() . PHP_EOL;
|
94 |
-
}
|
95 |
-
}
|
96 |
-
if ($refundDetails->isSetFeeRefunded()) {
|
97 |
-
print " FeeRefunded" . PHP_EOL;
|
98 |
-
$feeRefunded = $refundDetails->getFeeRefunded();
|
99 |
-
if ($feeRefunded->isSetAmount())
|
100 |
-
{
|
101 |
-
print " Amount" . PHP_EOL;
|
102 |
-
print " " . $feeRefunded->getAmount() . PHP_EOL;
|
103 |
-
}
|
104 |
-
if ($feeRefunded->isSetCurrencyCode())
|
105 |
-
{
|
106 |
-
print " CurrencyCode" . PHP_EOL;
|
107 |
-
print " " . $feeRefunded->getCurrencyCode() . PHP_EOL;
|
108 |
-
}
|
109 |
-
}
|
110 |
-
if ($refundDetails->isSetCreationTimestamp())
|
111 |
-
{
|
112 |
-
print " CreationTimestamp" . PHP_EOL;
|
113 |
-
print " " . $refundDetails->getCreationTimestamp() . PHP_EOL;
|
114 |
-
}
|
115 |
-
if ($refundDetails->isSetRefundStatus()) {
|
116 |
-
print " RefundStatus" . PHP_EOL;
|
117 |
-
$refundStatus = $refundDetails->getRefundStatus();
|
118 |
-
if ($refundStatus->isSetState())
|
119 |
-
{
|
120 |
-
print " State" . PHP_EOL;
|
121 |
-
print " " . $refundStatus->getState() . PHP_EOL;
|
122 |
-
}
|
123 |
-
if ($refundStatus->isSetLastUpdateTimestamp())
|
124 |
-
{
|
125 |
-
print " LastUpdateTimestamp" . PHP_EOL;
|
126 |
-
print " " . $refundStatus->getLastUpdateTimestamp() . PHP_EOL;
|
127 |
-
}
|
128 |
-
if ($refundStatus->isSetReasonCode())
|
129 |
-
{
|
130 |
-
print " ReasonCode" . PHP_EOL;
|
131 |
-
print " " . $refundStatus->getReasonCode() . PHP_EOL;
|
132 |
-
}
|
133 |
-
if ($refundStatus->isSetReasonDescription())
|
134 |
-
{
|
135 |
-
print " ReasonDescription" . PHP_EOL;
|
136 |
-
print " " . $refundStatus->getReasonDescription() . PHP_EOL;
|
137 |
-
}
|
138 |
-
}
|
139 |
-
if ($refundDetails->isSetSoftDescriptor())
|
140 |
-
{
|
141 |
-
print " SoftDescriptor" . PHP_EOL;
|
142 |
-
print " " . $refundDetails->getSoftDescriptor() . PHP_EOL;
|
143 |
-
}
|
144 |
-
if($refundDetails->isSetProviderCreditReversalSummaryList()){
|
145 |
-
print " ProviderCreditReversalSummaryList" . PHP_EOL;
|
146 |
-
$providerCreditReversalSummaryList = $refundDetails->getProviderCreditReversalSummaryList();
|
147 |
-
if($providerCreditReversalSummaryList->isSetProviderCreditReversalSummary()){
|
148 |
-
$values = $providerCreditReversalSummaryList->getProviderCreditReversalSummary();
|
149 |
-
foreach($values as $value){
|
150 |
-
print " ProviderCreditReversalSummary" . PHP_EOL;
|
151 |
-
if($value->isSetProviderId()){
|
152 |
-
print " ProviderId" . PHP_EOL;
|
153 |
-
print " ".$value->getProviderId() . PHP_EOL;
|
154 |
-
}
|
155 |
-
if($value->isSetProviderCreditReversalId()){
|
156 |
-
print " ProviderCreditReversalId" . PHP_EOL;
|
157 |
-
print " ".$value->getProviderCreditReversalId() . PHP_EOL;
|
158 |
-
}
|
159 |
-
}
|
160 |
-
}
|
161 |
-
}
|
162 |
-
}
|
163 |
-
}
|
164 |
-
if ($response->isSetResponseMetadata()) {
|
165 |
-
print " ResponseMetadata" . PHP_EOL;
|
166 |
-
$responseMetadata = $response->getResponseMetadata();
|
167 |
-
if ($responseMetadata->isSetRequestId())
|
168 |
-
{
|
169 |
-
print " RequestId" . PHP_EOL;
|
170 |
-
print " " . $responseMetadata->getRequestId() . PHP_EOL;
|
171 |
-
}
|
172 |
-
}
|
173 |
-
|
174 |
-
print " ResponseHeaderMetadata: " .
|
175 |
-
$response->getResponseHeaderMetadata() . PHP_EOL;
|
176 |
-
|
177 |
-
return $response;
|
178 |
-
}
|
179 |
-
|
180 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/ReverseProviderCreditExample.php
DELETED
@@ -1,71 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
*/
|
16 |
-
|
17 |
-
/*
|
18 |
-
* Refund example This demonstrates the scenario where merchant a merchant needs to perform a reverseProviderCredit on a previously captured amount for a closed order reference This example will show the following service calls: - GetOrderReferenceDetails - GetCaptureDetails - Refund - GetRefundDetails
|
19 |
-
*/
|
20 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/.config.inc.php';
|
21 |
-
|
22 |
-
/**
|
23 |
-
* ReverseProviderCreditExample includes the logic
|
24 |
-
* required to reverseProviderCredit a capture,
|
25 |
-
* which transfers the funds from
|
26 |
-
* the merchant back to the buyer
|
27 |
-
*/
|
28 |
-
class ReverseProviderCreditExample {
|
29 |
-
private $_sellerId;
|
30 |
-
private $_service;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Create a new instance of the reverseProviderCredit example case
|
34 |
-
*
|
35 |
-
* @param OffAmazonPaymentsService_Client $service
|
36 |
-
* instance of the service
|
37 |
-
* client
|
38 |
-
*
|
39 |
-
* @return new ReverseProviderCreditExample
|
40 |
-
*/
|
41 |
-
public function __construct($service) {
|
42 |
-
$this->_service = $service;
|
43 |
-
$this->_sellerId = $this->_service->getMerchantValues ()->getMerchantId ();
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Perform the reverseProviderCredit to transfer the amount from provider
|
48 |
-
* to merchant
|
49 |
-
*
|
50 |
-
* @param string $reverseProviderCreditAmount
|
51 |
-
* amount to reverseProviderCredit to the merchant
|
52 |
-
* @param string $reverseProviderCreditCurrency
|
53 |
-
* currency of the reverseProviderCredit
|
54 |
-
*
|
55 |
-
* @return void
|
56 |
-
*/
|
57 |
-
public function reverseToMerchant($amazonProviderCreditId, $reverseAmount, $creditReversalReferenceId) {
|
58 |
-
$reversePrice = new OffAmazonPaymentsService_Model_Price ();
|
59 |
-
$reversePrice->setCurrencyCode ( $this->_service->getMerchantValues ()->getCurrency () );
|
60 |
-
$reversePrice->setAmount ( $reverseAmount );
|
61 |
-
|
62 |
-
$reverseProviderCreditRequest = new OffAmazonPaymentsService_Model_ReverseProviderCreditRequest ();
|
63 |
-
$reverseProviderCreditRequest->setSellerId ( $this->_sellerId );
|
64 |
-
$reverseProviderCreditRequest->setAmazonProviderCreditId ( $amazonProviderCreditId );
|
65 |
-
$reverseProviderCreditRequest->setCreditReversalReferenceId ( $creditReversalReferenceId );
|
66 |
-
$reverseProviderCreditRequest->setCreditReversalAmount ( $reversePrice );
|
67 |
-
|
68 |
-
return $this->_service->reverseProviderCredit ( $reverseProviderCreditRequest );
|
69 |
-
}
|
70 |
-
}
|
71 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/ReverseProviderCreditExampleCLI.php
DELETED
@@ -1,93 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at: http://aws.amazon.com/apache2.0 This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /* Refund command line example This demonstrates the scenario where merchant a merchant needs to perform a reverse on a previously captured amount for a closed order reference See ReverseProviderCreditExample.php for further information
|
5 |
-
*/
|
6 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/.config.inc.php';
|
7 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/ReverseProviderCreditSample.php';
|
8 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/ReverseProviderCreditExample.php';
|
9 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/CLIExample.php';
|
10 |
-
|
11 |
-
/**
|
12 |
-
* ReverseProviderCreditExampleCLI class captures input from stdin and prints to stdout,
|
13 |
-
* and drives the reverse example
|
14 |
-
*/
|
15 |
-
class ReverseProviderCreditExampleCLI extends CLIExample {
|
16 |
-
/**
|
17 |
-
* Create a new instance of the cli example and validate command line arguments
|
18 |
-
*
|
19 |
-
* @param array $argv
|
20 |
-
* arguments to the application passed from the command line
|
21 |
-
*/
|
22 |
-
public function __construct($argv) {
|
23 |
-
|
24 |
-
/*
|
25 |
-
* Instantiate Implementation of OffAmazonPaymentsService client Merchant ids and access keys are defined in the constants are defined in the OffAmazonPaymentsService.config.inc.php file in the parent directory of this server
|
26 |
-
*/
|
27 |
-
$this->exampleClass = new ReverseProviderCreditExample ( new OffAmazonPaymentsService_Client () );
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Run all the steps for the sample in sequence
|
32 |
-
*/
|
33 |
-
public function runSample() {
|
34 |
-
$amazonProviderCreditId = $this->getProviderCreditId ();
|
35 |
-
$reverseAmount = $this->_getCreditReversalAmount ();
|
36 |
-
$creditReversalReferenceId = str_replace("-", "", $amazonProviderCreditId) . "q" . rand(1, 1000);
|
37 |
-
$this->_reverseToMerchant ( $amazonProviderCreditId, $reverseAmount, $creditReversalReferenceId );
|
38 |
-
|
39 |
-
print "Reverse provider credit completed" . PHP_EOL;
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Perform the reverse to transfer the amount from seller
|
44 |
-
* to merchant
|
45 |
-
*
|
46 |
-
* @param string $reverseAmount
|
47 |
-
* amount to reverse to the buyer
|
48 |
-
* @param string $reverseCurrency
|
49 |
-
* currency of the reverse
|
50 |
-
*/
|
51 |
-
private function _reverseToMerchant($amazonProviderCreditId, $reverseAmount, $creditReversalReferenceId) {
|
52 |
-
$response = $this->callStepAndCheckForException ( 'reverseToMerchant', array (
|
53 |
-
$amazonProviderCreditId,
|
54 |
-
$reverseAmount,
|
55 |
-
$creditReversalReferenceId
|
56 |
-
) );
|
57 |
-
|
58 |
-
printProviderCreditReversalDetailsResponse ( $response );
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
*
|
63 |
-
* @return AmazonProviderCreditId
|
64 |
-
*/
|
65 |
-
private function getProviderCreditId() {
|
66 |
-
|
67 |
-
print PHP_EOL."Enter the AmazonProviderCreditId >> ";
|
68 |
-
do {
|
69 |
-
$amazonProviderCreditId = trim ( fgets ( STDIN ) );
|
70 |
-
} while ( ! is_string ( $amazonProviderCreditId ) );
|
71 |
-
|
72 |
-
return $amazonProviderCreditId;
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Get the amount to reverse
|
77 |
-
*
|
78 |
-
* @return string reverse amount, as a numeric string`
|
79 |
-
*/
|
80 |
-
private function _getCreditReversalAmount() {
|
81 |
-
print PHP_EOL."Enter the amount to reverse from the provider (to 2 decimal places):";
|
82 |
-
do {
|
83 |
-
$reverseAmount = trim ( fgets ( STDIN ) );
|
84 |
-
} while ( ! is_numeric ( $reverseAmount ) );
|
85 |
-
|
86 |
-
return $reverseAmount;
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
$reverseProviderCreditExample = new ReverseProviderCreditExampleCLI ( $argv );
|
91 |
-
$reverseProviderCreditExample->runSample ();
|
92 |
-
|
93 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/ReverseProviderCreditSample.php
DELETED
@@ -1,98 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
/**
|
19 |
-
* ReverseProviderCredit Sample
|
20 |
-
*/
|
21 |
-
require_once realpath ( dirname ( __FILE__ ) ) . '/.config.inc.php';
|
22 |
-
|
23 |
-
/**
|
24 |
-
* ReverseProviderCredit Sample
|
25 |
-
*/
|
26 |
-
function printProviderCreditReversalDetailsResponse($response) {
|
27 |
-
print "Service Response" . PHP_EOL;
|
28 |
-
print "=============================================================================" . PHP_EOL;
|
29 |
-
if ($response->isSetReverseProviderCreditResult ()) {
|
30 |
-
print " ReverseProviderCreditResult" . PHP_EOL;
|
31 |
-
$reversalProviderCreditResult = $response->getReverseProviderCreditResult ();
|
32 |
-
if ($reversalProviderCreditResult->isSetProviderCreditReversalDetails ()) {
|
33 |
-
print " ProviderCreditReversalDetails" . PHP_EOL;
|
34 |
-
$providerCreditReversalDetails = $reversalProviderCreditResult->getProviderCreditReversalDetails ();
|
35 |
-
if ($providerCreditReversalDetails->isSetAmazonProviderCreditReversalId ()) {
|
36 |
-
print " AmazonProviderCreditReversalId" . PHP_EOL;
|
37 |
-
print " " . $providerCreditReversalDetails->getAmazonProviderCreditReversalId () . PHP_EOL;
|
38 |
-
}
|
39 |
-
if ($providerCreditReversalDetails->isSetCreditReversalReferenceId ()) {
|
40 |
-
print " CreditReversalReferenceId" . PHP_EOL;
|
41 |
-
print " " . $providerCreditReversalDetails->getCreditReversalReferenceId () . PHP_EOL;
|
42 |
-
}
|
43 |
-
if ($providerCreditReversalDetails->isSetCreditReversalAmount ()) {
|
44 |
-
print " CreditReversalAmount" . PHP_EOL;
|
45 |
-
$creditReversalAmount = $providerCreditReversalDetails->getCreditReversalAmount ();
|
46 |
-
if ($creditReversalAmount->isSetAmount ()) {
|
47 |
-
print " Amount" . PHP_EOL;
|
48 |
-
print " " . $creditReversalAmount->getAmount () . PHP_EOL;
|
49 |
-
}
|
50 |
-
if ($creditReversalAmount->isSetCurrencyCode ()) {
|
51 |
-
print " CurrencyCode" . PHP_EOL;
|
52 |
-
print " " . $creditReversalAmount->getCurrencyCode () . PHP_EOL;
|
53 |
-
}
|
54 |
-
}
|
55 |
-
if ($providerCreditReversalDetails->isSetCreationTimestamp ()) {
|
56 |
-
print " CreationTimestamp" . PHP_EOL;
|
57 |
-
print " " . $providerCreditReversalDetails->getCreationTimestamp () . PHP_EOL;
|
58 |
-
}
|
59 |
-
if ($providerCreditReversalDetails->isSetCreditReversalStatus ()) {
|
60 |
-
print " CreditReversalStatus" . PHP_EOL;
|
61 |
-
$creditStatus = $providerCreditReversalDetails->getCreditReversalStatus ();
|
62 |
-
if ($creditStatus->isSetState ()) {
|
63 |
-
print " State" . PHP_EOL;
|
64 |
-
print " " . $creditStatus->getState () . PHP_EOL;
|
65 |
-
}
|
66 |
-
if ($creditStatus->isSetLastUpdateTimestamp ()) {
|
67 |
-
print " LastUpdateTimestamp" . PHP_EOL;
|
68 |
-
print " " . $creditStatus->getLastUpdateTimestamp () . PHP_EOL;
|
69 |
-
}
|
70 |
-
if ($creditStatus->isSetReasonCode ()) {
|
71 |
-
print " ReasonCode" . PHP_EOL;
|
72 |
-
print " " . $creditStatus->getReasonCode () . PHP_EOL;
|
73 |
-
}
|
74 |
-
if ($creditStatus->isSetReasonDescription ()) {
|
75 |
-
print " ReasonDescription" . PHP_EOL;
|
76 |
-
print " " . $creditStatus->getReasonDescription () . PHP_EOL;
|
77 |
-
}
|
78 |
-
}
|
79 |
-
if ($providerCreditReversalDetails->isSetCreditReversalNote ()) {
|
80 |
-
print " CreditReversalNote" . PHP_EOL;
|
81 |
-
print " " . $providerCreditReversalDetails->getCreditReversalNote () . PHP_EOL;
|
82 |
-
}
|
83 |
-
}
|
84 |
-
}
|
85 |
-
if ($response->isSetResponseMetadata ()) {
|
86 |
-
print " ResponseMetadata" . PHP_EOL;
|
87 |
-
$responseMetadata = $response->getResponseMetadata ();
|
88 |
-
if ($responseMetadata->isSetRequestId ()) {
|
89 |
-
print " RequestId" . PHP_EOL;
|
90 |
-
print " " . $responseMetadata->getRequestId () . PHP_EOL;
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
print " ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata () . PHP_EOL;
|
95 |
-
|
96 |
-
return $response;
|
97 |
-
}
|
98 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/SetBillingAgreementDetailsSample.php
DELETED
@@ -1,337 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Print the SetBillingAgreementDetails response to the console
|
21 |
-
*
|
22 |
-
* @param OffAmazonPaymentsService_Model_SetBillingAgreementDetailsResponse $response
|
23 |
-
* response object
|
24 |
-
*
|
25 |
-
* @return void
|
26 |
-
*/
|
27 |
-
function printSetBillingAgreementDetailsResponse ($response)
|
28 |
-
{
|
29 |
-
echo ("Service Response\n");
|
30 |
-
echo ("=============================================================================\n");
|
31 |
-
|
32 |
-
echo (" SetBillingAgreementDetailsResponse\n");
|
33 |
-
if ($response->isSetSetBillingAgreementDetailsResult()) {
|
34 |
-
echo (" SetBillingAgreementDetailsResult\n");
|
35 |
-
$setBillingAgreementDetailsResult = $response->getSetBillingAgreementDetailsResult();
|
36 |
-
if ($setBillingAgreementDetailsResult->isSetBillingAgreementDetails()) {
|
37 |
-
echo (" BillingAgreementDetails\n");
|
38 |
-
$billingAgreementDetails = $setBillingAgreementDetailsResult->getBillingAgreementDetails();
|
39 |
-
if ($billingAgreementDetails->isSetAmazonBillingAgreementId()) {
|
40 |
-
echo (" AmazonBillingAgreementId\n");
|
41 |
-
echo (" " .
|
42 |
-
$billingAgreementDetails->getAmazonBillingAgreementId() . "\n");
|
43 |
-
}
|
44 |
-
if ($billingAgreementDetails->isSetBillingAgreementLimits()) {
|
45 |
-
echo (" BillingAgreementLimits\n");
|
46 |
-
$billingAgreementLimits = $billingAgreementDetails->getBillingAgreementLimits();
|
47 |
-
if ($billingAgreementLimits->isSetAmountLimitPerTimePeriod()) {
|
48 |
-
echo (" AmountLimitPerTimePeriod\n");
|
49 |
-
$amountLimitPerTimePeriod = $billingAgreementLimits->getAmountLimitPerTimePeriod();
|
50 |
-
if ($amountLimitPerTimePeriod->isSetAmount()) {
|
51 |
-
echo (" Amount\n");
|
52 |
-
echo (" " .
|
53 |
-
$amountLimitPerTimePeriod->getAmount() . "\n");
|
54 |
-
}
|
55 |
-
if ($amountLimitPerTimePeriod->isSetCurrencyCode()) {
|
56 |
-
echo (" CurrencyCode\n");
|
57 |
-
echo (" " .
|
58 |
-
$amountLimitPerTimePeriod->getCurrencyCode() . "\n");
|
59 |
-
}
|
60 |
-
}
|
61 |
-
if ($billingAgreementLimits->isSetTimePeriodStartDate()) {
|
62 |
-
echo (" TimePeriodStartDate\n");
|
63 |
-
echo (" " .
|
64 |
-
$billingAgreementLimits->getTimePeriodStartDate() . "\n");
|
65 |
-
}
|
66 |
-
if ($billingAgreementLimits->isSetTimePeriodEndDate()) {
|
67 |
-
echo (" TimePeriodEndDate\n");
|
68 |
-
echo (" " .
|
69 |
-
$billingAgreementLimits->getTimePeriodEndDate() . "\n");
|
70 |
-
}
|
71 |
-
if ($billingAgreementLimits->isSetCurrentRemainingBalance()) {
|
72 |
-
echo (" CurrentRemainingBalance\n");
|
73 |
-
$currentRemainingBalance = $billingAgreementLimits->getCurrentRemainingBalance();
|
74 |
-
if ($currentRemainingBalance->isSetAmount()) {
|
75 |
-
echo (" Amount\n");
|
76 |
-
echo (" " .
|
77 |
-
$currentRemainingBalance->getAmount() . "\n");
|
78 |
-
}
|
79 |
-
if ($currentRemainingBalance->isSetCurrencyCode()) {
|
80 |
-
echo (" CurrencyCode\n");
|
81 |
-
echo (" " .
|
82 |
-
$currentRemainingBalance->getCurrencyCode() . "\n");
|
83 |
-
}
|
84 |
-
}
|
85 |
-
}
|
86 |
-
if ($billingAgreementDetails->isSetBuyer()) {
|
87 |
-
echo (" Buyer\n");
|
88 |
-
$buyer = $billingAgreementDetails->getBuyer();
|
89 |
-
if ($buyer->isSetName()) {
|
90 |
-
echo (" Name\n");
|
91 |
-
echo (" " . $buyer->getName() . "\n");
|
92 |
-
}
|
93 |
-
if ($buyer->isSetEmail()) {
|
94 |
-
echo (" Email\n");
|
95 |
-
echo (" " . $buyer->getEmail() . "\n");
|
96 |
-
}
|
97 |
-
if ($buyer->isSetPhone()) {
|
98 |
-
echo (" Phone\n");
|
99 |
-
echo (" " . $buyer->getPhone() . "\n");
|
100 |
-
}
|
101 |
-
}
|
102 |
-
if ($billingAgreementDetails->isSetSellerNote()) {
|
103 |
-
echo (" SellerNote\n");
|
104 |
-
echo (" " . $billingAgreementDetails->getSellerNote() . "\n");
|
105 |
-
}
|
106 |
-
if ($billingAgreementDetails->isSetPlatformId()) {
|
107 |
-
echo (" PlatformId\n");
|
108 |
-
echo (" " . $billingAgreementDetails->getPlatformId() . "\n");
|
109 |
-
}
|
110 |
-
if ($billingAgreementDetails->isSetDestination()) {
|
111 |
-
echo (" Destination\n");
|
112 |
-
$destination = $billingAgreementDetails->getDestination();
|
113 |
-
if ($destination->isSetDestinationType()) {
|
114 |
-
echo (" DestinationType\n");
|
115 |
-
echo (" " . $destination->getDestinationType() . "\n");
|
116 |
-
}
|
117 |
-
if ($destination->isSetPhysicalDestination()) {
|
118 |
-
echo (" PhysicalDestination\n");
|
119 |
-
$physicalDestination = $destination->getPhysicalDestination();
|
120 |
-
if ($physicalDestination->isSetName()) {
|
121 |
-
echo (" Name\n");
|
122 |
-
echo (" " . $physicalDestination->getName() .
|
123 |
-
"\n");
|
124 |
-
}
|
125 |
-
if ($physicalDestination->isSetAddressLine1()) {
|
126 |
-
echo (" AddressLine1\n");
|
127 |
-
echo (" " .
|
128 |
-
$physicalDestination->getAddressLine1() . "\n");
|
129 |
-
}
|
130 |
-
if ($physicalDestination->isSetAddressLine2()) {
|
131 |
-
echo (" AddressLine2\n");
|
132 |
-
echo (" " .
|
133 |
-
$physicalDestination->getAddressLine2() . "\n");
|
134 |
-
}
|
135 |
-
if ($physicalDestination->isSetAddressLine3()) {
|
136 |
-
echo (" AddressLine3\n");
|
137 |
-
echo (" " .
|
138 |
-
$physicalDestination->getAddressLine3() . "\n");
|
139 |
-
}
|
140 |
-
if ($physicalDestination->isSetCity()) {
|
141 |
-
echo (" City\n");
|
142 |
-
echo (" " . $physicalDestination->getCity() .
|
143 |
-
"\n");
|
144 |
-
}
|
145 |
-
if ($physicalDestination->isSetCounty()) {
|
146 |
-
echo (" County\n");
|
147 |
-
echo (" " . $physicalDestination->getCounty() .
|
148 |
-
"\n");
|
149 |
-
}
|
150 |
-
if ($physicalDestination->isSetDistrict()) {
|
151 |
-
echo (" District\n");
|
152 |
-
echo (" " .
|
153 |
-
$physicalDestination->getDistrict() . "\n");
|
154 |
-
}
|
155 |
-
if ($physicalDestination->isSetStateOrRegion()) {
|
156 |
-
echo (" StateOrRegion\n");
|
157 |
-
echo (" " .
|
158 |
-
$physicalDestination->getStateOrRegion() . "\n");
|
159 |
-
}
|
160 |
-
if ($physicalDestination->isSetPostalCode()) {
|
161 |
-
echo (" PostalCode\n");
|
162 |
-
echo (" " .
|
163 |
-
$physicalDestination->getPostalCode() . "\n");
|
164 |
-
}
|
165 |
-
if ($physicalDestination->isSetCountryCode()) {
|
166 |
-
echo (" CountryCode\n");
|
167 |
-
echo (" " .
|
168 |
-
$physicalDestination->getCountryCode() . "\n");
|
169 |
-
}
|
170 |
-
if ($physicalDestination->isSetPhone()) {
|
171 |
-
echo (" Phone\n");
|
172 |
-
echo (" " . $physicalDestination->getPhone() .
|
173 |
-
"\n");
|
174 |
-
}
|
175 |
-
}
|
176 |
-
}
|
177 |
-
if ($billingAgreementDetails->isSetBillingAddress()) {
|
178 |
-
echo (" BillingAddress\n");
|
179 |
-
$billingAddress = $billingAgreementDetails->getBillingAddress();
|
180 |
-
if ($billingAddress->isSetAddressType()) {
|
181 |
-
echo (" AddressType\n");
|
182 |
-
echo (" " . $billingAddress->getAddressType() . "\n");
|
183 |
-
}
|
184 |
-
if ($billingAddress->isSetPhysicalAddress()) {
|
185 |
-
echo (" PhysicalAddress\n");
|
186 |
-
$physicalAddress = $billingAddress->getPhysicalAddress();
|
187 |
-
if ($physicalAddress->isSetName()) {
|
188 |
-
echo (" Name\n");
|
189 |
-
echo (" " . $physicalAddress->getName() .
|
190 |
-
"\n");
|
191 |
-
}
|
192 |
-
if ($physicalAddress->isSetAddressLine1()) {
|
193 |
-
echo (" AddressLine1\n");
|
194 |
-
echo (" " .
|
195 |
-
$physicalAddress->getAddressLine1() . "\n");
|
196 |
-
}
|
197 |
-
if ($physicalAddress->isSetAddressLine2()) {
|
198 |
-
echo (" AddressLine2\n");
|
199 |
-
echo (" " .
|
200 |
-
$physicalAddress->getAddressLine2() . "\n");
|
201 |
-
}
|
202 |
-
if ($physicalAddress->isSetAddressLine3()) {
|
203 |
-
echo (" AddressLine3\n");
|
204 |
-
echo (" " .
|
205 |
-
$physicalAddress->getAddressLine3() . "\n");
|
206 |
-
}
|
207 |
-
if ($physicalAddress->isSetCity()) {
|
208 |
-
echo (" City\n");
|
209 |
-
echo (" " . $physicalAddress->getCity() .
|
210 |
-
"\n");
|
211 |
-
}
|
212 |
-
if ($physicalAddress->isSetCounty()) {
|
213 |
-
echo (" County\n");
|
214 |
-
echo (" " . $physicalAddress->getCounty() .
|
215 |
-
"\n");
|
216 |
-
}
|
217 |
-
if ($physicalAddress->isSetDistrict()) {
|
218 |
-
echo (" District\n");
|
219 |
-
echo (" " .
|
220 |
-
$physicalAddress->getDistrict() . "\n");
|
221 |
-
}
|
222 |
-
if ($physicalAddress->isSetStateOrRegion()) {
|
223 |
-
echo (" StateOrRegion\n");
|
224 |
-
echo (" " .
|
225 |
-
$physicalAddress->getStateOrRegion() . "\n");
|
226 |
-
}
|
227 |
-
if ($physicalAddress->isSetPostalCode()) {
|
228 |
-
echo (" PostalCode\n");
|
229 |
-
echo (" " .
|
230 |
-
$physicalAddress->getPostalCode() . "\n");
|
231 |
-
}
|
232 |
-
if ($physicalAddress->isSetCountryCode()) {
|
233 |
-
echo (" CountryCode\n");
|
234 |
-
echo (" " .
|
235 |
-
$physicalAddress->getCountryCode() . "\n");
|
236 |
-
}
|
237 |
-
if ($physicalAddress->isSetPhone()) {
|
238 |
-
echo (" Phone\n");
|
239 |
-
echo (" " . $physicalAddress->getPhone() .
|
240 |
-
"\n");
|
241 |
-
}
|
242 |
-
}
|
243 |
-
}
|
244 |
-
if ($billingAgreementDetails->isSetReleaseEnvironment()) {
|
245 |
-
echo (" ReleaseEnvironment\n");
|
246 |
-
echo (" " . $billingAgreementDetails->getReleaseEnvironment() .
|
247 |
-
"\n");
|
248 |
-
}
|
249 |
-
if ($billingAgreementDetails->isSetSellerBillingAgreementAttributes()) {
|
250 |
-
echo (" SellerBillingAgreementAttributes\n");
|
251 |
-
$sellerBillingAgreementAttributes = $billingAgreementDetails->getSellerBillingAgreementAttributes();
|
252 |
-
if ($sellerBillingAgreementAttributes->isSetSellerBillingAgreementId()) {
|
253 |
-
echo (" SellerBillingAgreementId\n");
|
254 |
-
echo (" " .
|
255 |
-
$sellerBillingAgreementAttributes->getSellerBillingAgreementId() . "\n");
|
256 |
-
}
|
257 |
-
if ($sellerBillingAgreementAttributes->isSetStoreName()) {
|
258 |
-
echo (" StoreName\n");
|
259 |
-
echo (" " .
|
260 |
-
$sellerBillingAgreementAttributes->getStoreName() . "\n");
|
261 |
-
}
|
262 |
-
if ($sellerBillingAgreementAttributes->isSetCustomInformation()) {
|
263 |
-
echo (" CustomInformation\n");
|
264 |
-
echo (" " .
|
265 |
-
$sellerBillingAgreementAttributes->getCustomInformation() . "\n");
|
266 |
-
}
|
267 |
-
}
|
268 |
-
if ($billingAgreementDetails->isSetBillingAgreementStatus()) {
|
269 |
-
echo (" BillingAgreementStatus\n");
|
270 |
-
$billingAgreementStatus = $billingAgreementDetails->getBillingAgreementStatus();
|
271 |
-
if ($billingAgreementStatus->isSetState()) {
|
272 |
-
echo (" State\n");
|
273 |
-
echo (" " . $billingAgreementStatus->getState() . "\n");
|
274 |
-
}
|
275 |
-
if ($billingAgreementStatus->isSetLastUpdatedTimestamp()) {
|
276 |
-
echo (" LastUpdatedTimestamp\n");
|
277 |
-
echo (" " .
|
278 |
-
$billingAgreementStatus->getLastUpdatedTimestamp() . "\n");
|
279 |
-
}
|
280 |
-
if ($billingAgreementStatus->isSetReasonCode()) {
|
281 |
-
echo (" ReasonCode\n");
|
282 |
-
echo (" " . $billingAgreementStatus->getReasonCode() .
|
283 |
-
"\n");
|
284 |
-
}
|
285 |
-
if ($billingAgreementStatus->isSetReasonDescription()) {
|
286 |
-
echo (" ReasonDescription\n");
|
287 |
-
echo (" " .
|
288 |
-
$billingAgreementStatus->getReasonDescription() . "\n");
|
289 |
-
}
|
290 |
-
}
|
291 |
-
if ($billingAgreementDetails->isSetConstraints()) {
|
292 |
-
echo (" Constraints\n");
|
293 |
-
$constraints = $billingAgreementDetails->getConstraints();
|
294 |
-
$constraintList = $constraints->getConstraint();
|
295 |
-
foreach ($constraintList as $constraint) {
|
296 |
-
echo (" Constraint\n");
|
297 |
-
if ($constraint->isSetConstraintID()) {
|
298 |
-
echo (" ConstraintID\n");
|
299 |
-
echo (" " . $constraint->getConstraintID() .
|
300 |
-
"\n");
|
301 |
-
}
|
302 |
-
if ($constraint->isSetDescription()) {
|
303 |
-
echo (" Description\n");
|
304 |
-
echo (" " . $constraint->getDescription() .
|
305 |
-
"\n");
|
306 |
-
}
|
307 |
-
}
|
308 |
-
}
|
309 |
-
if ($billingAgreementDetails->isSetCreationTimestamp()) {
|
310 |
-
echo (" CreationTimestamp\n");
|
311 |
-
echo (" " . $billingAgreementDetails->getCreationTimestamp() .
|
312 |
-
"\n");
|
313 |
-
}
|
314 |
-
if ($billingAgreementDetails->isSetExpirationTimestamp()) {
|
315 |
-
echo (" ExpirationTimestamp\n");
|
316 |
-
echo (" " . $billingAgreementDetails->getExpirationTimestamp() .
|
317 |
-
"\n");
|
318 |
-
}
|
319 |
-
if ($billingAgreementDetails->isSetBillingAgreementConsent()) {
|
320 |
-
echo (" BillingAgreementConsent\n");
|
321 |
-
echo (" " .
|
322 |
-
$billingAgreementDetails->getBillingAgreementConsent() . "\n");
|
323 |
-
}
|
324 |
-
}
|
325 |
-
}
|
326 |
-
if ($response->isSetResponseMetadata()) {
|
327 |
-
echo (" ResponseMetadata\n");
|
328 |
-
$responseMetadata = $response->getResponseMetadata();
|
329 |
-
if ($responseMetadata->isSetRequestId()) {
|
330 |
-
echo (" RequestId\n");
|
331 |
-
echo (" " . $responseMetadata->getRequestId() . "\n");
|
332 |
-
}
|
333 |
-
}
|
334 |
-
|
335 |
-
echo (" ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");
|
336 |
-
}
|
337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/SetOrderReferenceDetailsSample.php
DELETED
@@ -1,347 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Set Order Reference Details Sample
|
21 |
-
*/
|
22 |
-
|
23 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
24 |
-
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Set Order Reference Details Action Sample
|
28 |
-
|
29 |
-
* @param OffAmazonPaymentsService_Interface $service instance of OffAmazonPaymentsService_Interface
|
30 |
-
* @param mixed $request OffAmazonPaymentsService_Model_SetOrderReferenceDetails or array of parameters
|
31 |
-
*/
|
32 |
-
function printSetOrderReferenceDetailsResponse($response)
|
33 |
-
{
|
34 |
-
|
35 |
-
print "Service Response" . PHP_EOL;
|
36 |
-
print "=============================================================================" . PHP_EOL;
|
37 |
-
|
38 |
-
print " SetOrderReferenceDetailsResponse" . PHP_EOL;
|
39 |
-
if ($response->isSetSetOrderReferenceDetailsResult()) {
|
40 |
-
print " SetOrderReferenceDetailsResult" . PHP_EOL;
|
41 |
-
$setOrderReferenceDetailsResult = $response->getSetOrderReferenceDetailsResult();
|
42 |
-
if ($setOrderReferenceDetailsResult->isSetOrderReferenceDetails()) {
|
43 |
-
print " OrderReferenceDetails" . PHP_EOL;
|
44 |
-
$orderReferenceDetails = $setOrderReferenceDetailsResult->getOrderReferenceDetails();
|
45 |
-
if ($orderReferenceDetails->isSetAmazonOrderReferenceId())
|
46 |
-
{
|
47 |
-
print " AmazonOrderReferenceId" . PHP_EOL;
|
48 |
-
print " " . $orderReferenceDetails->getAmazonOrderReferenceId() . PHP_EOL;
|
49 |
-
}
|
50 |
-
if ($orderReferenceDetails->isSetBuyer()) {
|
51 |
-
print " Buyer" . PHP_EOL;
|
52 |
-
$buyer = $orderReferenceDetails->getBuyer();
|
53 |
-
if ($buyer->isSetName())
|
54 |
-
{
|
55 |
-
print " Name" . PHP_EOL;
|
56 |
-
print " " . $buyer->getName() . PHP_EOL;
|
57 |
-
}
|
58 |
-
if ($buyer->isSetEmail())
|
59 |
-
{
|
60 |
-
print " Email" . PHP_EOL;
|
61 |
-
print " " . $buyer->getEmail() . PHP_EOL;
|
62 |
-
}
|
63 |
-
if ($buyer->isSetPhone())
|
64 |
-
{
|
65 |
-
print " Phone" . PHP_EOL;
|
66 |
-
print " " . $buyer->getPhone() . PHP_EOL;
|
67 |
-
}
|
68 |
-
}
|
69 |
-
if ($orderReferenceDetails->isSetOrderTotal()) {
|
70 |
-
print " OrderTotal" . PHP_EOL;
|
71 |
-
$orderTotal = $orderReferenceDetails->getOrderTotal();
|
72 |
-
if ($orderTotal->isSetCurrencyCode())
|
73 |
-
{
|
74 |
-
print " CurrencyCode" . PHP_EOL;
|
75 |
-
print " " . $orderTotal->getCurrencyCode() . PHP_EOL;
|
76 |
-
}
|
77 |
-
if ($orderTotal->isSetAmount())
|
78 |
-
{
|
79 |
-
print " Amount" . PHP_EOL;
|
80 |
-
print " " . $orderTotal->getAmount() . PHP_EOL;
|
81 |
-
}
|
82 |
-
}
|
83 |
-
if ($orderReferenceDetails->isSetSellerNote())
|
84 |
-
{
|
85 |
-
print " SellerNote" . PHP_EOL;
|
86 |
-
print " " . $orderReferenceDetails->getSellerNote() . PHP_EOL;
|
87 |
-
}
|
88 |
-
if ($orderReferenceDetails->isSetDestination()) {
|
89 |
-
print " Destination" . PHP_EOL;
|
90 |
-
$destination = $orderReferenceDetails->getDestination();
|
91 |
-
if ($destination->isSetDestinationType())
|
92 |
-
{
|
93 |
-
print " DestinationType" . PHP_EOL;
|
94 |
-
print " " . $destination->getDestinationType() . PHP_EOL;
|
95 |
-
}
|
96 |
-
if ($destination->isSetPhysicalDestination()) {
|
97 |
-
print " PhysicalDestination" . PHP_EOL;
|
98 |
-
$physicalDestination = $destination->getPhysicalDestination();
|
99 |
-
if ($physicalDestination->isSetName())
|
100 |
-
{
|
101 |
-
print " Name" . PHP_EOL;
|
102 |
-
print " " . $physicalDestination->getName() . PHP_EOL;
|
103 |
-
}
|
104 |
-
if ($physicalDestination->isSetAddressLine1())
|
105 |
-
{
|
106 |
-
print " AddressLine1" . PHP_EOL;
|
107 |
-
print " " . $physicalDestination->getAddressLine1() . PHP_EOL;
|
108 |
-
}
|
109 |
-
if ($physicalDestination->isSetAddressLine2())
|
110 |
-
{
|
111 |
-
print " AddressLine2" . PHP_EOL;
|
112 |
-
print " " . $physicalDestination->getAddressLine2() . PHP_EOL;
|
113 |
-
}
|
114 |
-
if ($physicalDestination->isSetAddressLine3())
|
115 |
-
{
|
116 |
-
print " AddressLine3" . PHP_EOL;
|
117 |
-
print " " . $physicalDestination->getAddressLine3() . PHP_EOL;
|
118 |
-
}
|
119 |
-
if ($physicalDestination->isSetCity())
|
120 |
-
{
|
121 |
-
print " City" . PHP_EOL;
|
122 |
-
print " " . $physicalDestination->getCity() . PHP_EOL;
|
123 |
-
}
|
124 |
-
if ($physicalDestination->isSetCounty())
|
125 |
-
{
|
126 |
-
print " County" . PHP_EOL;
|
127 |
-
print " " . $physicalDestination->getCounty() . PHP_EOL;
|
128 |
-
}
|
129 |
-
if ($physicalDestination->isSetDistrict())
|
130 |
-
{
|
131 |
-
print " District" . PHP_EOL;
|
132 |
-
print " " . $physicalDestination->getDistrict() . PHP_EOL;
|
133 |
-
}
|
134 |
-
if ($physicalDestination->isSetStateOrRegion())
|
135 |
-
{
|
136 |
-
print " StateOrRegion" . PHP_EOL;
|
137 |
-
print " " . $physicalDestination->getStateOrRegion() . PHP_EOL;
|
138 |
-
}
|
139 |
-
if ($physicalDestination->isSetPostalCode())
|
140 |
-
{
|
141 |
-
print " PostalCode" . PHP_EOL;
|
142 |
-
print " " . $physicalDestination->getPostalCode() . PHP_EOL;
|
143 |
-
}
|
144 |
-
if ($physicalDestination->isSetCountryCode())
|
145 |
-
{
|
146 |
-
print " CountryCode" . PHP_EOL;
|
147 |
-
print " " . $physicalDestination->getCountryCode() . PHP_EOL;
|
148 |
-
}
|
149 |
-
if ($physicalDestination->isSetPhone())
|
150 |
-
{
|
151 |
-
print " Phone" . PHP_EOL;
|
152 |
-
print " " . $physicalDestination->getPhone() . PHP_EOL;
|
153 |
-
}
|
154 |
-
}
|
155 |
-
}
|
156 |
-
if ($orderReferenceDetails->isSetBillingAddress()) {
|
157 |
-
echo (" BillingAddress\n");
|
158 |
-
$billingAddress = $orderReferenceDetails->getBillingAddress();
|
159 |
-
if ($billingAddress->isSetAddressType()) {
|
160 |
-
echo (" AddressType\n");
|
161 |
-
echo (" " . $billingAddress->getAddressType() . "\n");
|
162 |
-
}
|
163 |
-
if ($billingAddress->isSetPhysicalAddress()) {
|
164 |
-
echo (" PhysicalAddress\n");
|
165 |
-
$physicalAddress = $billingAddress->getPhysicalAddress();
|
166 |
-
if ($physicalAddress->isSetName()) {
|
167 |
-
echo (" Name\n");
|
168 |
-
echo (" " . $physicalAddress->getName() .
|
169 |
-
"\n");
|
170 |
-
}
|
171 |
-
if ($physicalAddress->isSetAddressLine1()) {
|
172 |
-
echo (" AddressLine1\n");
|
173 |
-
echo (" " .
|
174 |
-
$physicalAddress->getAddressLine1() . "\n");
|
175 |
-
}
|
176 |
-
if ($physicalAddress->isSetAddressLine2()) {
|
177 |
-
echo (" AddressLine2\n");
|
178 |
-
echo (" " .
|
179 |
-
$physicalAddress->getAddressLine2() . "\n");
|
180 |
-
}
|
181 |
-
if ($physicalAddress->isSetAddressLine3()) {
|
182 |
-
echo (" AddressLine3\n");
|
183 |
-
echo (" " .
|
184 |
-
$physicalAddress->getAddressLine3() . "\n");
|
185 |
-
}
|
186 |
-
if ($physicalAddress->isSetCity()) {
|
187 |
-
echo (" City\n");
|
188 |
-
echo (" " . $physicalAddress->getCity() .
|
189 |
-
"\n");
|
190 |
-
}
|
191 |
-
if ($physicalAddress->isSetCounty()) {
|
192 |
-
echo (" County\n");
|
193 |
-
echo (" " . $physicalAddress->getCounty() .
|
194 |
-
"\n");
|
195 |
-
}
|
196 |
-
if ($physicalAddress->isSetDistrict()) {
|
197 |
-
echo (" District\n");
|
198 |
-
echo (" " .
|
199 |
-
$physicalAddress->getDistrict() . "\n");
|
200 |
-
}
|
201 |
-
if ($physicalAddress->isSetStateOrRegion()) {
|
202 |
-
echo (" StateOrRegion\n");
|
203 |
-
echo (" " .
|
204 |
-
$physicalAddress->getStateOrRegion() . "\n");
|
205 |
-
}
|
206 |
-
if ($physicalAddress->isSetPostalCode()) {
|
207 |
-
echo (" PostalCode\n");
|
208 |
-
echo (" " .
|
209 |
-
$physicalAddress->getPostalCode() . "\n");
|
210 |
-
}
|
211 |
-
if ($physicalAddress->isSetCountryCode()) {
|
212 |
-
echo (" CountryCode\n");
|
213 |
-
echo (" " .
|
214 |
-
$physicalAddress->getCountryCode() . "\n");
|
215 |
-
}
|
216 |
-
if ($physicalAddress->isSetPhone()) {
|
217 |
-
echo (" Phone\n");
|
218 |
-
echo (" " . $physicalAddress->getPhone() .
|
219 |
-
"\n");
|
220 |
-
}
|
221 |
-
}
|
222 |
-
}
|
223 |
-
if ($orderReferenceDetails->isSetReleaseEnvironment())
|
224 |
-
{
|
225 |
-
print " ReleaseEnvironment" . PHP_EOL;
|
226 |
-
print " " . $orderReferenceDetails->getReleaseEnvironment() . PHP_EOL;
|
227 |
-
}
|
228 |
-
if ($orderReferenceDetails->isSetIdList())
|
229 |
-
{
|
230 |
-
print " IdList" . PHP_EOL;
|
231 |
-
$idList = $orderReferenceDetails->getIdList();
|
232 |
-
$memberList = $idList->getmember();
|
233 |
-
foreach ($memberList as $member) {
|
234 |
-
print " member" . PHP_EOL;
|
235 |
-
print " " . $member . PHP_EOL;;
|
236 |
-
}
|
237 |
-
}
|
238 |
-
if ($orderReferenceDetails->isSetSellerOrderAttributes()) {
|
239 |
-
print " SellerOrderAttributes" . PHP_EOL;
|
240 |
-
$sellerOrderAttributes = $orderReferenceDetails->getSellerOrderAttributes();
|
241 |
-
if ($sellerOrderAttributes->isSetSellerOrderId())
|
242 |
-
{
|
243 |
-
print " SellerOrderId" . PHP_EOL;
|
244 |
-
print " " . $sellerOrderAttributes->getSellerOrderId() . PHP_EOL;
|
245 |
-
}
|
246 |
-
if ($sellerOrderAttributes->isSetStoreName())
|
247 |
-
{
|
248 |
-
print " StoreName" . PHP_EOL;
|
249 |
-
print " " . $sellerOrderAttributes->getStoreName() . PHP_EOL;
|
250 |
-
}
|
251 |
-
if ($sellerOrderAttributes->isSetOrderItemCategories()) {
|
252 |
-
print " OrderItemCategories" . PHP_EOL;
|
253 |
-
$orderItemCategories = $sellerOrderAttributes->getOrderItemCategories();
|
254 |
-
$orderItemCategoryList = $orderItemCategories->getOrderItemCategory();
|
255 |
-
foreach ($orderItemCategoryList as $orderItemCategory) {
|
256 |
-
print " OrderItemCategory" . PHP_EOL;
|
257 |
-
print " " . $orderItemCategory;
|
258 |
-
}
|
259 |
-
}
|
260 |
-
if ($sellerOrderAttributes->isSetCustomInformation())
|
261 |
-
{
|
262 |
-
print " CustomInformation" . PHP_EOL;
|
263 |
-
print " " . $sellerOrderAttributes->getCustomInformation() . PHP_EOL;
|
264 |
-
}
|
265 |
-
}
|
266 |
-
if ($orderReferenceDetails->isSetOrderReferenceStatus()) {
|
267 |
-
print " OrderReferenceStatus" . PHP_EOL;
|
268 |
-
$orderReferenceStatus = $orderReferenceDetails->getOrderReferenceStatus();
|
269 |
-
if ($orderReferenceStatus->isSetState())
|
270 |
-
{
|
271 |
-
print " State" . PHP_EOL;
|
272 |
-
print " " . $orderReferenceStatus->getState() . PHP_EOL;
|
273 |
-
}
|
274 |
-
if ($orderReferenceStatus->isSetLastUpdateTimestamp())
|
275 |
-
{
|
276 |
-
print " LastUpdateTimestamp" . PHP_EOL;
|
277 |
-
print " " . $orderReferenceStatus->getLastUpdateTimestamp() . PHP_EOL;
|
278 |
-
}
|
279 |
-
if ($orderReferenceStatus->isSetReasonCode())
|
280 |
-
{
|
281 |
-
print " ReasonCode" . PHP_EOL;
|
282 |
-
print " " . $orderReferenceStatus->getReasonCode() . PHP_EOL;
|
283 |
-
}
|
284 |
-
if ($orderReferenceStatus->isSetReasonDescription())
|
285 |
-
{
|
286 |
-
print " ReasonDescription" . PHP_EOL;
|
287 |
-
print " " . $orderReferenceStatus->getReasonDescription() . PHP_EOL;
|
288 |
-
}
|
289 |
-
}
|
290 |
-
if ($orderReferenceDetails->isSetConstraints()) {
|
291 |
-
print " Constraints" . PHP_EOL;
|
292 |
-
$constraints = $orderReferenceDetails->getConstraints();
|
293 |
-
$constraintList = $constraints->getConstraint();
|
294 |
-
foreach ($constraintList as $constraint) {
|
295 |
-
print " Constraint" . PHP_EOL;
|
296 |
-
if ($constraint->isSetConstraintID())
|
297 |
-
{
|
298 |
-
print " ConstraintID" . PHP_EOL;
|
299 |
-
print " " . $constraint->getConstraintID() . PHP_EOL;
|
300 |
-
}
|
301 |
-
if ($constraint->isSetDescription())
|
302 |
-
{
|
303 |
-
print " Description" . PHP_EOL;
|
304 |
-
print " " . $constraint->getDescription() . PHP_EOL;
|
305 |
-
}
|
306 |
-
}
|
307 |
-
}
|
308 |
-
if ($orderReferenceDetails->isSetCreationTimestamp())
|
309 |
-
{
|
310 |
-
print " CreationTimestamp" . PHP_EOL;
|
311 |
-
print " " . $orderReferenceDetails->getCreationTimestamp() . PHP_EOL;
|
312 |
-
}
|
313 |
-
if ($orderReferenceDetails->isSetExpirationTimestamp())
|
314 |
-
{
|
315 |
-
print " ExpirationTimestamp" . PHP_EOL;
|
316 |
-
print " " . $orderReferenceDetails->getExpirationTimestamp() . PHP_EOL;
|
317 |
-
}
|
318 |
-
if ($orderReferenceDetails->isSetParentDetails()) {
|
319 |
-
print " ParentDetails" . PHP_EOL;
|
320 |
-
$parentDetails = $orderReferenceDetails->getParentDetails();
|
321 |
-
if ($parentDetails->isSetId()) {
|
322 |
-
print " Id" . PHP_EOL;
|
323 |
-
print " " . $parentDetails->getId() . PHP_EOL;
|
324 |
-
}
|
325 |
-
if ($parentDetails->isSetType()) {
|
326 |
-
print " Type" . PHP_EOL;
|
327 |
-
print " " . $parentDetails->getType() . PHP_EOL;
|
328 |
-
}
|
329 |
-
}
|
330 |
-
}
|
331 |
-
}
|
332 |
-
if ($response->isSetResponseMetadata()) {
|
333 |
-
print " ResponseMetadata" . PHP_EOL;
|
334 |
-
$responseMetadata = $response->getResponseMetadata();
|
335 |
-
if ($responseMetadata->isSetRequestId())
|
336 |
-
{
|
337 |
-
print " RequestId" . PHP_EOL;
|
338 |
-
print " " . $responseMetadata->getRequestId() . PHP_EOL;
|
339 |
-
}
|
340 |
-
}
|
341 |
-
|
342 |
-
print " ResponseHeaderMetadata: " .
|
343 |
-
$response->getResponseHeaderMetadata() . PHP_EOL;
|
344 |
-
|
345 |
-
return $response;
|
346 |
-
}
|
347 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php
DELETED
@@ -1,318 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
*/
|
15 |
-
|
16 |
-
/*
|
17 |
-
* Straight checkout example
|
18 |
-
*
|
19 |
-
* This demonstrates a merchant use case where the item is in stock, and
|
20 |
-
* the order reference creation is immediately followed by the order
|
21 |
-
* confirmation and capture of funds for the merchant
|
22 |
-
*
|
23 |
-
* This use case makes the assumption that the merchant is using the
|
24 |
-
* address capture widget to capture the destination address for the order, and
|
25 |
-
* uses the address information to calculate a tax and shipping rate
|
26 |
-
*
|
27 |
-
* This example will show the following service calls:
|
28 |
-
* - GetOrderReferenceDetails
|
29 |
-
* - SetOrderReferenceDetails
|
30 |
-
* - ConfirmOrderReference
|
31 |
-
* - Authorize
|
32 |
-
* - GetAuthorizeDetails
|
33 |
-
* - Capture
|
34 |
-
* - GetCaptureDetails
|
35 |
-
* - CloseOrderReference
|
36 |
-
*/
|
37 |
-
|
38 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
39 |
-
require_once realpath(dirname(__FILE__)) . '/Utils/ShippingAndTaxCostHelper.php';
|
40 |
-
|
41 |
-
|
42 |
-
/**
|
43 |
-
* SimpleCheckoutExample includes the logic
|
44 |
-
* required to capture an order and perform
|
45 |
-
* all actions to capture the order amount from
|
46 |
-
* the buyer
|
47 |
-
*
|
48 |
-
*/
|
49 |
-
class SimpleCheckoutExample
|
50 |
-
{
|
51 |
-
private $_sellerId;
|
52 |
-
private $_service;
|
53 |
-
private $_amazonOrderReferenceId;
|
54 |
-
private $_authorizationReferenceId;
|
55 |
-
private $_captureReferenceId;
|
56 |
-
private $_shippingAndTaxCostHelper;
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Create a new instance of the simple checkout example
|
60 |
-
* case
|
61 |
-
*
|
62 |
-
* @param OffAmazonPaymentsService_Client $service instance of the service
|
63 |
-
* client
|
64 |
-
* @param string $amazonOrderReferenceId an order reference object in
|
65 |
-
* draft state to use in
|
66 |
-
* the example
|
67 |
-
*
|
68 |
-
* @return new SimpleCheckoutExample
|
69 |
-
*/
|
70 |
-
public function __construct($service, $amazonOrderReferenceId)
|
71 |
-
{
|
72 |
-
|
73 |
-
$this->_service = $service;
|
74 |
-
$this->_amazonOrderReferenceId = $amazonOrderReferenceId;
|
75 |
-
$this->_sellerId = $this->_service->getMerchantValues()->getMerchantId();
|
76 |
-
$this->_shippingAndTaxCostHelper = new ShippingAndTaxCostHelper();
|
77 |
-
|
78 |
-
/*
|
79 |
-
* Setup shared identifiers for the series of transaction requests
|
80 |
-
*/
|
81 |
-
$this->_authorizationReferenceId
|
82 |
-
= str_replace("-", "", $this->_amazonOrderReferenceId) . "A01";
|
83 |
-
$this->_captureReferenceId = $this->_authorizationReferenceId . "C01";
|
84 |
-
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Use the order reference object to query the order information, including
|
89 |
-
* the current physical delivery address as selected by the buyer
|
90 |
-
*
|
91 |
-
* @return OffAmazonPaymentsService_Model_GetOrderReferenceDetailsResponse service response
|
92 |
-
*/
|
93 |
-
public function getOrderReferenceDetails()
|
94 |
-
{
|
95 |
-
$getOrderReferenceDetailsRequest = new OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest();
|
96 |
-
$getOrderReferenceDetailsRequest->setSellerId($this->_sellerId);
|
97 |
-
$getOrderReferenceDetailsRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
98 |
-
|
99 |
-
return $this->_service->getOrderReferenceDetails($getOrderReferenceDetailsRequest);
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Calculate the total amount to charge the buyer for this order,
|
104 |
-
* based on the buyer destination address
|
105 |
-
*
|
106 |
-
* Note that until the order is confirmed, the name & address fields will
|
107 |
-
* not be returned to the client
|
108 |
-
*
|
109 |
-
* @param OffAmazonPaymentsService_Model_OrderReferenceDetails $orderReferenceDetails response
|
110 |
-
* @param string $orderAmountPreTaxAndShipping order amount
|
111 |
-
* @param int $shippingType shipping type
|
112 |
-
*
|
113 |
-
* @return float total amount for the order, with shipping and tax included
|
114 |
-
*/
|
115 |
-
public function calculateOrderTotalBasedOnBuyerDetails($orderReferenceDetails, $orderAmountPreTaxAndShipping, $shippingType)
|
116 |
-
{
|
117 |
-
return $this->_shippingAndTaxCostHelper->calculateTotalAmount($orderReferenceDetails,
|
118 |
-
$orderAmountPreTaxAndShipping, $shippingType);
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Add order information by making the call to setOrderReferenceDetails with
|
123 |
-
* the total order amount, as well as notes describing the order information
|
124 |
-
*
|
125 |
-
* @param float $orderTotal total value of the order, incl shipping and tax
|
126 |
-
*
|
127 |
-
* @return OffAmazonPaymentsService_Model_SetOrderReferenceDetailsResponse service response
|
128 |
-
*/
|
129 |
-
public function addOrderTotalAndSellerInformationToOrder($orderTotal)
|
130 |
-
{
|
131 |
-
/*
|
132 |
-
* Setup request parameters and uncomment invoke to try out
|
133 |
-
* sample for Set Order Reference Details Action
|
134 |
-
*/
|
135 |
-
$setOrderReferenceDetailsRequest = new OffAmazonPaymentsService_Model_SetOrderReferenceDetailsRequest();
|
136 |
-
$setOrderReferenceDetailsRequest->setSellerId($this->_sellerId);
|
137 |
-
$setOrderReferenceDetailsRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
138 |
-
$setOrderReferenceDetailsRequest->setOrderReferenceAttributes(new OffAmazonPaymentsService_Model_OrderReferenceAttributes());
|
139 |
-
$setOrderReferenceDetailsRequest->getOrderReferenceAttributes()->setOrderTotal(new OffAmazonPaymentsService_Model_OrderTotal());
|
140 |
-
$setOrderReferenceDetailsRequest->getOrderReferenceAttributes()->getOrderTotal()->setCurrencyCode($this->_service->getMerchantValues()->getCurrency());
|
141 |
-
$setOrderReferenceDetailsRequest->getOrderReferenceAttributes()->getOrderTotal()->setAmount($orderTotal);
|
142 |
-
$setOrderReferenceDetailsRequest->getOrderReferenceAttributes()->setSellerNote("Red widgets");
|
143 |
-
$setOrderReferenceDetailsRequest->getOrderReferenceAttributes()->setSellerOrderAttributes(new OffAmazonPaymentsService_Model_SellerOrderAttributes());
|
144 |
-
$setOrderReferenceDetailsRequest->getOrderReferenceAttributes()->getSellerOrderAttributes()->setSellerOrderId("AD32333432212");
|
145 |
-
$setOrderReferenceDetailsRequest->getOrderReferenceAttributes()->getSellerOrderAttributes()->setStoreName("Domestic site");
|
146 |
-
$setOrderReferenceDetailsRequest->getOrderReferenceAttributes()->getSellerOrderAttributes()->setCustomInformation("Add blue stripe");
|
147 |
-
|
148 |
-
return $this->_service->setOrderReferenceDetails($setOrderReferenceDetailsRequest);
|
149 |
-
}
|
150 |
-
|
151 |
-
/**
|
152 |
-
* Confirm the order reference information, allowing for
|
153 |
-
* authorizations and captures to be created
|
154 |
-
*
|
155 |
-
* @return OffAmazonPaymentsService_Model_ConfirmOrderReferenceResponse service response
|
156 |
-
*/
|
157 |
-
public function confirmOrderReference()
|
158 |
-
{
|
159 |
-
$confirmOrderReferenceRequest
|
160 |
-
= new OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest();
|
161 |
-
$confirmOrderReferenceRequest
|
162 |
-
->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
163 |
-
$confirmOrderReferenceRequest->setSellerId($this->_sellerId);
|
164 |
-
|
165 |
-
return $this->_service->confirmOrderReference($confirmOrderReferenceRequest);
|
166 |
-
}
|
167 |
-
|
168 |
-
/**
|
169 |
-
* Perform the authorize call for the order
|
170 |
-
*
|
171 |
-
* @param float $authorizationAmount amount to authorize from the buyer
|
172 |
-
*
|
173 |
-
* @return OffAmazonPaymentsService_Model_AuthorizeResponse service response
|
174 |
-
*/
|
175 |
-
public function authorizeOrderAmount($authorizationAmount, $authOption = 1)
|
176 |
-
{
|
177 |
-
$authorizeRequest = new OffAmazonPaymentsService_Model_AuthorizeRequest();
|
178 |
-
$authorizeRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
179 |
-
$authorizeRequest->setSellerId($this->_sellerId);
|
180 |
-
$authorizeRequest->setAuthorizationReferenceId($this->_authorizationReferenceId);
|
181 |
-
$authorizeRequest->setAuthorizationAmount(new OffAmazonPaymentsService_Model_Price());
|
182 |
-
$authorizeRequest->getAuthorizationAmount()->setAmount($authorizationAmount);
|
183 |
-
$authorizeRequest->getAuthorizationAmount()->setCurrencyCode($this->_service->getMerchantValues()->getCurrency());
|
184 |
-
if($authOption == 2){
|
185 |
-
//To use fast authorization, set the Transaction Timeout (optional parameteter) to 0.
|
186 |
-
$authorizeRequest->setTransactionTimeout(0);
|
187 |
-
}
|
188 |
-
return $this->_service->authorize($authorizeRequest);
|
189 |
-
}
|
190 |
-
|
191 |
-
/**
|
192 |
-
* Poll the API for the status of the Authorization Request, and continue
|
193 |
-
* once the status has been updated
|
194 |
-
* WARNING: This is not the way to integrate for production systems,
|
195 |
-
* instead merchants should use IPN to receive a callback once the
|
196 |
-
* processing has been completed.
|
197 |
-
* Note that Amazon reserves the right to throttle requests that
|
198 |
-
* ignore this advice and poll for a response
|
199 |
-
*
|
200 |
-
* @param string $amazonAuthorizationReferenceId authorization transaction to query
|
201 |
-
*
|
202 |
-
* @return OffAmazonPaymentsService_Model_GetAuthorizationDetailsResponse service response
|
203 |
-
*/
|
204 |
-
public function waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId)
|
205 |
-
{
|
206 |
-
$getAuthorizationDetailsResponse = null;
|
207 |
-
do {
|
208 |
-
sleep(5);
|
209 |
-
$getAuthorizationDetailsResponse
|
210 |
-
= $this->getAuthorizationDetails($amazonAuthorizationId);
|
211 |
-
} while ((isset($getAuthorizationDetailsResponse)) and
|
212 |
-
(strcasecmp(
|
213 |
-
$getAuthorizationDetailsResponse
|
214 |
-
->getGetAuthorizationDetailsResult()->getAuthorizationDetails()
|
215 |
-
->getAuthorizationStatus()->getState(),
|
216 |
-
"Pending"
|
217 |
-
) == 0));
|
218 |
-
|
219 |
-
if (is_null($getAuthorizationDetailsResponse)) {
|
220 |
-
throw new ErrorException("No valid response from getAuthorizationDetails request");
|
221 |
-
}
|
222 |
-
|
223 |
-
return $getAuthorizationDetailsResponse;
|
224 |
-
}
|
225 |
-
|
226 |
-
/**
|
227 |
-
* Perform the getAuthroizationDetails request for the order
|
228 |
-
*
|
229 |
-
* @param string $amazonAuthorizationReferenceId authorization transaction
|
230 |
-
* to query
|
231 |
-
*
|
232 |
-
* @return OffAmazonPaymentsService_Model_GetAuthorizationDetailsResponse service response
|
233 |
-
*/
|
234 |
-
public function getAuthorizationDetails($amazonAuthorizationReferenceId)
|
235 |
-
{
|
236 |
-
$getAuthorizationDetailsRequest = new OffAmazonPaymentsService_Model_GetAuthorizationDetailsRequest();
|
237 |
-
$getAuthorizationDetailsRequest->setSellerId($this->_sellerId);
|
238 |
-
$getAuthorizationDetailsRequest->setAmazonAuthorizationId($amazonAuthorizationReferenceId);
|
239 |
-
|
240 |
-
return $this->_service->getAuthorizationDetails($getAuthorizationDetailsRequest);
|
241 |
-
}
|
242 |
-
|
243 |
-
/**
|
244 |
-
* Perform the capture call for the order
|
245 |
-
*
|
246 |
-
* @param float $captureAmount amount to capture from the buyer
|
247 |
-
* @param string $amazonAuthorizationId auth id to perform the capture on
|
248 |
-
*
|
249 |
-
* @return OffAmazonPaymentsService_Model_CaptureResponse service response
|
250 |
-
*/
|
251 |
-
public function captureOrderAmount($captureAmount, $amazonAuthorizationId, $providerCreditInfo = null)
|
252 |
-
{
|
253 |
-
$captureRequest = new OffAmazonPaymentsService_Model_CaptureRequest();
|
254 |
-
$captureRequest->setSellerId($this->_sellerId);
|
255 |
-
$captureRequest->setAmazonAuthorizationId($amazonAuthorizationId);
|
256 |
-
$captureRequest->setCaptureReferenceId($this->_captureReferenceId);
|
257 |
-
$captureRequest->setCaptureAmount(new OffAmazonPaymentsService_Model_Price());
|
258 |
-
$captureRequest->getCaptureAmount()->setAmount($captureAmount);
|
259 |
-
$captureRequest->getCaptureAmount()->setCurrencyCode($this->_service->getMerchantValues()->getCurrency());
|
260 |
-
|
261 |
-
if($providerCreditInfo != null){
|
262 |
-
$captureRequest->setProviderCreditList(new OffAmazonPaymentsService_Model_ProviderCreditList());
|
263 |
-
$values = array();
|
264 |
-
$providerCredit = new OffAmazonPaymentsService_Model_ProviderCredit();
|
265 |
-
$providerCredit->setProviderId($providerCreditInfo[0]);
|
266 |
-
$creditAmount = new OffAmazonPaymentsService_Model_Price();
|
267 |
-
$creditAmount->setAmount($providerCreditInfo[1]);
|
268 |
-
$creditAmount->setCurrencyCode($this->_service->getMerchantValues()->getCurrency());
|
269 |
-
$providerCredit->setCreditAmount($creditAmount);
|
270 |
-
array_push($values, $providerCredit);
|
271 |
-
$captureRequest->getProviderCreditList()->setmember($values);
|
272 |
-
}
|
273 |
-
|
274 |
-
return $this->_service->capture($captureRequest);
|
275 |
-
}
|
276 |
-
|
277 |
-
/**
|
278 |
-
* Perform the get capture details call for the order
|
279 |
-
*
|
280 |
-
* @param string $amazonCaptureId capture it to get details for
|
281 |
-
*
|
282 |
-
* @return OffAmazonPaymentsService_Model_CaptureResponse service response
|
283 |
-
*/
|
284 |
-
public function getCaptureDetails($amazonCaptureId)
|
285 |
-
{
|
286 |
-
$captureDetailsRequest
|
287 |
-
= new OffAmazonPaymentsService_Model_GetCaptureDetailsRequest();
|
288 |
-
$captureDetailsRequest->setSellerId($this->_sellerId);
|
289 |
-
$captureDetailsRequest->setAmazonCaptureId($amazonCaptureId);
|
290 |
-
|
291 |
-
return $this->_service->getCaptureDetails($captureDetailsRequest);
|
292 |
-
}
|
293 |
-
|
294 |
-
public function getProviderCreditDetails($providerCreditId){
|
295 |
-
$providerCreditDetailsRequest = new OffAmazonPaymentsService_Model_GetProviderCreditDetailsRequest();
|
296 |
-
$providerCreditDetailsRequest->setSellerId($this->_sellerId);
|
297 |
-
$providerCreditDetailsRequest->setAmazonProviderCreditId($providerCreditId);
|
298 |
-
return $this->_service->getProviderCreditDetails($providerCreditDetailsRequest);
|
299 |
-
}
|
300 |
-
|
301 |
-
|
302 |
-
/**
|
303 |
-
* Close this order reference to indicate that the order is complete, and
|
304 |
-
* no further authorizations and captures will be performed on this order
|
305 |
-
*
|
306 |
-
* @return OffAmazonPaymentsService_Model_CloseOrderReferenceResponse service response
|
307 |
-
*/
|
308 |
-
public function closeOrderReference()
|
309 |
-
{
|
310 |
-
$closeOrderReferenceRequest = new OffAmazonPaymentsService_Model_CloseOrderReferenceRequest();
|
311 |
-
$closeOrderReferenceRequest->setSellerId($this->_sellerId);
|
312 |
-
$closeOrderReferenceRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
313 |
-
$closeOrderReferenceRequest->setClosureReason("Order complete");
|
314 |
-
|
315 |
-
return $this->_service->closeOrderReference($closeOrderReferenceRequest);
|
316 |
-
}
|
317 |
-
};
|
318 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/SimpleCheckoutExampleCLI.php
DELETED
@@ -1,288 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
*/
|
15 |
-
|
16 |
-
/*
|
17 |
-
* Straight checkout example command line example
|
18 |
-
*
|
19 |
-
* This class drives the simple checkout example from a command line interface
|
20 |
-
* See SimpleCheckoutExample.php for more information
|
21 |
-
*/
|
22 |
-
|
23 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
24 |
-
require_once realpath(dirname(__FILE__)) . '/GetOrderReferenceDetailsSample.php';
|
25 |
-
require_once realpath(dirname(__FILE__)) . '/SetOrderReferenceDetailsSample.php';
|
26 |
-
require_once realpath(dirname(__FILE__)) . '/ConfirmOrderReferenceSample.php';
|
27 |
-
require_once realpath(dirname(__FILE__)) . '/AuthorizeSample.php';
|
28 |
-
require_once realpath(dirname(__FILE__)) . '/GetAuthorizationDetailsSample.php';
|
29 |
-
require_once realpath(dirname(__FILE__)) . '/GetCaptureDetailsSample.php';
|
30 |
-
require_once realpath(dirname(__FILE__)) . '/CaptureSample.php';
|
31 |
-
require_once realpath(dirname(__FILE__)) . '/CloseOrderReferenceSample.php';
|
32 |
-
require_once realpath(dirname(__FILE__)) . '/CLIExample.php';
|
33 |
-
require_once realpath(dirname(__FILE__)) . '/SimpleCheckoutExample.php';
|
34 |
-
|
35 |
-
/*
|
36 |
-
* SimpleCheckoutExampleCLI class captures input from stdin and prints to stdout,
|
37 |
-
* and drives the simple checkout example
|
38 |
-
*
|
39 |
-
*/
|
40 |
-
class SimpleCheckoutExampleCLI extends CLIExample
|
41 |
-
{
|
42 |
-
/**
|
43 |
-
* Create a new instance of the cli example and
|
44 |
-
* validate command line arguments
|
45 |
-
*
|
46 |
-
* @param array $argv arguments to the appplication passed from the command line
|
47 |
-
*/
|
48 |
-
public function __construct($argv)
|
49 |
-
{
|
50 |
-
if (count($argv) < 1) {
|
51 |
-
print "Missing mandatory argument: " .
|
52 |
-
"please provide an amazonOrderReferenceId";
|
53 |
-
exit(0);
|
54 |
-
}
|
55 |
-
|
56 |
-
/*
|
57 |
-
* Instantiate Implementation of OffAmazonPaymentsService client
|
58 |
-
*
|
59 |
-
* Merchant ids and access keys are defined in the constants
|
60 |
-
* are defined in the OffAmazonPaymentsService.config.inc.php file in
|
61 |
-
* the parent directory of this server
|
62 |
-
*/
|
63 |
-
$this->exampleClass
|
64 |
-
= new SimpleCheckoutExample(
|
65 |
-
new OffAmazonPaymentsService_Client(),
|
66 |
-
$argv[1]
|
67 |
-
);
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Run all the steps for the sample in sequence
|
72 |
-
*
|
73 |
-
*/
|
74 |
-
public function runSample()
|
75 |
-
{
|
76 |
-
$orderTotal = $this->_calculateOrderTotalBasedOnBuyerDestinationAddress();
|
77 |
-
$this->_addOrderTotalAndSellerInformationToOrder($orderTotal);
|
78 |
-
$this->_confirmOrderReference();
|
79 |
-
$amazonAuthorizationId = $this->_authorizeBasedOnOptionSelected($orderTotal);
|
80 |
-
$this->_captureOrderAmount($orderTotal, $amazonAuthorizationId);
|
81 |
-
$this->_closeOrderReference();
|
82 |
-
print "Payment capture completed" . PHP_EOL;
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Retreive the current information about the order as indicated by the buyer
|
87 |
-
* and calculate the total amount to charge, based on address destination state
|
88 |
-
* and country
|
89 |
-
*
|
90 |
-
* @return string total amount for the order that the merchant will
|
91 |
-
* charge the buyer
|
92 |
-
*/
|
93 |
-
private function _calculateOrderTotalBasedOnBuyerDestinationAddress()
|
94 |
-
{
|
95 |
-
$response = $this->callStepAndCheckForException('getOrderReferenceDetails');
|
96 |
-
printGetOrderReferenceDetailsResponse($response);
|
97 |
-
|
98 |
-
$orderTotalPreTaxAndShipping
|
99 |
-
= $this->_getPreTaxAndShippingOrderAmountFromStdIn();
|
100 |
-
$shippingType = $this->_getShippingTypeFromStdIn();
|
101 |
-
return $this->exampleClass->calculateOrderTotalBasedOnBuyerDetails(
|
102 |
-
$response->getGetOrderReferenceDetailsResult()->getOrderReferenceDetails(),
|
103 |
-
$orderTotalPreTaxAndShipping,
|
104 |
-
$shippingType
|
105 |
-
);
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Add order information by making the call to setOrderReferenceDetails with
|
110 |
-
* the total order amount, as well as notes describing the order information
|
111 |
-
*
|
112 |
-
* @param float $orderTotal total value of the order, incl shipping and tax
|
113 |
-
*
|
114 |
-
*/
|
115 |
-
private function _addOrderTotalAndSellerInformationToOrder($orderTotal)
|
116 |
-
{
|
117 |
-
$response
|
118 |
-
= $this->callStepAndCheckForException(
|
119 |
-
'addOrderTotalAndSellerInformationToOrder',
|
120 |
-
array($orderTotal)
|
121 |
-
);
|
122 |
-
printSetOrderReferenceDetailsResponse($response);
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Confirm the order reference information, allowing for
|
127 |
-
* authorizations and captures to be created
|
128 |
-
*
|
129 |
-
*
|
130 |
-
*/
|
131 |
-
private function _confirmOrderReference()
|
132 |
-
{
|
133 |
-
$response = $this->callStepAndCheckForException('confirmOrderReference');
|
134 |
-
printConfirmOrderReferenceResponse($response);
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Perform Authorize using Regular Authorization or Fast Authorization
|
139 |
-
*
|
140 |
-
* @param float $authorizationAmount amount to authorize from the buyer
|
141 |
-
*
|
142 |
-
* @return string amazonAuthorizationId amazon generated authorization id reference
|
143 |
-
*/
|
144 |
-
private function _authorizeBasedOnOptionSelected($authorizationAmount)
|
145 |
-
{
|
146 |
-
$authOption = $this->_getAuthOptionFromStdIn();
|
147 |
-
$amazonAuthorizationId = $this->_authorizeOrderAmount($authorizationAmount, $authOption);
|
148 |
-
if($authOption != 2){
|
149 |
-
//When Asynchronous Authorization is used, wait until the Authorization is completed.
|
150 |
-
//After the Authorization is out of the Pending state, we can continue.
|
151 |
-
//This is not needed for Fast Authorization since it has a synchronous response.
|
152 |
-
$this->_waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId);
|
153 |
-
}
|
154 |
-
return $amazonAuthorizationId;
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Perform the authorize call for the order
|
159 |
-
*
|
160 |
-
* @param float $authorizationAmount amount to authorize from the buyer
|
161 |
-
*
|
162 |
-
* @return string amazonAuthorizationId amazon generated authorization id reference
|
163 |
-
*/
|
164 |
-
private function _authorizeOrderAmount($authorizationAmount, $authOption = 1)
|
165 |
-
{
|
166 |
-
$response = $this->callStepAndCheckForException(
|
167 |
-
'authorizeOrderAmount',
|
168 |
-
array($authorizationAmount, $authOption)
|
169 |
-
);
|
170 |
-
printAuthorizeResponse($response);
|
171 |
-
return $response->getAuthorizeResult()->getAuthorizationDetails()->getAmazonAuthorizationId();
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Poll the API for the status of the Authorization Request, and continue
|
176 |
-
* once the status has been updated
|
177 |
-
* Throw an error if the status is not equal to Open
|
178 |
-
*
|
179 |
-
* @param string $amazonAuthorizationId authorization transaction to query
|
180 |
-
*
|
181 |
-
*/
|
182 |
-
private function _waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId)
|
183 |
-
{
|
184 |
-
$response
|
185 |
-
= $this->callStepAndCheckForException(
|
186 |
-
'waitUntilAuthorizationProcessingIsCompleted',
|
187 |
-
array($amazonAuthorizationId)
|
188 |
-
);
|
189 |
-
printGetAuthorizationDetailsResponse($response);
|
190 |
-
validateThatAuthorizationIsOpen($response);
|
191 |
-
}
|
192 |
-
|
193 |
-
/**
|
194 |
-
* Perform the capture call for the order
|
195 |
-
* Throw an exception if the capture is not processed, as this is the
|
196 |
-
* expected result
|
197 |
-
*
|
198 |
-
* @param float $captureAmount amount to capture from the buyer
|
199 |
-
* @param string $amazonAuthorizationId auth id to perform the capture on
|
200 |
-
*
|
201 |
-
* @return no response
|
202 |
-
*/
|
203 |
-
private function _captureOrderAmount($captureAmount, $amazonAuthorizationId)
|
204 |
-
{
|
205 |
-
$response = $this->callStepAndCheckForException(
|
206 |
-
'captureOrderAmount',
|
207 |
-
array($captureAmount, $amazonAuthorizationId)
|
208 |
-
);
|
209 |
-
|
210 |
-
validateThatCaptureIsCompleted($response->getCaptureResult());
|
211 |
-
printCaptureResponse($response);
|
212 |
-
}
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Close this order reference to indicate that the order is complete, and
|
216 |
-
* no further authorizations and captures will be performed on this order
|
217 |
-
*
|
218 |
-
* @return no value
|
219 |
-
*/
|
220 |
-
private function _closeOrderReference()
|
221 |
-
{
|
222 |
-
$response = $this->callStepAndCheckForException('closeOrderReference');
|
223 |
-
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
* Capture the pre tax order amount from standard input,
|
227 |
-
* making sure that it is a numeric string
|
228 |
-
*
|
229 |
-
* @return string total amount of the order before tax and shipping charges
|
230 |
-
*/
|
231 |
-
private function _getPreTaxAndShippingOrderAmountFromStdIn()
|
232 |
-
{
|
233 |
-
print PHP_EOL . "-------------------------------------------" . PHP_EOL;
|
234 |
-
print "Enter the pre tax amount to charge for the order as a number (to 2 decimal places): ";
|
235 |
-
do {
|
236 |
-
$orderAmount = trim(fgets(STDIN));
|
237 |
-
} while (!is_numeric($orderAmount));
|
238 |
-
|
239 |
-
return $orderAmount;
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Capture the shipping type for this order, which determines
|
244 |
-
* the shipping charge
|
245 |
-
*
|
246 |
-
* @return number selected shipping type index
|
247 |
-
*/
|
248 |
-
private function _getShippingTypeFromStdIn()
|
249 |
-
{
|
250 |
-
print PHP_EOL . "Select a shipping option for the order:" . PHP_EOL;
|
251 |
-
print "\t 1 - Overnight shipping" . PHP_EOL;
|
252 |
-
print "\t 2 - 2-day shipping" . PHP_EOL;
|
253 |
-
print "\t 3 - 5-day shipping" . PHP_EOL;
|
254 |
-
print ">>";
|
255 |
-
|
256 |
-
do {
|
257 |
-
$shippingType = trim(fgets(STDIN));
|
258 |
-
} while (!is_numeric($shippingType) and
|
259 |
-
($shippingType < 1 or $shippingType > 3));
|
260 |
-
|
261 |
-
return $shippingType - 1;
|
262 |
-
}
|
263 |
-
|
264 |
-
/**
|
265 |
-
* Use Regular Authorization or Fast Authorization?
|
266 |
-
*
|
267 |
-
* @return number , 1 for regular authorization and 2 for fast authorization.
|
268 |
-
*/
|
269 |
-
private function _getAuthOptionFromStdIn() {
|
270 |
-
print PHP_EOL . "-------------------------------------------" . PHP_EOL;
|
271 |
-
print "\t 1 - Use Regular Authorization (Asynchronous Response) [Default]" . PHP_EOL;
|
272 |
-
print "\t 2 - Use Fast Authorization (Synchronous Response)" . PHP_EOL;
|
273 |
-
print ">>";
|
274 |
-
do {
|
275 |
-
$authOption = trim ( fgets ( STDIN ) );
|
276 |
-
} while (!is_numeric($authOption) and
|
277 |
-
($authOption < 1 or $authOption > 2));
|
278 |
-
|
279 |
-
return $authOption;
|
280 |
-
}
|
281 |
-
|
282 |
-
};
|
283 |
-
|
284 |
-
|
285 |
-
$simpleCheckoutExample = new SimpleCheckoutExampleCLI($argv);
|
286 |
-
$simpleCheckoutExample->runSample();
|
287 |
-
|
288 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/SplitShipmentsCheckoutExample.php
DELETED
@@ -1,331 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
*/
|
15 |
-
|
16 |
-
/*
|
17 |
-
* Split shipments checkout example
|
18 |
-
*
|
19 |
-
* This demonstrates a merchant use case where the order needs to be
|
20 |
-
* furfilled in multiple shipments, or where a single item is shipped
|
21 |
-
* in multiple shipments over time.
|
22 |
-
*
|
23 |
-
* Note that the API does not require merchants to provide item level
|
24 |
-
* information in order to capture funds -this example uses items in
|
25 |
-
* order to show how to aggregate item level costs to a single value
|
26 |
-
* for an order
|
27 |
-
*
|
28 |
-
* This is done using multiple calls to authorize and capture for
|
29 |
-
* the full order amount
|
30 |
-
*
|
31 |
-
* This example will show the following service calls:
|
32 |
-
* - SetOrderReferenceDetails
|
33 |
-
* - ConfirmOrderReference
|
34 |
-
* - Authorize
|
35 |
-
* - GetAuthorizeDetails
|
36 |
-
* - Capture
|
37 |
-
* - GetCaptureDetails
|
38 |
-
* - CloseOrderReference
|
39 |
-
*/
|
40 |
-
|
41 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
42 |
-
|
43 |
-
class SplitShipmentsCheckoutExample
|
44 |
-
{
|
45 |
-
private $_sellerId;
|
46 |
-
private $_service;
|
47 |
-
private $_amazonOrderReferenceId;
|
48 |
-
private $_authorizationReferenceIdBase;
|
49 |
-
private $_captureReferenceIdBase;
|
50 |
-
private $_orderShipments;
|
51 |
-
private $_itemsInStock;
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Create a new instance of the split shipments
|
55 |
-
* checkout example
|
56 |
-
*
|
57 |
-
* @param OffAmazonPaymentsService_Client $service instance of the service client
|
58 |
-
*
|
59 |
-
* @param string $amazonOrderReferenceId an order reference object in
|
60 |
-
* draft state to use in
|
61 |
-
* the example
|
62 |
-
*
|
63 |
-
* @return new SplitShipmentsCheckoutExample
|
64 |
-
*/
|
65 |
-
public function __construct($service, $amazonOrderReferenceId)
|
66 |
-
{
|
67 |
-
$this->_service = $service;
|
68 |
-
$this->_amazonOrderReferenceId = $amazonOrderReferenceId;
|
69 |
-
|
70 |
-
/*
|
71 |
-
* Setup shared identifiers for the series of transaction requests
|
72 |
-
*/
|
73 |
-
$this->_authorizationReferenceIdBase
|
74 |
-
= str_replace("-", "", $this->_amazonOrderReferenceId) . "a01";
|
75 |
-
$this->_captureReferenceIdBase = $this->_authorizationReferenceIdBase . "c01";
|
76 |
-
|
77 |
-
$this->_sellerId
|
78 |
-
= $this->_service->getMerchantValues()->getMerchantId();
|
79 |
-
|
80 |
-
/*
|
81 |
-
* Initialize the variable holding the shipments that are part
|
82 |
-
* of the order
|
83 |
-
*/
|
84 |
-
$this->_orderShipments = array();
|
85 |
-
$this->_itemsInStock = array(
|
86 |
-
new Item("Apple", 3.20),
|
87 |
-
new Item("Pinapple", 1.8),
|
88 |
-
new Item("Banana", 0.9),
|
89 |
-
new Item("Orange", 1.2),
|
90 |
-
new Item("Pear", 2.1)
|
91 |
-
);
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Step 1: calcaulte the total value of the order and set the amount on the order
|
96 |
-
* reference
|
97 |
-
*
|
98 |
-
*/
|
99 |
-
public function addOrderAmountToOrderReference()
|
100 |
-
{
|
101 |
-
$setOrderReferenceDetailsRequest = new OffAmazonPaymentsService_Model_SetOrderReferenceDetailsRequest();
|
102 |
-
$setOrderReferenceDetailsRequest->setSellerId($this->_sellerId);
|
103 |
-
$setOrderReferenceDetailsRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
104 |
-
$setOrderReferenceDetailsRequest->setOrderReferenceAttributes(new OffAmazonPaymentsService_Model_OrderReferenceAttributes());
|
105 |
-
$setOrderReferenceDetailsRequest->getOrderReferenceAttributes()->setOrderTotal(new OffAmazonPaymentsService_Model_OrderTotal());
|
106 |
-
$setOrderReferenceDetailsRequest->getOrderReferenceAttributes()->getOrderTotal()->setCurrencyCode($this->_service->getMerchantValues()->getCurrency());
|
107 |
-
$setOrderReferenceDetailsRequest->getOrderReferenceAttributes()->getOrderTotal()->setAmount($this->_getOrderTotal());
|
108 |
-
|
109 |
-
return $this->_service->setOrderReferenceDetails($setOrderReferenceDetailsRequest);
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Confirm the order reference information, allowing for
|
114 |
-
* authorizations and captures to be created
|
115 |
-
*
|
116 |
-
* @return OffAmazonPaymentsService_Model_ConfirmOrderReferenceResponse service response
|
117 |
-
*/
|
118 |
-
public function confirmOrderReference()
|
119 |
-
{
|
120 |
-
$confirmOrderReferenceRequest
|
121 |
-
= new OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest();
|
122 |
-
$confirmOrderReferenceRequest
|
123 |
-
->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
124 |
-
$confirmOrderReferenceRequest->setSellerId($this->_sellerId);
|
125 |
-
|
126 |
-
return $this->_service->confirmOrderReference($confirmOrderReferenceRequest);
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Perform the authorization for the shipment at the given index
|
131 |
-
*
|
132 |
-
* @param int $shipmentNumber order item index to authorize
|
133 |
-
*
|
134 |
-
* @return OffAmazonPaymentsService_Model_AuthorizeResponse service response
|
135 |
-
*/
|
136 |
-
public function performAuthorizationForShipment($shipmentNumber)
|
137 |
-
{
|
138 |
-
$item = $this->_orderShipments[$shipmentNumber];
|
139 |
-
|
140 |
-
$authorizeRequest = new OffAmazonPaymentsService_Model_AuthorizeRequest();
|
141 |
-
$authorizeRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
142 |
-
$authorizeRequest->setSellerId($this->_sellerId);
|
143 |
-
$authorizeRequest
|
144 |
-
->setAuthorizationReferenceId($this->_authorizationReferenceIdBase . $shipmentNumber);
|
145 |
-
$authorizeRequest->setAuthorizationAmount(new OffAmazonPaymentsService_Model_Price());
|
146 |
-
$authorizeRequest->getAuthorizationAmount()->setAmount($item->price);
|
147 |
-
$authorizeRequest->getAuthorizationAmount()->setCurrencyCode($this->_service->getMerchantValues()->getCurrency());
|
148 |
-
|
149 |
-
// Set the application timeout so that the polling request will
|
150 |
-
// get a definitive response within this period of time
|
151 |
-
$authorizeRequest->setTransactionTimeout(5);
|
152 |
-
|
153 |
-
return $this->_service->authorize($authorizeRequest);
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Poll the API for the status of the Authorization Request, and continue
|
158 |
-
* once the status has been updated
|
159 |
-
* WARNING: This is not the way to integrate for production systems,
|
160 |
-
* instead merchants should use IPN to receive a callback once the
|
161 |
-
* processing has been completed.
|
162 |
-
* Note that Amazon reserves the right to throttle requests that
|
163 |
-
* ignore this advice and poll for a response
|
164 |
-
*
|
165 |
-
* @param string $amazonAuthorizationReferenceId authorization transaction to query
|
166 |
-
*
|
167 |
-
* @return OffAmazonPaymentsService_Model_GetAuthorizationDetailsResponse service response
|
168 |
-
*/
|
169 |
-
public function waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId)
|
170 |
-
{
|
171 |
-
$getAuthorizationDetailsResponse = null;
|
172 |
-
do {
|
173 |
-
sleep(5);
|
174 |
-
$getAuthorizationDetailsResponse
|
175 |
-
= $this->getAuthorizationDetails($amazonAuthorizationId);
|
176 |
-
} while ((isset($getAuthorizationDetailsResponse)) and
|
177 |
-
(strcasecmp(
|
178 |
-
$getAuthorizationDetailsResponse
|
179 |
-
->getGetAuthorizationDetailsResult()->getAuthorizationDetails()
|
180 |
-
->getAuthorizationStatus()->getState(),
|
181 |
-
"Pending"
|
182 |
-
) == 0));
|
183 |
-
|
184 |
-
if (is_null($getAuthorizationDetailsResponse)) {
|
185 |
-
throw new ErrorException("No valid response from getAuthorizationDetails request");
|
186 |
-
}
|
187 |
-
|
188 |
-
return $getAuthorizationDetailsResponse;
|
189 |
-
}
|
190 |
-
|
191 |
-
/**
|
192 |
-
* Perform the getAuthroizationDetails request for the order
|
193 |
-
*
|
194 |
-
* @param string $amazonAuthorizationReferenceId authorization transaction
|
195 |
-
* to query
|
196 |
-
*
|
197 |
-
* @return OffAmazonPaymentsService_Model_GetAuthorizationDetailsResponse service response
|
198 |
-
*/
|
199 |
-
public function getAuthorizationDetails($amazonAuthorizationId)
|
200 |
-
{
|
201 |
-
$getAuthorizationDetailsRequest = new OffAmazonPaymentsService_Model_GetAuthorizationDetailsRequest();
|
202 |
-
$getAuthorizationDetailsRequest->setSellerId($this->_sellerId);
|
203 |
-
$getAuthorizationDetailsRequest->setAmazonAuthorizationId($amazonAuthorizationId);
|
204 |
-
|
205 |
-
return $this->_service->getAuthorizationDetails($getAuthorizationDetailsRequest);
|
206 |
-
}
|
207 |
-
|
208 |
-
/**
|
209 |
-
* Perform the capture for a single shipment
|
210 |
-
*
|
211 |
-
* @param int $shipmentNumber order item index to capture
|
212 |
-
* @param string $amazonAuthorizationId authorization to capture
|
213 |
-
*
|
214 |
-
* @return OffAmazonPayments_Model_CaptureResponse service response
|
215 |
-
*/
|
216 |
-
public function performCaptureForShipment($shipmentNumber, $amazonAuthorizationId)
|
217 |
-
{
|
218 |
-
$item = $this->_orderShipments[$shipmentNumber];
|
219 |
-
|
220 |
-
$captureRequest = new OffAmazonPaymentsService_Model_CaptureRequest();
|
221 |
-
$captureRequest->setSellerId($this->_sellerId);
|
222 |
-
$captureRequest->setAmazonAuthorizationId($amazonAuthorizationId);
|
223 |
-
$captureRequest
|
224 |
-
->setCaptureReferenceId($this->_captureReferenceIdBase . $shipmentNumber);
|
225 |
-
$captureRequest->setCaptureAmount(new OffAmazonPaymentsService_Model_Price());
|
226 |
-
$captureRequest->getCaptureAmount()->setAmount($item->price);
|
227 |
-
$captureRequest->getCaptureAmount()->setCurrencyCode($this->_service->getMerchantValues()->getCurrency());
|
228 |
-
|
229 |
-
return $this->_service->capture($captureRequest);
|
230 |
-
}
|
231 |
-
|
232 |
-
/**
|
233 |
-
* Perform the get capture details call for the order
|
234 |
-
*
|
235 |
-
* @param string $amazonCaptureId capture it to get details for
|
236 |
-
*
|
237 |
-
* @return OffAmazonPaymentsService_Model_CaptureResponse service response
|
238 |
-
*/
|
239 |
-
public function getCaptureDetails($amazonCaptureId)
|
240 |
-
{
|
241 |
-
$captureDetailsRequest
|
242 |
-
= new OffAmazonPaymentsService_Model_GetCaptureDetailsRequest();
|
243 |
-
$captureDetailsRequest->setSellerId($this->_sellerId);
|
244 |
-
$captureDetailsRequest->setAmazonCaptureId($amazonCaptureId);
|
245 |
-
|
246 |
-
return $this->_service->getCaptureDetails($captureDetailsRequest);
|
247 |
-
}
|
248 |
-
|
249 |
-
/**
|
250 |
-
* Close this order reference to indicate that the order is complete, and
|
251 |
-
* no further authorizations and captures will be performed on this order
|
252 |
-
*
|
253 |
-
* @return OffAmazonPaymentsService_Model_CloseOrderReferenceResponse service response
|
254 |
-
*/
|
255 |
-
public function closeOrderReference()
|
256 |
-
{
|
257 |
-
$closeOrderReferenceRequest = new OffAmazonPaymentsService_Model_CloseOrderReferenceRequest();
|
258 |
-
$closeOrderReferenceRequest->setSellerId($this->_sellerId);
|
259 |
-
$closeOrderReferenceRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
|
260 |
-
$closeOrderReferenceRequest->setClosureReason("Order complete");
|
261 |
-
|
262 |
-
return $this->_service->closeOrderReference($closeOrderReferenceRequest);
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Add a new shipment of an item to the order
|
267 |
-
*
|
268 |
-
* @param int $itemIndex index of the item to place in this order
|
269 |
-
*
|
270 |
-
*/
|
271 |
-
public function addShipmentToOrder($itemIndex)
|
272 |
-
{
|
273 |
-
array_push($this->_orderShipments, $this->_itemsInStock[$itemIndex]);
|
274 |
-
}
|
275 |
-
|
276 |
-
/**
|
277 |
-
* Return the names of the items available to place into the order
|
278 |
-
*
|
279 |
-
* @return array names of available items
|
280 |
-
*/
|
281 |
-
public function getItemNames()
|
282 |
-
{
|
283 |
-
return array_map(
|
284 |
-
function($item) {
|
285 |
-
return $item->name;
|
286 |
-
}, $this->_itemsInStock
|
287 |
-
);
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Return the total amount for the order
|
292 |
-
*
|
293 |
-
* @return int order total
|
294 |
-
*/
|
295 |
-
private function _getOrderTotal()
|
296 |
-
{
|
297 |
-
return array_reduce(
|
298 |
-
$this->_orderShipments,
|
299 |
-
function($runningTotal, $item) {
|
300 |
-
$runningTotal += $item->price;
|
301 |
-
return $runningTotal;
|
302 |
-
}
|
303 |
-
);
|
304 |
-
}
|
305 |
-
|
306 |
-
}
|
307 |
-
|
308 |
-
/*
|
309 |
-
* Helper class to store item information for the
|
310 |
-
* split shipment scenario
|
311 |
-
*/
|
312 |
-
class Item
|
313 |
-
{
|
314 |
-
public $price;
|
315 |
-
public $name;
|
316 |
-
|
317 |
-
/**
|
318 |
-
* Create a new item
|
319 |
-
*
|
320 |
-
* @param float $price
|
321 |
-
* @param string $name
|
322 |
-
*
|
323 |
-
* @return new Item instance
|
324 |
-
*/
|
325 |
-
public function __construct($name, $price)
|
326 |
-
{
|
327 |
-
$this->price = $price;
|
328 |
-
$this->name = $name;
|
329 |
-
}
|
330 |
-
}
|
331 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/SplitShipmentsCheckoutExampleCLI.php
DELETED
@@ -1,252 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
*
|
6 |
-
* You may not use this file except in compliance with the License.
|
7 |
-
* You may obtain a copy of the License at:
|
8 |
-
* http://aws.amazon.com/apache2.0
|
9 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
10 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
11 |
-
* for the
|
12 |
-
* specific language governing permissions and limitations under the
|
13 |
-
* License.
|
14 |
-
*/
|
15 |
-
|
16 |
-
/*
|
17 |
-
* Split shipments checkout example
|
18 |
-
*
|
19 |
-
* This demonstrates a merchant use case where the order needs to be
|
20 |
-
* furfilled in multiple shipments, or where a single item is shipped
|
21 |
-
* in multiple shipments over time.
|
22 |
-
*
|
23 |
-
* See SplitShipmentsCheckoutExample.php for more information
|
24 |
-
*/
|
25 |
-
|
26 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
27 |
-
require_once realpath(dirname(__FILE__)) . '/SetOrderReferenceDetailsSample.php';
|
28 |
-
require_once realpath(dirname(__FILE__)) . '/ConfirmOrderReferenceSample.php';
|
29 |
-
require_once realpath(dirname(__FILE__)) . '/AuthorizeSample.php';
|
30 |
-
require_once realpath(dirname(__FILE__)) . '/GetAuthorizationDetailsSample.php';
|
31 |
-
require_once realpath(dirname(__FILE__)) . '/CaptureSample.php';
|
32 |
-
require_once realpath(dirname(__FILE__)) . '/CloseOrderReferenceSample.php';
|
33 |
-
require_once realpath(dirname(__FILE__)) . '/CLIExample.php';
|
34 |
-
require_once realpath(dirname(__FILE__)) . '/SplitShipmentsCheckoutExample.php';
|
35 |
-
require_once realpath(dirname(__FILE__)) . '/GetCaptureDetailsSample.php';
|
36 |
-
|
37 |
-
/*
|
38 |
-
* SplitShipmentsCheckoutExampleCLI class captures input from stdin and prints to stdout,
|
39 |
-
* and drives the split shipment checkout example
|
40 |
-
*
|
41 |
-
*/
|
42 |
-
class SplitShipmentsCheckoutExampleCLI extends CLIExample
|
43 |
-
{
|
44 |
-
/**
|
45 |
-
* Create a new instance of the cli example and
|
46 |
-
* validate command line arguments
|
47 |
-
*
|
48 |
-
* @param array $argv arguments to the application passed to the command line
|
49 |
-
*/
|
50 |
-
public function __construct($argv)
|
51 |
-
{
|
52 |
-
if (count($argv) < 1) {
|
53 |
-
print "Missing mandatory argument: " .
|
54 |
-
"please provide an amazonOrderReferenceId";
|
55 |
-
exit(0);
|
56 |
-
}
|
57 |
-
|
58 |
-
/*
|
59 |
-
* Instantiate Implementation of OffAmazonPaymentsService client
|
60 |
-
*
|
61 |
-
* Merchant ids and access keys are defined in the constants
|
62 |
-
* are defined in the OffAmazonPaymentsService.config.inc.php file in
|
63 |
-
* the parent directory of this server
|
64 |
-
*/
|
65 |
-
$this->exampleClass
|
66 |
-
= new SplitShipmentsCheckoutExample(
|
67 |
-
new OffAmazonPaymentsService_Client(),
|
68 |
-
$argv[1]
|
69 |
-
);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Run all the steps for the sample in sequence
|
74 |
-
*
|
75 |
-
*/
|
76 |
-
public function runSample()
|
77 |
-
{
|
78 |
-
$shipments = $this->_getNumberOfShipmentsInOrder();
|
79 |
-
$this->_addShipmentsToOrder($shipments);
|
80 |
-
$this->_addOrderAmountToOrderReference();
|
81 |
-
$this->_confirmOrderReference();
|
82 |
-
$this->_performAuthAndCaptureForOrderShipments($shipments);
|
83 |
-
$this->_closeOrderReference();
|
84 |
-
print "Split shipments checkout example completed" . PHP_EOL;
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Capture the number of shipments for this run of the scenario
|
89 |
-
*
|
90 |
-
* @return int number of shipments in this order
|
91 |
-
*/
|
92 |
-
private function _getNumberOfShipmentsInOrder()
|
93 |
-
{
|
94 |
-
print "Enter the number of shipments that you want to perform for this order: ";
|
95 |
-
|
96 |
-
do {
|
97 |
-
$shipments = trim(fgets(STDIN));
|
98 |
-
} while (!is_numeric($shipments));
|
99 |
-
|
100 |
-
print PHP_EOL;
|
101 |
-
return $shipments;
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Fill in the details for each shipment in this order
|
106 |
-
*
|
107 |
-
* @param int $shipments number of shipments to fill
|
108 |
-
*
|
109 |
-
*/
|
110 |
-
private function _addShipmentsToOrder($shipments)
|
111 |
-
{
|
112 |
-
for ($i = 0; $i < $shipments; $i++) {
|
113 |
-
$this->_addShipmentToOrder($i);
|
114 |
-
}
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Fill in the details for a single shipment in the order
|
119 |
-
*
|
120 |
-
* @param int $shipmentNumber nth shipment for the order
|
121 |
-
*/
|
122 |
-
private function _addShipmentToOrder($shipmentNumber)
|
123 |
-
{
|
124 |
-
print "Select an item to add to shipment #" . ($shipmentNumber + 1) . ":" . PHP_EOL;
|
125 |
-
$items = $this->exampleClass->getItemNames();
|
126 |
-
for ($i = 0; $i < count($items); $i++) {
|
127 |
-
print " " . $i . " - " . $items[$i] . PHP_EOL;
|
128 |
-
}
|
129 |
-
|
130 |
-
do {
|
131 |
-
print "Select the number of the item to add to this shipment:";
|
132 |
-
$itemToAdd = trim(fgets(STDIN));
|
133 |
-
} while (!is_numeric($itemToAdd));
|
134 |
-
|
135 |
-
print PHP_EOL;
|
136 |
-
|
137 |
-
$this->exampleClass->addShipmentToOrder($itemToAdd);
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Add the total price of all items in the order and update the payment contract
|
142 |
-
*
|
143 |
-
*/
|
144 |
-
private function _addOrderAmountToOrderReference()
|
145 |
-
{
|
146 |
-
$response = $this->callStepAndCheckForException('addOrderAmountToOrderReference');
|
147 |
-
printSetOrderReferenceDetailsResponse($response);
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Confirm the order reference information, allowing for
|
152 |
-
* authorizations and captures to be created
|
153 |
-
*
|
154 |
-
* @return OffAmazonPaymentsService_Model_ConfirmOrderReferenceResponse service response
|
155 |
-
*/
|
156 |
-
private function _confirmOrderReference()
|
157 |
-
{
|
158 |
-
$response = $this->callStepAndCheckForException('confirmOrderReference');
|
159 |
-
printConfirmOrderReferenceResponse($response);
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* Perform the authorize and captures for all shipments in this
|
164 |
-
* order
|
165 |
-
*
|
166 |
-
* @param int $shipments total number of shipments in this order
|
167 |
-
*/
|
168 |
-
private function _performAuthAndCaptureForOrderShipments($shipments)
|
169 |
-
{
|
170 |
-
for ($i = 0; $i < $shipments; $i++) {
|
171 |
-
$this->_performAuthAndCaptureForOrderShipment($i);
|
172 |
-
}
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Perform the authorize and capture for a single shipment in the order
|
177 |
-
*
|
178 |
-
* @param int $shipmentNumber the shipment to perform transactions on
|
179 |
-
*/
|
180 |
-
private function _performAuthAndCaptureForOrderShipment($shipmentNumber)
|
181 |
-
{
|
182 |
-
$response = $amazonAuthorizationId = $this->_performAuthorizationForShipment($shipmentNumber);
|
183 |
-
$this->_waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId);
|
184 |
-
$this->_performCaptureForShipment($shipmentNumber, $amazonAuthorizationId);
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Perform the authorization for the shipment at the given index
|
189 |
-
*
|
190 |
-
* @param int $shipmentNumber order item index to authorize
|
191 |
-
*
|
192 |
-
* @return string amazonAuthorizationId for the single auth call
|
193 |
-
*/
|
194 |
-
private function _performAuthorizationForShipment($shipmentNumber)
|
195 |
-
{
|
196 |
-
$response = $this->callStepAndCheckForException('performAuthorizationForShipment', array($shipmentNumber));
|
197 |
-
printAuthorizeResponse($response);
|
198 |
-
return $response->getAuthorizeResult()->getAuthorizationDetails()->getAmazonAuthorizationId();
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Poll the API for the status of the Authorization Request, and continue
|
203 |
-
* once the status has been updated
|
204 |
-
* WARNING: This is not the way to integrate for production systems,
|
205 |
-
* instead merchants should use IPN to receive a callback once the
|
206 |
-
* processing has been completed.
|
207 |
-
* Note that Amazon reserves the right to throttle requests that
|
208 |
-
* ignore this advice and poll for a response
|
209 |
-
*
|
210 |
-
* @param string $amazonAuthorizationReferenceId authorization transaction to query
|
211 |
-
*/
|
212 |
-
private function _waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId)
|
213 |
-
{
|
214 |
-
$response = $this->callStepAndCheckForException(
|
215 |
-
'waitUntilAuthorizationProcessingIsCompleted',
|
216 |
-
array($amazonAuthorizationId)
|
217 |
-
);
|
218 |
-
printGetAuthorizationDetailsResponse($response);
|
219 |
-
validateThatAuthorizationIsOpen($response);
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Perform the capture for a single shipment
|
224 |
-
*
|
225 |
-
* @param int $shipmentNumber order item index to capture
|
226 |
-
* @param string $amazonAuthorizationId authorization to capture
|
227 |
-
*
|
228 |
-
*/
|
229 |
-
private function _performCaptureForShipment($shipmentNumber, $amazonAuthorizationId)
|
230 |
-
{
|
231 |
-
$response = $this->callStepAndCheckForException(
|
232 |
-
'performCaptureForShipment',
|
233 |
-
array($shipmentNumber, $amazonAuthorizationId)
|
234 |
-
);
|
235 |
-
validateThatCaptureIsCompleted($response->getCaptureResult());
|
236 |
-
printCaptureResponse($response);
|
237 |
-
}
|
238 |
-
|
239 |
-
/**
|
240 |
-
* Close this order reference to indicate that the order is complete, and
|
241 |
-
* no further authorizations and captures will be performed on this order
|
242 |
-
*
|
243 |
-
*/
|
244 |
-
private function _closeOrderReference()
|
245 |
-
{
|
246 |
-
$response = $this->callStepAndCheckForException('closeOrderReference');
|
247 |
-
}
|
248 |
-
}
|
249 |
-
|
250 |
-
$splitShipmentsCheckoutExample = new SplitShipmentsCheckoutExampleCLI($argv);
|
251 |
-
$splitShipmentsCheckoutExample->runSample();
|
252 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/Utils/CountryRate.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/* *****************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
12 |
-
* specific language governing permissions and limitations under the License.
|
13 |
-
* *****************************************************************************
|
14 |
-
*/
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Utility class to help store data required for our payment scenario
|
18 |
-
*/
|
19 |
-
class CountryRates
|
20 |
-
{
|
21 |
-
|
22 |
-
public $shippingRates;
|
23 |
-
|
24 |
-
public $taxRates;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Creates a new instance of the country rates class with
|
28 |
-
* the specified tax rate and shipping rate maps
|
29 |
-
*
|
30 |
-
* @param array $shippingRates
|
31 |
-
* association of shipping types to costs
|
32 |
-
* @param array $taxRates
|
33 |
-
* association of states to tax rate %
|
34 |
-
*
|
35 |
-
* @return new CountryRates
|
36 |
-
*/
|
37 |
-
public function __construct ($shippingRates, $taxRates)
|
38 |
-
{
|
39 |
-
$this->shippingRates = $shippingRates;
|
40 |
-
$this->taxRates = $taxRates;
|
41 |
-
}
|
42 |
-
}
|
43 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/Utils/ShippingAndTaxCostHelper.php
DELETED
@@ -1,104 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/* *****************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
12 |
-
* specific language governing permissions and limitations under the License.
|
13 |
-
* *****************************************************************************
|
14 |
-
*/
|
15 |
-
require_once 'CountryRate.php';
|
16 |
-
|
17 |
-
class ShippingAndTaxCostHelper
|
18 |
-
{
|
19 |
-
|
20 |
-
private $_countryCostsMatrix;
|
21 |
-
|
22 |
-
public function __construct ()
|
23 |
-
{
|
24 |
-
/*
|
25 |
-
* Define overnight, 2 day and 5 day shipping rates for the countries in
|
26 |
-
* the example
|
27 |
-
*/
|
28 |
-
$baseOvernightShipping = 50.00;
|
29 |
-
$baseTwoDayShipping = 40.00;
|
30 |
-
$baseFiveDayShipping = 30.00;
|
31 |
-
|
32 |
-
$usShippingRates = array($baseOvernightShipping,$baseTwoDayShipping,$baseFiveDayShipping
|
33 |
-
);
|
34 |
-
$caShippingRates = array($baseOvernightShipping + 10.00,$baseTwoDayShipping + 10.00,
|
35 |
-
$baseFiveDayShipping + 10.00
|
36 |
-
);
|
37 |
-
$auShippingRates = array($baseOvernightShipping * 2,$baseTwoDayShipping * 2,
|
38 |
-
$baseFiveDayShipping * 2
|
39 |
-
);
|
40 |
-
$otherShippingRates = array($baseOvernightShipping + 30.00,$baseTwoDayShipping + 30.00,
|
41 |
-
$baseFiveDayShipping + 30.00
|
42 |
-
);
|
43 |
-
|
44 |
-
/*
|
45 |
-
* Define tax rates for different juristrictions in our example.
|
46 |
-
*/
|
47 |
-
$usTaxRates = array('WA' => 1.2,'IL' => 1.42,'NY' => 1.2
|
48 |
-
);
|
49 |
-
$caTaxRates = array('BC' => 1.1,'ON' => 1.11,'QC' => 1.5
|
50 |
-
);
|
51 |
-
$auTaxRates = array('NSW' => 1.1,'VIC' => 1.1,'QLD' => 1.1
|
52 |
-
);
|
53 |
-
$otherTaxRates = array();
|
54 |
-
|
55 |
-
/*
|
56 |
-
* Setup sample shipping and tax rates for our scenario
|
57 |
-
*/
|
58 |
-
$this->_countryCostsMatrix = array('US' => new CountryRates($usShippingRates, $usTaxRates),
|
59 |
-
'CA' => new CountryRates($caShippingRates, $caTaxRates),
|
60 |
-
'AU' => new CountryRates($auShippingRates, $auTaxRates),
|
61 |
-
'Unknown' => new CountryRates($otherShippingRates, $otherTaxRates)
|
62 |
-
);
|
63 |
-
}
|
64 |
-
|
65 |
-
public function calculateTotalAmount ($BillingAgreementDetails, $paymentAmountPreTaxAndShipping,
|
66 |
-
$shippingType)
|
67 |
-
{
|
68 |
-
$paymentTotal = $paymentAmountPreTaxAndShipping;
|
69 |
-
if ($BillingAgreementDetails->getDestination() == null) {
|
70 |
-
throw Exception(
|
71 |
-
"Error - expected to find destination in billing agreement details response" .
|
72 |
-
", check that correct versions of the widgets have been" .
|
73 |
-
" used to create the Amazon billing agreement Id");
|
74 |
-
}
|
75 |
-
$physicalAddress = $BillingAgreementDetails->getDestination()->getPhysicalDestination();
|
76 |
-
|
77 |
-
/* *********************************************************************
|
78 |
-
* Add shipping costs to the total order, based on the country of the
|
79 |
-
* destination address
|
80 |
-
* ******************************************************************
|
81 |
-
*/
|
82 |
-
if (array_key_exists($physicalAddress->getCountryCode(), $this->_countryCostsMatrix)) {
|
83 |
-
$paymentTotal = $paymentTotal +
|
84 |
-
$this->_countryCostsMatrix[$physicalAddress->getCountryCode()]->shippingRates[$shippingType];
|
85 |
-
|
86 |
-
/* *********************************************************************
|
87 |
-
* Add tax to the order if the the state or region exists in our
|
88 |
-
* tax rate map
|
89 |
-
* ********************************************************************
|
90 |
-
*/
|
91 |
-
if (array_key_exists($physicalAddress->getStateOrRegion(),
|
92 |
-
$this->_countryCostsMatrix[$physicalAddress->getCountryCode()]->taxRates)) {
|
93 |
-
$paymentTotal = $paymentTotal *
|
94 |
-
$this->_countryCostsMatrix[$physicalAddress->getCountryCode()]->taxRates[$physicalAddress->getStateOrRegion()];
|
95 |
-
}
|
96 |
-
} else {
|
97 |
-
$paymentTotal = $paymentTotal +
|
98 |
-
$_this->countryCostsMatrix["Unknown"]->shippingRates[$shippingType];
|
99 |
-
}
|
100 |
-
|
101 |
-
return $paymentTotal;
|
102 |
-
}
|
103 |
-
}
|
104 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/OffAmazonPaymentsService/Samples/ValidateBillingAgreementSample.php
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*******************************************************************************
|
4 |
-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
5 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
-
*
|
7 |
-
* You may not use this file except in compliance with the License.
|
8 |
-
* You may obtain a copy of the License at:
|
9 |
-
* http://aws.amazon.com/apache2.0
|
10 |
-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11 |
-
* CONDITIONS OF ANY KIND, either express or implied. See the License
|
12 |
-
* for the
|
13 |
-
* specific language governing permissions and limitations under the
|
14 |
-
* License.
|
15 |
-
* *****************************************************************************
|
16 |
-
*/
|
17 |
-
require_once realpath(dirname(__FILE__)) . '/.config.inc.php';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Print the printValidateBillingAgreement response to the console
|
21 |
-
*
|
22 |
-
* @param OffAmazonPaymentsService_Model_ValidateBillingAgreementResponse $response
|
23 |
-
* response object
|
24 |
-
*
|
25 |
-
* @return void
|
26 |
-
*/
|
27 |
-
function printValidateBillingAgreementResponse ($response)
|
28 |
-
{
|
29 |
-
echo ("Service Response\n");
|
30 |
-
echo ("=============================================================================\n");
|
31 |
-
|
32 |
-
echo (" ValidateBillingAgreementResponse\n");
|
33 |
-
if ($response->isSetValidateBillingAgreementResult()) {
|
34 |
-
echo (" ValidateBillingAgreementResult\n");
|
35 |
-
$validateBillingAgreementResult = $response->getValidateBillingAgreementResult();
|
36 |
-
if ($validateBillingAgreementResult->isSetValidationResult()) {
|
37 |
-
echo (" ValidationResult\n");
|
38 |
-
echo (" " . $validateBillingAgreementResult->getValidationResult() .
|
39 |
-
"\n");
|
40 |
-
}
|
41 |
-
if ($validateBillingAgreementResult->isSetFailureReasonCode()) {
|
42 |
-
echo (" FailureReasonCode\n");
|
43 |
-
echo (" " . $validateBillingAgreementResult->getFailureReasonCode() .
|
44 |
-
"\n");
|
45 |
-
}
|
46 |
-
if ($validateBillingAgreementResult->isSetBillingAgreementStatus()) {
|
47 |
-
echo (" BillingAgreementStatus\n");
|
48 |
-
$billingAgreementStatus = $validateBillingAgreementResult->getBillingAgreementStatus();
|
49 |
-
if ($billingAgreementStatus->isSetState()) {
|
50 |
-
echo (" State\n");
|
51 |
-
echo (" " . $billingAgreementStatus->getState() . "\n");
|
52 |
-
}
|
53 |
-
if ($billingAgreementStatus->isSetLastUpdatedTimestamp()) {
|
54 |
-
echo (" LastUpdatedTimestamp\n");
|
55 |
-
echo (" " . $billingAgreementStatus->getLastUpdatedTimestamp() .
|
56 |
-
"\n");
|
57 |
-
}
|
58 |
-
if ($billingAgreementStatus->isSetReasonCode()) {
|
59 |
-
echo (" ReasonCode\n");
|
60 |
-
echo (" " . $billingAgreementStatus->getReasonCode() . "\n");
|
61 |
-
}
|
62 |
-
if ($billingAgreementStatus->isSetReasonDescription()) {
|
63 |
-
echo (" ReasonDescription\n");
|
64 |
-
echo (" " . $billingAgreementStatus->getReasonDescription() .
|
65 |
-
"\n");
|
66 |
-
}
|
67 |
-
}
|
68 |
-
}
|
69 |
-
if ($response->isSetResponseMetadata()) {
|
70 |
-
echo (" ResponseMetadata\n");
|
71 |
-
$responseMetadata = $response->getResponseMetadata();
|
72 |
-
if ($responseMetadata->isSetRequestId()) {
|
73 |
-
echo (" RequestId\n");
|
74 |
-
echo (" " . $responseMetadata->getRequestId() . "\n");
|
75 |
-
}
|
76 |
-
}
|
77 |
-
|
78 |
-
echo (" ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");
|
79 |
-
}
|
80 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>login_and_pay_for_magento</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License, Version 2.0</license>
|
7 |
<channel>community</channel>
|
@@ -31,11 +31,14 @@
|
|
31 |
Keep your customers secure! Leverage the same user authentication system used on Amazon.com.</p>
|
32 |

|
33 |
</description>
|
34 |
-
<notes
|
|
|
|
|
|
|
35 |
<authors><author><name>Amazon Payments</name><user>payments-cp-devel</user><email>payments-cp-devel@amazon.com</email></author></authors>
|
36 |
-
<date>2014-09-
|
37 |
-
<time>
|
38 |
-
<contents><target name="magecommunity"><dir name="Amazon"><dir name="Login"><dir name="Block"><file name="Script.php" hash="40c4cca328e24521e3562f1466251c55"/><file name="Verify.php" hash="71ae4c427a3846f47ae3de927c54097a"/></dir><dir name="Helper"><file name="Data.php" hash="ae6797f0228b6cada765368d661d6bf6"/></dir><dir name="Model"><file name="Api.php" hash="48a3f6306d97f31fa4c3b954a665f334"/><file name="Customer.php" hash="7a019551c6efc3e073f838196c154f3f"/><file name="Login.php" hash="81a09b4f2c0c62e874ad209ef78ef462"/><dir name="Resource"><file name="Login.php" hash="cea5ac352d61cace9965f1cb940a7272"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Enabled.php" hash="94bc7fde24ab2ee54ed15bbe7084f118"/><file name="Popupcomment.php" hash="dfae81ef7bfa585feb33f8efa9f058c4"/></dir><dir name="Source"><file name="Buttoncolor.php" hash="ac335e432cd8e47c9ca4be601c706072"/><file name="Buttonsize.php" hash="827e414291e371c6dde686b224c5e57f"/><file name="Buttontype.php" hash="5e333d6cb1d70d0227766d78e390530b"/></dir></dir></dir></dir><dir name="controllers"><file name="CustomerController.php" hash="d326a02cb53c18bb78f988adb94a6478"/></dir><dir name="etc"><file name="adminhtml.xml" hash="0aa18eecfebd3e0bb1d84cd6b1040f50"/><file name="config.xml" hash="96acfda506615306cf0554bfd5dbbda2"/><file name="system.xml" hash="84f96ce1bcad7ad9c0ec03f21182f983"/></dir><dir name="sql"><dir name="login_setup"><file name="install-0.1.0.php" hash="1b277e3f5b16e2342b9c9ec767d13fb1"/><file name="mysql4-install-0.1.0.php" hash="3a2fdffc1744b894deee5ebfb5e0cf6d"/></dir></dir></dir><dir name="Payments"><dir name="Block"><dir name="Adminhtml"><file name="Notifications.php" hash="16e9934aec3fadb1823e2d1a496cc7c9"/></dir><file name="Button.php" hash="b5e6ec0b061f8d904cede42b4a697a77"/><file name="Checkout.php" hash="532f647be6bd8ed047ae72d380461b7a"/><file name="Link.php" hash="47c237fe4604333b2080588c5498a865"/><dir name="Onepage"><file name="Widget.php" hash="f10bb86d3e7e5a88dfdfa4e645a61086"/></dir><file name="Onepage.php" hash="1d865069483bbe776f511119e0e2252b"/><dir name="Review"><file name="Info.php" hash="8d3688c55137971b18aec41272cf13a6"/></dir><file name="Review.php" hash="d9cf9b6ef7d6f063a06e006e01f09513"/></dir><dir name="Controller"><file name="Checkout.php" hash="4b8c6f1b52ac59b9611dbb9e4fec2d4f"/></dir><dir name="Helper"><file name="Data.php" hash="b8a91e228801ed8adbbffc003e6847f3"/></dir><dir name="Model"><file name="Api.php" hash="494525fc06fcedd12429ece085303c8e"/><file name="Config.php" hash="6adceda8e7a5afbc79ca37665b1c57ab"/><dir name="Observer"><file name="Onepage.php" hash="ec9f1b60d5d2206c98e56fb6669461a2"/></dir><file name="PaymentMethod.php" hash="fb7d2de8a55dcb423c7c222e63a6ccfc"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Clientid.php" hash="4512003bcffedf26bc2fe415b91b1be7"/><file name="Clientsecret.php" hash="d2d5f275e4275676e3f494da704e41da"/><file name="Enabled.php" hash="e34c04693a65718675b2150810a6c6be"/></dir><dir name="Source"><file name="Buttoncolor.php" hash="2564780faa369e54339bded78a882636"/><file name="Buttonsize.php" hash="c7b0e76a9dcbdcc61c5b17cf184c917d"/><file name="Buttontype.php" hash="735083e4848fa2258b95670b1a546843"/><file name="Checkoutpage.php" hash="2969f9eaa9d87571e0fa8f005e2cdeaf"/><file name="Paymentaction.php" hash="4dba1ce3518538d1a5add743d65c8695"/><file name="Region.php" hash="0718cf97d03a8c56c73fb7ea3a103bc5"/></dir></dir></dir><dir name="Type"><file name="Checkout.php" hash="a99538049d00fe13bb9110f2bd92f3bc"/></dir></dir><dir name="controllers"><file name="CheckoutController.php" hash="6d005be14745219d5f7d28d4c6f51a4b"/><file name="IndexController.php" hash="128f218a9e1bf4af4f7b380f14d87a52"/><file name="OnepageController.php" hash="cc03d109ee1cf98f85aba606f5a44654"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3c56d63f30e0e5cc8c22d3686046631b"/><file name="config.xml" hash="835923b959b317a280373a62016c0ee8"/><file name="system.xml" hash="67a3a72922a32c4800af59215ace2713"/></dir><dir name="sql"><dir name="payments_setup"><file name="install-0.1.0.php" hash="658f9d8c8634b3158cee7b59866e6f39"/></dir></dir></dir></dir></target><target name="magelib"><dir name="OffAmazonPayments"><file name="Model.php" hash="a608217f17166ba11901f5334ad445de"/><file name=".autoloader.php" hash="193fddab8b5ca74646bb78243c0c7dda"/></dir><dir name="OffAmazonPaymentsNotifications"><file name="Client.php" hash="0ab53a8a0a0c069f13e1de3731eaebde"/><dir name="Impl"><file name="IpnNotificationParser.php" hash="fcad418dc58a93e87b854e4067f1e24d"/><file name="Message.php" hash="2ab8cb01bd97ceaeaae0df2bf93ddbf5"/><file name="OpenSslVerifySignature.php" hash="427e2e171daab9ef454ca4ce939edd68"/><file name="SnsMessageParser.php" hash="6a1088096d27a3cdc586e4c298ddf068"/><file name="SnsMessageValidator.php" hash="076f63d5960e4c72a3dc63a76e75316c"/><file name="VerifySignature.php" hash="b18edb328fbe91c1c7b0aa8afe2904d0"/><file name="XmlNotificationParser.php" hash="4881b7d021a86215e43798497bceea24"/></dir><file name="Interface.php" hash="effe919508aab0c2aa1e585d2783c4e6"/><file name="InvalidMessageException.php" hash="2edda9cd6cc0c059846c4858cedfcd66"/><dir name="Model"><file name="AuthorizationDetails.php" hash="843711e02fb56fffcdfb6afcf097e373"/><file name="AuthorizationNotification.php" hash="b00c64bd48ae3bd3c3fa6d991e4b9f5c"/><file name="BillingAgreement.php" hash="677eadcbc4c91282eab548afc6482fdc"/><file name="BillingAgreementLimits.php" hash="a1bd8e8ec111f516528e09340c47de4a"/><file name="BillingAgreementNotification.php" hash="e39a3189bdc937b29b8488e0ef62b562"/><file name="BillingAgreementStatus.php" hash="fae14e95f03245fe6c53e7c7b725c5ca"/><file name="CaptureDetails.php" hash="adb45ebf66daa15990e032025a420e1b"/><file name="CaptureNotification.php" hash="14c2bdc8f6bd6ce881f4403d1f08c6ef"/><file name="IdList.php" hash="2907bdba4b5a534f535c026c40e6d6cc"/><file name="IpnNotificationMetadata.php" hash="58674fca7aa30eea82cb4cba17dec04e"/><file name="MerchantRegistrationDetails.php" hash="37ecb29de3d2d98fbe6f6c8c23f670a2"/><file name="NotificationImpl.php" hash="bfd2e22da29de6dfa15c82a19240132a"/><file name="NotificationMetadataImpl.php" hash="b297f69b967338d433ff90054e06da4b"/><file name="OrderItemCategories.php" hash="a0655ec5a9127ddbd51174ef9e046c5d"/><file name="OrderReference.php" hash="94b51567b72f62355d885e37e365a032"/><file name="OrderReferenceNotification.php" hash="8e6e3a67bf0ae55e86bd718ceca20e0e"/><file name="OrderReferenceStatus.php" hash="e29870a166b75c6d90955a08e0dfe048"/><file name="OrderTotal.php" hash="4141b92ed1bdeb9cfa4c13837df41221"/><file name="Price.php" hash="d94b947bb989fb974e076f2727a0dceb"/><file name="ProviderCreditDetails.php" hash="bf29c9938744effcd759cd95b8a7beab"/><file name="ProviderCreditNotification.php" hash="14b3d8a09ee0feb53cfb701e93e3180e"/><file name="ProviderCreditReversalDetails.php" hash="e9980476af6da3f09de6faff86220f85"/><file name="ProviderCreditReversalNotification.php" hash="bfff2d0e347b1f1dd9e96b0612c87b46"/><file name="ProviderCreditReversalSummary.php" hash="1e69dc1cde4ffac600f89487930cc38c"/><file name="ProviderCreditReversalSummaryList.php" hash="b4b7edc94d7dad37221ca1da5f0969f9"/><file name="ProviderCreditSummary.php" hash="946e787472dc1ee7c9dbcb5d29d62af2"/><file name="ProviderCreditSummaryList.php" hash="fad79864ec1797eed4412d9463c0d02c"/><file name="RefundDetails.php" hash="e0c9fd8c1a921097b4c7e6eb71c20f47"/><file name="RefundNotification.php" hash="28f003801abeb45e0978df05068d73da"/><file name="SellerBillingAgreementAttributes.php" hash="79572632ec2c776fb6a7e96554d7291a"/><file name="SellerOrderAttributes.php" hash="aa6f71cb667d2efb50cc336603b6029c"/><file name="SnsNotificationMetadata.php" hash="835ebe9f84b23e6d59e3f7e2101df531"/><file name="SolutionProviderMerchantNotification.php" hash="91b02852ed507b91e70907e5db488f6f"/><file name="SolutionProviderOption.php" hash="33eca51f6789687e5472cded23be5328"/><file name="SolutionProviderOptions.php" hash="806d915cdd1bd0be5c0e92a3040d49aa"/><file name="Status.php" hash="60765642cca51b523276421d995be784"/></dir><file name="Notification.php" hash="edaf311309c64b67a4fd82ccb86393a3"/><file name="NotificationMetadata.php" hash="9ffe2779593da053e82587dbb61da7d1"/><dir name="Samples"><file name="AddressConsentSample.php" hash="b95018daffc217ef934eeb71193fca89"/><file name="AddressConsentSampleResult.php" hash="668487d6e2714772ab72578f6736f9f5"/><file name="AuthorizationNotificationSample.php" hash="6adb3c72895d7637feb34cf2e286d194"/><dir name="AutomaticPayments"><file name="address.php" hash="748326615efb528899286fda379996be"/><file name="signin.php" hash="d5c7f1d4f8c071b0ce07cd2f5c256385"/><file name="wallet.php" hash="e9b2af78fc9b4df7b5fb656d8e609e14"/></dir><file name="AutomaticPaymentsSimpleCheckoutDataInput.php" hash="3e8962278ed0edaf695e1b109c60de22"/><file name="AutomaticPaymentsSimpleCheckoutResult.php" hash="b031cc895bbea2be09f0f999b49eb8bc"/><file name="BillingAgreementNotificationSample.php" hash="a4a99f98a3de9b30a36aa349d167b5c1"/><file name="CancellationDataInput.php" hash="63c1a539175fec725cf2a05013a3bc07"/><file name="CancellationResult.php" hash="f21fd3d16b7ecfa41460a43df8a356b7"/><file name="CaptureNotificationSample.php" hash="dbee7b0ca88268ec9b7f78f65196a41a"/><file name="IpnHandler.php" hash="f5ac73bc9ec3786620442b6444622320"/><file name="IpnLogFile.php" hash="32d769cd258751f1990a3ee89bae9d3c"/><file name="NotificationSample.php" hash="f3a2a27e681ad9809fd7cc68d98f01f8"/><file name="OrderReferenceSample.php" hash="846e2a653f7b7da3d35ac5bdc2fd155d"/><dir name="PayWithAmazon"><file name="address.php" hash="79d644493abdac48d5aa4936ce32126a"/><file name="signin.php" hash="ba5fccb1eebb7694ab4f24a09a2e0884"/><file name="wallet.php" hash="c675ba68f1f58b000f5b36d17a1e815a"/></dir><file name="ProviderCheckoutDataInput.php" hash="90cdc88e19ec1f2074b0f52d6b206f17"/><file name="ProviderCheckoutResult.php" hash="09cf1baa0d0c7e27b2331b78b20b77ed"/><file name="ProviderCreditNotificationSample.php" hash="434f022d39fc783cfac3c89a23944c2c"/><file name="ProviderCreditReversalNotificationSample.php" hash="a6dfaaedfa47b5322d18c54f03510cb8"/><file name="ProviderRefundDataInput.php" hash="779fa0a9f7276b7f8bf0b3d5677b817b"/><file name="ProviderRefundResult.php" hash="a53a15f2362c41a10219d2ac038e001a"/><file name="RefundDataInput.php" hash="9917c990c28d89183f4d094077a87e03"/><file name="RefundNotificationSample.php" hash="6c49d2bb1f0d6a0baf91da3bb2d1b6a6"/><file name="RefundResult.php" hash="fea1ec3db763ebd1246dc34ff12df368"/><file name="ReverseProviderCreditDataInput.php" hash="b9fcb0e30d005dfc6c79a7962bab426d"/><file name="ReverseProviderCreditResult.php" hash="0205823bd948ec906e0ad355f9b94be8"/><file name="Samples.html" hash="ca2252af3af2baa9ea9b9f62724658ca"/><file name="SimpleCheckoutDataInput.php" hash="ab81f22982cf80e6152d8e8437e71fac"/><file name="SimpleCheckoutResult.php" hash="7da3f51bc078fe9bf9ccf93d063fcb22"/><file name="SolutionProviderMerchantNotificationSample.php" hash="9d8c791c08a63dfba3cac22831ee5026"/><file name="SplitShipmentsCheckoutDataInput_1.php" hash="8eed739e31d2c19f2b58a02f82c5706c"/><file name="SplitShipmentsCheckoutDataInput_2.php" hash="78c92aa0b3262ea644f2d2a78d8f3119"/><file name="SplitShipmentsCheckoutResult.php" hash="90bad23ceceb215f0ea9787b389a8f1e"/><file name="WebServerExample.php" hash="83d09cb492c843383ffdda55421a4ad2"/><file name="address.php" hash="0d091ddd60bc76d0c7c84e49d1bbb8a4"/><file name="signin.php" hash="454ccafef368d8f4a73fbadda8ae87ce"/><file name="wallet.php" hash="f45ea6e2b22e893d560e9e18b3c34664"/><file name=".config.inc.php" hash="e53a346fea00eb06e67af3f1a2fed615"/></dir></dir><dir name="OffAmazonPaymentsService"><file name="Client.php" hash="803c77a200489265e9c11a92adc86492"/><file name="Environments.php" hash="d84e7322b3394033b427f91be0a0abdb"/><file name="Exception.php" hash="dd85e54cfa5783c7ef7b1f93ca3995b2"/><file name="Interface.php" hash="ca1693109051f319740e4cd7e8ed4de7"/><file name="MerchantValues.php" hash="31cf41c1d58a078a193a1abec6ec7bd3"/><dir name="Model"><file name="Address.php" hash="3b3c00f4b50a4a6f42da15701343ce91"/><file name="AuthorizationDetails.php" hash="77aa03389903c2f777930d838d396da5"/><file name="AuthorizeOnBillingAgreementRequest.php" hash="fcb797660fa5c9cde02c4d482ec69f79"/><file name="AuthorizeOnBillingAgreementResponse.php" hash="c641d4e41db304d6f8f4136ea5d2f500"/><file name="AuthorizeOnBillingAgreementResult.php" hash="7b10d0dc68e7cbf18681abb4e600cca4"/><file name="AuthorizeRequest.php" hash="e7944fb6372becb0c3dd022bb30a9140"/><file name="AuthorizeResponse.php" hash="fb396a94285cacc3eb0fb798a0895466"/><file name="AuthorizeResult.php" hash="0c8f0581538ebba22a5dac5287c0fcc9"/><file name="BillingAddress.php" hash="bef3c0a443ba48ad19d832b91e8740b9"/><file name="BillingAgreementAttributes.php" hash="fe9c760e12c3db71125412ada5a65ec2"/><file name="BillingAgreementDetails.php" hash="0fef2badb342c32a01c44389bcfb52bc"/><file name="BillingAgreementLimits.php" hash="974d1252d7b914169203acdfa6e7082b"/><file name="BillingAgreementStatus.php" hash="002b0516c52264ea95847ea840d68545"/><file name="Buyer.php" hash="83759bcb729cdd8718cdb80182d9a237"/><file name="CancelOrderReferenceRequest.php" hash="86a2753aac94ae645fda1117cf90a926"/><file name="CancelOrderReferenceResponse.php" hash="4d6bc1d4818d81fd5b5820510b608275"/><file name="CancelOrderReferenceResult.php" hash="32013170a09bccf0aac178a7acb56a30"/><file name="CaptureDetails.php" hash="9ca070a0a890be4ec84d7a7264b33800"/><file name="CaptureRequest.php" hash="436da55de37deb4227a685167eb4eaa3"/><file name="CaptureResponse.php" hash="05540d55de14a3252f909fd17c8b62b6"/><file name="CaptureResult.php" hash="20e0bc168c13eb69848f09b520232eeb"/><file name="CloseAuthorizationRequest.php" hash="92d56fd8a0ae338213fdd4f8a5d1b5fc"/><file name="CloseAuthorizationResponse.php" hash="d5887ecf3981534842a9a2371ae063f0"/><file name="CloseAuthorizationResult.php" hash="0505c8c12f3b5252ad389c0c5b94ca8d"/><file name="CloseBillingAgreementRequest.php" hash="c845cdde3cde3242d4c40b1381e0ab2f"/><file name="CloseBillingAgreementResponse.php" hash="51530b8a5d14896488dbf82d6b5a37dc"/><file name="CloseBillingAgreementResult.php" hash="21cb77e2fa38defbc076263c71593168"/><file name="CloseOrderReferenceRequest.php" hash="85ae367281cb4d59f5d347be8bf0147d"/><file name="CloseOrderReferenceResponse.php" hash="d06107418145176a4038f2b0937fd9d7"/><file name="CloseOrderReferenceResult.php" hash="17bc6d72eb29b021fad7d8a222f366dc"/><file name="ConfirmBillingAgreementRequest.php" hash="965b88fe77576f07ce439bc4909e5723"/><file name="ConfirmBillingAgreementResponse.php" hash="989a66f5c217ad50a2a36afd00c763f1"/><file name="ConfirmBillingAgreementResult.php" hash="f0acdd5b7e2e1027bec651e6a6f4681d"/><file name="ConfirmOrderReferenceRequest.php" hash="8561edc4d074fd376e647bd0cdf9a686"/><file name="ConfirmOrderReferenceResponse.php" hash="b94a17b5afd4d923bda35d606c974982"/><file name="Constraint.php" hash="436ed3c926e321bcc9d9c6eaf9b4003a"/><file name="Constraints.php" hash="0063db27ee04067daf94c448f57d5c30"/><file name="CreateOrderReferenceForIdRequest.php" hash="b1c22ce6d83e510d0b9530c99b955711"/><file name="CreateOrderReferenceForIdResponse.php" hash="c811a7c44241a8b968bf4408218ac08f"/><file name="CreateOrderReferenceForIdResult.php" hash="f532299b151a1c4fe4264891737efeaf"/><file name="Destination.php" hash="4e6067e4a3b5f9acb3b9c96452b216fe"/><file name="Error.php" hash="56651e2c89e0214a3c4226903ca84d87"/><file name="ErrorResponse.php" hash="6df06e3cca71a1e73dbcde4bc6b30a3f"/><file name="GetAuthorizationDetailsRequest.php" hash="a0eb816954b6770a7fd8d54d0d75bc1a"/><file name="GetAuthorizationDetailsResponse.php" hash="82b879ccc0212f0752446b40d5338332"/><file name="GetAuthorizationDetailsResult.php" hash="a23e9463ce78b01cc51c45c21b065b6e"/><file name="GetBillingAgreementDetailsRequest.php" hash="91f33b1b1533cc4e98a019ce2c405850"/><file name="GetBillingAgreementDetailsResponse.php" hash="3abcae092618211ae5487f678a45c94f"/><file name="GetBillingAgreementDetailsResult.php" hash="37dc2407a2e9e8dd3e7feae1f690d160"/><file name="GetCaptureDetailsRequest.php" hash="48a9edebb0c7c8284241ac12b53e2d41"/><file name="GetCaptureDetailsResponse.php" hash="49cb6ae36cfba0aedef3c74c24256d53"/><file name="GetCaptureDetailsResult.php" hash="9110dbde9258a74d9933f8a50d10bd3b"/><file name="GetOrderReferenceDetailsRequest.php" hash="b1704b0e1e1f98778501792b82403c50"/><file name="GetOrderReferenceDetailsResponse.php" hash="3ea19407068d478f6c2b077bf8489a74"/><file name="GetOrderReferenceDetailsResult.php" hash="51bc2cd9a665edfb00cec970fc1fd328"/><file name="GetProviderCreditDetailsRequest.php" hash="2ff598dcc690c90b36727351f95bc76a"/><file name="GetProviderCreditDetailsResponse.php" hash="7ec3943a5c7fb0890d1304ccf52cb7d3"/><file name="GetProviderCreditDetailsResult.php" hash="a9033131b919f4f79b1000268892e64b"/><file name="GetProviderCreditReversalDetailsRequest.php" hash="5502cdd97afce7c42d177706cdcb7d0b"/><file name="GetProviderCreditReversalDetailsResponse.php" hash="19d4d9337646583f4a69776965a9f193"/><file name="GetProviderCreditReversalDetailsResult.php" hash="bb56c2f2ec45144234d7534352fe35c4"/><file name="GetRefundDetailsRequest.php" hash="c798b0b57c53e22d20e7e4a92d9eb225"/><file name="GetRefundDetailsResponse.php" hash="c1011e3b07e32792c4ac8ceabab3bc6b"/><file name="GetRefundDetailsResult.php" hash="463db01fb3a45adf9634116f3397f8a7"/><file name="IdList.php" hash="07daf191c601560ddfe50440f9006450"/><file name="OrderItemCategories.php" hash="2820e45ffb6cb36a14368a1dfe89fa84"/><file name="OrderReferenceAttributes.php" hash="990daffb0857fca0c05292ae2fb465cf"/><file name="OrderReferenceDetails.php" hash="2c75125691a884aa8bdc40318bce3b06"/><file name="OrderReferenceStatus.php" hash="04459e930111cf70c989196440f6400f"/><file name="OrderTotal.php" hash="6fda4ce95b066f960eebe41731717925"/><file name="ParentDetails.php" hash="1c6738a58079ffdaaef6e3d5e6afff01"/><file name="Price.php" hash="ea1d5a6e473542f5b0cb8ed1e70436bd"/><file name="ProviderCredit.php" hash="9834503bcc2f619b38157400984377e4"/><file name="ProviderCreditDetails.php" hash="a74f8e42aacd945989e6c5513d808fb3"/><file name="ProviderCreditList.php" hash="1c90c2d71fd33e9b059503b0b0815b53"/><file name="ProviderCreditReversal.php" hash="37aa96053d61a290d98d595d3c3c9226"/><file name="ProviderCreditReversalDetails.php" hash="7585eab585360dcabe7acb0e616f3afb"/><file name="ProviderCreditReversalList.php" hash="e30c2373f4a708443e7dde8f75e1d794"/><file name="ProviderCreditReversalSummary.php" hash="03b0b5aefae44ea5dcac06a4322e57cd"/><file name="ProviderCreditReversalSummaryList.php" hash="23a82515eb4d9f288dbc97691fef9153"/><file name="ProviderCreditSummary.php" hash="530091cb8d5e103ca3e44a0a3384eff2"/><file name="ProviderCreditSummaryList.php" hash="23115d04c6987208d7ba307781e433a5"/><file name="RefundDetails.php" hash="01866f818651ad6c0a7bc12d3c7e6644"/><file name="RefundRequest.php" hash="22b14eadcf9679a92c4325225dbf8c39"/><file name="RefundResponse.php" hash="b01d5c4c81a040bca2e1109e5d34b3e9"/><file name="RefundResult.php" hash="8f2478b1f27a295bff8f30664fd45235"/><file name="ResponseHeaderMetadata.php" hash="d8024e3bf444e8a843a6f2f6a2f836ca"/><file name="ResponseMetadata.php" hash="18e8035d5fc28d2919c1500b9f8734c5"/><file name="ReverseProviderCreditRequest.php" hash="d1b710b8911346ee0437de4e6178ac8e"/><file name="ReverseProviderCreditResponse.php" hash="38c6958d2ceb9ee244e86adee3c55acf"/><file name="ReverseProviderCreditResult.php" hash="313db1523bd575da7ab1fd956866a15d"/><file name="SellerBillingAgreementAttributes.php" hash="b4dc6401ae4340df3c484c00622d234f"/><file name="SellerOrderAttributes.php" hash="9ec79bc1be30eb322d7e88c4102a4ced"/><file name="SetBillingAgreementDetailsRequest.php" hash="9b47c3c72825fe661948aa36a2947da2"/><file name="SetBillingAgreementDetailsResponse.php" hash="7b6886f3597c434e585fb576d84fd9eb"/><file name="SetBillingAgreementDetailsResult.php" hash="d03a4c84cb96eb30f7ef5c76f981d086"/><file name="SetOrderReferenceDetailsRequest.php" hash="eed7e3485bc27f9f73cf7b67a893a1fa"/><file name="SetOrderReferenceDetailsResponse.php" hash="145bdfcfbf3bb091e0eada1361d6f581"/><file name="SetOrderReferenceDetailsResult.php" hash="246c06e0c62ee6a6ec0cfe504940c12d"/><file name="Status.php" hash="11c00f2cc32b11d4cfb8541d5ba2c279"/><file name="ValidateBillingAgreementRequest.php" hash="60250e9c62eaffa0a841bce7238ace22"/><file name="ValidateBillingAgreementResponse.php" hash="c77eebf5805b5972de84a814b3872cc7"/><file name="ValidateBillingAgreementResult.php" hash="95d4e8efc88317a097e376a4aa37a287"/></dir><file name="Model.php" hash="ca87227ca87a9f7062e6eb6a99ef086b"/><file name="OffAmazonPaymentsService.config.inc.php" hash="20807040ef4565a6b78f09cda6529a34"/><file name="RegionSpecificProperties.php" hash="e9a14a7392a83a57b471dfb2d77ff610"/><file name="Regions.php" hash="a544d12c6321899770c039426e063cce"/><dir name="Samples"><file name="AddressConsentSample.php" hash="744ea39f99ca0f7978d44a6d2eba972e"/><file name="AuthorizeOnBillingAgreementSample.php" hash="1c2153c5eb0314ef7ef59d9c150766a8"/><file name="AuthorizeSample.php" hash="545027e450c0add8d40586b6092bbab8"/><file name="AutomaticPaymentsSimpleCheckoutExample.php" hash="30459c9f3d410ff96bebeb850c259c8f"/><file name="AutomaticPaymentsSimpleCheckoutExampleCLI.php" hash="23e991fa1b8991606abe1a187667936d"/><file name="CLIExample.php" hash="420310d7236adf2f1d4cf57eee68f092"/><file name="CancelOrderReferenceSample.php" hash="6841eaf26527ff80fc8679f0a2eb4437"/><file name="CancellationExample.php" hash="76610ce6b4943005433520012c3dea2f"/><file name="CancellationExampleCLI.php" hash="fa3711ff27aa2d11ecd34d93487a5c65"/><file name="CaptureSample.php" hash="289f472192df977663a108e49eb87afc"/><file name="CloseAuthorizationSample.php" hash="c344ee2306ed1b793bf6379d163d0a13"/><file name="CloseBillingAgreementSample.php" hash="777474f6eb7c292e7554607be53a6457"/><file name="CloseOrderReferenceSample.php" hash="22bcdebc9affca6dd7ea768d0a73f072"/><file name="ConfirmBillingAgreementSample.php" hash="d8fa26ed0d37391cda630c2c74d59ec1"/><file name="ConfirmOrderReferenceSample.php" hash="41a4808c38b1e3e384ddb820a33e2e0a"/><file name="CreateOrderReferenceForIdSample.php" hash="f79f714cd6a160a4af3a098246745445"/><file name="GetAuthorizationDetailsSample.php" hash="517805036a6064c001b685cf0bbc93ee"/><file name="GetBillingAgreementDetailsSample.php" hash="df2014298d8a6bac2c566d610c0b068a"/><file name="GetCaptureDetailsSample.php" hash="b5d8d76430983b6db788be91cad1789c"/><file name="GetOrderReferenceDetailsSample.php" hash="34e3bea3bfe0d760e263c811318ca0e8"/><file name="GetProviderCreditDetailsSample.php" hash="5bc6f971eb9f06cc2bfb648b74576212"/><file name="GetProviderCreditReversalDetailsSample.php" hash="4375dfee20cb0c31f41f61407ab281e1"/><file name="GetRefundDetailsSample.php" hash="2cca1d93586aa52f610b5a08e4a15687"/><file name="ProviderCheckoutExampleCLI.php" hash="a99458af9e268d984b026355b9504c6c"/><file name="ProviderRefundExampleCLI.php" hash="6adfeb51526296b971289b647fa9e0ef"/><file name="RefundExample.php" hash="cebdc340e3704b0af91a9a1a0a1b876d"/><file name="RefundExampleCLI.php" hash="3a27283feca0d5755e810582357982b1"/><file name="RefundSample.php" hash="9e604d2fda4aaa7bfb7fdcebe6fd9996"/><file name="ReverseProviderCreditExample.php" hash="caf27918617f7f8b8d915ac42c9831c8"/><file name="ReverseProviderCreditExampleCLI.php" hash="5946c04ad5a5c3abb3fcb752bb3c4f14"/><file name="ReverseProviderCreditSample.php" hash="f2497593656c3e099d9e780dafe15702"/><file name="SetBillingAgreementDetailsSample.php" hash="bb662b3ae070b72af0d0d4f04373f5cd"/><file name="SetOrderReferenceDetailsSample.php" hash="9e51328a77c22d3dbd88142f8759868c"/><file name="SimpleCheckoutExample.php" hash="dd51827b2ca304c92b77735512a0d900"/><file name="SimpleCheckoutExampleCLI.php" hash="05c26c7d197125dab56d0008e6f16858"/><file name="SplitShipmentsCheckoutExample.php" hash="79400d737a036c5dbc24fa698ef12229"/><file name="SplitShipmentsCheckoutExampleCLI.php" hash="5276fcb53da88a363e0cf6c124685c6e"/><dir name="Utils"><file name="CountryRate.php" hash="026bb0abb6e571ea2451a39f4b0ad4ce"/><file name="ShippingAndTaxCostHelper.php" hash="91cd5f8c4bda1e3213b60de8addf62d0"/></dir><file name="ValidateBillingAgreementSample.php" hash="03f1ebae3a08930ab4bb375c129f9aeb"/><file name=".config.inc.php" hash="fe505741620d8ef4b2fea3a0b6ef25ca"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="amazon_payments.xml" hash="86dc7900219559e892ffc0728e8bb136"/></dir><dir name="template"><dir name="amazon_payments"><file name="notifications.phtml" hash="b1d84206d51f9b35fb777ec439acf7d0"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="amazon_login.xml" hash="c2f5970f638e7c9ad20b742a97d23313"/><file name="amazon_payments.xml" hash="8dff524dc78d11d68baf3987a664abcc"/></dir><dir name="template"><dir name="amazon_login"><file name="button.phtml" hash="9df487c3e24de8978a382a2dfe0af924"/><file name="script.phtml" hash="d88a072633c10bc92aa43e2b23632ae1"/><file name="script_authorize.phtml" hash="b48b1dd8bd8c2f79e3656f16d522f388"/><file name="verify.phtml" hash="bdc80396ca2a7f096ac334f97b402a0a"/></dir><dir name="amazon_payments"><file name="button.phtml" hash="e799a97c3f971e10d4f6d6a0ca025d6a"/><file name="button_shortcut.phtml" hash="476fb3915c4a62fc6b913d6ac84639ce"/><file name="cart.phtml" hash="20375f05aabc98f1384f1d7bf74750fc"/><file name="checkout.phtml" hash="71e0e90136c6ea5e0bdb7be24432113b"/><dir name="onepage"><file name="button.phtml" hash="a30ed2b190c5a04c2a66a1bad8be6dcd"/><file name="login.phtml" hash="7147910e6940014ee96694150d3a0e99"/><file name="login_cancel.phtml" hash="ef82f978828a3f81bb9b6c525c5874e1"/><dir name="progress"><file name="widget.phtml" hash="cc26b9857c9f95f5a239e0adb94f6c3e"/></dir><file name="widget.phtml" hash="615c83e92e5a44dfa571fd580ba1e9bf"/></dir><file name="script.phtml" hash="d70b2bcfd1382011bca75e5459b4db70"/><file name="shipping_method.phtml" hash="b8ab8fcb1a91d7646e0f53d0997c231f"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="amazon_payments"><dir name="css"><file name="popup_alphacube.css" hash="bef655ef0df54d92bd06cec2b2c1a202"/><file name="styles_checkout.css" hash="f19ccf112b542569a719de1fe0add31e"/><file name="styles_onepage.css" hash="8c0889b17279ccfb2e7cbd018c3b554c"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Amazon_Login.xml" hash="d8a59c5f864353ed00225b56d4567e19"/><file name="Amazon_Payments.xml" hash="524c5cecde418e14ed6e44c16fd8bae6"/></dir></target></contents>
|
39 |
<compatible/>
|
40 |
<dependencies><required><php><min>5.2.1</min><max>6.0.0</max></php></required></dependencies>
|
41 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>login_and_pay_for_magento</name>
|
4 |
+
<version>1.1.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License, Version 2.0</license>
|
7 |
<channel>community</channel>
|
31 |
Keep your customers secure! Leverage the same user authentication system used on Amazon.com.</p>
|
32 |

|
33 |
</description>
|
34 |
+
<notes>-Updated payments admin screen to make it easier to configure.
|
35 |
+
-Fixed JQuery conflict on product detail button shortcut.
|
36 |
+
-Fixed compilation issue. (Issue #52)
|
37 |
+
-Added button styling options. (Issue #47)</notes>
|
38 |
<authors><author><name>Amazon Payments</name><user>payments-cp-devel</user><email>payments-cp-devel@amazon.com</email></author></authors>
|
39 |
+
<date>2014-09-25</date>
|
40 |
+
<time>02:42:29</time>
|
41 |
+
<contents><target name="magecommunity"><dir name="Amazon"><dir name="Login"><dir name="Block"><file name="Button.php" hash="6522fd3c81a5959c75979b8d17a62000"/><file name="Script.php" hash="40c4cca328e24521e3562f1466251c55"/><file name="Verify.php" hash="71ae4c427a3846f47ae3de927c54097a"/></dir><dir name="Helper"><file name="Data.php" hash="ae6797f0228b6cada765368d661d6bf6"/></dir><dir name="Model"><file name="Api.php" hash="48a3f6306d97f31fa4c3b954a665f334"/><file name="Customer.php" hash="7a019551c6efc3e073f838196c154f3f"/><file name="Login.php" hash="81a09b4f2c0c62e874ad209ef78ef462"/><dir name="Resource"><file name="Login.php" hash="cea5ac352d61cace9965f1cb940a7272"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Enabled.php" hash="94bc7fde24ab2ee54ed15bbe7084f118"/><file name="Popupcomment.php" hash="dfae81ef7bfa585feb33f8efa9f058c4"/></dir><dir name="Source"><file name="Buttoncolor.php" hash="ac335e432cd8e47c9ca4be601c706072"/><file name="Buttonsize.php" hash="76ef1db11834db449a7d52c34f3668d8"/><file name="Buttontype.php" hash="5e333d6cb1d70d0227766d78e390530b"/></dir></dir></dir></dir><dir name="controllers"><file name="CustomerController.php" hash="d326a02cb53c18bb78f988adb94a6478"/></dir><dir name="etc"><file name="adminhtml.xml" hash="0aa18eecfebd3e0bb1d84cd6b1040f50"/><file name="config.xml" hash="96acfda506615306cf0554bfd5dbbda2"/><file name="system.xml" hash="cc00b85cef386caf51e2cfa729183091"/></dir><dir name="sql"><dir name="login_setup"><file name="install-0.1.0.php" hash="690c4c33f4c5221185c0589e3add63b3"/></dir></dir></dir><dir name="Payments"><dir name="Block"><dir name="Adminhtml"><file name="Notifications.php" hash="16e9934aec3fadb1823e2d1a496cc7c9"/></dir><file name="Button.php" hash="b5e6ec0b061f8d904cede42b4a697a77"/><file name="Checkout.php" hash="532f647be6bd8ed047ae72d380461b7a"/><file name="Link.php" hash="47c237fe4604333b2080588c5498a865"/><dir name="Onepage"><file name="Widget.php" hash="f10bb86d3e7e5a88dfdfa4e645a61086"/></dir><file name="Onepage.php" hash="1d865069483bbe776f511119e0e2252b"/><dir name="Review"><file name="Info.php" hash="8d3688c55137971b18aec41272cf13a6"/></dir><file name="Review.php" hash="d9cf9b6ef7d6f063a06e006e01f09513"/></dir><dir name="Controller"><file name="Checkout.php" hash="4b8c6f1b52ac59b9611dbb9e4fec2d4f"/></dir><dir name="Helper"><file name="Data.php" hash="b8a91e228801ed8adbbffc003e6847f3"/></dir><dir name="Model"><file name="Api.php" hash="494525fc06fcedd12429ece085303c8e"/><file name="Config.php" hash="6adceda8e7a5afbc79ca37665b1c57ab"/><dir name="Observer"><file name="Onepage.php" hash="ec9f1b60d5d2206c98e56fb6669461a2"/></dir><file name="PaymentMethod.php" hash="8a37f70f03fedd6bc05407a37f157789"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Clientid.php" hash="4512003bcffedf26bc2fe415b91b1be7"/><file name="Clientsecret.php" hash="d2d5f275e4275676e3f494da704e41da"/><file name="Enabled.php" hash="e34c04693a65718675b2150810a6c6be"/></dir><dir name="Source"><file name="Buttoncolor.php" hash="2564780faa369e54339bded78a882636"/><file name="Buttonsize.php" hash="7f740927b5a58a3ea15d07ac4cfbed28"/><file name="Buttontype.php" hash="735083e4848fa2258b95670b1a546843"/><file name="Checkoutpage.php" hash="2969f9eaa9d87571e0fa8f005e2cdeaf"/><file name="Paymentaction.php" hash="4dba1ce3518538d1a5add743d65c8695"/><file name="Region.php" hash="0718cf97d03a8c56c73fb7ea3a103bc5"/></dir></dir></dir><dir name="Type"><file name="Checkout.php" hash="a99538049d00fe13bb9110f2bd92f3bc"/></dir></dir><dir name="controllers"><file name="CheckoutController.php" hash="6d005be14745219d5f7d28d4c6f51a4b"/><file name="IndexController.php" hash="128f218a9e1bf4af4f7b380f14d87a52"/><file name="OnepageController.php" hash="cc03d109ee1cf98f85aba606f5a44654"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3c56d63f30e0e5cc8c22d3686046631b"/><file name="config.xml" hash="835923b959b317a280373a62016c0ee8"/><file name="system.xml" hash="ca88691a1ae8a5b39ed08f1a0888b9d4"/></dir><dir name="sql"><dir name="payments_setup"><file name="install-0.1.0.php" hash="658f9d8c8634b3158cee7b59866e6f39"/></dir></dir></dir></dir></target><target name="magelib"><dir name="OffAmazonPayments"><file name="Model.php" hash="a608217f17166ba11901f5334ad445de"/><file name=".autoloader.php" hash="193fddab8b5ca74646bb78243c0c7dda"/></dir><dir name="OffAmazonPaymentsNotifications"><file name="Client.php" hash="0ab53a8a0a0c069f13e1de3731eaebde"/><dir name="Impl"><file name="IpnNotificationParser.php" hash="fcad418dc58a93e87b854e4067f1e24d"/><file name="Message.php" hash="2ab8cb01bd97ceaeaae0df2bf93ddbf5"/><file name="OpenSslVerifySignature.php" hash="427e2e171daab9ef454ca4ce939edd68"/><file name="SnsMessageParser.php" hash="6a1088096d27a3cdc586e4c298ddf068"/><file name="SnsMessageValidator.php" hash="076f63d5960e4c72a3dc63a76e75316c"/><file name="VerifySignature.php" hash="b18edb328fbe91c1c7b0aa8afe2904d0"/><file name="XmlNotificationParser.php" hash="4881b7d021a86215e43798497bceea24"/></dir><file name="Interface.php" hash="effe919508aab0c2aa1e585d2783c4e6"/><file name="InvalidMessageException.php" hash="2edda9cd6cc0c059846c4858cedfcd66"/><dir name="Model"><file name="AuthorizationDetails.php" hash="843711e02fb56fffcdfb6afcf097e373"/><file name="AuthorizationNotification.php" hash="b00c64bd48ae3bd3c3fa6d991e4b9f5c"/><file name="BillingAgreement.php" hash="677eadcbc4c91282eab548afc6482fdc"/><file name="BillingAgreementLimits.php" hash="a1bd8e8ec111f516528e09340c47de4a"/><file name="BillingAgreementNotification.php" hash="e39a3189bdc937b29b8488e0ef62b562"/><file name="BillingAgreementStatus.php" hash="fae14e95f03245fe6c53e7c7b725c5ca"/><file name="CaptureDetails.php" hash="adb45ebf66daa15990e032025a420e1b"/><file name="CaptureNotification.php" hash="14c2bdc8f6bd6ce881f4403d1f08c6ef"/><file name="IdList.php" hash="2907bdba4b5a534f535c026c40e6d6cc"/><file name="IpnNotificationMetadata.php" hash="58674fca7aa30eea82cb4cba17dec04e"/><file name="MerchantRegistrationDetails.php" hash="37ecb29de3d2d98fbe6f6c8c23f670a2"/><file name="NotificationImpl.php" hash="bfd2e22da29de6dfa15c82a19240132a"/><file name="NotificationMetadataImpl.php" hash="b297f69b967338d433ff90054e06da4b"/><file name="OrderItemCategories.php" hash="a0655ec5a9127ddbd51174ef9e046c5d"/><file name="OrderReference.php" hash="94b51567b72f62355d885e37e365a032"/><file name="OrderReferenceNotification.php" hash="8e6e3a67bf0ae55e86bd718ceca20e0e"/><file name="OrderReferenceStatus.php" hash="e29870a166b75c6d90955a08e0dfe048"/><file name="OrderTotal.php" hash="4141b92ed1bdeb9cfa4c13837df41221"/><file name="Price.php" hash="d94b947bb989fb974e076f2727a0dceb"/><file name="ProviderCreditDetails.php" hash="bf29c9938744effcd759cd95b8a7beab"/><file name="ProviderCreditNotification.php" hash="14b3d8a09ee0feb53cfb701e93e3180e"/><file name="ProviderCreditReversalDetails.php" hash="e9980476af6da3f09de6faff86220f85"/><file name="ProviderCreditReversalNotification.php" hash="bfff2d0e347b1f1dd9e96b0612c87b46"/><file name="ProviderCreditReversalSummary.php" hash="1e69dc1cde4ffac600f89487930cc38c"/><file name="ProviderCreditReversalSummaryList.php" hash="b4b7edc94d7dad37221ca1da5f0969f9"/><file name="ProviderCreditSummary.php" hash="946e787472dc1ee7c9dbcb5d29d62af2"/><file name="ProviderCreditSummaryList.php" hash="fad79864ec1797eed4412d9463c0d02c"/><file name="RefundDetails.php" hash="e0c9fd8c1a921097b4c7e6eb71c20f47"/><file name="RefundNotification.php" hash="28f003801abeb45e0978df05068d73da"/><file name="SellerBillingAgreementAttributes.php" hash="79572632ec2c776fb6a7e96554d7291a"/><file name="SellerOrderAttributes.php" hash="aa6f71cb667d2efb50cc336603b6029c"/><file name="SnsNotificationMetadata.php" hash="835ebe9f84b23e6d59e3f7e2101df531"/><file name="SolutionProviderMerchantNotification.php" hash="91b02852ed507b91e70907e5db488f6f"/><file name="SolutionProviderOption.php" hash="33eca51f6789687e5472cded23be5328"/><file name="SolutionProviderOptions.php" hash="806d915cdd1bd0be5c0e92a3040d49aa"/><file name="Status.php" hash="60765642cca51b523276421d995be784"/></dir><file name="Notification.php" hash="edaf311309c64b67a4fd82ccb86393a3"/><file name="NotificationMetadata.php" hash="9ffe2779593da053e82587dbb61da7d1"/></dir><dir name="OffAmazonPaymentsService"><file name="Client.php" hash="2b5807dda8510506c32adda6686f19e8"/><file name="Environments.php" hash="d84e7322b3394033b427f91be0a0abdb"/><file name="Exception.php" hash="dd85e54cfa5783c7ef7b1f93ca3995b2"/><file name="Interface.php" hash="ca1693109051f319740e4cd7e8ed4de7"/><file name="MerchantValues.php" hash="adb10859cd24d7ab62fecb3c0b67b90d"/><dir name="Model"><file name="Address.php" hash="3b3c00f4b50a4a6f42da15701343ce91"/><file name="AuthorizationDetails.php" hash="77aa03389903c2f777930d838d396da5"/><file name="AuthorizeOnBillingAgreementRequest.php" hash="fcb797660fa5c9cde02c4d482ec69f79"/><file name="AuthorizeOnBillingAgreementResponse.php" hash="c641d4e41db304d6f8f4136ea5d2f500"/><file name="AuthorizeOnBillingAgreementResult.php" hash="7b10d0dc68e7cbf18681abb4e600cca4"/><file name="AuthorizeRequest.php" hash="e7944fb6372becb0c3dd022bb30a9140"/><file name="AuthorizeResponse.php" hash="fb396a94285cacc3eb0fb798a0895466"/><file name="AuthorizeResult.php" hash="0c8f0581538ebba22a5dac5287c0fcc9"/><file name="BillingAddress.php" hash="bef3c0a443ba48ad19d832b91e8740b9"/><file name="BillingAgreementAttributes.php" hash="fe9c760e12c3db71125412ada5a65ec2"/><file name="BillingAgreementDetails.php" hash="0fef2badb342c32a01c44389bcfb52bc"/><file name="BillingAgreementLimits.php" hash="974d1252d7b914169203acdfa6e7082b"/><file name="BillingAgreementStatus.php" hash="002b0516c52264ea95847ea840d68545"/><file name="Buyer.php" hash="83759bcb729cdd8718cdb80182d9a237"/><file name="CancelOrderReferenceRequest.php" hash="86a2753aac94ae645fda1117cf90a926"/><file name="CancelOrderReferenceResponse.php" hash="4d6bc1d4818d81fd5b5820510b608275"/><file name="CancelOrderReferenceResult.php" hash="32013170a09bccf0aac178a7acb56a30"/><file name="CaptureDetails.php" hash="9ca070a0a890be4ec84d7a7264b33800"/><file name="CaptureRequest.php" hash="436da55de37deb4227a685167eb4eaa3"/><file name="CaptureResponse.php" hash="05540d55de14a3252f909fd17c8b62b6"/><file name="CaptureResult.php" hash="20e0bc168c13eb69848f09b520232eeb"/><file name="CloseAuthorizationRequest.php" hash="92d56fd8a0ae338213fdd4f8a5d1b5fc"/><file name="CloseAuthorizationResponse.php" hash="d5887ecf3981534842a9a2371ae063f0"/><file name="CloseAuthorizationResult.php" hash="0505c8c12f3b5252ad389c0c5b94ca8d"/><file name="CloseBillingAgreementRequest.php" hash="c845cdde3cde3242d4c40b1381e0ab2f"/><file name="CloseBillingAgreementResponse.php" hash="51530b8a5d14896488dbf82d6b5a37dc"/><file name="CloseBillingAgreementResult.php" hash="21cb77e2fa38defbc076263c71593168"/><file name="CloseOrderReferenceRequest.php" hash="85ae367281cb4d59f5d347be8bf0147d"/><file name="CloseOrderReferenceResponse.php" hash="d06107418145176a4038f2b0937fd9d7"/><file name="CloseOrderReferenceResult.php" hash="17bc6d72eb29b021fad7d8a222f366dc"/><file name="ConfirmBillingAgreementRequest.php" hash="965b88fe77576f07ce439bc4909e5723"/><file name="ConfirmBillingAgreementResponse.php" hash="989a66f5c217ad50a2a36afd00c763f1"/><file name="ConfirmBillingAgreementResult.php" hash="f0acdd5b7e2e1027bec651e6a6f4681d"/><file name="ConfirmOrderReferenceRequest.php" hash="8561edc4d074fd376e647bd0cdf9a686"/><file name="ConfirmOrderReferenceResponse.php" hash="b94a17b5afd4d923bda35d606c974982"/><file name="Constraint.php" hash="436ed3c926e321bcc9d9c6eaf9b4003a"/><file name="Constraints.php" hash="0063db27ee04067daf94c448f57d5c30"/><file name="CreateOrderReferenceForIdRequest.php" hash="b1c22ce6d83e510d0b9530c99b955711"/><file name="CreateOrderReferenceForIdResponse.php" hash="c811a7c44241a8b968bf4408218ac08f"/><file name="CreateOrderReferenceForIdResult.php" hash="f532299b151a1c4fe4264891737efeaf"/><file name="Destination.php" hash="4e6067e4a3b5f9acb3b9c96452b216fe"/><file name="Error.php" hash="56651e2c89e0214a3c4226903ca84d87"/><file name="ErrorResponse.php" hash="6df06e3cca71a1e73dbcde4bc6b30a3f"/><file name="GetAuthorizationDetailsRequest.php" hash="a0eb816954b6770a7fd8d54d0d75bc1a"/><file name="GetAuthorizationDetailsResponse.php" hash="82b879ccc0212f0752446b40d5338332"/><file name="GetAuthorizationDetailsResult.php" hash="a23e9463ce78b01cc51c45c21b065b6e"/><file name="GetBillingAgreementDetailsRequest.php" hash="91f33b1b1533cc4e98a019ce2c405850"/><file name="GetBillingAgreementDetailsResponse.php" hash="3abcae092618211ae5487f678a45c94f"/><file name="GetBillingAgreementDetailsResult.php" hash="37dc2407a2e9e8dd3e7feae1f690d160"/><file name="GetCaptureDetailsRequest.php" hash="48a9edebb0c7c8284241ac12b53e2d41"/><file name="GetCaptureDetailsResponse.php" hash="49cb6ae36cfba0aedef3c74c24256d53"/><file name="GetCaptureDetailsResult.php" hash="9110dbde9258a74d9933f8a50d10bd3b"/><file name="GetOrderReferenceDetailsRequest.php" hash="b1704b0e1e1f98778501792b82403c50"/><file name="GetOrderReferenceDetailsResponse.php" hash="3ea19407068d478f6c2b077bf8489a74"/><file name="GetOrderReferenceDetailsResult.php" hash="51bc2cd9a665edfb00cec970fc1fd328"/><file name="GetProviderCreditDetailsRequest.php" hash="2ff598dcc690c90b36727351f95bc76a"/><file name="GetProviderCreditDetailsResponse.php" hash="7ec3943a5c7fb0890d1304ccf52cb7d3"/><file name="GetProviderCreditDetailsResult.php" hash="a9033131b919f4f79b1000268892e64b"/><file name="GetProviderCreditReversalDetailsRequest.php" hash="5502cdd97afce7c42d177706cdcb7d0b"/><file name="GetProviderCreditReversalDetailsResponse.php" hash="19d4d9337646583f4a69776965a9f193"/><file name="GetProviderCreditReversalDetailsResult.php" hash="bb56c2f2ec45144234d7534352fe35c4"/><file name="GetRefundDetailsRequest.php" hash="c798b0b57c53e22d20e7e4a92d9eb225"/><file name="GetRefundDetailsResponse.php" hash="c1011e3b07e32792c4ac8ceabab3bc6b"/><file name="GetRefundDetailsResult.php" hash="463db01fb3a45adf9634116f3397f8a7"/><file name="IdList.php" hash="07daf191c601560ddfe50440f9006450"/><file name="OrderItemCategories.php" hash="2820e45ffb6cb36a14368a1dfe89fa84"/><file name="OrderReferenceAttributes.php" hash="990daffb0857fca0c05292ae2fb465cf"/><file name="OrderReferenceDetails.php" hash="2c75125691a884aa8bdc40318bce3b06"/><file name="OrderReferenceStatus.php" hash="04459e930111cf70c989196440f6400f"/><file name="OrderTotal.php" hash="6fda4ce95b066f960eebe41731717925"/><file name="ParentDetails.php" hash="1c6738a58079ffdaaef6e3d5e6afff01"/><file name="Price.php" hash="ea1d5a6e473542f5b0cb8ed1e70436bd"/><file name="ProviderCredit.php" hash="9834503bcc2f619b38157400984377e4"/><file name="ProviderCreditDetails.php" hash="a74f8e42aacd945989e6c5513d808fb3"/><file name="ProviderCreditList.php" hash="1c90c2d71fd33e9b059503b0b0815b53"/><file name="ProviderCreditReversal.php" hash="37aa96053d61a290d98d595d3c3c9226"/><file name="ProviderCreditReversalDetails.php" hash="7585eab585360dcabe7acb0e616f3afb"/><file name="ProviderCreditReversalList.php" hash="e30c2373f4a708443e7dde8f75e1d794"/><file name="ProviderCreditReversalSummary.php" hash="03b0b5aefae44ea5dcac06a4322e57cd"/><file name="ProviderCreditReversalSummaryList.php" hash="23a82515eb4d9f288dbc97691fef9153"/><file name="ProviderCreditSummary.php" hash="530091cb8d5e103ca3e44a0a3384eff2"/><file name="ProviderCreditSummaryList.php" hash="23115d04c6987208d7ba307781e433a5"/><file name="RefundDetails.php" hash="01866f818651ad6c0a7bc12d3c7e6644"/><file name="RefundRequest.php" hash="22b14eadcf9679a92c4325225dbf8c39"/><file name="RefundResponse.php" hash="b01d5c4c81a040bca2e1109e5d34b3e9"/><file name="RefundResult.php" hash="8f2478b1f27a295bff8f30664fd45235"/><file name="ResponseHeaderMetadata.php" hash="d8024e3bf444e8a843a6f2f6a2f836ca"/><file name="ResponseMetadata.php" hash="18e8035d5fc28d2919c1500b9f8734c5"/><file name="ReverseProviderCreditRequest.php" hash="d1b710b8911346ee0437de4e6178ac8e"/><file name="ReverseProviderCreditResponse.php" hash="38c6958d2ceb9ee244e86adee3c55acf"/><file name="ReverseProviderCreditResult.php" hash="313db1523bd575da7ab1fd956866a15d"/><file name="SellerBillingAgreementAttributes.php" hash="b4dc6401ae4340df3c484c00622d234f"/><file name="SellerOrderAttributes.php" hash="9ec79bc1be30eb322d7e88c4102a4ced"/><file name="SetBillingAgreementDetailsRequest.php" hash="9b47c3c72825fe661948aa36a2947da2"/><file name="SetBillingAgreementDetailsResponse.php" hash="7b6886f3597c434e585fb576d84fd9eb"/><file name="SetBillingAgreementDetailsResult.php" hash="d03a4c84cb96eb30f7ef5c76f981d086"/><file name="SetOrderReferenceDetailsRequest.php" hash="eed7e3485bc27f9f73cf7b67a893a1fa"/><file name="SetOrderReferenceDetailsResponse.php" hash="145bdfcfbf3bb091e0eada1361d6f581"/><file name="SetOrderReferenceDetailsResult.php" hash="246c06e0c62ee6a6ec0cfe504940c12d"/><file name="Status.php" hash="11c00f2cc32b11d4cfb8541d5ba2c279"/><file name="ValidateBillingAgreementRequest.php" hash="60250e9c62eaffa0a841bce7238ace22"/><file name="ValidateBillingAgreementResponse.php" hash="c77eebf5805b5972de84a814b3872cc7"/><file name="ValidateBillingAgreementResult.php" hash="95d4e8efc88317a097e376a4aa37a287"/></dir><file name="Model.php" hash="1147a05809ff0cc5f115bb213e38cf02"/><file name="OffAmazonPaymentsService.config.inc.php" hash="20807040ef4565a6b78f09cda6529a34"/><file name="RegionSpecificProperties.php" hash="b18f449745ebbbde5eae769eaf89ade1"/><file name="Regions.php" hash="a544d12c6321899770c039426e063cce"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="amazon_payments.xml" hash="86dc7900219559e892ffc0728e8bb136"/></dir><dir name="template"><dir name="amazon_payments"><file name="notifications.phtml" hash="b1d84206d51f9b35fb777ec439acf7d0"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="amazon_login.xml" hash="8a64187752279fe95b7d46052b032f08"/><file name="amazon_payments.xml" hash="8dff524dc78d11d68baf3987a664abcc"/></dir><dir name="template"><dir name="amazon_login"><file name="button.phtml" hash="f480e98b14c76a712f71a9f396dec198"/><file name="script.phtml" hash="d88a072633c10bc92aa43e2b23632ae1"/><file name="script_authorize.phtml" hash="b48b1dd8bd8c2f79e3656f16d522f388"/><file name="verify.phtml" hash="bdc80396ca2a7f096ac334f97b402a0a"/></dir><dir name="amazon_payments"><file name="button.phtml" hash="e799a97c3f971e10d4f6d6a0ca025d6a"/><file name="button_shortcut.phtml" hash="f4a276ab45930ffff4ddc408d47d0e32"/><file name="cart.phtml" hash="20375f05aabc98f1384f1d7bf74750fc"/><file name="checkout.phtml" hash="71e0e90136c6ea5e0bdb7be24432113b"/><dir name="onepage"><file name="button.phtml" hash="a30ed2b190c5a04c2a66a1bad8be6dcd"/><file name="login.phtml" hash="7147910e6940014ee96694150d3a0e99"/><file name="login_cancel.phtml" hash="ef82f978828a3f81bb9b6c525c5874e1"/><dir name="progress"><file name="widget.phtml" hash="cc26b9857c9f95f5a239e0adb94f6c3e"/></dir><file name="widget.phtml" hash="615c83e92e5a44dfa571fd580ba1e9bf"/></dir><file name="script.phtml" hash="d70b2bcfd1382011bca75e5459b4db70"/><file name="shipping_method.phtml" hash="b8ab8fcb1a91d7646e0f53d0997c231f"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="amazon_payments"><dir name="css"><file name="popup_alphacube.css" hash="bef655ef0df54d92bd06cec2b2c1a202"/><file name="styles_checkout.css" hash="f19ccf112b542569a719de1fe0add31e"/><file name="styles_onepage.css" hash="8c0889b17279ccfb2e7cbd018c3b554c"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Amazon_Login.xml" hash="d8a59c5f864353ed00225b56d4567e19"/><file name="Amazon_Payments.xml" hash="524c5cecde418e14ed6e44c16fd8bae6"/></dir></target></contents>
|
42 |
<compatible/>
|
43 |
<dependencies><required><php><min>5.2.1</min><max>6.0.0</max></php></required></dependencies>
|
44 |
</package>
|