login_and_pay_for_magento - Version 1.4.4

Version Notes

v1.4.4 Release
Enhancements
#294 Feature: Ability to add Coupon/Discount Code Field on Amazon Standalone Checkout
#61 Enable tokenized payments
#292 Change Widgets.js loading to async

Pull Requests Merged
#270 Update Modman

Issues Resolved
#281 ShipStation Phone Number Issue
#274 Problem using onestepcheckout
#287 Customer verify redirect to empty cart
#291 Fix check for enabled amazon login
#295 Amazon Payments Diagnostics tool throwing exception
#284 JQuery Conflict Render Unusable
#261 Script Loading Issue
#286 Logout Error
#293 JS failing to Serialize form during SaveOrder function call
#280 Double Redirect on Cart Page
#271 Add secure URL from config files
#264 Fix broken admin in Magento 1.6
#272 Add Disable Login with Amazon functionality
#255 Disable shipping widget during decline flow
#263 Limit shipping to supported countries

Download this release

Release Info

Developer Amazon Payments
Extension login_and_pay_for_magento
Version 1.4.4
Comparing to
See all releases


Code changes from version 1.4.0 to 1.4.4

Files changed (177) hide show
  1. app/code/community/Amazon/Diagnostics/controllers/Adminhtml/DiagnosticsController.php +9 -2
  2. app/code/community/Amazon/Diagnostics/etc/config.xml +11 -0
  3. app/code/community/Amazon/Payments/Block/Button.php +27 -1
  4. app/code/community/Amazon/Payments/Block/Checkout.php +24 -0
  5. app/code/community/Amazon/Payments/Block/Login/Button.php +19 -1
  6. app/code/community/Amazon/Payments/Block/Login/Script.php +22 -0
  7. app/code/community/Amazon/Payments/Block/Onepage.php +1 -0
  8. app/code/community/Amazon/Payments/Block/Onepage/Widget.php +17 -0
  9. app/code/community/Amazon/Payments/Block/Script.php +20 -0
  10. app/code/community/Amazon/Payments/Controller/Checkout.php +74 -41
  11. app/code/community/Amazon/Payments/Helper/Data.php +147 -1
  12. app/code/community/Amazon/Payments/Model/Api.php +149 -2
  13. app/code/community/Amazon/Payments/Model/Async.php +19 -4
  14. app/code/community/Amazon/Payments/Model/Config.php +71 -4
  15. app/code/community/Amazon/Payments/Model/Customer.php +8 -2
  16. app/code/community/Amazon/Payments/Model/Login.php +14 -2
  17. app/code/community/Amazon/Payments/Model/Observer/Action.php +24 -5
  18. app/code/community/Amazon/Payments/Model/PaymentMethod.php +226 -37
  19. app/code/community/Amazon/Payments/Model/Resource/Token.php +17 -0
  20. app/code/community/Amazon/Payments/Model/SimplePath.php +21 -8
  21. app/code/community/Amazon/Payments/Model/System/Config/Backend/Enabled.php +24 -60
  22. app/code/community/Amazon/Payments/Model/System/Config/Backend/Language.php +35 -0
  23. app/code/community/Amazon/Payments/Model/System/Config/Backend/Localizecomment.php +60 -0
  24. app/code/community/Amazon/Payments/Model/System/Config/Backend/Popupcomment.php +16 -4
  25. app/code/community/Amazon/Payments/Model/System/Config/Source/Region.php +3 -3
  26. app/code/community/Amazon/Payments/Model/Token.php +73 -0
  27. app/code/community/Amazon/Payments/Model/Type/Checkout.php +90 -0
  28. app/code/community/Amazon/Payments/controllers/CheckoutController.php +182 -5
  29. app/code/community/Amazon/Payments/controllers/CustomerController.php +2 -2
  30. app/code/community/Amazon/Payments/controllers/IndexController.php +0 -1
  31. app/code/community/Amazon/Payments/controllers/OnepageController.php +8 -0
  32. app/code/community/Amazon/Payments/controllers/OrderController.php +2 -2
  33. app/code/community/Amazon/Payments/controllers/TokenController.php +140 -0
  34. app/code/community/Amazon/Payments/etc/config.xml +46 -2
  35. app/code/community/Amazon/Payments/etc/system.xml +127 -34
  36. app/code/community/Amazon/Payments/etc/system.xml-1.6 +503 -0
  37. app/code/community/Amazon/Payments/sql/payments_setup/upgrade-1.3.0-1.4.0.php +2 -2
  38. app/code/community/Amazon/Payments/sql/payments_setup/upgrade-1.4.2-1.4.3.php +56 -0
  39. app/design/adminhtml/default/default/template/amazon_payments/notifications.phtml +2 -2
  40. app/design/frontend/base/default/layout/amazon_payments.xml +121 -45
  41. app/design/frontend/base/default/template/amazon_payments/button.phtml +36 -21
  42. app/design/frontend/base/default/template/amazon_payments/button_shortcut.phtml +101 -57
  43. app/design/frontend/base/default/template/amazon_payments/button_shortcut_ajaxcart.phtml +65 -0
  44. app/design/frontend/base/default/template/amazon_payments/checkout.phtml +247 -54
  45. app/design/frontend/base/default/template/amazon_payments/coupon.phtml +47 -0
  46. app/design/frontend/base/default/template/amazon_payments/login/button.phtml +30 -20
  47. app/design/frontend/base/default/template/amazon_payments/login/script.phtml +0 -116
  48. app/design/frontend/base/default/template/amazon_payments/login/script_logout.phtml +22 -0
  49. app/design/frontend/base/default/template/amazon_payments/onepage/button.phtml +31 -17
  50. app/design/frontend/base/default/template/amazon_payments/onepage/widget.phtml +152 -38
  51. app/design/frontend/base/default/template/amazon_payments/script.phtml +12 -11
  52. app/design/frontend/base/default/template/amazon_payments/script_async.phtml +16 -0
  53. app/locale/de_DE/Amazon_Diagnostics.csv +0 -0
  54. app/locale/de_DE/Amazon_Login.csv +9 -0
  55. app/locale/de_DE/Amazon_Payments.csv +69 -0
  56. app/locale/de_DE/template/email/amazon_payments_async_decline_hard.html +40 -0
  57. app/locale/de_DE/template/email/amazon_payments_async_decline_soft.html +40 -0
  58. app/locale/en_GB/Amazon_Diagnostics.csv +0 -0
  59. app/locale/en_GB/Amazon_Login.csv +9 -0
  60. app/locale/en_GB/Amazon_Payments.csv +69 -0
  61. app/locale/en_GB/template/email/amazon_payments_async_decline_soft.html +42 -0
  62. app/locale/en_US/Amazon_Diagnostics.csv +0 -0
  63. app/locale/en_US/Amazon_Login.csv +9 -0
  64. app/locale/en_US/Amazon_Payments.csv +69 -0
  65. app/locale/en_US/template/email/amazon_payments_async_decline_soft.html +4 -4
  66. app/locale/es_ES/Amazon_Diagnostics.csv +0 -0
  67. app/locale/es_ES/Amazon_Login.csv +9 -0
  68. app/locale/es_ES/Amazon_Payments.csv +69 -0
  69. app/locale/es_ES/template/email/amazon_payments_async_decline_hard.html +40 -0
  70. app/locale/es_ES/template/email/amazon_payments_async_decline_soft.html +42 -0
  71. app/locale/fr_FR/Amazon_Diagnostics.csv +0 -0
  72. app/locale/fr_FR/Amazon_Login.csv +9 -0
  73. app/locale/fr_FR/Amazon_Payments.csv +69 -0
  74. app/locale/fr_FR/template/email/amazon_payments_async_decline_hard.html +40 -0
  75. app/locale/fr_FR/template/email/amazon_payments_async_decline_soft.html +42 -0
  76. app/locale/it_IT/Amazon_Diagnostics.csv +0 -0
  77. app/locale/it_IT/Amazon_Login.csv +9 -0
  78. app/locale/it_IT/Amazon_Payments.csv +69 -0
  79. app/locale/it_IT/template/email/amazon_payments_async_decline_hard.html +40 -0
  80. app/locale/it_IT/template/email/amazon_payments_async_decline_soft.html +42 -0
  81. lib/MarketplaceWebServiceSellers/Client.php +36 -30
  82. lib/MarketplaceWebServiceSellers/KeycheckClient.php +36 -30
  83. lib/MarketplaceWebServiceSellers/Model/ResponseHeaderMetaData.php +2 -2
  84. lib/OffAmazonPayments/HttpRequest/HttpException.php +27 -0
  85. lib/OffAmazonPayments/HttpRequest/IHttpRequest.php +31 -0
  86. lib/OffAmazonPayments/HttpRequest/IHttpRequestFactory.php +41 -0
  87. lib/OffAmazonPayments/HttpRequest/Impl/HttpRequestCurlImpl.php +162 -0
  88. lib/OffAmazonPayments/HttpRequest/Impl/HttpRequestFactoryCurlImpl.php +166 -0
  89. lib/OffAmazonPayments/OffAmazonPaymentsServiceUtils.php +137 -0
  90. lib/OffAmazonPaymentsNotifications/Impl/Certificate.php +79 -0
  91. lib/OffAmazonPaymentsNotifications/InvalidCertificateException.php +27 -0
  92. lib/OffAmazonPaymentsNotifications/Samples/.config.inc.php +12 -0
  93. lib/OffAmazonPaymentsNotifications/Samples/AddressConsentSample.php +42 -0
  94. lib/OffAmazonPaymentsNotifications/Samples/AddressConsentSampleResult.php +133 -0
  95. lib/OffAmazonPaymentsNotifications/Samples/AuthorizationNotificationSample.php +176 -0
  96. lib/OffAmazonPaymentsNotifications/Samples/AutomaticPayments/address.php +88 -0
  97. lib/OffAmazonPaymentsNotifications/Samples/AutomaticPayments/signin.php +56 -0
  98. lib/OffAmazonPaymentsNotifications/Samples/AutomaticPayments/wallet.php +113 -0
  99. lib/OffAmazonPaymentsNotifications/Samples/AutomaticPaymentsSimpleCheckoutDataInput.php +44 -0
  100. lib/OffAmazonPaymentsNotifications/Samples/AutomaticPaymentsSimpleCheckoutResult.php +326 -0
  101. lib/OffAmazonPaymentsNotifications/Samples/BillingAgreementNotificationSample.php +168 -0
  102. lib/OffAmazonPaymentsNotifications/Samples/CancellationDataInput.php +42 -0
  103. lib/OffAmazonPaymentsNotifications/Samples/CancellationResult.php +188 -0
  104. lib/OffAmazonPaymentsNotifications/Samples/CaptureNotificationSample.php +173 -0
  105. lib/OffAmazonPaymentsNotifications/Samples/IpnHandler.php +132 -0
  106. lib/OffAmazonPaymentsNotifications/Samples/IpnLogFile.php +91 -0
  107. lib/OffAmazonPaymentsNotifications/Samples/NotificationSample.php +97 -0
  108. lib/OffAmazonPaymentsNotifications/Samples/OrderReferencePayments/address.php +87 -0
  109. lib/OffAmazonPaymentsNotifications/Samples/OrderReferencePayments/signin.php +53 -0
  110. lib/OffAmazonPaymentsNotifications/Samples/OrderReferencePayments/wallet.php +84 -0
  111. lib/OffAmazonPaymentsNotifications/Samples/OrderReferenceSample.php +143 -0
  112. lib/OffAmazonPaymentsNotifications/Samples/ProviderCheckoutDataInput.php +49 -0
  113. lib/OffAmazonPaymentsNotifications/Samples/ProviderCheckoutResult.php +344 -0
  114. lib/OffAmazonPaymentsNotifications/Samples/ProviderCreditNotificationSample.php +127 -0
  115. lib/OffAmazonPaymentsNotifications/Samples/ProviderCreditReversalNotificationSample.php +115 -0
  116. lib/OffAmazonPaymentsNotifications/Samples/ProviderRefundDataInput.php +38 -0
  117. lib/OffAmazonPaymentsNotifications/Samples/ProviderRefundResult.php +173 -0
  118. lib/OffAmazonPaymentsNotifications/Samples/RefundDataInput.php +36 -0
  119. lib/OffAmazonPaymentsNotifications/Samples/RefundNotificationSample.php +154 -0
  120. lib/OffAmazonPaymentsNotifications/Samples/RefundResult.php +161 -0
  121. lib/OffAmazonPaymentsNotifications/Samples/ReverseProviderCreditDataInput.php +34 -0
  122. lib/OffAmazonPaymentsNotifications/Samples/ReverseProviderCreditResult.php +80 -0
  123. lib/OffAmazonPaymentsNotifications/Samples/Samples.html +67 -0
  124. lib/OffAmazonPaymentsNotifications/Samples/SimpleCheckoutDataInput.php +46 -0
  125. lib/OffAmazonPaymentsNotifications/Samples/SimpleCheckoutResult.php +307 -0
  126. lib/OffAmazonPaymentsNotifications/Samples/SolutionProviderMerchantNotificationSample.php +89 -0
  127. lib/OffAmazonPaymentsNotifications/Samples/SplitShipmentsCheckoutDataInput_1.php +41 -0
  128. lib/OffAmazonPaymentsNotifications/Samples/SplitShipmentsCheckoutDataInput_2.php +49 -0
  129. lib/OffAmazonPaymentsNotifications/Samples/SplitShipmentsCheckoutResult.php +259 -0
  130. lib/OffAmazonPaymentsNotifications/Samples/WebServerExample.php +205 -0
  131. lib/OffAmazonPaymentsService/Client.php +6 -0
  132. lib/OffAmazonPaymentsService/MerchantValuesBuilder.php +122 -0
  133. lib/OffAmazonPaymentsService/Samples/.config.inc.php +13 -0
  134. lib/OffAmazonPaymentsService/Samples/AddressConsentSample.php +78 -0
  135. lib/OffAmazonPaymentsService/Samples/AuthorizeOnBillingAgreementSample.php +258 -0
  136. lib/OffAmazonPaymentsService/Samples/AuthorizeSample.php +271 -0
  137. lib/OffAmazonPaymentsService/Samples/AutomaticPaymentsSimpleCheckoutExample.php +366 -0
  138. lib/OffAmazonPaymentsService/Samples/AutomaticPaymentsSimpleCheckoutExampleCLI.php +319 -0
  139. lib/OffAmazonPaymentsService/Samples/CLIExample.php +76 -0
  140. lib/OffAmazonPaymentsService/Samples/CancelOrderReferenceSample.php +54 -0
  141. lib/OffAmazonPaymentsService/Samples/CancellationExample.php +263 -0
  142. lib/OffAmazonPaymentsService/Samples/CancellationExampleCLI.php +164 -0
  143. lib/OffAmazonPaymentsService/Samples/CaptureSample.php +162 -0
  144. lib/OffAmazonPaymentsService/Samples/CloseAuthorizationSample.php +54 -0
  145. lib/OffAmazonPaymentsService/Samples/CloseBillingAgreementSample.php +43 -0
  146. lib/OffAmazonPaymentsService/Samples/CloseOrderReferenceSample.php +54 -0
  147. lib/OffAmazonPaymentsService/Samples/ConfirmBillingAgreementSample.php +44 -0
  148. lib/OffAmazonPaymentsService/Samples/ConfirmOrderReferenceSample.php +54 -0
  149. lib/OffAmazonPaymentsService/Samples/CreateOrderReferenceForIdSample.php +333 -0
  150. lib/OffAmazonPaymentsService/Samples/GetAuthorizationDetailsSample.php +266 -0
  151. lib/OffAmazonPaymentsService/Samples/GetBillingAgreementDetailsSample.php +337 -0
  152. lib/OffAmazonPaymentsService/Samples/GetCaptureDetailsSample.php +203 -0
  153. lib/OffAmazonPaymentsService/Samples/GetOrderReferenceDetailsSample.php +368 -0
  154. lib/OffAmazonPaymentsService/Samples/GetProviderCreditDetailsSample.php +115 -0
  155. lib/OffAmazonPaymentsService/Samples/GetProviderCreditReversalDetailsSample.php +99 -0
  156. lib/OffAmazonPaymentsService/Samples/GetRefundDetailsSample.php +162 -0
  157. lib/OffAmazonPaymentsService/Samples/ProviderCheckoutExampleCLI.php +322 -0
  158. lib/OffAmazonPaymentsService/Samples/ProviderRefundExampleCLI.php +189 -0
  159. lib/OffAmazonPaymentsService/Samples/RefundExample.php +223 -0
  160. lib/OffAmazonPaymentsService/Samples/RefundExampleCLI.php +182 -0
  161. lib/OffAmazonPaymentsService/Samples/RefundSample.php +180 -0
  162. lib/OffAmazonPaymentsService/Samples/ReverseProviderCreditExample.php +71 -0
  163. lib/OffAmazonPaymentsService/Samples/ReverseProviderCreditExampleCLI.php +93 -0
  164. lib/OffAmazonPaymentsService/Samples/ReverseProviderCreditSample.php +98 -0
  165. lib/OffAmazonPaymentsService/Samples/SetBillingAgreementDetailsSample.php +337 -0
  166. lib/OffAmazonPaymentsService/Samples/SetOrderReferenceDetailsSample.php +347 -0
  167. lib/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php +318 -0
  168. lib/OffAmazonPaymentsService/Samples/SimpleCheckoutExampleCLI.php +288 -0
  169. lib/OffAmazonPaymentsService/Samples/SplitShipmentsCheckoutExample.php +331 -0
  170. lib/OffAmazonPaymentsService/Samples/SplitShipmentsCheckoutExampleCLI.php +252 -0
  171. lib/OffAmazonPaymentsService/Samples/Utils/CountryRate.php +43 -0
  172. lib/OffAmazonPaymentsService/Samples/Utils/ShippingAndTaxCostHelper.php +104 -0
  173. lib/OffAmazonPaymentsService/Samples/ValidateBillingAgreementSample.php +80 -0
  174. package.xml +28 -55
  175. skin/frontend/base/default/amazon_payments/css/popup_alphacube.css +6 -0
  176. skin/frontend/base/default/amazon_payments/css/styles_checkout.css +5 -0
  177. skin/frontend/base/default/amazon_payments/css/styles_onepage.css +10 -0
app/code/community/Amazon/Diagnostics/controllers/Adminhtml/DiagnosticsController.php CHANGED
@@ -62,8 +62,11 @@ class Amazon_Diagnostics_Adminhtml_DiagnosticsController extends Mage_Adminhtml_
62
 
63
  private function getPayments() {
64
 
 
 
 
65
  $this->log("\n===== PAYMENT SETTINGS =====");
66
- $payments_secret_key = Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/amazon_payments/access_secret'));
67
  if (strlen($payments_secret_key) > 6) {
68
  $payments_secret_key = substr($payments_secret_key, 0, 3) . "..." . substr($payments_secret_key, strlen($payments_secret_key - 3), 3);
69
  }
@@ -102,6 +105,8 @@ class Amazon_Diagnostics_Adminhtml_DiagnosticsController extends Mage_Adminhtml_
102
  $payments_payment_option = (Mage::getStoreConfig('payment/amazon_payments/use_in_checkout') == 1 ? 'yes' : 'no');
103
  $payments_async = (Mage::getStoreConfig('payment/amazon_payments/is_async') == 1 ? 'yes' : 'no');
104
  $payments_sandbox = (Mage::getStoreConfig('payment/amazon_payments/sandbox') == 1 ? 'yes' : 'no');
 
 
105
 
106
  $this->log("enabled: ". $enabled);
107
  $this->log("sandbox: ". $payments_sandbox);
@@ -114,6 +119,8 @@ class Amazon_Diagnostics_Adminhtml_DiagnosticsController extends Mage_Adminhtml_
114
  $this->log("secure_cart: ". $payments_secure_cart);
115
  $this->log("payment_option: ". $payments_payment_option);
116
  $this->log("async: ". $payments_async);
 
 
117
  }
118
 
119
  private function getLogin() {
@@ -193,7 +200,7 @@ class Amazon_Diagnostics_Adminhtml_DiagnosticsController extends Mage_Adminhtml_
193
  $mxml = json_decode($mxml, true);
194
 
195
  /* get version */
196
- $this->log(" version: ". $mxml['modules'][$k]['version']);
197
 
198
  /* get global blocks */
199
  $this->log(" [blocks]");
62
 
63
  private function getPayments() {
64
 
65
+
66
+ $_config = Mage::getSingleton('amazon_payments/config');
67
+
68
  $this->log("\n===== PAYMENT SETTINGS =====");
69
+ $payments_secret_key = Mage::getStoreConfig('payment/amazon_payments/access_secret');
70
  if (strlen($payments_secret_key) > 6) {
71
  $payments_secret_key = substr($payments_secret_key, 0, 3) . "..." . substr($payments_secret_key, strlen($payments_secret_key - 3), 3);
72
  }
105
  $payments_payment_option = (Mage::getStoreConfig('payment/amazon_payments/use_in_checkout') == 1 ? 'yes' : 'no');
106
  $payments_async = (Mage::getStoreConfig('payment/amazon_payments/is_async') == 1 ? 'yes' : 'no');
107
  $payments_sandbox = (Mage::getStoreConfig('payment/amazon_payments/sandbox') == 1 ? 'yes' : 'no');
108
+ $region = $_config->getRegion();
109
+ $locale = Mage::getStoreConfig('general/country/default');
110
 
111
  $this->log("enabled: ". $enabled);
112
  $this->log("sandbox: ". $payments_sandbox);
119
  $this->log("secure_cart: ". $payments_secure_cart);
120
  $this->log("payment_option: ". $payments_payment_option);
121
  $this->log("async: ". $payments_async);
122
+ $this->log("api region: ". $region);
123
+ $this->log("locale: ". $locale);
124
  }
125
 
126
  private function getLogin() {
200
  $mxml = json_decode($mxml, true);
201
 
202
  /* get version */
203
+ $this->log(" version: " . (isset($mxml['modules']) ? $mxml['modules'][$k]['version'] : 'unknown'));
204
 
205
  /* get global blocks */
206
  $this->log(" [blocks]");
app/code/community/Amazon/Diagnostics/etc/config.xml CHANGED
@@ -36,4 +36,15 @@
36
  </adminhtml>
37
  </routers>
38
  </admin>
 
 
 
 
 
 
 
 
 
 
 
39
  </config>
36
  </adminhtml>
37
  </routers>
38
  </admin>
39
+ <adminhtml>
40
+ <translate>
41
+ <modules>
42
+ <Amazon_Diagnostics>
43
+ <files>
44
+ <default>Amazon_Diagnostics.csv</default>
45
+ </files>
46
+ </Amazon_Diagnostics>
47
+ </modules>
48
+ </translate>
49
+ </adminhtml>
50
  </config>
app/code/community/Amazon/Payments/Block/Button.php CHANGED
@@ -81,6 +81,22 @@ class Amazon_Payments_Block_Button extends Mage_Core_Block_Template
81
  return Mage::getSingleton('amazon_payments/config')->getButtonColor();
82
  }
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  /**
85
  * Is Disabled?
86
  *
@@ -98,7 +114,7 @@ class Amazon_Payments_Block_Button extends Mage_Core_Block_Template
98
  */
99
  public function isAmazonLoginEnabled()
100
  {
101
- return $this->helper('amazon_payments')->isEnabled();
102
  }
103
 
104
  /**
@@ -155,4 +171,14 @@ class Amazon_Payments_Block_Button extends Mage_Core_Block_Template
155
  return ($this->helper('amazon_payments')->isPopup());
156
  }
157
 
 
 
 
 
 
 
 
 
 
 
158
  }
81
  return Mage::getSingleton('amazon_payments/config')->getButtonColor();
82
  }
83
 
84
+ /**
85
+ * Get language
86
+ */
87
+ public function getLanguage()
88
+ {
89
+ return Mage::helper('amazon_payments')->getLanguage();
90
+ }
91
+
92
+ /**
93
+ * Retrieve ajax cart popup modal URL
94
+ */
95
+ public function getAjaxCartModalUrl()
96
+ {
97
+ return $this->helper('amazon_payments')->getAjaxCartModalUrl();
98
+ }
99
+
100
  /**
101
  * Is Disabled?
102
  *
114
  */
115
  public function isAmazonLoginEnabled()
116
  {
117
+ return $this->helper('amazon_payments')->isLoginEnabled();
118
  }
119
 
120
  /**
171
  return ($this->helper('amazon_payments')->isPopup());
172
  }
173
 
174
+ /**
175
+ * Is tokenized payments enabled?
176
+ *
177
+ * @return bool
178
+ */
179
+ public function isTokenEnabled()
180
+ {
181
+ return Mage::getSingleton('amazon_payments/config')->isTokenEnabled();
182
+ }
183
+
184
  }
app/code/community/Amazon/Payments/Block/Checkout.php CHANGED
@@ -37,4 +37,28 @@ class Amazon_Payments_Block_Checkout extends Mage_Core_Block_Template
37
  return Mage::getSingleton('amazon_payments/config')->isDebugMode();
38
  }
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  }
37
  return Mage::getSingleton('amazon_payments/config')->isDebugMode();
38
  }
39
 
40
+ /**
41
+ * Is tokenized payments enabled?
42
+ */
43
+ public function isTokenEnabled()
44
+ {
45
+ return Mage::getSingleton('amazon_payments/config')->isTokenEnabled();
46
+ }
47
+
48
+ /**
49
+ * Is tokenized payments required?
50
+ */
51
+ public function isTokenRequired()
52
+ {
53
+ return $this->isTokenEnabled() && Mage::getSingleton('amazon_payments/config')->isTokenRequired();
54
+ }
55
+
56
+ /**
57
+ * Show coupon/discount code?
58
+ */
59
+ public function isShowCoupon()
60
+ {
61
+ return Mage::getSingleton('amazon_payments/config')->isShowCoupon();
62
+ }
63
+
64
  }
app/code/community/Amazon/Payments/Block/Login/Button.php CHANGED
@@ -54,6 +54,16 @@ class Amazon_Payments_Block_Login_Button extends Mage_Core_Block_Template
54
  return $this->helper('amazon_payments')->isEnabled();
55
  }
56
 
 
 
 
 
 
 
 
 
 
 
57
  /**
58
  * Is popup window?
59
  *
@@ -125,7 +135,15 @@ class Amazon_Payments_Block_Login_Button extends Mage_Core_Block_Template
125
  */
126
  public function getCheckoutUrl()
127
  {
128
- return $this->helper('amazon_payments')->getCheckoutUrl() . 'account/redirect';
 
 
 
 
 
 
 
 
129
  }
130
 
131
  }
54
  return $this->helper('amazon_payments')->isEnabled();
55
  }
56
 
57
+ /**
58
+ * Is Login with Amazon enabled?
59
+ *
60
+ * @return bool
61
+ */
62
+ public function isAmazonLoginEnabled()
63
+ {
64
+ return $this->helper('amazon_payments')->isLoginEnabled();
65
+ }
66
+
67
  /**
68
  * Is popup window?
69
  *
135
  */
136
  public function getCheckoutUrl()
137
  {
138
+ return $this->helper('amazon_payments')->getCheckoutUrl() . 'account/redirect?account_login=1';
139
+ }
140
+
141
+ /**
142
+ * Get language
143
+ */
144
+ public function getLanguage()
145
+ {
146
+ return Mage::helper('amazon_payments')->getLanguage();
147
  }
148
 
149
  }
app/code/community/Amazon/Payments/Block/Login/Script.php CHANGED
@@ -92,6 +92,28 @@ class Amazon_Payments_Block_Login_Script extends Mage_Core_Block_Template
92
  return $this->helper('amazon_payments')->getLoginAuthUrl();
93
  }
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  /**
96
  * Is Amazon Payments enabled?
97
  *
92
  return $this->helper('amazon_payments')->getLoginAuthUrl();
93
  }
94
 
95
+ /**
96
+ * Get region
97
+ */
98
+ public function getRegion()
99
+ {
100
+ switch ($this->helper('amazon_payments')->getRegion()) {
101
+ case 'uk':
102
+ case 'de':
103
+ return 'EU';
104
+ default:
105
+ return 'NA'; // North America
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Get language
111
+ */
112
+ public function getLanguage()
113
+ {
114
+ return Mage::getStoreConfig('payment/amazon_payments/language');
115
+ }
116
+
117
  /**
118
  * Is Amazon Payments enabled?
119
  *
app/code/community/Amazon/Payments/Block/Onepage.php CHANGED
@@ -57,4 +57,5 @@ class Amazon_Payments_Block_Onepage extends Mage_Checkout_Block_Onepage_Abstract
57
  {
58
  return array('login', 'widget', 'shipping_method', 'review');
59
  }
 
60
  }
57
  {
58
  return array('login', 'widget', 'shipping_method', 'review');
59
  }
60
+
61
  }
app/code/community/Amazon/Payments/Block/Onepage/Widget.php CHANGED
@@ -66,6 +66,23 @@ class Amazon_Payments_Block_Onepage_Widget extends Mage_Checkout_Block_Onepage_A
66
  {
67
  return (Mage::helper('core')->isModuleOutputEnabled('Mage_Newsletter') &&
68
  !Mage::getModel('newsletter/subscriber')->loadByCustomer(Mage::getSingleton('customer/session')->getCustomer())->isSubscribed());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  }
70
 
71
  }
66
  {
67
  return (Mage::helper('core')->isModuleOutputEnabled('Mage_Newsletter') &&
68
  !Mage::getModel('newsletter/subscriber')->loadByCustomer(Mage::getSingleton('customer/session')->getCustomer())->isSubscribed());
69
+
70
+ }
71
+
72
+ /**
73
+ * Is tokenized payments enabled?
74
+ */
75
+ public function isTokenEnabled()
76
+ {
77
+ return Mage::getSingleton('amazon_payments/config')->isTokenEnabled();
78
+ }
79
+
80
+ /**
81
+ * Is tokenized payments required?
82
+ */
83
+ public function isTokenRequired()
84
+ {
85
+ return $this->isTokenEnabled() && Mage::getSingleton('amazon_payments/config')->isTokenRequired();
86
  }
87
 
88
  }
app/code/community/Amazon/Payments/Block/Script.php CHANGED
@@ -88,5 +88,25 @@ class Amazon_Payments_Block_Script extends Mage_Core_Block_Template
88
  return Mage::helper('amazon_payments/data')->isPopup();
89
  }
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
  }
88
  return Mage::helper('amazon_payments/data')->isPopup();
89
  }
90
 
91
+ /**
92
+ * Is enabled?
93
+ */
94
+ public function isEnabled()
95
+ {
96
+ return Mage::helper('amazon_payments/data')->isEnabled();
97
+ }
98
+
99
+ /**
100
+ * Is loaded?
101
+ */
102
+ public function isLoaded()
103
+ {
104
+ if ($this->getIsLoaded()) {
105
+ return true;
106
+ }
107
+ $this->setIsLoaded(true);
108
+ return false;
109
+ }
110
+
111
 
112
  }
app/code/community/Amazon/Payments/Controller/Checkout.php CHANGED
@@ -10,7 +10,7 @@
10
 
11
  abstract class Amazon_Payments_Controller_Checkout extends Mage_Checkout_Controller_Action
12
  {
13
- protected $_amazonOrderReferenceId;
14
  protected $_checkoutUrl;
15
 
16
  /**
@@ -21,6 +21,22 @@ abstract class Amazon_Payments_Controller_Checkout extends Mage_Checkout_Control
21
  return $this->_amazonOrderReferenceId;
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  /**
25
  * Check query string paramters for order reference and/or access token
26
  */
@@ -28,6 +44,12 @@ abstract class Amazon_Payments_Controller_Checkout extends Mage_Checkout_Control
28
  {
29
  parent::preDispatch();
30
 
 
 
 
 
 
 
31
  $this->_amazonOrderReferenceId = htmlentities($this->getRequest()->getParam('amazon_order_reference_id'));
32
 
33
  if (!$this->_amazonOrderReferenceId) {
@@ -37,6 +59,9 @@ abstract class Amazon_Payments_Controller_Checkout extends Mage_Checkout_Control
37
  Mage::getSingleton('checkout/session')->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
38
  }
39
 
 
 
 
40
  // User is logging in...
41
 
42
  $token = htmlentities($this->getRequest()->getParam('access_token'));
@@ -45,8 +70,8 @@ abstract class Amazon_Payments_Controller_Checkout extends Mage_Checkout_Control
45
  $_amazonLogin = Mage::getModel('amazon_payments/customer');
46
 
47
  if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
48
- if (!$this->_getConfig()->isGuestCheckout() || !$this->_getOnepage()->getQuote()->isAllowedGuestCheckout()) {
49
- $customer = $_amazonLogin->loginWithToken($token, $this->_checkoutUrl);
50
  }
51
  // Guest
52
  else {
@@ -68,13 +93,29 @@ abstract class Amazon_Payments_Controller_Checkout extends Mage_Checkout_Control
68
  else if (Mage::app()->getRequest()->getParams('account') == 'redirect') {
69
  $this->_redirect('customer/account');
70
  }
71
- // Redirect to clean URL
72
  else if (!$this->getRequest()->getParam('ajax')) {
 
 
 
 
 
 
 
 
 
 
 
 
73
  $this->_redirect($this->_checkoutUrl, array('_secure' => true));
74
  return;
75
  }
76
 
77
 
 
 
 
 
78
  }
79
 
80
  }
@@ -101,6 +142,14 @@ abstract class Amazon_Payments_Controller_Checkout extends Mage_Checkout_Control
101
  }
102
  }
103
 
 
 
 
 
 
 
 
 
104
  /**
105
  * Validate ajax request and redirect on failure
106
  *
@@ -200,63 +249,48 @@ abstract class Amazon_Payments_Controller_Checkout extends Mage_Checkout_Control
200
  */
201
  protected function _saveShipping()
202
  {
203
- if ($this->getAmazonOrderReferenceId()) {
204
 
205
- $orderReferenceDetails = $this->_getApi()->getOrderReferenceDetails($this->getAmazonOrderReferenceId(), Mage::getSingleton('checkout/session')->getAmazonAccessToken());
 
 
 
 
 
206
 
207
  $address = $orderReferenceDetails->getDestination()->getPhysicalDestination();
208
 
209
  // Split name into first/last
210
- $name = $address->getName();
211
- $firstName = substr($name, 0, strrpos($name, ' '));
212
- $lastName = substr($name, strlen($firstName) + 1);
213
 
214
  // Find Mage state/region ID
215
  $regionModel = Mage::getModel('directory/region')->loadByCode($address->getStateOrRegion(), $address->getCountryCode());
216
  $regionId = $regionModel->getId();
217
 
218
- $data = array(
219
- 'firstname' => $firstName,
220
- 'lastname' => $lastName,
221
- 'street' => array($address->getAddressLine1(), $address->getAddressLine2()),
222
- 'city' => $address->getCity(),
223
- 'region' => $address->getStateOrRegion(),
224
- 'region_id' => $regionId,
225
- 'postcode' => $address->getPostalCode(),
226
- 'country_id' => $address->getCountryCode(),
227
- 'telephone' => ($address->getPhone()) ? $address->getPhone() : '-', // Mage requires phone number
228
- 'use_for_shipping' => true,
229
- );
230
 
231
  if ($email = Mage::getSingleton('checkout/session')->getCustomerEmail()) {
232
  $data['email'] = $email;
233
  }
234
 
235
-
236
  // Set billing address (if allowed by scope)
237
  if ($orderReferenceDetails->getBillingAddress()) {
238
  $billing = $orderReferenceDetails->getBillingAddress()->getPhysicalAddress();
239
- //$data['use_for_shipping'] = false;
240
-
241
- $name = $billing->getName();
242
- $firstName = substr($name, 0, strrpos($name, ' '));
243
- $lastName = substr($name, strlen($firstName) + 1);
244
 
245
  $regionModel = Mage::getModel('directory/region')->loadByCode($billing->getStateOrRegion(), $billing->getCountryCode());
246
  $regionId = $regionModel->getId();
247
-
248
- $dataBilling = array(
249
- 'firstname' => $firstName,
250
- 'lastname' => $lastName,
251
- 'street' => array($billing->getAddressLine1(), $billing->getAddressLine2()),
252
- 'city' => $billing->getCity(),
253
- 'region' => $billing->getStateOrRegion(),
254
- 'region_id' => $regionId,
255
- 'postcode' => $billing->getPostalCode(),
256
- 'country_id' => $billing->getCountryCode(),
257
- 'telephone' => ($billing->getPhone()) ? $billing->getPhone() : '-',
258
- 'use_for_shipping' => false,
259
- );
260
 
261
  $this->_getCheckout()->saveBilling($dataBilling, null);
262
 
@@ -268,6 +302,5 @@ abstract class Amazon_Payments_Controller_Checkout extends Mage_Checkout_Control
268
  return $this->_getCheckout()->saveShipping($data);
269
  }
270
  }
271
-
272
  }
273
 
10
 
11
  abstract class Amazon_Payments_Controller_Checkout extends Mage_Checkout_Controller_Action
12
  {
13
+ protected $_amazonOrderReferenceId, $_amazonBillingAgreementId, $_amazonBillingAgreementConsent;
14
  protected $_checkoutUrl;
15
 
16
  /**
21
  return $this->_amazonOrderReferenceId;
22
  }
23
 
24
+ /**
25
+ * Return Amazon Billing Agreement Id
26
+ */
27
+ public function getAmazonBillingAgreementId()
28
+ {
29
+ return $this->_amazonBillingAgreementId;
30
+ }
31
+
32
+ /**
33
+ * Return Amazon Billing Agreement Consent
34
+ */
35
+ public function getAmazonBillingAgreementConsent()
36
+ {
37
+ return $this->_amazonBillingAgreementConsent;
38
+ }
39
+
40
  /**
41
  * Check query string paramters for order reference and/or access token
42
  */
44
  {
45
  parent::preDispatch();
46
 
47
+ // User clicked "Cancel" on Amazon Login consent form
48
+ if ($this->getRequest()->getParam('error') == 'access_denied') {
49
+ $this->_redirect('checkout/cart');
50
+ return;
51
+ }
52
+
53
  $this->_amazonOrderReferenceId = htmlentities($this->getRequest()->getParam('amazon_order_reference_id'));
54
 
55
  if (!$this->_amazonOrderReferenceId) {
59
  Mage::getSingleton('checkout/session')->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
60
  }
61
 
62
+ $this->_amazonBillingAgreementId = htmlentities($this->getRequest()->getParam('amazon_billing_agreement_id'));
63
+ $this->_amazonBillingAgreementConsent = $this->getRequest()->getParam('amazon_billing_agreement_consent') == 'true' ? true : false;
64
+
65
  // User is logging in...
66
 
67
  $token = htmlentities($this->getRequest()->getParam('access_token'));
70
  $_amazonLogin = Mage::getModel('amazon_payments/customer');
71
 
72
  if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
73
+ if ($this->_getConfig()->isLoginEnabled() || !$this->_getOnepage()->getQuote()->isAllowedGuestCheckout()) {
74
+ $customer = $_amazonLogin->loginWithToken($token, $this->getRequest()->getParam('account_login') ? 'customer/account' : $this->_checkoutUrl);
75
  }
76
  // Guest
77
  else {
93
  else if (Mage::app()->getRequest()->getParams('account') == 'redirect') {
94
  $this->_redirect('customer/account');
95
  }
96
+ // User signed-in via popup
97
  else if (!$this->getRequest()->getParam('ajax')) {
98
+ $state = $this->getRequest()->getParam('state');
99
+ // Shortcut clicked (e.g. from product page)
100
+ if ($state == 'shortcut' && $this->_getConfig()->isTokenEnabled()) {
101
+ // Does user have billing agreement token?
102
+ $token = Mage::getModel('amazon_payments/token')->getBillingAgreement();
103
+ if ($amazonBillingAgreementId = $token->getAmazonBillingAgreementId()) {
104
+ $this->_redirect('amazon_payments/token/checkout');
105
+ return;
106
+ }
107
+ }
108
+
109
+ // Redirect to clean URL
110
  $this->_redirect($this->_checkoutUrl, array('_secure' => true));
111
  return;
112
  }
113
 
114
 
115
+
116
+
117
+
118
+
119
  }
120
 
121
  }
142
  }
143
  }
144
 
145
+ /**
146
+ * Check if country is allowed by config
147
+ */
148
+ public function isCountryAllowed($country)
149
+ {
150
+ return in_array(strtoupper($country), explode(',', Mage::getStoreConfig('general/country/allow')));
151
+ }
152
+
153
  /**
154
  * Validate ajax request and redirect on failure
155
  *
249
  */
250
  protected function _saveShipping()
251
  {
252
+ if ($this->getAmazonOrderReferenceId() || $this->getAmazonBillingAgreementId()) {
253
 
254
+ if ($this->getAmazonBillingAgreementId()) {
255
+ $orderReferenceDetails = $this->_getApi()->getBillingAgreementDetails($this->getAmazonBillingAgreementId(), Mage::getSingleton('checkout/session')->getAmazonAccessToken());
256
+ }
257
+ else {
258
+ $orderReferenceDetails = $this->_getApi()->getOrderReferenceDetails($this->getAmazonOrderReferenceId(), Mage::getSingleton('checkout/session')->getAmazonAccessToken());
259
+ }
260
 
261
  $address = $orderReferenceDetails->getDestination()->getPhysicalDestination();
262
 
263
  // Split name into first/last
 
 
 
264
 
265
  // Find Mage state/region ID
266
  $regionModel = Mage::getModel('directory/region')->loadByCode($address->getStateOrRegion(), $address->getCountryCode());
267
  $regionId = $regionModel->getId();
268
 
269
+ // Load region ID by name
270
+ if (!$regionId) {
271
+ $regionModel = Mage::getModel('directory/region')->loadByName($address->getStateOrRegion(), $address->getCountryCode());
272
+ $regionId = $regionModel->getId();
273
+ }
274
+
275
+ $data = Mage::helper('amazon_payments')->transformAmazonAddressToMagentoAddress($address);
276
+ $data['use_for_shipping'] = true;
277
+ $data['region'] = $address->getStateOrRegion();
278
+ $data['region_id'] = $regionId;
 
 
279
 
280
  if ($email = Mage::getSingleton('checkout/session')->getCustomerEmail()) {
281
  $data['email'] = $email;
282
  }
283
 
 
284
  // Set billing address (if allowed by scope)
285
  if ($orderReferenceDetails->getBillingAddress()) {
286
  $billing = $orderReferenceDetails->getBillingAddress()->getPhysicalAddress();
 
 
 
 
 
287
 
288
  $regionModel = Mage::getModel('directory/region')->loadByCode($billing->getStateOrRegion(), $billing->getCountryCode());
289
  $regionId = $regionModel->getId();
290
+ $dataBilling = Mage::helper('amazon_payments')->transformAmazonAddressToMagentoAddress($billing);
291
+ $dataBilling['use_for_shipping'] = false;
292
+ $dataBilling['region'] = $billing->getStateOrRegion();
293
+ $dataBilling['region_id'] = $regionId;
 
 
 
 
 
 
 
 
 
294
 
295
  $this->_getCheckout()->saveBilling($dataBilling, null);
296
 
302
  return $this->_getCheckout()->saveShipping($data);
303
  }
304
  }
 
305
  }
306
 
app/code/community/Amazon/Payments/Helper/Data.php CHANGED
@@ -102,6 +102,16 @@ class Amazon_Payments_Helper_Data extends Mage_Core_Helper_Abstract
102
  return Mage::getUrl('checkout/cart?amazon_modal=1', array('_secure'=>true));
103
  }
104
 
 
 
 
 
 
 
 
 
 
 
105
  /**
106
  * Does product attribute allow purchase with Amazon payments?
107
  */
@@ -174,6 +184,14 @@ class Amazon_Payments_Helper_Data extends Mage_Core_Helper_Abstract
174
  return $this->getConfig()->isEnabled();
175
  }
176
 
 
 
 
 
 
 
 
 
177
  /**
178
  * Show modal?
179
  */
@@ -239,6 +257,69 @@ class Amazon_Payments_Helper_Data extends Mage_Core_Helper_Abstract
239
  return (Mage::getStoreConfig('amazon_login/settings/popup'));
240
  }
241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  /**
243
  * Get config by website or store admin scope
244
  */
@@ -255,4 +336,69 @@ class Amazon_Payments_Helper_Data extends Mage_Core_Helper_Abstract
255
  }
256
  }
257
 
258
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  return Mage::getUrl('checkout/cart?amazon_modal=1', array('_secure'=>true));
103
  }
104
 
105
+ /**
106
+ * Retrieve ajax cart popup modal URL
107
+ *
108
+ * @return string
109
+ */
110
+ public function getAjaxCartModalUrl()
111
+ {
112
+ return Mage::getUrl('amazon_payments/token/ajaxcart', array('_secure'=>true));
113
+ }
114
+
115
  /**
116
  * Does product attribute allow purchase with Amazon payments?
117
  */
184
  return $this->getConfig()->isEnabled();
185
  }
186
 
187
+ /**
188
+ * Is Login with Amazon enabled?
189
+ */
190
+ public function isLoginEnabled()
191
+ {
192
+ return $this->getConfig()->isLoginEnabled();
193
+ }
194
+
195
  /**
196
  * Show modal?
197
  */
257
  return (Mage::getStoreConfig('amazon_login/settings/popup'));
258
  }
259
 
260
+ /**
261
+ * Return API region
262
+ */
263
+ public function getRegion()
264
+ {
265
+ $region = $this->getConfig()->getRegion();
266
+ return ($region) ? $region : 'us';
267
+ }
268
+
269
+ /**
270
+ * Return language for Amazon frontend
271
+ */
272
+ public function getLanguage()
273
+ {
274
+
275
+ if ($language = $this->getConfig()->getLanguage()) {
276
+ return $language;
277
+ }
278
+
279
+ $code = Mage::getStoreConfig('general/locale/code');
280
+
281
+ if ($code == 'en_GB') {
282
+ return 'en-GB';
283
+ }
284
+
285
+ switch (substr($code, 0, 2)) {
286
+ case 'de': return 'de-DE'; break;
287
+ case 'fr': return 'fr-FR'; break;
288
+ case 'it': return 'it-IT'; break;
289
+ case 'es': return 'es-ES'; break;
290
+ default: return false;
291
+ }
292
+ }
293
+
294
+ /**
295
+ * Get admin region for localizing URLs to Amazon
296
+ */
297
+ public function getAdminRegion()
298
+ {
299
+ $config = $this->getConfig();
300
+
301
+ if (in_array($this->getAdminConfig($config::CONFIG_XML_PATH_REGION), array('uk', 'de'))) {
302
+ return 'eu';
303
+ }
304
+
305
+ $countryCode = $this->getAdminConfig('general/country/default');
306
+
307
+ // Is EU country?
308
+ $euCountries = explode(',', Mage::getStoreConfig('general/country/eu_countries'));
309
+ if (in_array($countryCode, $euCountries)) {
310
+ return 'eu';
311
+ }
312
+ }
313
+
314
+ /**
315
+ * Is admin set to DE?
316
+ */
317
+ public function isAdminGermany()
318
+ {
319
+ $config = $this->getConfig();
320
+ return $this->getAdminConfig($config::CONFIG_XML_PATH_REGION) == 'de' || substr($this->getAdminConfig('general/country/default'), 0, 2) == 'DE';
321
+ }
322
+
323
  /**
324
  * Get config by website or store admin scope
325
  */
336
  }
337
  }
338
 
339
+ /**
340
+ * Transform an Amazon address into a standard Magento address
341
+ *
342
+ * @param OffAmazonPaymentsService_Model_Address amazonAddress
343
+ */
344
+ public function transformAmazonAddressToMagentoAddress($amazonAddress) {
345
+ $name = $amazonAddress->getName();
346
+ $firstName = substr($name, 0, strrpos($name, ' '));
347
+ $lastName = substr($name, strlen($firstName) + 1);
348
+
349
+ $data['firstname'] = $firstName;
350
+ $data['lastname'] = $lastName;
351
+ $data['country_id'] = $amazonAddress->getCountryCode();
352
+ $data['city'] = $amazonAddress->getCity();
353
+ $data['postcode'] = $amazonAddress->getPostalCode();
354
+ $data['telephone'] = $amazonAddress->getPhone() ? $amazonAddress->getPhone() : $this->__('000-000-0000');
355
+
356
+ $data['street'] = array();
357
+
358
+ $countryCode = $amazonAddress->getCountryCode();
359
+ $addressLine1 = $amazonAddress->getAddressLine1();
360
+ $addressLine2 = $amazonAddress->getAddressLine2();
361
+ $addressLine3 = $amazonAddress->getAddressLine3();
362
+ if($countryCode && in_array($countryCode, array('AT', 'DE'))){
363
+ if ($addressLine3) {
364
+ $data['company'] = trim($addressLine1.' '.$addressLine2);
365
+ $data['street'][] = $addressLine3;
366
+ } else if ($addressLine2) {
367
+ $data['company'] = $addressLine1;
368
+ $data['street'][] = $addressLine2;
369
+ } else {
370
+ $data['street'][] = $addressLine1;
371
+ }
372
+ } else {
373
+ if ($addressLine1) {
374
+ $data['street'][] = $addressLine1;
375
+ }
376
+ if ($addressLine2) {
377
+ $data['street'][] = $addressLine2;
378
+ }
379
+ if ($addressLine3) {
380
+ $data['street'][] = $addressLine3;
381
+ }
382
+ }
383
+ return $data;
384
+ }
385
+
386
+ /**
387
+ * Get admin/default store id
388
+ */
389
+ public function getAdminStoreId()
390
+ {
391
+ if ($code = Mage::getSingleton('adminhtml/config_data')->getStore()) {
392
+ return Mage::getModel('core/store')->load($code)->getId();
393
+ }
394
+ elseif ($code = Mage::getSingleton('adminhtml/config_data')->getWebsite()) {
395
+ $website_id = Mage::getModel('core/website')->load($code)->getId();
396
+ return Mage::app()->getWebsite($website_id)->getDefaultStore()->getId();
397
+ }
398
+ else
399
+ {
400
+ return Mage::app()->getDefaultStoreView()->getId();
401
+ }
402
+ }
403
+
404
+ }
app/code/community/Amazon/Payments/Model/Api.php CHANGED
@@ -224,7 +224,7 @@ class Amazon_Payments_Model_Api extends Varien_Object
224
  *
225
  * @param string $amazonOrderReferenceId
226
  * @param string $addressConsentToken
227
- * @return OffAmazonPaymentsService_Model_GetOrderReferenceDetailsResponse
228
  * @link http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetOrderReferenceDetails.html
229
  */
230
  public function getOrderReferenceDetails($amazonOrderReferenceId, $addressConsentToken = null)
@@ -234,6 +234,10 @@ class Amazon_Payments_Model_Api extends Varien_Object
234
  'AddressConsentToken' => $addressConsentToken,
235
  );
236
 
 
 
 
 
237
  $response = $this->request('getOrderReferenceDetails', $request);
238
 
239
  if ($response && $response->isSetGetOrderReferenceDetailsResult()) {
@@ -279,7 +283,7 @@ class Amazon_Payments_Model_Api extends Varien_Object
279
  * @param string $orderCurrency
280
  * @param string $orderId
281
  * @param string $storeName
282
- * @return OffAmazonPaymentsService_Model_SetOrderReferenceDetailsResponse
283
  * @link http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_SetOrderReferenceDetails.html
284
  */
285
  public function setOrderReferenceDetails($orderReferenceId, $orderAmount, $orderCurrency, $orderId = '', $storeName = '')
@@ -398,5 +402,148 @@ class Amazon_Payments_Model_Api extends Varien_Object
398
  return $response;
399
  }
400
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
401
  }
402
 
224
  *
225
  * @param string $amazonOrderReferenceId
226
  * @param string $addressConsentToken
227
+ * @return OrderReferenceDetails
228
  * @link http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetOrderReferenceDetails.html
229
  */
230
  public function getOrderReferenceDetails($amazonOrderReferenceId, $addressConsentToken = null)
234
  'AddressConsentToken' => $addressConsentToken,
235
  );
236
 
237
+ if (!$amazonOrderReferenceId && $this->_isLoggingEnabled()) {
238
+ Mage::log('GetOrderReferenceDetails Error: No Order Reference ID', null, $this->logFile);
239
+ }
240
+
241
  $response = $this->request('getOrderReferenceDetails', $request);
242
 
243
  if ($response && $response->isSetGetOrderReferenceDetailsResult()) {
283
  * @param string $orderCurrency
284
  * @param string $orderId
285
  * @param string $storeName
286
+ * @return OrderReferenceDetails
287
  * @link http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_SetOrderReferenceDetails.html
288
  */
289
  public function setOrderReferenceDetails($orderReferenceId, $orderAmount, $orderCurrency, $orderId = '', $storeName = '')
402
  return $response;
403
  }
404
 
405
+ /**
406
+ * GetBillingAgreementDetails
407
+ *
408
+ * @param string $amazonBillingAgreementId
409
+ * @param string $addressConsentToken
410
+ * @return OffAmazonPaymentsService_Model_GetBillingAgreementDetails
411
+ * @link http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetBillingAgreementDetails.html
412
+ */
413
+ public function getBillingAgreementDetails($amazonBillingAgreementId, $addressConsentToken = null)
414
+ {
415
+ $request = array(
416
+ 'AmazonBillingAgreementId' => $amazonBillingAgreementId,
417
+ 'AddressConsentToken' => $addressConsentToken,
418
+ );
419
+
420
+ $response = $this->request('getBillingAgreementDetails', $request);
421
+
422
+ if ($response && $response->isSetGetBillingAgreementDetailsResult()) {
423
+ $result = $response->getGetBillingAgreementDetailsResult();
424
+ if ($result->isSetBillingAgreementDetails()) {
425
+ return $result->getBillingAgreementDetails();
426
+ }
427
+ }
428
+
429
+ return $response;
430
+ }
431
+
432
+ /**
433
+ * ConfirmBillingAgreement
434
+ *
435
+ * @param string $amazonBillingAgreementId
436
+ * @return OffAmazonPaymentsService_Model_ConfirmBillingAgreementResponse
437
+ * @link http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ConfirmOrderReference.html
438
+ */
439
+ public function confirmBillingAgreement($amazonBillingAgreementId)
440
+ {
441
+ $request = array(
442
+ 'AmazonBillingAgreementId' => $amazonBillingAgreementId,
443
+ );
444
+
445
+ return $this->request('confirmBillingAgreement', $request);
446
+ }
447
+
448
+ /**
449
+ * AuthorizeOnBillingAgreement
450
+ *
451
+ * @param string $amazonBillingAgreementId
452
+ * @return OffAmazonPaymentsService_Model_AuthorizeOnBillingAgreementResult
453
+ * @link http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_AuthorizeOnBillingAgreement.html
454
+ */
455
+ public function authorizeOnBillingAgreement($amazonBillingAgreementId, $authorizationReferenceId, $authorizationAmount, $authorizationCurrency, $captureNow = false, $softDescriptor = null, $sellerAuthorizationNote = null, $forceSync = false)
456
+ {
457
+ $request = array(
458
+ 'AmazonBillingAgreementId' => $amazonBillingAgreementId,
459
+ 'AuthorizationReferenceId' => $authorizationReferenceId,
460
+ 'AuthorizationAmount' => array(
461
+ 'Amount' => $authorizationAmount,
462
+ 'CurrencyCode' => $authorizationCurrency
463
+ ),
464
+ 'CaptureNow' => $captureNow,
465
+ );
466
+
467
+ if (!$this->getConfig()->isAsync() || $forceSync) {
468
+ $request['TransactionTimeout'] = 0; // Synchronous Mode
469
+ }
470
+
471
+ if ($softDescriptor) {
472
+ $request['SoftDescriptor'] = $softDescriptor;
473
+ }
474
+
475
+ if ($sellerAuthorizationNote) {
476
+ $request['SellerAuthorizationNote'] = trim($sellerAuthorizationNote);
477
+ }
478
+
479
+ $response = $this->request('authorizeOnBillingAgreement', $request);
480
+
481
+ if ($response && $response->isSetAuthorizeOnBillingAgreementResult()) {
482
+ return $response->getAuthorizeOnBillingAgreementResult();
483
+ }
484
+
485
+ return $response;
486
+ }
487
+
488
+ /**
489
+ * CreateOrderReferenceForId
490
+ *
491
+ * @param string $id
492
+ * @param string $idType
493
+ * @param bool $inheritShippingAddress
494
+ * @param bool $confirmNow
495
+ * @param OrderReferenceAttributes $orderReferenceAttributes
496
+ * @return OffAmazonPaymentsService_Model_CreateOrderReferenceForIdResult
497
+ * @link http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CreateOrderReferenceForId.html
498
+ */
499
+ public function createOrderReferenceForId($id, $idType, $inheritShippingAddress = true, $confirmNow = false, array $orderReferenceAttributes = null)
500
+ {
501
+ $request = array(
502
+ 'Id' => $id,
503
+ 'IdType' => $idType,
504
+ 'InheritShippingAddress' => $inheritShippingAddress,
505
+ 'ConfirmNow' => $confirmNow,
506
+ );
507
+
508
+ if ($orderReferenceAttributes) {
509
+ $request['OrderReferenceAttributes'] = $orderReferenceAttributes;
510
+ }
511
+
512
+ $response = $this->request('createOrderReferenceForId', $request);
513
+
514
+ if ($response && $response->isSetCreateOrderReferenceForIdResult()) {
515
+ $result = $response->getCreateOrderReferenceForIdResult();
516
+ if ($result->isSetOrderReferenceDetails()) {
517
+ return $result->getOrderReferenceDetails();
518
+ }
519
+ }
520
+
521
+ return $response;
522
+ }
523
+
524
+ /**
525
+ * CloseBillingAgreement
526
+ *
527
+ * @param string $amazonBillingAgreementId
528
+ * @param string $closureReason
529
+ * @return OffAmazonPaymentsService_Model_CloseBillingAgreementResult
530
+ * @link http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseBillingAgreement.html
531
+ */
532
+ public function closeBillingAgreement($amazonBillingAgreementId, $closureReason = null)
533
+ {
534
+ $request = array(
535
+ 'AmazonBillingAgreementId' => $amazonBillingAgreementId,
536
+ 'ClosureReason' => $closureReason,
537
+ );
538
+
539
+ $response = $this->request('closeBillingAgreement', $request);
540
+
541
+ if ($response && $response->isSetCloseBillingAgreementResult()) {
542
+ return $response->getCloseBillingAgreement();
543
+ }
544
+
545
+ return $response;
546
+ }
547
+
548
  }
549
 
app/code/community/Amazon/Payments/Model/Async.php CHANGED
@@ -81,9 +81,24 @@ class Amazon_Payments_Model_Async extends Mage_Core_Model_Abstract
81
  $message = '';
82
 
83
  try {
84
-
 
 
85
  $amazonOrderReference = $order->getPayment()->getAdditionalInformation('order_reference');
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  $orderReferenceDetails = $_api->getOrderReferenceDetails($amazonOrderReference);
88
 
89
  if ($orderReferenceDetails) {
@@ -127,12 +142,12 @@ class Amazon_Payments_Model_Async extends Mage_Core_Model_Abstract
127
  return;
128
  }
129
 
130
- $message = Mage::helper('payment')->__('Sync with Amazon: Authorization state is %s.', $amazonAuthorizationState);
131
 
132
  switch ($amazonAuthorizationState) {
133
  // Pending (All Authorization objects are in the Pending state for 30 seconds after Authorize request)
134
  case Amazon_Payments_Model_Api::AUTH_STATUS_PENDING:
135
- $message .= ' (Payment is currently authorizing. Please try again momentarily.)';
136
  break;
137
 
138
  // Declined
@@ -171,7 +186,7 @@ class Amazon_Payments_Model_Async extends Mage_Core_Model_Abstract
171
  else {
172
  $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true);
173
 
174
- $message .= ' Unable to create invoice due to Authorization Reason Code: ' . $reasonCode;
175
  }
176
 
177
  break;
81
  $message = '';
82
 
83
  try {
84
+ $payment = $order->getPayment();
85
+ $method = $payment->getMethodInstance(); // Amazon_Payments_Model_PaymentMethod
86
+ $amount = $payment->getAmountOrdered();
87
  $amazonOrderReference = $order->getPayment()->getAdditionalInformation('order_reference');
88
 
89
+ // Pre-orders
90
+ if ($method->_isPreorder($payment)) {
91
+ // Authorize pre-order on manual sync
92
+ if ($isManualSync) {
93
+ $method->authorize($payment, $amount);
94
+ $amazonOrderReference = $payment->getAdditionalInformation('order_reference');
95
+ }
96
+ // Ignore pre-order if cron
97
+ else {
98
+ return;
99
+ }
100
+ }
101
+
102
  $orderReferenceDetails = $_api->getOrderReferenceDetails($amazonOrderReference);
103
 
104
  if ($orderReferenceDetails) {
142
  return;
143
  }
144
 
145
+ $message = Mage::helper('payment')->__('Sync with Amazon: Authorization state is "%s".', $amazonAuthorizationState);
146
 
147
  switch ($amazonAuthorizationState) {
148
  // Pending (All Authorization objects are in the Pending state for 30 seconds after Authorize request)
149
  case Amazon_Payments_Model_Api::AUTH_STATUS_PENDING:
150
+ $message .= Mage::helper('payment')->__(' (Payment is currently authorizing. Please try again momentarily.)');
151
  break;
152
 
153
  // Declined
186
  else {
187
  $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true);
188
 
189
+ $message .= Mage::helper('payment')->__(' Unable to create invoice due to Authorization Reason Code: %s', $reasonCode);
190
  }
191
 
192
  break;
app/code/community/Amazon/Payments/Model/Config.php CHANGED
@@ -20,7 +20,6 @@ class Amazon_Payments_Model_Config
20
  const CONFIG_XML_PATH_SELLER_ID = 'payment/amazon_payments/seller_id';
21
  const CONFIG_XML_PATH_ACCESS_KEY = 'payment/amazon_payments/access_key';
22
  const CONFIG_XML_PATH_ACCESS_SECRET = 'payment/amazon_payments/access_secret';
23
- const CONFIG_XML_PATH_REGION = 'payment/amazon_payments/region';
24
  const CONFIG_XML_PATH_SANDBOX = 'payment/amazon_payments/sandbox';
25
  const CONFIG_XML_PATH_DEBUG = 'payment/amazon_payments/debug';
26
  const CONFIG_XML_PATH_CHECKOUT_PAGE = 'payment/amazon_payments/checkout_page';
@@ -28,15 +27,23 @@ class Amazon_Payments_Model_Config
28
  const CONFIG_XML_PATH_ORDER_STATUS = 'payment/amazon_payments/order_status';
29
  const CONFIG_XML_PATH_SHOW_PAY_CART = 'payment/amazon_payments/show_pay_cart';
30
  const CONFIG_XML_PATH_STORE_NAME = 'payment/amazon_payments/store_name';
 
31
  const CONFIG_XML_PATH_SECURE_CART = 'payment/amazon_payments/secure_cart';
32
  const CONFIG_XML_PATH_IS_ASYNC = 'payment/amazon_payments/is_async';
 
 
33
  const CONFIG_XML_PATH_RESTRICTED_IPS = 'payment/amazon_payments/restricted_ips';
 
34
 
35
  const CONFIG_XML_PATH_BUTTON_TYPE = 'payment/amazon_payments/button_type';
36
  const CONFIG_XML_PATH_BUTTON_COLOR = 'payment/amazon_payments/button_color';
37
  const CONFIG_XML_PATH_BUTTON_SIZE = 'payment/amazon_payments/button_size';
38
  const CONFIG_XML_PATH_BUTTON_BADGE = 'payment/amazon_payments/button_badge';
39
 
 
 
 
 
40
  /**
41
  * Retrieve config value for store by path
42
  *
@@ -79,14 +86,14 @@ class Amazon_Payments_Model_Config
79
  }
80
 
81
  /**
82
- * Is guest checkout/pay only? (does not create customer account)
83
  *
84
  * @param store $store
85
  * @return bool
86
  */
87
- public function isGuestCheckout($store = null)
88
  {
89
- return false;
90
  }
91
 
92
  /**
@@ -100,6 +107,28 @@ class Amazon_Payments_Model_Config
100
  return (bool) $this->_getStoreConfig(self::CONFIG_XML_PATH_DEBUG, $store);
101
  }
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  /**
104
  * Get client ID
105
  *
@@ -170,6 +199,17 @@ class Amazon_Payments_Model_Config
170
  return $region;
171
  }
172
 
 
 
 
 
 
 
 
 
 
 
 
173
  /**
174
  * Get Checkout Page type
175
  *
@@ -220,6 +260,22 @@ class Amazon_Payments_Model_Config
220
  }
221
  }
222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  /**
224
  * Is Checkout using OnePage?
225
  *
@@ -319,4 +375,15 @@ class Amazon_Payments_Model_Config
319
  return ($this->_getStoreConfig(self::CONFIG_XML_PATH_BUTTON_BADGE, $store));
320
  }
321
 
 
 
 
 
 
 
 
 
 
 
 
322
  }
20
  const CONFIG_XML_PATH_SELLER_ID = 'payment/amazon_payments/seller_id';
21
  const CONFIG_XML_PATH_ACCESS_KEY = 'payment/amazon_payments/access_key';
22
  const CONFIG_XML_PATH_ACCESS_SECRET = 'payment/amazon_payments/access_secret';
 
23
  const CONFIG_XML_PATH_SANDBOX = 'payment/amazon_payments/sandbox';
24
  const CONFIG_XML_PATH_DEBUG = 'payment/amazon_payments/debug';
25
  const CONFIG_XML_PATH_CHECKOUT_PAGE = 'payment/amazon_payments/checkout_page';
27
  const CONFIG_XML_PATH_ORDER_STATUS = 'payment/amazon_payments/order_status';
28
  const CONFIG_XML_PATH_SHOW_PAY_CART = 'payment/amazon_payments/show_pay_cart';
29
  const CONFIG_XML_PATH_STORE_NAME = 'payment/amazon_payments/store_name';
30
+ const CONFIG_XML_PATH_SOFT_DESC = 'payment/amazon_payments/soft_descriptor';
31
  const CONFIG_XML_PATH_SECURE_CART = 'payment/amazon_payments/secure_cart';
32
  const CONFIG_XML_PATH_IS_ASYNC = 'payment/amazon_payments/is_async';
33
+ const CONFIG_XML_PATH_TOKEN_ENABLED = 'payment/amazon_payments/token_enabled';
34
+ const CONFIG_XML_PATH_TOKEN_REQUIRED = 'payment/amazon_payments/token_required';
35
  const CONFIG_XML_PATH_RESTRICTED_IPS = 'payment/amazon_payments/restricted_ips';
36
+ const CONFIG_XML_PATH_SHOW_COUPON = 'payment/amazon_payments/show_coupon';
37
 
38
  const CONFIG_XML_PATH_BUTTON_TYPE = 'payment/amazon_payments/button_type';
39
  const CONFIG_XML_PATH_BUTTON_COLOR = 'payment/amazon_payments/button_color';
40
  const CONFIG_XML_PATH_BUTTON_SIZE = 'payment/amazon_payments/button_size';
41
  const CONFIG_XML_PATH_BUTTON_BADGE = 'payment/amazon_payments/button_badge';
42
 
43
+ const CONFIG_XML_PATH_REGION = 'amazon_login/settings/region';
44
+ const CONFIG_XML_PATH_LANGUAGE = 'amazon_login/settings/language';
45
+ const CONFIG_XML_PATH_LOGIN_ENABLED = 'amazon_login/settings/enabled';
46
+
47
  /**
48
  * Retrieve config value for store by path
49
  *
86
  }
87
 
88
  /**
89
+ * Is Login with Amazon enabled?
90
  *
91
  * @param store $store
92
  * @return bool
93
  */
94
+ public function isLoginEnabled($store = null)
95
  {
96
+ return (bool) $this->_getStoreConfig(self::CONFIG_XML_PATH_LOGIN_ENABLED, $store);
97
  }
98
 
99
  /**
107
  return (bool) $this->_getStoreConfig(self::CONFIG_XML_PATH_DEBUG, $store);
108
  }
109
 
110
+ /**
111
+ * Is tokenized payments enabled?
112
+ *
113
+ * @param store $store
114
+ * @return bool
115
+ */
116
+ public function isTokenEnabled($store = null)
117
+ {
118
+ return (bool) $this->_getStoreConfig(self::CONFIG_XML_PATH_TOKEN_ENABLED, $store);
119
+ }
120
+
121
+ /**
122
+ * Is tokenized payments required?
123
+ *
124
+ * @param store $store
125
+ * @return bool
126
+ */
127
+ public function isTokenRequired($store = null)
128
+ {
129
+ return (bool) $this->_getStoreConfig(self::CONFIG_XML_PATH_TOKEN_REQUIRED, $store);
130
+ }
131
+
132
  /**
133
  * Get client ID
134
  *
199
  return $region;
200
  }
201
 
202
+ /**
203
+ * Get language UI
204
+ *
205
+ * @param store $store
206
+ * @return string
207
+ */
208
+ public function getLanguage($store = null)
209
+ {
210
+ return trim($this->_getStoreConfig(self::CONFIG_XML_PATH_LANGUAGE, $store));
211
+ }
212
+
213
  /**
214
  * Get Checkout Page type
215
  *
260
  }
261
  }
262
 
263
+ /**
264
+ * Get customzied soft descriptor, if used
265
+ *
266
+ * @param store $store
267
+ * @return string
268
+ */
269
+ public function getSoftDesc($store = null)
270
+ {
271
+ $softDesc = $this->_getStoreConfig(self::CONFIG_XML_PATH_SOFT_DESC, $store);
272
+ if (!$softDesc) {
273
+ $softDesc = Mage::app()->getStore()->getName();
274
+ }
275
+
276
+ return substr($softDesc, 0, 16); // 16 chars max
277
+ }
278
+
279
  /**
280
  * Is Checkout using OnePage?
281
  *
375
  return ($this->_getStoreConfig(self::CONFIG_XML_PATH_BUTTON_BADGE, $store));
376
  }
377
 
378
+ /**
379
+ * Show coupon/discount code?
380
+ *
381
+ * @param store $store
382
+ * @return bool
383
+ */
384
+ public function isShowCoupon($store = null)
385
+ {
386
+ return ($this->_getStoreConfig(self::CONFIG_XML_PATH_SHOW_COUPON, $store));
387
+ }
388
+
389
  }
app/code/community/Amazon/Payments/Model/Customer.php CHANGED
@@ -33,10 +33,11 @@ class Amazon_Payments_Model_Customer extends Mage_Customer_Model_Customer
33
  $this->setWebsiteId(Mage::app()->getWebsite()->getId())->loadByEmail($amazonProfile['email']);
34
  }
35
 
 
 
36
  // If Magento customer account exists and there is no association, then the Magento account
37
  // must be verified, as Amazon does not verify email addresses.
38
  if (!$row->getLoginId() && $this->getId()) {
39
- Mage::getSingleton('customer/session')->setAmazonProfile($amazonProfile);
40
  Mage::getSingleton('checkout/session')->setAmazonAccessTokenVerify($token);
41
 
42
  Mage::app()->getResponse()
@@ -46,7 +47,7 @@ class Amazon_Payments_Model_Customer extends Mage_Customer_Model_Customer
46
  exit;
47
 
48
  }
49
- // Log user in
50
  else {
51
  // Create account
52
  if (!$this->getId()) {
@@ -113,6 +114,11 @@ class Amazon_Payments_Model_Customer extends Mage_Customer_Model_Customer
113
  ->save()
114
  ->sendNewAccountEmail('registered', '', Mage::app()->getStore()->getId());
115
 
 
 
 
 
 
116
  $this->createAssociation($amazonProfile, $this->getId());
117
 
118
  }
33
  $this->setWebsiteId(Mage::app()->getWebsite()->getId())->loadByEmail($amazonProfile['email']);
34
  }
35
 
36
+ Mage::getSingleton('customer/session')->setAmazonProfile($amazonProfile);
37
+
38
  // If Magento customer account exists and there is no association, then the Magento account
39
  // must be verified, as Amazon does not verify email addresses.
40
  if (!$row->getLoginId() && $this->getId()) {
 
41
  Mage::getSingleton('checkout/session')->setAmazonAccessTokenVerify($token);
42
 
43
  Mage::app()->getResponse()
47
  exit;
48
 
49
  }
50
+ // Create account if applicable and log user in
51
  else {
52
  // Create account
53
  if (!$this->getId()) {
114
  ->save()
115
  ->sendNewAccountEmail('registered', '', Mage::app()->getStore()->getId());
116
 
117
+ // If email confirmation required, must resave customer
118
+ if ($this->isConfirmationRequired()) {
119
+ $this->setConfirmation(null)->save();
120
+ }
121
+
122
  $this->createAssociation($amazonProfile, $this->getId());
123
 
124
  }
app/code/community/Amazon/Payments/Model/Login.php CHANGED
@@ -36,8 +36,20 @@ class Amazon_Payments_Model_Login extends Mage_Core_Model_Abstract
36
 
37
  $sandbox = $config->isSandbox() ? 'sandbox.' : '';
38
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  $client = new Zend_Http_Client();
40
- $client->setUri("https://api.{$sandbox}amazon.com/$path");
41
  $client->setConfig($this->http_client_config);
42
  $client->setMethod($postParams ? 'POST' : 'GET');
43
 
@@ -68,4 +80,4 @@ class Amazon_Payments_Model_Login extends Mage_Core_Model_Abstract
68
  return $data;
69
  }
70
  }
71
- }
36
 
37
  $sandbox = $config->isSandbox() ? 'sandbox.' : '';
38
 
39
+ switch (Mage::helper('amazon_payments')->getRegion()) {
40
+ case 'uk':
41
+ $tld = 'co.uk';
42
+ break;
43
+ case 'de':
44
+ $tld = 'de';
45
+ break;
46
+ default:
47
+ $tld = 'com';
48
+ break;
49
+ }
50
+
51
  $client = new Zend_Http_Client();
52
+ $client->setUri("https://api.{$sandbox}amazon.$tld/$path");
53
  $client->setConfig($this->http_client_config);
54
  $client->setMethod($postParams ? 'POST' : 'GET');
55
 
80
  return $data;
81
  }
82
  }
83
+ }
app/code/community/Amazon/Payments/Model/Observer/Action.php CHANGED
@@ -10,6 +10,16 @@
10
 
11
  class Amazon_Payments_Model_Observer_Action
12
  {
 
 
 
 
 
 
 
 
 
 
13
  /**
14
  * Event: controller_action_predispatch_checkout_cart_index
15
  *
@@ -17,11 +27,7 @@ class Amazon_Payments_Model_Observer_Action
17
  */
18
  public function secureCart(Varien_Event_Observer $observer)
19
  {
20
- if (Mage::getSingleton('amazon_payments/config')->isEnabled()
21
- && Mage::getSingleton('amazon_payments/config')->isSecureCart()
22
- && !Mage::app()->getStore()->isCurrentlySecure()
23
- && strpos(Mage::getStoreConfig('web/secure/base_url'), 'https') !== false
24
- ) {
25
  $redirectUrl = Mage::getUrl('checkout/cart/', array('_forced_secure' => true));
26
  Mage::app()->getResponse()
27
  ->setRedirect($redirectUrl)
@@ -29,4 +35,17 @@ class Amazon_Payments_Model_Observer_Action
29
  exit;
30
  }
31
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
10
 
11
  class Amazon_Payments_Model_Observer_Action
12
  {
13
+ /**
14
+ * Redirect to secure cart? (required for Amazon button)
15
+ */
16
+ private function _shouldRedirectCart()
17
+ {
18
+ return (Mage::getSingleton('amazon_payments/config')->isEnabled()
19
+ && Mage::getSingleton('amazon_payments/config')->isSecureCart()
20
+ && strpos(Mage::getStoreConfig('web/secure/base_url'), 'https') !== false);
21
+ }
22
+
23
  /**
24
  * Event: controller_action_predispatch_checkout_cart_index
25
  *
27
  */
28
  public function secureCart(Varien_Event_Observer $observer)
29
  {
30
+ if ($this->_shouldRedirectCart() && !Mage::app()->getStore()->isCurrentlySecure()) {
 
 
 
 
31
  $redirectUrl = Mage::getUrl('checkout/cart/', array('_forced_secure' => true));
32
  Mage::app()->getResponse()
33
  ->setRedirect($redirectUrl)
35
  exit;
36
  }
37
  }
38
+
39
+ /**
40
+ * Event: controller_response_redirect
41
+ *
42
+ * Redirect to HTTPS cart page
43
+ */
44
+ public function responseRedirect(Varien_Event_Observer $observer)
45
+ {
46
+ $event = $observer->getEvent();
47
+ if ($this->_shouldRedirectCart() && $event->getTransport() && $event->getTransport()->getUrl() == Mage::getUrl('checkout/cart/')) {
48
+ $observer->getEvent()->getTransport()->setUrl(Mage::getUrl('checkout/cart/', array('_forced_secure' => true)));
49
+ }
50
+ }
51
  }
app/code/community/Amazon/Payments/Model/PaymentMethod.php CHANGED
@@ -56,7 +56,7 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
56
  */
57
  protected function _getSoftDescriptor()
58
  {
59
- return substr($this->_getApi()->getConfig()->getStoreName(), 0, 16); // 16 chars max
60
  }
61
 
62
  /**
@@ -75,6 +75,39 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
75
  return Mage::getSingleton('checkout/session')->getAmazonErrorCheck();
76
  }
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  /**
79
  * Instantiate state and set it to state object
80
  *
@@ -105,6 +138,20 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
105
  $stateObject->setIsNotified(Mage_Sales_Model_Order_Status_History::CUSTOMER_NOTIFICATION_NOT_APPLICABLE);
106
  }
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  /**
110
  * Authorize, with option to Capture
@@ -112,6 +159,7 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
112
  protected function _authorize(Varien_Object $payment, $amount, $captureNow = false)
113
  {
114
  $order = $payment->getOrder();
 
115
 
116
  $sellerAuthorizationNote = null;
117
 
@@ -128,25 +176,48 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
128
  // For core and third-party checkouts, may test credit card decline by uncommenting:
129
  //$sellerAuthorizationNote = '{"SandboxSimulation": {"State":"Declined", "ReasonCode":"InvalidPaymentMethod", "PaymentMethodUpdateTimeInMins":5}}';
130
 
131
- $result = $this->_getApi($order->getStoreId())->authorize(
132
- $payment->getTransactionId(),
133
- $this->_getMagentoReferenceId($payment) . '-auth',
134
- $amount,
135
- $order->getBaseCurrencyCode(),
136
- $captureNow,
137
- ($captureNow) ? $this->_getSoftDescriptor() : null,
138
- $sellerAuthorizationNote,
139
- $this->isForceSync
140
- );
 
 
 
 
141
 
142
- $status = $result->getAuthorizationStatus();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
 
144
  switch ($status->getState()) {
145
  case Amazon_Payments_Model_Api::AUTH_STATUS_PENDING:
146
  case Amazon_Payments_Model_Api::AUTH_STATUS_OPEN:
147
  case Amazon_Payments_Model_Api::AUTH_STATUS_CLOSED:
148
 
149
- $payment->setTransactionId($result->getAmazonAuthorizationId());
150
  $payment->setParentTransactionId($payment->getAdditionalInformation('order_reference'));
151
  $payment->setIsTransactionClosed(false);
152
 
@@ -156,7 +227,7 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
156
  if ($this->isForceSync) { // Not async
157
  $transactionSave = Mage::getModel('core/resource_transaction');
158
 
159
- $captureReferenceIds = $result->getIdList()->getmember();
160
 
161
  if ($order->canInvoice()) {
162
  // Create invoice
@@ -184,6 +255,10 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
184
 
185
  $payment->addTransaction($transactionType, null, false, $message);
186
 
 
 
 
 
187
 
188
  break;
189
 
@@ -243,7 +318,36 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
243
  return $this;
244
  }
245
 
246
- $orderReferenceId = $payment->getAdditionalInformation('order_reference');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
 
248
  if (!$orderReferenceId) {
249
  $orderReferenceId = Mage::getSingleton('checkout/session')->getAmazonOrderReferenceId();
@@ -258,40 +362,59 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
258
  $payment->setTransactionId($orderReferenceId);
259
  $order = $payment->getOrder();
260
 
261
- // If previous order submission failed (e.g. bad credit card), must validate order status to prevent multiple setOrderReferenceDetails()
262
- if ($this->_getErrorCheck()) {
263
- $orderReferenceDetails = $this->_getApi()->getOrderReferenceDetails($orderReferenceId);
264
- }
 
 
265
 
266
- if (!$this->_getErrorCheck() || $orderReferenceDetails->getOrderReferenceStatus()->getState() == 'Draft') {
267
- $apiResult = $this->_getApi()->setOrderReferenceDetails(
268
- $orderReferenceId,
269
- $order->getBaseGrandTotal(),
270
- $order->getBaseCurrencyCode(),
271
- $order->getIncrementId(),
272
- $this->_getApi()->getConfig()->getStoreName()
273
- );
274
- }
275
 
276
- try {
277
- $apiResult = $this->_getApi()->confirmOrderReference($orderReferenceId);
 
 
 
 
 
 
278
  }
279
- catch (Exception $e) {
280
- Mage::throwException("Please try another Amazon payment method."); // . "\n\n" . substr($e->getMessage(), 0, strpos($e->getMessage(), 'Stack trace')));
281
- $this->_setErrorCheck();
282
- return;
 
 
 
283
  }
284
 
285
  $payment->setIsTransactionClosed(false);
286
  $payment->setSkipOrderProcessing(true);
287
 
288
  $comment = '';
289
- $comment .= $this->_getApi()->getConfig()->isSandbox() ? 'Sandbox ' : '';
 
 
 
290
  $comment .= 'Order of %s sent to Amazon Payments.';
291
  $message = Mage::helper('payment')->__($comment, $order->getStore()->convertPrice($amount, true, false));
292
 
293
- $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, null, false, $message);
 
 
 
 
294
 
 
295
 
296
  switch ($this->getConfigData('payment_action')) {
297
  case self::ACTION_AUTHORIZE:
@@ -333,6 +456,11 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
333
  */
334
  public function capture(Varien_Object $payment, $amount)
335
  {
 
 
 
 
 
336
  $transactionAuth = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
337
  $authReferenceId = $transactionAuth->getTxnId();
338
 
@@ -434,19 +562,45 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
434
  $order = $payment->getOrder();
435
  $orderTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
436
 
437
- if (!$orderTransaction) {
438
  $orderTransactionId = $payment->getAdditionalInformation('order_reference');
439
  }
440
  else {
441
  $orderTransactionId = $orderTransaction->getTxnId();
442
  }
443
 
 
 
 
 
 
 
 
 
444
  if ($orderTransaction) {
445
  $this->_getApi($order->getStoreId())->cancelOrderReference($orderTransactionId);
446
  }
 
447
  return $this;
448
  }
449
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
450
  /**
451
  * Can capture?
452
  *
@@ -456,6 +610,12 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
456
  {
457
  $payment = $this->getInfoInstance();
458
  if ($payment) {
 
 
 
 
 
 
459
  $transactionAuth = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
460
 
461
  if (!$transactionAuth || $transactionAuth->getIsClosed()) {
@@ -494,6 +654,35 @@ class Amazon_Payments_Model_PaymentMethod extends Mage_Payment_Model_Method_Abst
494
  return (Mage::getSingleton('amazon_payments/config')->isEnabled() && Mage::helper('amazon_payments')->isEnableProductPayments() && ((Mage::helper('amazon_payments')->isCheckoutAmazonSession() && $this->getConfigData('checkout_page') == 'onepage') || $this->getConfigData('use_in_checkout')));
495
  }
496
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
497
  /**
498
  * Force sync instead of async
499
  */
56
  */
57
  protected function _getSoftDescriptor()
58
  {
59
+ return $this->_getApi()->getConfig()->getSoftDesc();
60
  }
61
 
62
  /**
75
  return Mage::getSingleton('checkout/session')->getAmazonErrorCheck();
76
  }
77
 
78
+ /**
79
+ * Update billing address from authorization request
80
+ */
81
+ protected function _updateBilling(Varien_Object $payment, $amazonAuthorizationId)
82
+ {
83
+ try {
84
+ $mageBilling = $payment->getOrder()->getBillingAddress();
85
+
86
+ $authorizationDetails = $this->_getApi()->getAuthorizationDetails($amazonAuthorizationId);
87
+ $billing = $authorizationDetails->getAuthorizationBillingAddress();
88
+
89
+ if ($billing) {
90
+
91
+ $regionModel = Mage::getModel('directory/region')->loadByCode($billing->getStateOrRegion(), $billing->getCountryCode());
92
+ $regionId = $regionModel->getId();
93
+ $dataBilling = Mage::helper('amazon_payments')->transformAmazonAddressToMagentoAddress($billing);
94
+ $dataBilling['use_for_shipping'] = false;
95
+ $dataBilling['region'] = $billing->getStateOrRegion();
96
+ $dataBilling['region_id'] = $regionId;
97
+
98
+ foreach ($dataBilling as $key => $value) {
99
+ $mageBilling->setData($key, $value);
100
+ }
101
+
102
+ $mageBilling->implodeStreetAddress()->save();
103
+ }
104
+
105
+ } catch (Exception $e) {
106
+ Mage::logException($e);
107
+ }
108
+ }
109
+
110
+
111
  /**
112
  * Instantiate state and set it to state object
113
  *
138
  $stateObject->setIsNotified(Mage_Sales_Model_Order_Status_History::CUSTOMER_NOTIFICATION_NOT_APPLICABLE);
139
  }
140
 
141
+ /**
142
+ * Pre-order (no authorize or capture)
143
+ */
144
+ protected function _preorder(Varien_Object $payment, $amount, $message)
145
+ {
146
+ $order = $payment->getOrder();
147
+ $message = str_ireplace('order', 'Pre-order', $message);
148
+
149
+ $payment->setTransactionId($payment->getAdditionalInformation('order_reference'));
150
+ $payment->setIsTransactionClosed(false);
151
+
152
+ $transactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER;
153
+ $payment->addTransaction($transactionType, null, false, $message);
154
+ }
155
 
156
  /**
157
  * Authorize, with option to Capture
159
  protected function _authorize(Varien_Object $payment, $amount, $captureNow = false)
160
  {
161
  $order = $payment->getOrder();
162
+ $orderReference = $payment->getAdditionalInformation('order_reference');
163
 
164
  $sellerAuthorizationNote = null;
165
 
176
  // For core and third-party checkouts, may test credit card decline by uncommenting:
177
  //$sellerAuthorizationNote = '{"SandboxSimulation": {"State":"Declined", "ReasonCode":"InvalidPaymentMethod", "PaymentMethodUpdateTimeInMins":5}}';
178
 
179
+ // Token payment (i.e. authorize against billing agreement id)
180
+ if ($amazonBillingAgreementId = $payment->getAdditionalInformation('billing_agreement_id')) {
181
+ $forceSync = $this->_isPreorder($payment) && $this->getConfig('is_async'); // Manual Sync
182
+
183
+ $result = $this->_getApi($order->getStoreId())->authorizeOnBillingAgreement(
184
+ $amazonBillingAgreementId,
185
+ $this->_getMagentoReferenceId($payment) . '-bill',
186
+ $amount,
187
+ $order->getBaseCurrencyCode(),
188
+ $captureNow,
189
+ ($captureNow) ? $this->_getSoftDescriptor() : null,
190
+ $sellerAuthorizationNote,
191
+ $forceSync
192
+ );
193
 
194
+ $authorizationDetails = $result->getAuthorizationDetails();
195
+
196
+ $orderReference = $result->getAmazonOrderReferenceId();
197
+ $payment->setAdditionalInformation('order_reference', $orderReference);
198
+ }
199
+ // Normal payment
200
+ else {
201
+ $authorizationDetails = $this->_getApi($order->getStoreId())->authorize(
202
+ $payment->getTransactionId(),
203
+ $this->_getMagentoReferenceId($payment) . '-auth',
204
+ $amount,
205
+ $order->getBaseCurrencyCode(),
206
+ $captureNow,
207
+ ($captureNow) ? $this->_getSoftDescriptor() : null,
208
+ $sellerAuthorizationNote,
209
+ $this->isForceSync
210
+ );
211
+ }
212
+
213
+ $status = $authorizationDetails->getAuthorizationStatus();
214
 
215
  switch ($status->getState()) {
216
  case Amazon_Payments_Model_Api::AUTH_STATUS_PENDING:
217
  case Amazon_Payments_Model_Api::AUTH_STATUS_OPEN:
218
  case Amazon_Payments_Model_Api::AUTH_STATUS_CLOSED:
219
 
220
+ $payment->setTransactionId($authorizationDetails->getAmazonAuthorizationId());
221
  $payment->setParentTransactionId($payment->getAdditionalInformation('order_reference'));
222
  $payment->setIsTransactionClosed(false);
223
 
227
  if ($this->isForceSync) { // Not async
228
  $transactionSave = Mage::getModel('core/resource_transaction');
229
 
230
+ $captureReferenceIds = $authorizationDetails->getIdList()->getmember();
231
 
232
  if ($order->canInvoice()) {
233
  // Create invoice
255
 
256
  $payment->addTransaction($transactionType, null, false, $message);
257
 
258
+ // Set billing address for non-US countries
259
+ if ($this->getConfigData('region') && $this->getConfigData('region') != 'us') {
260
+ $this->_updateBilling($payment, $result->getAmazonAuthorizationId());
261
+ }
262
 
263
  break;
264
 
318
  return $this;
319
  }
320
 
321
+ // Admin order using token (Amazon Billing Agreement id)
322
+ if ($adminBillingAgreementId = Mage::getSingleton('adminhtml/session_quote')->getAmazonBillingAgreementId()) {
323
+ $payment->setAdditionalInformation('order_reference', $adminBillingAgreementId);
324
+ $payment->setAdditionalInformation('billing_agreement_id', $adminBillingAgreementId);
325
+ }
326
+
327
+ $orderReferenceId = $payment->getAdditionalInformation('order_reference');
328
+ $billingAgreementId = $payment->getAdditionalInformation('billing_agreement_id'); // token payment. orderReferenceId will be the same.
329
+
330
+ $orderConfirmed = false;
331
+
332
+ // User did not agree to billing agreement; create order reference ID from billing agreement ID
333
+ if ($billingAgreementId && !$adminBillingAgreementId && !$payment->getAdditionalInformation('billing_agreement_consent')) {
334
+ $orderAttributes = array(
335
+ 'PlatformId' => Amazon_Payments_Model_Api::ORDER_PLATFORM_ID,
336
+ 'OrderTotal' => array(
337
+ 'CurrencyCode' => $payment->getOrder()->getBaseCurrencyCode(),
338
+ 'Amount' => $amount,
339
+ )
340
+ );
341
+
342
+ $orderReferenceDetails = $this->_getApi()->createOrderReferenceForId($billingAgreementId, 'BillingAgreement', true, true, $orderAttributes);
343
+ $orderReferenceId = $orderReferenceDetails->getAmazonOrderReferenceId();
344
+ $billingAgreementId = false;
345
+ $orderConfirmed = true;
346
+
347
+ $payment->setAdditionalInformation('order_reference', $orderReferenceId);
348
+ $payment->unsAdditionalInformation('billing_agreement_id');
349
+ $payment->unsAdditionalInformation('billing_agreement_consent');
350
+ }
351
 
352
  if (!$orderReferenceId) {
353
  $orderReferenceId = Mage::getSingleton('checkout/session')->getAmazonOrderReferenceId();
362
  $payment->setTransactionId($orderReferenceId);
363
  $order = $payment->getOrder();
364
 
365
+ // Normal order (no token)
366
+ if (!$billingAgreementId && !$orderConfirmed) {
367
+ // If previous order submission failed (e.g. bad credit card), must validate order status to prevent multiple setOrderReferenceDetails()
368
+ if ($this->_getErrorCheck()) {
369
+ $orderReferenceDetails = $this->_getApi()->getOrderReferenceDetails($orderReferenceId);
370
+ }
371
 
372
+ if (!$this->_getErrorCheck() || $orderReferenceDetails->getOrderReferenceStatus()->getState() == 'Draft') {
373
+ $apiResult = $this->_getApi()->setOrderReferenceDetails(
374
+ $orderReferenceId,
375
+ $order->getBaseGrandTotal(),
376
+ $order->getBaseCurrencyCode(),
377
+ $order->getIncrementId(),
378
+ $this->_getApi()->getConfig()->getStoreName()
379
+ );
380
+ }
381
 
382
+ try {
383
+ $apiResult = $this->_getApi()->confirmOrderReference($orderReferenceId);
384
+ }
385
+ catch (Exception $e) {
386
+ Mage::throwException("Please try another Amazon payment method." . "\n\n" . substr($e->getMessage(), 0, strpos($e->getMessage(), 'Stack trace')));
387
+ $this->_setErrorCheck();
388
+ return;
389
+ }
390
  }
391
+ // Token payment
392
+ else if ($billingAgreementId) {
393
+ $apiResult = $this->_getApi()->confirmBillingAgreement($billingAgreementId);
394
+ // Save token
395
+ if ($apiResult && $payment->getAdditionalInformation('billing_agreement_consent')) {
396
+ Mage::getModel('amazon_payments/token')->saveBillingAgreementId($billingAgreementId, $order->getQuote()->getShippingAddress()->getShippingMethod());
397
+ }
398
  }
399
 
400
  $payment->setIsTransactionClosed(false);
401
  $payment->setSkipOrderProcessing(true);
402
 
403
  $comment = '';
404
+ $comment .= $this->getConfigData('is_async') ? 'Asynchronous ' : '';
405
+ $comment .= $billingAgreementId ? 'Tokenized ' : '';
406
+ $comment .= $this->_getApi()->getConfig()->isSandbox() ? 'Sandbox ' : '';
407
+
408
  $comment .= 'Order of %s sent to Amazon Payments.';
409
  $message = Mage::helper('payment')->__($comment, $order->getStore()->convertPrice($amount, true, false));
410
 
411
+ // Pre-order (delayed tokenized payment)
412
+ if ($this->getConfigData('token_delayed') && $billingAgreementId) {
413
+ $this->_preorder($payment, $amount, $message);
414
+ return $this;
415
+ }
416
 
417
+ $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, null, false, $message);
418
 
419
  switch ($this->getConfigData('payment_action')) {
420
  case self::ACTION_AUTHORIZE:
456
  */
457
  public function capture(Varien_Object $payment, $amount)
458
  {
459
+ // Pre-order (delayed tokenized) payment must authorize and capture
460
+ if ($this->_isPreorder($payment)) {
461
+ return $this->_authorize($payment, $amount, true);
462
+ }
463
+
464
  $transactionAuth = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
465
  $authReferenceId = $transactionAuth->getTxnId();
466
 
562
  $order = $payment->getOrder();
563
  $orderTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
564
 
565
+ if (!$orderTransaction || $payment->getAdditionalInformation('billing_agreement_id')) {
566
  $orderTransactionId = $payment->getAdditionalInformation('order_reference');
567
  }
568
  else {
569
  $orderTransactionId = $orderTransaction->getTxnId();
570
  }
571
 
572
+ if ($payment->getAdditionalInformation('billing_agreement_id')) {
573
+ $orderReferenceDetails = $this->_getApi()->getOrderReferenceDetails($orderTransactionId);
574
+ $state = $orderReferenceDetails->getOrderReferenceStatus()->getState();
575
+ if ($state == 'Closed' || $state == 'Canceled') {
576
+ return $this;
577
+ }
578
+ }
579
+
580
  if ($orderTransaction) {
581
  $this->_getApi($order->getStoreId())->cancelOrderReference($orderTransactionId);
582
  }
583
+
584
  return $this;
585
  }
586
 
587
+ /**
588
+ * Is pre-order?
589
+ *
590
+ * @return bool
591
+ */
592
+ function _isPreorder($payment)
593
+ {
594
+ // Pre-order (delayed tokenized) payment must authorize and capture
595
+ if ($payment->getAdditionalInformation('billing_agreement_id')) {
596
+ $lastTrans = $payment->lookupTransaction($payment->getLastTransId());
597
+ if ($lastTrans && $lastTrans->getTxnType() == Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER) {
598
+ return true;
599
+ }
600
+ }
601
+ return false;
602
+ }
603
+
604
  /**
605
  * Can capture?
606
  *
610
  {
611
  $payment = $this->getInfoInstance();
612
  if ($payment) {
613
+
614
+ // Pre-order (delayed tokenized) payment?
615
+ if ($this->_isPreorder($payment)) {
616
+ return true;
617
+ }
618
+
619
  $transactionAuth = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
620
 
621
  if (!$transactionAuth || $transactionAuth->getIsClosed()) {
654
  return (Mage::getSingleton('amazon_payments/config')->isEnabled() && Mage::helper('amazon_payments')->isEnableProductPayments() && ((Mage::helper('amazon_payments')->isCheckoutAmazonSession() && $this->getConfigData('checkout_page') == 'onepage') || $this->getConfigData('use_in_checkout')));
655
  }
656
 
657
+ /**
658
+ * Using internal pages for input payment data
659
+ * Can be used in admin
660
+ *
661
+ * @return bool
662
+ */
663
+ public function canUseInternal()
664
+ {
665
+ // Allow admin to create order using token (Amazon billing agreement id)
666
+ if ($this->getConfigData('token_enabled')) {
667
+ // Admin session
668
+ $session = Mage::getSingleton('adminhtml/session_quote');
669
+ if ($session) {
670
+ if (($quote = $session->getQuote()) && $quote->getCustomerId() != null) {
671
+ $row = Mage::getSingleton('amazon_payments/token')->getBillingAgreement($quote->getCustomerId());
672
+
673
+ if ($token = $row->getAmazonBillingAgreementId()) {
674
+ $session->setAmazonBillingAgreementId($token);
675
+ return true;
676
+ }
677
+ }
678
+ else {
679
+ $session->unsAmazonBillingAgreementId();
680
+ }
681
+ }
682
+ }
683
+ return $this->_canUseInternal;
684
+ }
685
+
686
  /**
687
  * Force sync instead of async
688
  */
app/code/community/Amazon/Payments/Model/Resource/Token.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Amazon Payments
4
+ *
5
+ * @category Amazon
6
+ * @package Amazon_Payments
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_Payments_Model_Resource_Token extends Mage_Core_Model_Mysql4_Abstract
12
+ {
13
+ public function _construct()
14
+ {
15
+ $this->_init('amazon_payments/token', 'token_id');
16
+ }
17
+ }
app/code/community/Amazon/Payments/Model/SimplePath.php CHANGED
@@ -24,7 +24,7 @@ class Amazon_Payments_Model_SimplePath
24
  public function generateKeys()
25
  {
26
  $rsa = new Zend_Crypt_Rsa;
27
- $keys = $rsa->generateKeys(array('private_key_bits' => 2048, 'hashAlgorithm' => 'sha1'));
28
 
29
  Mage::getConfig()
30
  ->saveConfig(self::CONFIG_XML_PATH_PUBLIC_KEY, $keys['publicKey'], 'default', 0)
@@ -57,7 +57,7 @@ class Amazon_Payments_Model_SimplePath
57
  $publickey = Mage::getStoreConfig(self::CONFIG_XML_PATH_PUBLIC_KEY, 0);
58
 
59
  // Generate key pair
60
- if (!$publickey || $reset) {
61
  $keys = $this->generateKeys();
62
  $publickey = $keys['publicKey'];
63
  }
@@ -159,7 +159,7 @@ class Amazon_Payments_Model_SimplePath
159
  Mage::getSingleton('adminhtml/session')->addError(Mage::helper('amazon_payments')->__($e->getMessage()));
160
 
161
  $link = 'https://payments.amazon.com/help/202024240';
162
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('amazon_payments')->__("If you're experiencing consistant errors with transfering keys, click <a href=\"%s\" target=\"_blank\">Manual Transfer Instructions</a> to learn more.", $link));
163
  }
164
 
165
  return false;
@@ -219,7 +219,7 @@ class Amazon_Payments_Model_SimplePath
219
  */
220
  public function getListenerUrl()
221
  {
222
- $url = Mage::getUrl('amazon_payments/simplepath', array('_store' => 1, '_forced_secure' => true));
223
  // Add index.php
224
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
225
  return str_replace($baseUrl, $baseUrl . 'index.php/', $url);
@@ -245,18 +245,31 @@ class Amazon_Payments_Model_SimplePath
245
  $db = Mage::getSingleton('core/resource')->getConnection('core_read');
246
 
247
  $select = $db->select()
248
- ->from('core_config_data')
249
  ->where('path IN (?)', array('web/unsecure/base_url', 'web/secure/base_url'));
250
 
251
  foreach ($db->fetchAll($select) as $row) {
252
  $url = parse_url($row['value']);
253
- $urls[] = 'https://' . $url['host'];
 
 
 
 
 
 
 
 
 
 
 
254
  }
255
 
 
 
256
  return array(
257
  'locale' => Mage::getStoreConfig('general/country/default'),
258
  'spId' => self::PARAM_SP_ID,
259
- 'allowedLoginDomains[]' => array_unique($urls),
260
  'spSoftwareVersion' => Mage::getVersion(),
261
  'spAmazonPluginVersion' => Mage::getConfig()->getModuleConfig("Amazon_Payments")->version,
262
  );
@@ -275,7 +288,7 @@ class Amazon_Payments_Model_SimplePath
275
  //'spUrl' => Mage::helper("adminhtml")->getUrl('adminhtml/amazon_simplepath/spurl'),
276
  'importUrl' => Mage::helper('adminhtml')->getUrl('adminhtml/amazon_simplepath/import'),
277
  'isSecure' => (int) (Mage::app()->getFrontController()->getRequest()->isSecure()),
278
- 'isUsa' => (int) (Mage::helper('amazon_payments')->getAdminConfig('general/country/default') == 'US'),
279
  'hasOpenssl' => (int) (extension_loaded('openssl')),
280
  'formParams' => $this->getFormParams(),
281
  );
24
  public function generateKeys()
25
  {
26
  $rsa = new Zend_Crypt_Rsa;
27
+ $keys = $rsa->generateKeys(array('private_key_bits' => 2048, 'privateKeyBits' => 2048, 'hashAlgorithm' => 'sha1'));
28
 
29
  Mage::getConfig()
30
  ->saveConfig(self::CONFIG_XML_PATH_PUBLIC_KEY, $keys['publicKey'], 'default', 0)
57
  $publickey = Mage::getStoreConfig(self::CONFIG_XML_PATH_PUBLIC_KEY, 0);
58
 
59
  // Generate key pair
60
+ if (!$publickey || $reset || strlen($publickey) < 300) {
61
  $keys = $this->generateKeys();
62
  $publickey = $keys['publicKey'];
63
  }
159
  Mage::getSingleton('adminhtml/session')->addError(Mage::helper('amazon_payments')->__($e->getMessage()));
160
 
161
  $link = 'https://payments.amazon.com/help/202024240';
162
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('amazon_payments')->__("If you're experiencing consistent errors with transferring keys, click <a href=\"%s\" target=\"_blank\">Manual Transfer Instructions</a> to learn more.", $link));
163
  }
164
 
165
  return false;
219
  */
220
  public function getListenerUrl()
221
  {
222
+ $url = Mage::getUrl('amazon_payments/simplepath', array('_store' => Mage::helper('amazon_payments')->getAdminStoreId(), '_forced_secure' => true));
223
  // Add index.php
224
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
225
  return str_replace($baseUrl, $baseUrl . 'index.php/', $url);
245
  $db = Mage::getSingleton('core/resource')->getConnection('core_read');
246
 
247
  $select = $db->select()
248
+ ->from(Mage::getSingleton('core/resource')->getTableName('core_config_data'))
249
  ->where('path IN (?)', array('web/unsecure/base_url', 'web/secure/base_url'));
250
 
251
  foreach ($db->fetchAll($select) as $row) {
252
  $url = parse_url($row['value']);
253
+
254
+ if (isset($url['host'])){
255
+ $urls[] = 'https://' . $url['host'];
256
+ }
257
+ }
258
+
259
+ // Check config files
260
+ foreach (Mage::app()->getStores() as $store) {
261
+ $storeCode = $store->getCode();
262
+ if ($url = (string) Mage::getConfig()->getNode('stores/' . $storeCode . '/web/secure/base_url')) {
263
+ $urls[] = rtrim($url, '/');
264
+ }
265
  }
266
 
267
+ $urls = array_unique($urls);
268
+
269
  return array(
270
  'locale' => Mage::getStoreConfig('general/country/default'),
271
  'spId' => self::PARAM_SP_ID,
272
+ 'allowedLoginDomains[]' => $urls,
273
  'spSoftwareVersion' => Mage::getVersion(),
274
  'spAmazonPluginVersion' => Mage::getConfig()->getModuleConfig("Amazon_Payments")->version,
275
  );
288
  //'spUrl' => Mage::helper("adminhtml")->getUrl('adminhtml/amazon_simplepath/spurl'),
289
  'importUrl' => Mage::helper('adminhtml')->getUrl('adminhtml/amazon_simplepath/import'),
290
  'isSecure' => (int) (Mage::app()->getFrontController()->getRequest()->isSecure()),
291
+ 'isUsa' => (int) (Mage::helper('amazon_payments')->getAdminConfig('general/country/default') == 'US' && Mage::helper('amazon_payments')->getAdminRegion() != 'eu'),
292
  'hasOpenssl' => (int) (extension_loaded('openssl')),
293
  'formParams' => $this->getFormParams(),
294
  );
app/code/community/Amazon/Payments/Model/System/Config/Backend/Enabled.php CHANGED
@@ -21,70 +21,11 @@ class Amazon_Payments_Model_System_Config_Backend_Enabled extends Mage_Core_Mode
21
 
22
  if ($isEnabled) {
23
  if ($data['seller_id']['value'] && !ctype_alnum($data['seller_id']['value'])) {
24
- Mage::getSingleton('core/session')->addError('Error: Please verify your Seller ID (alphanumeric characters only).');
25
  }
26
  }
27
  return parent::save();
28
  }
29
- /**
30
- * Perform API call to Amazon to validate keys
31
- *
32
- */
33
- public function _afterSaveCommit()
34
- {
35
- $data = $this->_getCredentials();
36
- $isEnabled = $this->getValue();
37
-
38
- $access_secret = $data['access_secret']['value'];
39
- if (strpos($access_secret, '*****') !== FALSE) { // Encrypted
40
- $access_secret = Mage::getSingleton('amazon_payments/config')->getAccessSecret();
41
- }
42
-
43
- if ($isEnabled && $data['access_key']['value']) {
44
- $config = array (
45
- 'ServiceURL' => "https://mws.amazonservices.com/Sellers/2011-07-01",
46
- 'ProxyHost' => null,
47
- 'ProxyPort' => -1,
48
- 'ProxyUsername' => null,
49
- 'ProxyPassword' => null,
50
- 'MaxErrorRetry' => 3,
51
- );
52
- $service = new MarketplaceWebServiceSellers_Client(
53
- $data['access_key']['value'],
54
- $access_secret,
55
- 'Login and Pay for Magento',
56
- '1.3',
57
- $config);
58
-
59
- $request = new MarketplaceWebServiceSellers_Model_ListMarketplaceParticipationsRequest();
60
- $request->setSellerId($data['seller_id']['value']);
61
- try {
62
- $service->ListMarketplaceParticipations($request);
63
- Mage::getSingleton('core/session')->addSuccess("All of your Amazon API keys are correct!");
64
- }
65
- catch (MarketplaceWebServiceSellers_Exception $ex) {
66
- if ($ex->getErrorCode() == 'InvalidAccessKeyId'){
67
- Mage::getSingleton('core/session')->addError("The Amazon MWS Access Key is incorrect");
68
- }
69
- else if ($ex->getErrorCode() == 'SignatureDoesNotMatch'){
70
- Mage::getSingleton('core/session')->addError("The Amazon MWS Secret Key is incorrect");
71
- }
72
- else if ($ex->getErrorCode() == 'InvalidParameterValue'){
73
- Mage::getSingleton('core/session')->addError("The Amazon Seller/Merchant ID is incorrect");
74
- }
75
- else if ($ex->getErrorCode() == 'AccessDenied') {
76
- Mage::getSingleton('core/session')->addError("The Amazon Seller/Merchant ID does not match the MWS keys provided");
77
- }
78
- else{
79
- $string = " Error Message: " . $ex->getMessage();
80
- $string .= " Response Status Code: " . $ex->getStatusCode();
81
- $string .= " Error Code: " . $ex->getErrorCode();
82
- Mage::getSingleton('core/session')->addError($string);
83
- }
84
- }
85
- }
86
- return parent::_afterSaveCommit();
87
- }
88
 
89
  /**
90
  * Return dynamic help/comment text
@@ -121,4 +62,27 @@ class Amazon_Payments_Model_System_Config_Backend_Enabled extends Mage_Core_Mode
121
  return $groups['ap_credentials']['fields'];
122
  }
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
21
 
22
  if ($isEnabled) {
23
  if ($data['seller_id']['value'] && !ctype_alnum($data['seller_id']['value'])) {
24
+ Mage::getSingleton('core/session')->addError(Mage::helper('adminhtml')->__('Error: Please verify your Seller ID (alphanumeric characters only).'));
25
  }
26
  }
27
  return parent::save();
28
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  /**
31
  * Return dynamic help/comment text
62
  return $groups['ap_credentials']['fields'];
63
  }
64
 
65
+ /**
66
+ * Return Widgets.js URL
67
+ */
68
+ public function getMwsSellerApiUrl()
69
+ {
70
+ switch (Mage::getStoreConfig('amazon_login/settings/region')) {
71
+ case 'uk':
72
+ $tld = 'co.uk';
73
+ break;
74
+
75
+ case 'de':
76
+ $tld = 'de';
77
+ break;
78
+
79
+ // US
80
+ default:
81
+ $tld = 'com';
82
+ break;
83
+ }
84
+
85
+ return "https://mws.amazonservices.".$tld."/Sellers/2011-07-01";
86
+ }
87
+
88
  }
app/code/community/Amazon/Payments/Model/System/Config/Backend/Language.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Amazon Payments
4
+ *
5
+ * @category Amazon
6
+ * @package Amazon_Payments
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_Payments_Model_System_Config_Backend_Language extends Mage_Core_Model_Config_Data
12
+ {
13
+ private $_path = 'amazon_login/settings/language';
14
+
15
+ /**
16
+ * Use Amazon_Login Region
17
+ */
18
+ public function save()
19
+ {
20
+ Mage::getConfig()->saveConfig($this->_path, $this->getValue(), $this->getScope(), $this->getScopeId());
21
+ return parent::save();
22
+ }
23
+
24
+ public function afterLoad()
25
+ {
26
+ if ($this->website) {
27
+ $this->value = Mage::app()->getWebsite($this->getWebsite())->getConfig($this->_path);
28
+ }
29
+ else {
30
+ $this->value = Mage::getStoreConfig($this->_path);
31
+ }
32
+ $this->_afterLoad();
33
+ }
34
+
35
+ }
app/code/community/Amazon/Payments/Model/System/Config/Backend/Localizecomment.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Amazon Payments
4
+ *
5
+ * @category Amazon
6
+ * @package Amazon_Payments
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_Payments_Model_System_Config_Backend_Localizecomment extends Mage_Core_Model_Config_Data
12
+ {
13
+ /**
14
+ * Localize links found in Amazon admin
15
+ */
16
+ public function getCommentText(Mage_Core_Model_Config_Element $element, $currentValue)
17
+ {
18
+ switch (Mage::helper('amazon_payments')->getAdminRegion()) {
19
+ case 'eu':
20
+ $domain = 'sellercentral-europe.amazon.com';
21
+ break;
22
+ default:
23
+ $domain = null;
24
+ break;
25
+ }
26
+
27
+ // Use JS as the settings/header comment doesn't support getCommentText
28
+ if ($domain) {
29
+ $script = '
30
+ $$(".amzn-link").each(function(el, i) {
31
+ if (el.href) {
32
+ //el.href = el.href.replace("sellercentral.amazon.com", "' . $domain . '");
33
+ el.href = "https://' . $domain . '";
34
+ }
35
+
36
+ var onclick = el.readAttribute("onclick");
37
+
38
+ if (onclick) {
39
+ el.writeAttribute("href", "javascript:window.open(\'https://' . $domain . '\')");
40
+ //el.writeAttribute("onclick", onclick.toString().replace("sellercentral.amazon.com", "' . $domain . '"));
41
+ }
42
+
43
+ });
44
+
45
+ $$(".amzn-us-signup").invoke("hide");
46
+ ';
47
+
48
+ // Update doc domain
49
+ if (Mage::helper('amazon_payments')->isAdminGermany()) {
50
+ $script .= '
51
+ $$(".amzn-doc-link").each(function(el, i) {
52
+ el.href = el.href.replace(".co.uk", ".de");
53
+ });
54
+ ';
55
+ }
56
+
57
+ return '<script>document.observe("dom:loaded", function() { '. $script . '});</script>';
58
+ }
59
+ }
60
+ }
app/code/community/Amazon/Payments/Model/System/Config/Backend/Popupcomment.php CHANGED
@@ -17,14 +17,26 @@ class Amazon_Payments_Model_System_Config_Backend_Popupcomment extends Mage_Core
17
  public function getCommentText(Mage_Core_Model_Config_Element $element, $currentValue)
18
  {
19
 
20
- $replace_cleanup = array('index.php/', ':80', ':443');
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  return '
23
  <div style="border:1px solid #ccc; color:#666; padding:8px; margin-top:0.5em; font-size:90%">
24
  If "No," add these URLs in Seller Central under "Allowed Return URLs":<br />
25
  <ul style="list-style:disc inside">
26
- <li>' . str_replace($replace_cleanup, '', Mage::getUrl('amazon_payments/customer/authorize', array('_store' => 1, '_forced_secure' => true))) . '</li>
27
- <li>' . str_replace($replace_cleanup, '', Mage::getUrl('amazon_payments/checkout/authorize', array('_store' => 1, '_forced_secure' => true))) . '</li>
28
  </ul>
29
  </div>
30
  <style>#payment_amazon_payments_popupcomment{display:none;}</style>
@@ -32,4 +44,4 @@ class Amazon_Payments_Model_System_Config_Backend_Popupcomment extends Mage_Core
32
 
33
  ';
34
  }
35
- }
17
  public function getCommentText(Mage_Core_Model_Config_Element $element, $currentValue)
18
  {
19
 
20
+ $replace_cleanup = array(':80', ':443');
21
+
22
+ if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules())) {
23
+ $replace_cleanup[] = 'index.php/';
24
+ }
25
+
26
+ // Website level
27
+ if (strlen($code = Mage::getSingleton('adminhtml/config_data')->getWebsite())) {
28
+ $website_id = Mage::getModel('core/website')->load($code)->getId();
29
+ $store_id = Mage::app()->getWebsite($website_id)->getDefaultStore()->getId();
30
+ } else {
31
+ $store_id = 1;
32
+ }
33
 
34
  return '
35
  <div style="border:1px solid #ccc; color:#666; padding:8px; margin-top:0.5em; font-size:90%">
36
  If "No," add these URLs in Seller Central under "Allowed Return URLs":<br />
37
  <ul style="list-style:disc inside">
38
+ <li>' . str_replace($replace_cleanup, '', Mage::getUrl('amazon_payments/customer/authorize', array('_store' => Mage::helper('amazon_payments')->getAdminStoreId(), '_forced_secure' => true))) . '</li>
39
+ <li>' . str_replace($replace_cleanup, '', Mage::getUrl('amazon_payments/checkout/authorize', array('_store' => Mage::helper('amazon_payments')->getAdminStoreId(), '_forced_secure' => true))) . '</li>
40
  </ul>
41
  </div>
42
  <style>#payment_amazon_payments_popupcomment{display:none;}</style>
44
 
45
  ';
46
  }
47
+ }
app/code/community/Amazon/Payments/Model/System/Config/Source/Region.php CHANGED
@@ -8,14 +8,14 @@
8
  * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
9
  */
10
 
11
- class Amazon_Payments_Model_System_Config_Source_region
12
  {
13
  public function toOptionArray()
14
  {
15
  return array(
16
  array('value'=>'us', 'label'=>Mage::helper('adminhtml')->__('United States')),
17
- array('value'=>'eu', 'label'=>Mage::helper('adminhtml')->__('Europe')),
 
18
  );
19
  }
20
  }
21
-
8
  * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
9
  */
10
 
11
+ class Amazon_Payments_Model_System_Config_Source_Region
12
  {
13
  public function toOptionArray()
14
  {
15
  return array(
16
  array('value'=>'us', 'label'=>Mage::helper('adminhtml')->__('United States')),
17
+ //array('value'=>'uk', 'label'=>Mage::helper('adminhtml')->__('United Kingdom')),
18
+ //array('value'=>'de', 'label'=>Mage::helper('adminhtml')->__('Germany')),
19
  );
20
  }
21
  }
 
app/code/community/Amazon/Payments/Model/Token.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Amazon Payments
4
+ *
5
+ * @category Amazon
6
+ * @package Amazon_Payments
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_Payments_Model_Token extends Mage_Core_Model_Abstract
12
+ {
13
+ public function _construct()
14
+ {
15
+ parent::_construct();
16
+ $this->_init('amazon_payments/token');
17
+ }
18
+
19
+ /**
20
+ * Get token info (Amazon billing agreement ID and shipping method)
21
+ */
22
+ public function getBillingAgreement($customerId = null, $amazonUid = null)
23
+ {
24
+ if ($customerId) {
25
+ $row = $this->load($customerId, 'customer_id');
26
+ }
27
+ elseif ($amazonUid) {
28
+ $row = $this->load($amazonUid, 'amazon_uid');
29
+ }
30
+ else {
31
+ $amazonProfile = Mage::getSingleton('customer/session')->getAmazonProfile();
32
+ $amazonUid = $amazonProfile['user_id'];
33
+ $row = $this->load($amazonUid, 'amazon_uid');
34
+ }
35
+
36
+ return $row;
37
+ }
38
+
39
+ /**
40
+ * Save token (Amazon billing agreement ID)
41
+ */
42
+ public function saveBillingAgreementId($amazonBillingAgreementId, $shippingMethod, $amazonUid = null)
43
+ {
44
+ if (!$amazonUid) {
45
+ $amazonProfile = Mage::getSingleton('customer/session')->getAmazonProfile();
46
+ $amazonUid = $amazonProfile['user_id'];
47
+ }
48
+
49
+ $row = $this->load($amazonUid, 'amazon_uid');
50
+
51
+ if ($row->getTokenId()) {
52
+ $row
53
+ ->setAmazonBillingAgreementId($amazonBillingAgreementId)
54
+ ->setShippingMethod($shippingMethod)
55
+ ->save();
56
+ }
57
+ else {
58
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
59
+ $customerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
60
+ }
61
+ else {
62
+ $customerId = null;
63
+ }
64
+
65
+ $this->setAmazonBillingAgreementId($amazonBillingAgreementId)
66
+ ->setAmazonUid($amazonUid)
67
+ ->setCustomerId($customerId)
68
+ ->setShippingMethod($shippingMethod)
69
+ ->save();
70
+ }
71
+ }
72
+
73
+ }
app/code/community/Amazon/Payments/Model/Type/Checkout.php CHANGED
@@ -94,6 +94,96 @@ class Amazon_Payments_Model_Type_Checkout extends Mage_Checkout_Model_Type_Onepa
94
  }
95
 
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  /**
98
  * Create order based on checkout type. Create customer if necessary.
99
  *
94
  }
95
 
96
 
97
+ /**
98
+ * Save billing address information to quote
99
+ * This method is called by One Page Checkout JS (AJAX) while saving the billing information.
100
+ *
101
+ * @param array $data
102
+ * @param int $customerAddressId
103
+ * @return Mage_Checkout_Model_Type_Onepage
104
+ */
105
+ public function saveBilling($data, $customerAddressId = null)
106
+ {
107
+ if (empty($data)) {
108
+ return array('error' => -1, 'message' => Mage::helper('checkout')->__('Invalid data.'));
109
+ }
110
+
111
+ $address = $this->getQuote()->getBillingAddress();
112
+
113
+ foreach ($data as $attribute => $value) {
114
+ $address->setData($attribute, $value);
115
+ }
116
+
117
+ // validate billing address
118
+ if (($validateRes = $address->validate()) !== true) {
119
+ return array('error' => 1, 'message' => $validateRes);
120
+ }
121
+
122
+ $address->implodeStreetAddress();
123
+
124
+ if (true !== ($result = $this->_validateCustomerData($data))) {
125
+ return $result;
126
+ }
127
+
128
+ if (!$this->getQuote()->getCustomerId() && self::METHOD_REGISTER == $this->getQuote()->getCheckoutMethod()) {
129
+ if ($this->_customerEmailExists($address->getEmail(), Mage::app()->getWebsite()->getId())) {
130
+ return array('error' => 1, 'message' => $this->_customerEmailExistsMessage);
131
+ }
132
+ }
133
+
134
+ if (!$this->getQuote()->isVirtual()) {
135
+ /**
136
+ * Billing address using otions
137
+ */
138
+ $usingCase = isset($data['use_for_shipping']) ? (int)$data['use_for_shipping'] : 0;
139
+
140
+ switch ($usingCase) {
141
+ case 0:
142
+ $shipping = $this->getQuote()->getShippingAddress();
143
+ $shipping->setSameAsBilling(0);
144
+ break;
145
+ case 1:
146
+ $billing = clone $address;
147
+ $billing->unsAddressId()->unsAddressType();
148
+ $shipping = $this->getQuote()->getShippingAddress();
149
+ $shippingMethod = $shipping->getShippingMethod();
150
+
151
+ // Billing address properties that must be always copied to shipping address
152
+ $requiredBillingAttributes = array('customer_address_id');
153
+
154
+ // don't reset original shipping data, if it was not changed by customer
155
+ foreach ($shipping->getData() as $shippingKey => $shippingValue) {
156
+ if (!is_null($shippingValue) && !is_null($billing->getData($shippingKey))
157
+ && !isset($data[$shippingKey]) && !in_array($shippingKey, $requiredBillingAttributes)
158
+ ) {
159
+ $billing->unsetData($shippingKey);
160
+ }
161
+ }
162
+ $shipping->addData($billing->getData())
163
+ ->setSameAsBilling(1)
164
+ ->setSaveInAddressBook(0)
165
+ ->setShippingMethod($shippingMethod)
166
+ ->setCollectShippingRates(true);
167
+ $this->getCheckout()->setStepData('shipping', 'complete', true);
168
+ break;
169
+ }
170
+ }
171
+
172
+ $this->getQuote()->collectTotals()->save();
173
+
174
+ if (!$this->getQuote()->isVirtual() && $this->getCheckout()->getStepData('shipping', 'complete') == true) {
175
+ //Recollect Shipping rates for shipping methods
176
+ $this->getQuote()->getShippingAddress()->setCollectShippingRates(true);
177
+ }
178
+
179
+ $this->getCheckout()
180
+ ->setStepData('billing', 'allow', true)
181
+ ->setStepData('billing', 'complete', true)
182
+ ->setStepData('shipping', 'allow', true);
183
+
184
+ return array();
185
+ }
186
+
187
  /**
188
  * Create order based on checkout type. Create customer if necessary.
189
  *
app/code/community/Amazon/Payments/controllers/CheckoutController.php CHANGED
@@ -34,15 +34,24 @@ class Amazon_Payments_CheckoutController extends Amazon_Payments_Controller_Chec
34
  }
35
  Mage::getSingleton('checkout/session')->setCartWasUpdated(false);
36
  Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_secure' => true)));
37
- $this->_initLayoutMessages('checkout/session');
38
  $this->_getCheckout()->initCheckout();
39
- $this->loadLayout();
 
40
 
41
  // Ajax Modal
42
  if($this->getRequest()->getParam('ajax')){
43
  $this->getLayout()->getBlock('root')->setTemplate('page/popup.phtml');
44
  }
45
 
 
 
 
 
 
 
 
 
46
  $this->getLayout()->getBlock('head')->setTitle($this->__('Checkout'));
47
  $this->renderLayout();
48
  }
@@ -108,6 +117,42 @@ class Amazon_Payments_CheckoutController extends Amazon_Payments_Controller_Chec
108
  $this->renderLayout();
109
  }
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  /**
112
  * Shipping method action
113
  */
@@ -123,6 +168,30 @@ class Amazon_Payments_CheckoutController extends Amazon_Payments_Controller_Chec
123
  $this->renderLayout();
124
  }
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  /**
127
  * Review page action
128
  */
@@ -219,9 +288,26 @@ class Amazon_Payments_CheckoutController extends Amazon_Payments_Controller_Chec
219
  }
220
  }
221
 
222
- $additional_information = array(
223
- 'order_reference' => $this->getAmazonOrderReferenceId()
224
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
 
226
  if ($this->getRequest()->getPost('sandbox')) {
227
  $additional_information['sandbox'] = $this->getRequest()->getPost('sandbox');
@@ -291,7 +377,80 @@ class Amazon_Payments_CheckoutController extends Amazon_Payments_Controller_Chec
291
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
292
  }
293
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
 
 
 
 
 
 
 
 
 
 
295
 
296
  /**
297
  * Create invoice
@@ -323,5 +482,23 @@ class Amazon_Payments_CheckoutController extends Amazon_Payments_Controller_Chec
323
  return $this->getLayout()->getBlock('root')->toHtml();
324
  }
325
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326
  }
327
 
34
  }
35
  Mage::getSingleton('checkout/session')->setCartWasUpdated(false);
36
  Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_secure' => true)));
37
+
38
  $this->_getCheckout()->initCheckout();
39
+ $this->loadLayout()
40
+ ->_initLayoutMessages('checkout/session');
41
 
42
  // Ajax Modal
43
  if($this->getRequest()->getParam('ajax')){
44
  $this->getLayout()->getBlock('root')->setTemplate('page/popup.phtml');
45
  }
46
 
47
+ // Add EE gift wrapping options
48
+ if (Mage::helper('core')->isModuleEnabled('Enterprise_GiftWrapping')) {
49
+ $block = $this->getLayout()
50
+ ->createBlock('enterprise_giftwrapping/checkout_options', 'checkout.options')
51
+ ->setTemplate('giftwrapping/checkout/options.phtml');
52
+ $this->getLayout()->getBlock('content')->append($block);
53
+ }
54
+
55
  $this->getLayout()->getBlock('head')->setTitle($this->__('Checkout'));
56
  $this->renderLayout();
57
  }
117
  $this->renderLayout();
118
  }
119
 
120
+ /**
121
+ * Widget Address select action
122
+ */
123
+ public function addressSelectAction()
124
+ {
125
+ if ($this->_expireAjax()) {
126
+ return;
127
+ }
128
+
129
+ $this->_saveShipping();
130
+ $this->_getCheckout()->getQuote()->collectTotals()->save();
131
+
132
+ $shipping_block = 'checkout_amazon_payments_shippingmethod';
133
+
134
+ // Use ShipperHQ template for split rates
135
+ if (Mage::helper('core')->isModuleEnabled('Shipperhq_Shipper')) {
136
+ $splitRates = $this->_getCheckout()->getQuote()->getShippingAddress()->getSplitRates();
137
+ if((Mage::helper('shipperhq_shipper')->isModuleEnabled('Shipperhq_Splitrates') && $splitRates == 1)
138
+ || Mage::helper('core')->isModuleEnabled('Shipperhq_Pickup')) {
139
+ $shipping_block = 'checkout_amazon_payments_shippingmethod_shipperhq';
140
+ }
141
+ }
142
+
143
+ $result = array(
144
+ 'shipping_method' => $this->_getBlockHtml($shipping_block),
145
+ 'review' => $this->_getBlockHtml('checkout_amazon_payments_review'),
146
+ );
147
+
148
+ // Validate country
149
+ if (!$this->isCountryAllowed($this->_getCheckout()->getQuote()->getShippingAddress()->getCountry())) {
150
+ $result['shipping_method'] = $this->__('This order cannot be shipped to the selected country. Please use a different shipping address.');
151
+ }
152
+
153
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
154
+ }
155
+
156
  /**
157
  * Shipping method action
158
  */
168
  $this->renderLayout();
169
  }
170
 
171
+ /**
172
+ * Additional options action (e.g. gift options)
173
+ */
174
+ public function additionalAction()
175
+ {
176
+ if ($this->_expireAjax()) {
177
+ return;
178
+ }
179
+
180
+ if ($this->getRequest()->isPost()) {
181
+ Mage::dispatchEvent(
182
+ 'checkout_controller_onepage_save_shipping_method',
183
+ array(
184
+ 'request' => $this->getRequest(),
185
+ 'quote' => $this->_getCheckout()->getQuote()));
186
+
187
+ $this->_getCheckout()->getQuote()->collectTotals()->save();
188
+
189
+ }
190
+
191
+ $this->getResponse()->setBody($this->_getBlockHtml('checkout_amazon_payments_review'));
192
+ }
193
+
194
+
195
  /**
196
  * Review page action
197
  */
288
  }
289
  }
290
 
291
+ // Validate shipping method
292
+ if (!$this->_getCheckout()->getQuote()->isVirtual()) {
293
+ $address = $this->_getCheckout()->getQuote()->getShippingAddress();
294
+ $method = $address->getShippingMethod();
295
+ $rate = $address->getShippingRateByCode($method);
296
+ if (!$this->_getCheckout()->getQuote()->isVirtual() && (!$method || !$rate)) {
297
+ Mage::throwException(Mage::helper('sales')->__('Please specify a shipping method.'));
298
+ }
299
+ }
300
+
301
+
302
+ $additional_information = array();
303
+
304
+ if ($this->getAmazonBillingAgreementId()) {
305
+ $additional_information['billing_agreement_id'] = $this->getAmazonBillingAgreementId();
306
+ $additional_information['billing_agreement_consent'] = $this->getAmazonBillingAgreementConsent();
307
+ }
308
+ else {
309
+ $additional_information['order_reference'] = $this->getAmazonOrderReferenceId();
310
+ }
311
 
312
  if ($this->getRequest()->getPost('sandbox')) {
313
  $additional_information['sandbox'] = $this->getRequest()->getPost('sandbox');
377
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
378
  }
379
 
380
+ /**
381
+ * Initialize coupon
382
+ */
383
+ public function couponPostAction()
384
+ {
385
+
386
+ $couponCode = (string) $this->getRequest()->getParam('coupon_code');
387
+ if ($this->getRequest()->getParam('remove') == 1) {
388
+ $couponCode = '';
389
+ }
390
+ $oldCouponCode = $this->_getQuote()->getCouponCode();
391
+
392
+ try {
393
+ $codeLength = strlen($couponCode);
394
+ $isCodeLengthValid = $codeLength && $codeLength <= Mage_Checkout_Helper_Cart::COUPON_CODE_MAX_LENGTH;
395
+
396
+ $this->_getQuote()->getShippingAddress()->setCollectShippingRates(true);
397
+ $this->_getQuote()->setCouponCode($isCodeLengthValid ? $couponCode : '')
398
+ ->collectTotals()
399
+ ->save();
400
+
401
+ if ($codeLength) {
402
+ if ($isCodeLengthValid && $couponCode == $this->_getQuote()->getCouponCode()) {
403
+ $this->_getSession()->addSuccess(
404
+ $this->__('Coupon code "%s" was applied.', Mage::helper('core')->escapeHtml($couponCode))
405
+ );
406
+ } else {
407
+ $this->_getSession()->addError(
408
+ $this->__('Coupon code "%s" is not valid.', Mage::helper('core')->escapeHtml($couponCode))
409
+ );
410
+ }
411
+ } else {
412
+ $this->_getSession()->addSuccess($this->__('Coupon code was canceled.'));
413
+ }
414
+
415
+ } catch (Mage_Core_Exception $e) {
416
+ $this->_getSession()->addError($e->getMessage());
417
+ } catch (Exception $e) {
418
+ $this->_getSession()->addError($this->__('Cannot apply the coupon code.'));
419
+ Mage::logException($e);
420
+ }
421
+
422
+ $this->_redirect($this->_checkoutUrl);
423
+ }
424
+
425
+ /**
426
+ * Get checkout session model instance
427
+ *
428
+ * @return Mage_Checkout_Model_Session
429
+ */
430
+ protected function _getSession()
431
+ {
432
+ return Mage::getSingleton('checkout/session');
433
+ }
434
+
435
+ /**
436
+ * Get current active quote instance
437
+ *
438
+ * @return Mage_Sales_Model_Quote
439
+ */
440
+ protected function _getQuote()
441
+ {
442
+ return $this->_getCart()->getQuote();
443
+ }
444
 
445
+ /**
446
+ * Retrieve shopping cart model object
447
+ *
448
+ * @return Mage_Checkout_Model_Cart
449
+ */
450
+ protected function _getCart()
451
+ {
452
+ return Mage::getSingleton('checkout/cart');
453
+ }
454
 
455
  /**
456
  * Create invoice
482
  return $this->getLayout()->getBlock('root')->toHtml();
483
  }
484
 
485
+ /**
486
+ * Render block HTML
487
+ *
488
+ * @string $node block name
489
+ */
490
+ protected function _getBlockHtml($node)
491
+ {
492
+ $cache = Mage::app()->getCacheInstance();
493
+ $cache->banUse('layout');
494
+
495
+ $layout = $this->getLayout();
496
+ $update = $layout->getUpdate();
497
+ $update->load($node);
498
+ $layout->generateXml();
499
+ $layout->generateBlocks();
500
+ return $layout->getOutput();
501
+ }
502
+
503
  }
504
 
app/code/community/Amazon/Payments/controllers/CustomerController.php CHANGED
@@ -32,7 +32,7 @@ class Amazon_Payments_CustomerController extends Mage_Core_Controller_Front_Acti
32
  }
33
  // Login failed
34
  else {
35
- Mage::getSingleton('customer/session')->addError('Unable to log in with Amazon.');
36
 
37
  if ($referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME)) {
38
  $referer = Mage::helper('core')->urlDecode($referer);
@@ -43,7 +43,7 @@ class Amazon_Payments_CustomerController extends Mage_Core_Controller_Front_Acti
43
  }
44
  // Error
45
  else if ($error = $this->getRequest()->getParam('error_description')) {
46
- Mage::getSingleton('customer/session')->addError('Unable to log in with Amazon: ' . htmlspecialchars($error));
47
  $this->_redirectUrl(Mage::getUrl(''));
48
  }
49
  // Non-popup/full-page redirect login requires JavaScript
32
  }
33
  // Login failed
34
  else {
35
+ Mage::getSingleton('customer/session')->addError(Mage::helper('amazon_payments')->__('Unable to log in with Amazon'));
36
 
37
  if ($referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME)) {
38
  $referer = Mage::helper('core')->urlDecode($referer);
43
  }
44
  // Error
45
  else if ($error = $this->getRequest()->getParam('error_description')) {
46
+ Mage::getSingleton('customer/session')->addError(Mage::helper('amazon_payments')->__('Unable to log in with Amazon') . ': ' . htmlspecialchars($error));
47
  $this->_redirectUrl(Mage::getUrl(''));
48
  }
49
  // Non-popup/full-page redirect login requires JavaScript
app/code/community/Amazon/Payments/controllers/IndexController.php CHANGED
@@ -18,5 +18,4 @@ class Amazon_Payments_IndexController extends Mage_Core_Controller_Front_Action
18
  {
19
 
20
  }
21
-
22
  }
18
  {
19
 
20
  }
 
21
  }
app/code/community/Amazon/Payments/controllers/OnepageController.php CHANGED
@@ -39,6 +39,8 @@ class Amazon_Payments_OnepageController extends Amazon_Payments_Controller_Check
39
  'method' => 'amazon_payments',
40
  'additional_information' => array(
41
  'order_reference' => $this->getAmazonOrderReferenceId(),
 
 
42
  )
43
  ));
44
 
@@ -72,6 +74,12 @@ class Amazon_Payments_OnepageController extends Amazon_Payments_Controller_Check
72
  ->save();
73
  }
74
 
 
 
 
 
 
 
75
  }
76
  // Catch any API errors like invalid keys
77
  catch (Exception $e) {
39
  'method' => 'amazon_payments',
40
  'additional_information' => array(
41
  'order_reference' => $this->getAmazonOrderReferenceId(),
42
+ 'billing_agreement_id' => $this->getAmazonBillingAgreementId(),
43
+ 'billing_agreement_consent' => $this->getAmazonBillingAgreementConsent(),
44
  )
45
  ));
46
 
74
  ->save();
75
  }
76
 
77
+ // Validate country
78
+ if (!$this->isCountryAllowed($this->_getCheckout()->getQuote()->getShippingAddress()->getCountry())) {
79
+ $result['error'] = true;
80
+ $result['message'] = $this->__('This order cannot be shipped to the selected country. Please use a different shipping address.');
81
+ }
82
+
83
  }
84
  // Catch any API errors like invalid keys
85
  catch (Exception $e) {
app/code/community/Amazon/Payments/controllers/OrderController.php CHANGED
@@ -35,11 +35,11 @@ class Amazon_Payments_OrderController extends Mage_Core_Controller_Front_Action
35
  // Re-authorize
36
  Mage::getModel('amazon_payments/async')->syncOrderStatus($order, true);
37
 
38
- Mage::getSingleton('core/session')->addSuccess('Thank you for updating your payment method.');
39
 
40
  }
41
  catch (Exception $e) {
42
- Mage::getSingleton('core/session')->addError('Please try another payment method.');
43
  Mage::logException($e);
44
  }
45
  }
35
  // Re-authorize
36
  Mage::getModel('amazon_payments/async')->syncOrderStatus($order, true);
37
 
38
+ Mage::getSingleton('core/session')->addSuccess(Mage::helper('checkout')->__('Thank you for updating your payment method.'));
39
 
40
  }
41
  catch (Exception $e) {
42
+ Mage::getSingleton('core/session')->addError(Mage::helper('checkout')->__('Please try another payment method.'));
43
  Mage::logException($e);
44
  }
45
  }
app/code/community/Amazon/Payments/controllers/TokenController.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Amazon Payments
4
+ *
5
+ * @category Amazon
6
+ * @package Amazon_Payments
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_Payments_TokenController extends Mage_Core_Controller_Front_Action
12
+ {
13
+
14
+ /**
15
+ * Display Ajax cart
16
+ */
17
+ public function ajaxcartAction()
18
+ {
19
+ header('X-Frame-Options: ALLOW-FROM ' . Mage::getBaseUrl());
20
+
21
+ $this->loadLayout();
22
+ $this->renderLayout();
23
+ }
24
+
25
+ /**
26
+ * Token checkout
27
+ */
28
+ public function checkoutAction()
29
+ {
30
+ header('Access-Control-Allow-Origin: ' . Mage::getUrl('',array('_secure'=>true)));
31
+ header('Access-Control-Allow-Methods: GET, POST');
32
+ header('Access-Control-Allow-Headers: Content-Type');
33
+
34
+
35
+ $redirectUrl = Mage::getUrl('checkout/onepage/success');
36
+
37
+
38
+ $token = Mage::getModel('amazon_payments/token')->getBillingAgreement();
39
+
40
+ if ($amazonBillingAgreementId = $token->getAmazonBillingAgreementId()) {
41
+ $_api = Mage::getModel('amazon_payments/api');
42
+
43
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
44
+
45
+ $quote->setSendCconfirmation(1);
46
+
47
+ $orderDetails = $_api->getBillingAgreementDetails($amazonBillingAgreementId, Mage::getSingleton('checkout/session')->getAmazonAccessToken());
48
+
49
+ $address = $orderDetails->getDestination()->getPhysicalDestination();
50
+
51
+ // Split name into first/last
52
+ $name = $address->getName();
53
+ $firstName = substr($name, 0, strrpos($name, ' '));
54
+ $lastName = substr($name, strlen($firstName) + 1);
55
+
56
+ // Find Mage state/region ID
57
+ $regionModel = Mage::getModel('directory/region')->loadByCode($address->getStateOrRegion(), $address->getCountryCode());
58
+ $regionId = $regionModel->getId();
59
+
60
+ $data = array(
61
+ 'customer_address_id' => '',
62
+ 'firstname' => $firstName,
63
+ 'lastname' => $lastName,
64
+ //'street' => array($address->getAddressLine1(), $address->getAddressLine2()),
65
+ 'street' => $address->getAddressLine1(),
66
+ 'city' => $address->getCity(),
67
+ 'region_id' => $regionId,
68
+ 'postcode' => $address->getPostalCode(),
69
+ 'country_id' => $address->getCountryCode(),
70
+ 'telephone' => ($address->getPhone()) ? $address->getPhone() : '-', // Mage requires phone number
71
+ 'use_for_shipping' => true,
72
+ );
73
+
74
+ if ($email = Mage::getSingleton('checkout/session')->getCustomerEmail()) {
75
+ $data['email'] = $email;
76
+ }
77
+
78
+
79
+ $quote->getBillingAddress()->addData($data);
80
+ $shippingAddress = $quote->getShippingAddress()->addData($data);
81
+
82
+ // Collect Rates and Set Shipping & Payment Method
83
+ $shippingAddress->setCollectShippingRates(true)
84
+ ->collectShippingRates()
85
+ ->setShippingMethod($token->getShippingMethod())
86
+ ->setPaymentMethod('amazon_payments');
87
+
88
+ // Set Sales Order Payment
89
+ $quote->getPayment()->importData(array(
90
+ 'method' => 'amazon_payments',
91
+ 'additional_information' => array(
92
+ 'order_reference' => $amazonBillingAgreementId,
93
+ 'billing_agreement_id' => $amazonBillingAgreementId,
94
+ ),
95
+ ));
96
+
97
+ // Collect Totals & Save Quote
98
+ $quote->collectTotals()->save();
99
+
100
+ // Create Order From Quote
101
+ $service = Mage::getModel('sales/service_quote', $quote);
102
+
103
+ try {
104
+ $service->submitAll();
105
+
106
+ $order = $service->getOrder();
107
+
108
+ // Set checkout session values for success page
109
+ Mage::getSingleton('checkout/session')->setLastQuoteId($quote->getId())
110
+ ->setLastSuccessQuoteId($quote->getId())
111
+ ->setLastOrderId($order->getId())
112
+ ->setRedirectUrl($redirectUrl)
113
+ ->setLastRealOrderId($order->getIncrementId())
114
+ ;
115
+
116
+ // Clear cart
117
+ foreach($quote->getItemsCollection() as $item){
118
+ Mage::getSingleton('checkout/cart')->removeItem($item->getId())->save();
119
+ }
120
+
121
+ }
122
+ catch (Exception $e) {
123
+ $redirectUrl = Mage::helper('core/http')->getHttpReferer() ? Mage::helper('core/http')->getHttpReferer() : Mage::getUrl();
124
+ Mage::getSingleton('core/session')->addError($e->getMessage());
125
+
126
+ if (strpos($redirectUrl, 'ajaxcart') !== false) {
127
+ $redirectUrl = Mage::getUrl();
128
+ }
129
+ }
130
+
131
+ // Use JS to redirect from ajaxcart modal
132
+ $this->getResponse()->setHeader('Content-Type', 'text/html')
133
+ ->setBody("<script>window.top.location.href = '$redirectUrl';</script>");
134
+
135
+ }
136
+
137
+
138
+ }
139
+
140
+ }
app/code/community/Amazon/Payments/etc/config.xml CHANGED
@@ -10,7 +10,7 @@
10
  <config>
11
  <modules>
12
  <Amazon_Payments>
13
- <version>1.4.0</version>
14
  </Amazon_Payments>
15
  <Amazon_Login>
16
  <!-- Disable legacy module -->
@@ -34,6 +34,9 @@
34
  <login>
35
  <table>amazon_login</table>
36
  </login>
 
 
 
37
  </entities>
38
  </login_mysql4>
39
  <sales>
@@ -77,6 +80,16 @@
77
  <use>core_setup</use>
78
  </connection>
79
  </payments_setup>
 
 
 
 
 
 
 
 
 
 
80
  </resources>
81
  </global>
82
  <admin>
@@ -99,6 +112,15 @@
99
  </tax>
100
  </updates>
101
  </layout>
 
 
 
 
 
 
 
 
 
102
  <events>
103
  <adminhtml_widget_container_html_before>
104
  <observers>
@@ -127,6 +149,8 @@
127
  <amazon_checkout>/amazon_payments/checkout</amazon_checkout>
128
  <simplepath>/amazon_payments/simplepath</simplepath>
129
  <amazon_login_verify>/amazon_payments/customer/verify</amazon_login_verify>
 
 
130
  </secure_url>
131
  <routers>
132
  <amazon_payments>
@@ -137,6 +161,15 @@
137
  </args>
138
  </amazon_payments>
139
  </routers>
 
 
 
 
 
 
 
 
 
140
  <layout>
141
  <updates>
142
  <amazon_payments>
@@ -169,6 +202,14 @@
169
  </amazon_payments_observer>
170
  </observers>
171
  </controller_action_predispatch_checkout_cart_index>
 
 
 
 
 
 
 
 
172
  <custom_quote_process>
173
  <observers>
174
  <amazon_payments_observer>
@@ -189,18 +230,21 @@
189
  <show_pay_cart>1</show_pay_cart>
190
  <order_status>processing</order_status>
191
  <active>1</active>
 
192
  <secure_cart>1</secure_cart>
193
  <button_type>PwA</button_type>
194
  <button_color>Gold</button_color>
195
  <button_size>medium</button_size>
196
  <button_badge>1</button_badge>
197
  <popup>1</popup>
 
198
  <access_secret backend_model="adminhtml/system_config_backend_encrypted" />
199
  <client_secret backend_model="adminhtml/system_config_backend_encrypted" />
200
  </amazon_payments>
201
  </payment>
202
  <amazon_login>
203
  <settings>
 
204
  <popup>1</popup>
205
  </settings>
206
  </amazon_login>
@@ -213,4 +257,4 @@
213
  </amazon_payments_async>
214
  </jobs>
215
  </crontab>
216
- </config>
10
  <config>
11
  <modules>
12
  <Amazon_Payments>
13
+ <version>1.4.4</version>
14
  </Amazon_Payments>
15
  <Amazon_Login>
16
  <!-- Disable legacy module -->
34
  <login>
35
  <table>amazon_login</table>
36
  </login>
37
+ <token>
38
+ <table>amazon_payments_token</table>
39
+ </token>
40
  </entities>
41
  </login_mysql4>
42
  <sales>
80
  <use>core_setup</use>
81
  </connection>
82
  </payments_setup>
83
+ <payments_write>
84
+ <connection>
85
+ <use>core_write</use>
86
+ </connection>
87
+ </payments_write>
88
+ <payments_read>
89
+ <connection>
90
+ <use>core_read</use>
91
+ </connection>
92
+ </payments_read>
93
  </resources>
94
  </global>
95
  <admin>
112
  </tax>
113
  </updates>
114
  </layout>
115
+ <translate>
116
+ <modules>
117
+ <Amazon_Payments>
118
+ <files>
119
+ <default>Amazon_Payments.csv</default>
120
+ </files>
121
+ </Amazon_Payments>
122
+ </modules>
123
+ </translate>
124
  <events>
125
  <adminhtml_widget_container_html_before>
126
  <observers>
149
  <amazon_checkout>/amazon_payments/checkout</amazon_checkout>
150
  <simplepath>/amazon_payments/simplepath</simplepath>
151
  <amazon_login_verify>/amazon_payments/customer/verify</amazon_login_verify>
152
+ <amazon_ajaxcart>/amazon_payments/token/ajaxcart</amazon_ajaxcart>
153
+ <amazon_token_checkout>/amazon_payments/token/checkout</amazon_token_checkout>
154
  </secure_url>
155
  <routers>
156
  <amazon_payments>
161
  </args>
162
  </amazon_payments>
163
  </routers>
164
+ <translate>
165
+ <modules>
166
+ <Amazon_Payments>
167
+ <files>
168
+ <default>Amazon_Payments.csv</default>
169
+ </files>
170
+ </Amazon_Payments>
171
+ </modules>
172
+ </translate>
173
  <layout>
174
  <updates>
175
  <amazon_payments>
202
  </amazon_payments_observer>
203
  </observers>
204
  </controller_action_predispatch_checkout_cart_index>
205
+ <controller_response_redirect>
206
+ <observers>
207
+ <amazon_payments_observer>
208
+ <class>Amazon_Payments_Model_Observer_Action</class>
209
+ <method>responseRedirect</method>
210
+ </amazon_payments_observer>
211
+ </observers>
212
+ </controller_response_redirect>
213
  <custom_quote_process>
214
  <observers>
215
  <amazon_payments_observer>
230
  <show_pay_cart>1</show_pay_cart>
231
  <order_status>processing</order_status>
232
  <active>1</active>
233
+ <region>us</region>
234
  <secure_cart>1</secure_cart>
235
  <button_type>PwA</button_type>
236
  <button_color>Gold</button_color>
237
  <button_size>medium</button_size>
238
  <button_badge>1</button_badge>
239
  <popup>1</popup>
240
+ <show_coupon>1</show_coupon>
241
  <access_secret backend_model="adminhtml/system_config_backend_encrypted" />
242
  <client_secret backend_model="adminhtml/system_config_backend_encrypted" />
243
  </amazon_payments>
244
  </payment>
245
  <amazon_login>
246
  <settings>
247
+ <enabled>1</enabled>
248
  <popup>1</popup>
249
  </settings>
250
  </amazon_login>
257
  </amazon_payments_async>
258
  </jobs>
259
  </crontab>
260
+ </config>
app/code/community/Amazon/Payments/etc/system.xml CHANGED
@@ -25,10 +25,8 @@
25
 
26
  <comment>
27
  <![CDATA[
28
- Login and Pay with Amazon helps you increase conversation, reduce fraud, acquire new customers and build loyalty. <a href="https://payments.amazon.com/" target="_blank">Learn More.</a>
29
  <br /><br />
30
-
31
-
32
  <div id="amazon_simplepath">
33
  <span style="display:inline-block;padding-bottom:1em;">
34
  <button><span>Get started with account registration</span></button>
@@ -55,19 +53,16 @@
55
 
56
  <strong>Steps to Launch Login and Pay with Amazon</strong>
57
  <ol style="list-style:inside decimal;">
58
- <li>Register through our custom <a href="https://sellercentral.amazon.com/hz/me/sp/signup?solutionProviderOptions=lwa%3Bmws-acc%3B&marketplaceId=AGWSWK15IEJJ7&solutionProviderToken=AAAAAQAAAAEAAAAQCz2wulRfR9nOADyzVQrq5wAAAHAIIULh6RBNvlw68WY5S9ATlmInlyg2PLVF44yUVowkyjvDZPhtLf3UYn6fshHlKqwR4qptfBeltbxLtLrrIfK6JoxzuWe9FRTnCfSey8a0sFKuL3mwNenjLyMC9BAN1xU0S6pebxA2mz8t8Y1v5Axi&solutionProviderId=A2K7HE1S3M5XJ" target="_blank">Magento registration</a> or visit <a href="https://payments.amazon.com/signup" target="_blank">https://payments.amazon.com/signup</a>
59
  <!--
60
  Register or login to retrieve your account keys: &nbsp<button onclick="javascript:window.open(&#39;&#39;, &#39;get_keys&#39,&#39;left=50, top=50, width=950, height=750&#39;); return false;" class="scalable" type="button"><span>Login to Get Your Keys</span></button></span></button>
61
  -->
62
 
63
 
64
- <li>Visit <a href="https://sellercentral.amazon.com/" target="_blank">Amazon Seller Central</a> and Configure OAuth "Allowed Javascript Origins" in your Login with Amazon settings.
65
  <li>Under General->Web, enable "Use Secure URLs in Frontend." (HTTPS is required.)
66
  </ol>
67
  </div>
68
-
69
-
70
-
71
  <div style="clear:both;"></div>
72
  ]]>
73
  </comment>
@@ -77,26 +72,26 @@
77
 
78
 
79
  <enabled translate="label">
80
- <label>Enabled</label>
81
- <frontend_type>select</frontend_type>
82
- <source_model>adminhtml/system_config_source_yesno</source_model>
83
- <backend_model>amazon_payments/system_config_backend_enabled</backend_model>
84
- <comment><model>amazon_payments/system_config_backend_enabled</model></comment>
85
- <sort_order>5</sort_order>
86
- <show_in_default>1</show_in_default>
87
- <show_in_website>1</show_in_website>
88
- <show_in_store>0</show_in_store>
89
  </enabled>
90
 
91
  <ap_credentials type="group" translate="label">
92
  <label>Credentials</label>
93
  <show_in_default>1</show_in_default>
94
  <show_in_website>1</show_in_website>
 
95
  <expanded>1</expanded>
96
  <frontend_model>adminhtml/system_config_form_fieldset</frontend_model>
97
  <sort_order>10</sort_order>
98
  <fields>
99
-
100
  <simplepath_import_button>
101
  <frontend_type>button</frontend_type>
102
  <frontend_model>amazon_payments/adminhtml_system_config_simplepathimport</frontend_model>
@@ -121,7 +116,7 @@
121
  <sort_order>15</sort_order>
122
  <show_in_default>1</show_in_default>
123
  <show_in_website>1</show_in_website>
124
- <show_in_store>0</show_in_store>
125
  <config_path>payment/amazon_payments/seller_id</config_path>
126
  </seller_id>
127
  <access_key translate="label">
@@ -130,7 +125,7 @@
130
  <sort_order>20</sort_order>
131
  <show_in_default>1</show_in_default>
132
  <show_in_website>1</show_in_website>
133
- <show_in_store>0</show_in_store>
134
  <config_path>payment/amazon_payments/access_key</config_path>
135
  </access_key>
136
  <access_secret translate="label">
@@ -139,7 +134,7 @@
139
  <sort_order>30</sort_order>
140
  <show_in_default>1</show_in_default>
141
  <show_in_website>1</show_in_website>
142
- <show_in_store>0</show_in_store>
143
  <config_path>payment/amazon_payments/access_secret</config_path>
144
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
145
  </access_secret>
@@ -149,7 +144,7 @@
149
  <sort_order>31</sort_order>
150
  <show_in_default>1</show_in_default>
151
  <show_in_website>1</show_in_website>
152
- <show_in_store>0</show_in_store>
153
  <config_path>payment/amazon_payments/client_id</config_path>
154
  </client_id>
155
  <client_secret translate="label">
@@ -158,11 +153,10 @@
158
  <sort_order>32</sort_order>
159
  <show_in_default>1</show_in_default>
160
  <show_in_website>1</show_in_website>
161
- <show_in_store>0</show_in_store>
162
  <config_path>payment/amazon_payments/client_secret</config_path>
163
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
164
  </client_secret>
165
-
166
  <sandbox translate="label">
167
  <label>Sandbox Mode</label>
168
  <frontend_type>select</frontend_type>
@@ -170,25 +164,44 @@
170
  <sort_order>510</sort_order>
171
  <show_in_default>1</show_in_default>
172
  <show_in_website>1</show_in_website>
173
- <show_in_store>0</show_in_store>
174
  <config_path>payment/amazon_payments/sandbox</config_path>
175
  </sandbox>
 
 
176
 
177
- <!--
 
 
 
 
 
 
 
178
  <region translate="label">
179
- <label>API Region</label>
180
  <frontend_type>select</frontend_type>
181
  <source_model>amazon_payments/system_config_source_region</source_model>
182
- <sort_order>35</sort_order>
 
183
  <show_in_default>1</show_in_default>
184
  <show_in_website>1</show_in_website>
185
  <show_in_store>1</show_in_store>
186
- <config_path>payment/amazon_payments/region</config_path>
187
  </region>
188
- -->
189
-
 
 
 
 
 
 
 
 
190
  </fields>
191
- </ap_credentials>
 
192
 
193
  <ap_checkout type="group" translate="label">
194
  <label>Checkout Style</label>
@@ -250,6 +263,26 @@
250
  <depends><use_in_checkout>1</use_in_checkout></depends>
251
  <config_path>payment/amazon_payments/sort_order</config_path>
252
  </sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  <buttons type="group" translate="label">
254
  <label>Button Styles</label>
255
  <show_in_default>1</show_in_default>
@@ -307,6 +340,17 @@
307
  <show_in_store>1</show_in_store>
308
  <sort_order>210</sort_order>
309
  <fields>
 
 
 
 
 
 
 
 
 
 
 
310
  <popup translate="label">
311
  <label>Pop-up</label>
312
  <comment>
@@ -387,11 +431,22 @@
387
  <frontend_type>text</frontend_type>
388
  <comment><![CDATA[Store name to display in Amazon emails. If left blank, current Magento store name will be used.]]></comment>
389
  <sort_order>150</sort_order>
390
- <show_in_default>0</show_in_default>
391
  <show_in_website>1</show_in_website>
392
  <show_in_store>1</show_in_store>
393
  <config_path>payment/amazon_payments/store_name</config_path>
394
  </store_name>
 
 
 
 
 
 
 
 
 
 
 
395
 
396
  <ap_advanced type="group" translate="label">
397
  <label>Advanced Transaction Options</label>
@@ -411,6 +466,45 @@
411
  <show_in_store>0</show_in_store>
412
  <config_path>payment/amazon_payments/is_async</config_path>
413
  </is_async>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
414
  </fields>
415
  </ap_advanced>
416
  </fields>
@@ -463,7 +557,6 @@
463
  </fields>
464
  </ap_developer>
465
 
466
-
467
  </fields>
468
  </amazon_payments>
469
  </groups>
25
 
26
  <comment>
27
  <![CDATA[
28
+ Login and Pay with Amazon helps you increase conversation, reduce fraud, acquire new customers and build loyalty. <a href="https://payments.amazon.com/" target="_blank" class="amzn-signup">Learn More.</a>
29
  <br /><br />
 
 
30
  <div id="amazon_simplepath">
31
  <span style="display:inline-block;padding-bottom:1em;">
32
  <button><span>Get started with account registration</span></button>
53
 
54
  <strong>Steps to Launch Login and Pay with Amazon</strong>
55
  <ol style="list-style:inside decimal;">
56
+ <li>Register through our custom <a href="https://sellercentral.amazon.com/hz/me/sp/signup?solutionProviderOptions=lwa%3Bmws-acc%3B&marketplaceId=AGWSWK15IEJJ7&solutionProviderToken=AAAAAQAAAAEAAAAQCz2wulRfR9nOADyzVQrq5wAAAHAIIULh6RBNvlw68WY5S9ATlmInlyg2PLVF44yUVowkyjvDZPhtLf3UYn6fshHlKqwR4qptfBeltbxLtLrrIfK6JoxzuWe9FRTnCfSey8a0sFKuL3mwNenjLyMC9BAN1xU0S6pebxA2mz8t8Y1v5Axi&solutionProviderId=A2K7HE1S3M5XJ" target="_blank" class="amzn-link">Magento registration</a> <span class="amzn-us-signup">or visit <a href="https://payments.amazon.com/signup" target="_blank" class="amzn-link">https://payments.amazon.com/signup</a></span>
57
  <!--
58
  Register or login to retrieve your account keys: &nbsp<button onclick="javascript:window.open(&#39;&#39;, &#39;get_keys&#39,&#39;left=50, top=50, width=950, height=750&#39;); return false;" class="scalable" type="button"><span>Login to Get Your Keys</span></button></span></button>
59
  -->
60
 
61
 
62
+ <li>Visit <a href="https://sellercentral.amazon.com/" target="_blank" class="amzn-link">Amazon Seller Central</a> and Configure OAuth "Allowed Javascript Origins" in your Login with Amazon settings.
63
  <li>Under General->Web, enable "Use Secure URLs in Frontend." (HTTPS is required.)
64
  </ol>
65
  </div>
 
 
 
66
  <div style="clear:both;"></div>
67
  ]]>
68
  </comment>
72
 
73
 
74
  <enabled translate="label">
75
+ <label>Enabled</label>
76
+ <frontend_type>select</frontend_type>
77
+ <source_model>adminhtml/system_config_source_yesno</source_model>
78
+ <backend_model>amazon_payments/system_config_backend_enabled</backend_model>
79
+ <comment><model>amazon_payments/system_config_backend_enabled</model></comment>
80
+ <sort_order>0</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>1</show_in_store>
84
  </enabled>
85
 
86
  <ap_credentials type="group" translate="label">
87
  <label>Credentials</label>
88
  <show_in_default>1</show_in_default>
89
  <show_in_website>1</show_in_website>
90
+ <show_in_store>1</show_in_store>
91
  <expanded>1</expanded>
92
  <frontend_model>adminhtml/system_config_form_fieldset</frontend_model>
93
  <sort_order>10</sort_order>
94
  <fields>
 
95
  <simplepath_import_button>
96
  <frontend_type>button</frontend_type>
97
  <frontend_model>amazon_payments/adminhtml_system_config_simplepathimport</frontend_model>
116
  <sort_order>15</sort_order>
117
  <show_in_default>1</show_in_default>
118
  <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
  <config_path>payment/amazon_payments/seller_id</config_path>
121
  </seller_id>
122
  <access_key translate="label">
125
  <sort_order>20</sort_order>
126
  <show_in_default>1</show_in_default>
127
  <show_in_website>1</show_in_website>
128
+ <show_in_store>1</show_in_store>
129
  <config_path>payment/amazon_payments/access_key</config_path>
130
  </access_key>
131
  <access_secret translate="label">
134
  <sort_order>30</sort_order>
135
  <show_in_default>1</show_in_default>
136
  <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
  <config_path>payment/amazon_payments/access_secret</config_path>
139
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
140
  </access_secret>
144
  <sort_order>31</sort_order>
145
  <show_in_default>1</show_in_default>
146
  <show_in_website>1</show_in_website>
147
+ <show_in_store>1</show_in_store>
148
  <config_path>payment/amazon_payments/client_id</config_path>
149
  </client_id>
150
  <client_secret translate="label">
153
  <sort_order>32</sort_order>
154
  <show_in_default>1</show_in_default>
155
  <show_in_website>1</show_in_website>
156
+ <show_in_store>1</show_in_store>
157
  <config_path>payment/amazon_payments/client_secret</config_path>
158
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
159
  </client_secret>
 
160
  <sandbox translate="label">
161
  <label>Sandbox Mode</label>
162
  <frontend_type>select</frontend_type>
164
  <sort_order>510</sort_order>
165
  <show_in_default>1</show_in_default>
166
  <show_in_website>1</show_in_website>
167
+ <show_in_store>1</show_in_store>
168
  <config_path>payment/amazon_payments/sandbox</config_path>
169
  </sandbox>
170
+ </fields>
171
+ </ap_credentials>
172
 
173
+ <!-- BEGIN EU REGION -->
174
+ <ap_region type="group" translate="label">
175
+ <label>Region</label>
176
+ <show_in_default>1</show_in_default>
177
+ <show_in_website>1</show_in_website>
178
+ <frontend_model>adminhtml/system_config_form_fieldset</frontend_model>
179
+ <sort_order>15</sort_order>
180
+ <fields>
181
  <region translate="label">
182
+ <label>Region</label>
183
  <frontend_type>select</frontend_type>
184
  <source_model>amazon_payments/system_config_source_region</source_model>
185
+ <comment><model>amazon_payments/system_config_backend_localizecomment</model></comment>
186
+ <sort_order>10</sort_order>
187
  <show_in_default>1</show_in_default>
188
  <show_in_website>1</show_in_website>
189
  <show_in_store>1</show_in_store>
190
+ <config_path>amazon_login/settings/region</config_path>
191
  </region>
192
+ <!--language translate="label">
193
+ <label>Language</label>
194
+ <comment><![CDATA[You can chanage the language of the button and widgets here. The default language is your store's locale. EX: US = 'en_US'. More information can be found <a href="https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950" target="_blank" class="amzn-doc-link">here</a>.]]></comment>
195
+ <frontend_type>text</frontend_type>
196
+ <sort_order>20</sort_order>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_website>1</show_in_website>
199
+ <show_in_store>1</show_in_store>
200
+ <config_path>amazon_login/settings/language</config_path>
201
+ </language-->
202
  </fields>
203
+ </ap_region>
204
+ <!-- END EU REGION -->
205
 
206
  <ap_checkout type="group" translate="label">
207
  <label>Checkout Style</label>
263
  <depends><use_in_checkout>1</use_in_checkout></depends>
264
  <config_path>payment/amazon_payments/sort_order</config_path>
265
  </sort_order>
266
+ <show_in_minicart translate="label">
267
+ <label>Show in Minicart</label>
268
+ <frontend_type>select</frontend_type>
269
+ <source_model>adminhtml/system_config_source_yesno</source_model>
270
+ <sort_order>195</sort_order>
271
+ <show_in_default>1</show_in_default>
272
+ <show_in_website>1</show_in_website>
273
+ <show_in_store>1</show_in_store>
274
+ <config_path>payment/amazon_payments/show_in_minicart</config_path>
275
+ </show_in_minicart>
276
+ <show_coupon translate="label">
277
+ <label>Show Coupon/Discount Code</label>
278
+ <frontend_type>select</frontend_type>
279
+ <source_model>adminhtml/system_config_source_yesno</source_model>
280
+ <sort_order>195</sort_order>
281
+ <show_in_default>1</show_in_default>
282
+ <show_in_website>1</show_in_website>
283
+ <show_in_store>1</show_in_store>
284
+ <config_path>payment/amazon_payments/show_coupon</config_path>
285
+ </show_coupon>
286
  <buttons type="group" translate="label">
287
  <label>Button Styles</label>
288
  <show_in_default>1</show_in_default>
340
  <show_in_store>1</show_in_store>
341
  <sort_order>210</sort_order>
342
  <fields>
343
+ <enabled translate="label">
344
+ <label>Enabled</label>
345
+ <frontend_type>select</frontend_type>
346
+ <source_model>adminhtml/system_config_source_yesno</source_model>
347
+ <comment><![CDATA[Display "Login with Amazon" button on account pages and auto-create Magento accounts during checkout.]]></comment>
348
+ <sort_order>30</sort_order>
349
+ <show_in_default>1</show_in_default>
350
+ <show_in_website>1</show_in_website>
351
+ <show_in_store>0</show_in_store>
352
+ <config_path>amazon_login/settings/enabled</config_path>
353
+ </enabled>
354
  <popup translate="label">
355
  <label>Pop-up</label>
356
  <comment>
431
  <frontend_type>text</frontend_type>
432
  <comment><![CDATA[Store name to display in Amazon emails. If left blank, current Magento store name will be used.]]></comment>
433
  <sort_order>150</sort_order>
434
+ <show_in_default>1</show_in_default>
435
  <show_in_website>1</show_in_website>
436
  <show_in_store>1</show_in_store>
437
  <config_path>payment/amazon_payments/store_name</config_path>
438
  </store_name>
439
+ <soft_descriptor translate="label">
440
+ <label>Soft Descriptor</label>
441
+ <frontend_type>text</frontend_type>
442
+ <comment><![CDATA[Billing descriptor to display on credit card statements. Limited to 16 characters. If left blank, current Magento store name will be used.]]></comment>
443
+ <validate>validate-length maximum-length-16</validate>
444
+ <sort_order>160</sort_order>
445
+ <show_in_default>1</show_in_default>
446
+ <show_in_website>1</show_in_website>
447
+ <show_in_store>1</show_in_store>
448
+ <config_path>payment/amazon_payments/soft_descriptor</config_path>
449
+ </soft_descriptor>
450
 
451
  <ap_advanced type="group" translate="label">
452
  <label>Advanced Transaction Options</label>
466
  <show_in_store>0</show_in_store>
467
  <config_path>payment/amazon_payments/is_async</config_path>
468
  </is_async>
469
+
470
+ <token_enabled translate="label">
471
+ <label>Enable Tokenized Payments</label>
472
+ <comment><![CDATA[Pre-authorizes payments for future purchases through a billing agreement, limited at $500 per month per token. If you require a higher limit, please contact an Amazon account manager.]]></comment>
473
+ <frontend_type>select</frontend_type>
474
+ <source_model>adminhtml/system_config_source_yesno</source_model>
475
+ <sort_order>210</sort_order>
476
+ <show_in_default>1</show_in_default>
477
+ <show_in_website>1</show_in_website>
478
+ <show_in_store>0</show_in_store>
479
+ <config_path>payment/amazon_payments/token_enabled</config_path>
480
+ </token_enabled>
481
+
482
+ <token_required translate="label">
483
+ <label>Require Tokenized Payments for Purchases</label>
484
+ <comment><![CDATA[Require user to agree to billing agreement before completing their purchase.]]></comment>
485
+ <frontend_type>select</frontend_type>
486
+ <source_model>adminhtml/system_config_source_yesno</source_model>
487
+ <sort_order>220</sort_order>
488
+ <show_in_default>1</show_in_default>
489
+ <show_in_website>1</show_in_website>
490
+ <show_in_store>0</show_in_store>
491
+ <depends><token_enabled>1</token_enabled></depends>
492
+ <config_path>payment/amazon_payments/token_required</config_path>
493
+ </token_required>
494
+
495
+ <token_delayed translate="label">
496
+ <label>Allow Pre-Orders</label>
497
+ <comment><![CDATA[Delay payment authorization and capture until invoice is created.]]></comment>
498
+ <frontend_type>select</frontend_type>
499
+ <source_model>adminhtml/system_config_source_yesno</source_model>
500
+ <sort_order>230</sort_order>
501
+ <show_in_default>1</show_in_default>
502
+ <show_in_website>1</show_in_website>
503
+ <show_in_store>0</show_in_store>
504
+ <depends><token_enabled>1</token_enabled></depends>
505
+ <config_path>payment/amazon_payments/token_delayed</config_path>
506
+ </token_delayed>
507
+
508
  </fields>
509
  </ap_advanced>
510
  </fields>
557
  </fields>
558
  </ap_developer>
559
 
 
560
  </fields>
561
  </amazon_payments>
562
  </groups>
app/code/community/Amazon/Payments/etc/system.xml-1.6 ADDED
@@ -0,0 +1,503 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Amazon Payments
5
+ *
6
+ * @category Amazon
7
+ * @package Amazon_Payments
8
+ * @copyright Copyright (c) 2014 Amazon.com
9
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
10
+ */
11
+ -->
12
+ <config>
13
+ <sections>
14
+ <payment>
15
+
16
+ <groups>
17
+ <amazon_payments translate="label">
18
+ <label>Login and Pay with Amazon</label>
19
+ <sort_order>100</sort_order>
20
+ <expanded>1</expanded>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+
25
+
26
+ <comment>
27
+ <![CDATA[
28
+ Login and Pay with Amazon helps you increase conversation, reduce fraud, acquire new customers and build loyalty. <a href="https://payments.amazon.com/" target="_blank" class="amzn-signup">Learn More.</a>
29
+ <br /><br />
30
+ <div id="amazon_simplepath">
31
+ <span style="display:inline-block;padding-bottom:1em;">
32
+ <button><span>Get started with account registration</span></button>
33
+ &nbsp; &nbsp;
34
+ <button><span>My account is ready, I need to connect it to Magento</span></button>
35
+ </span>
36
+ <span style="display:inline-block;">
37
+ &nbsp; or &nbsp;
38
+ <a href="#" id="simplepath-skip">I've already setup Pay with Amazon, I want to edit my settings</a>
39
+ </span>
40
+
41
+ <p style="color:red;display:none" id="amazon_https_required">In order to enable automatic account configuration using Amazon's secure key exchange, please turn on secure admin pages in System > Configuration > Web > Use secure URLs in Admin.</p>
42
+ <p style="color:red;display:none" id="amazon_openssl_required">In order to set keys, the OpenSSL PHP library is required.</p>
43
+ <p style="color:red;display:none" id="amazon_reload">Updating your config with new keys, please wait...</p>
44
+
45
+ </div>
46
+
47
+ <div id="amazon_simplepath_back" style="display:none;margin-bottom:1em;margin-top:-0.5em;">
48
+ <a href="#">&laquo; Back</a>
49
+ </div>
50
+
51
+
52
+ <div id="amazon_instructions">
53
+
54
+ <strong>Steps to Launch Login and Pay with Amazon</strong>
55
+ <ol style="list-style:inside decimal;">
56
+ <li>Register through our custom <a href="https://sellercentral.amazon.com/hz/me/sp/signup?solutionProviderOptions=lwa%3Bmws-acc%3B&marketplaceId=AGWSWK15IEJJ7&solutionProviderToken=AAAAAQAAAAEAAAAQCz2wulRfR9nOADyzVQrq5wAAAHAIIULh6RBNvlw68WY5S9ATlmInlyg2PLVF44yUVowkyjvDZPhtLf3UYn6fshHlKqwR4qptfBeltbxLtLrrIfK6JoxzuWe9FRTnCfSey8a0sFKuL3mwNenjLyMC9BAN1xU0S6pebxA2mz8t8Y1v5Axi&solutionProviderId=A2K7HE1S3M5XJ" target="_blank" class="amzn-link">Magento registration</a> <span class="amzn-us-signup">or visit <a href="https://payments.amazon.com/signup" target="_blank" class="amzn-link">https://payments.amazon.com/signup</a></span>
57
+ <!--
58
+ Register or login to retrieve your account keys: &nbsp<button onclick="javascript:window.open(&#39;&#39;, &#39;get_keys&#39,&#39;left=50, top=50, width=950, height=750&#39;); return false;" class="scalable" type="button"><span>Login to Get Your Keys</span></button></span></button>
59
+ -->
60
+
61
+
62
+ <li>Visit <a href="https://sellercentral.amazon.com/" target="_blank" class="amzn-link">Amazon Seller Central</a> and Configure OAuth "Allowed Javascript Origins" in your Login with Amazon settings.
63
+ <li>Under General->Web, enable "Use Secure URLs in Frontend." (HTTPS is required.)
64
+ </ol>
65
+ </div>
66
+ <div style="clear:both;"></div>
67
+ ]]>
68
+ </comment>
69
+
70
+
71
+ <fields>
72
+
73
+
74
+ <enabled translate="label">
75
+ <label>Enabled</label>
76
+ <frontend_type>select</frontend_type>
77
+ <source_model>adminhtml/system_config_source_yesno</source_model>
78
+ <backend_model>amazon_payments/system_config_backend_enabled</backend_model>
79
+ <comment><model>amazon_payments/system_config_backend_enabled</model></comment>
80
+ <sort_order>5</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>0</show_in_store>
84
+ </enabled>
85
+
86
+ <ap_credentials type="group" translate="label">
87
+ <label>Credentials</label>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>1</show_in_store>
91
+ <expanded>1</expanded>
92
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
93
+ <sort_order>10</sort_order>
94
+
95
+ </ap_credentials>
96
+
97
+ <simplepath_import_button>
98
+ <frontend_type>button</frontend_type>
99
+ <frontend_model>amazon_payments/adminhtml_system_config_simplepathimport</frontend_model>
100
+ <sort_order>15</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>0</show_in_store>
104
+ </simplepath_import_button>
105
+ <simplepath_json translate="label">
106
+ <label>Import From Clipboard</label>
107
+ <frontend_type>textarea</frontend_type>
108
+ <backend_model>amazon_payments/system_config_backend_simplepath</backend_model>
109
+ <comment><![CDATA[<button><span>Save</span></button>]]></comment>
110
+ <sort_order>20</sort_order>
111
+ <show_in_default>1</show_in_default>
112
+ <show_in_website>1</show_in_website>
113
+ <show_in_store>0</show_in_store>
114
+ </simplepath_json>
115
+ <seller_id translate="label">
116
+ <label>SellerId/MerchantId</label>
117
+ <frontend_type>text</frontend_type>
118
+ <sort_order>25</sort_order>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>1</show_in_store>
122
+ <config_path>payment/amazon_payments/seller_id</config_path>
123
+ </seller_id>
124
+ <access_key translate="label">
125
+ <label>MWS Access Key</label>
126
+ <frontend_type>text</frontend_type>
127
+ <sort_order>30</sort_order>
128
+ <show_in_default>1</show_in_default>
129
+ <show_in_website>1</show_in_website>
130
+ <show_in_store>1</show_in_store>
131
+ <config_path>payment/amazon_payments/access_key</config_path>
132
+ </access_key>
133
+ <access_secret translate="label">
134
+ <label>MWS Secret Key</label>
135
+ <frontend_type>obscure</frontend_type>
136
+ <sort_order>35</sort_order>
137
+ <show_in_default>1</show_in_default>
138
+ <show_in_website>1</show_in_website>
139
+ <show_in_store>1</show_in_store>
140
+ <config_path>payment/amazon_payments/access_secret</config_path>
141
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
142
+ </access_secret>
143
+ <client_id translate="label">
144
+ <label>Client ID</label>
145
+ <frontend_type>text</frontend_type>
146
+ <sort_order>40</sort_order>
147
+ <show_in_default>1</show_in_default>
148
+ <show_in_website>1</show_in_website>
149
+ <show_in_store>1</show_in_store>
150
+ <config_path>payment/amazon_payments/client_id</config_path>
151
+ </client_id>
152
+ <client_secret translate="label">
153
+ <label>Client Secret</label>
154
+ <frontend_type>obscure</frontend_type>
155
+ <sort_order>45</sort_order>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ <show_in_store>1</show_in_store>
159
+ <config_path>payment/amazon_payments/client_secret</config_path>
160
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
161
+ </client_secret>
162
+ <sandbox translate="label">
163
+ <label>Sandbox Mode</label>
164
+ <frontend_type>select</frontend_type>
165
+ <source_model>adminhtml/system_config_source_yesno</source_model>
166
+ <sort_order>50</sort_order>
167
+ <show_in_default>1</show_in_default>
168
+ <show_in_website>1</show_in_website>
169
+ <show_in_store>1</show_in_store>
170
+ <config_path>payment/amazon_payments/sandbox</config_path>
171
+ </sandbox>
172
+
173
+
174
+
175
+ <!-- BEGIN EU REGION -->
176
+ <ap_region type="group" translate="label">
177
+ <label>Region</label>
178
+ <show_in_default>1</show_in_default>
179
+ <show_in_website>1</show_in_website>
180
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
181
+ <sort_order>55</sort_order>
182
+ </ap_region>
183
+ <!-- END EU REGION -->
184
+
185
+
186
+ <region translate="label">
187
+ <label>Region</label>
188
+ <frontend_type>select</frontend_type>
189
+ <source_model>amazon_payments/system_config_source_region</source_model>
190
+ <comment><model>amazon_payments/system_config_backend_localizecomment</model></comment>
191
+ <sort_order>60</sort_order>
192
+ <show_in_default>1</show_in_default>
193
+ <show_in_website>1</show_in_website>
194
+ <show_in_store>1</show_in_store>
195
+ <config_path>amazon_login/settings/region</config_path>
196
+ </region>
197
+ <!--language translate="label">
198
+ <label>Language</label>
199
+ <comment><![CDATA[You can chanage the language of the button and widgets here. The default language is your store's locale. EX: US = 'en_US'. More information can be found <a href="https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950" target="_blank" class="amzn-doc-link">here</a>.]]></comment>
200
+ <frontend_type>text</frontend_type>
201
+ <sort_order>20</sort_order>
202
+ <show_in_default>1</show_in_default>
203
+ <show_in_website>1</show_in_website>
204
+ <show_in_store>1</show_in_store>
205
+ <config_path>amazon_login/settings/language</config_path>
206
+ </language-->
207
+
208
+
209
+ <ap_checkout type="group" translate="label">
210
+ <label>Checkout Style</label>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>1</show_in_website>
213
+ <sort_order>65</sort_order>
214
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
215
+ </ap_checkout>
216
+
217
+ <checkout_page translate="label">
218
+ <label>Checkout Page Type</label>
219
+ <frontend_type>select</frontend_type>
220
+ <source_model>amazon_payments/system_config_source_checkoutpage</source_model>
221
+ <sort_order>70</sort_order>
222
+ <show_in_default>1</show_in_default>
223
+ <show_in_website>1</show_in_website>
224
+ <show_in_store>0</show_in_store>
225
+ <config_path>payment/amazon_payments/checkout_page</config_path>
226
+ </checkout_page>
227
+ <show_pay_cart translate="label">
228
+ <label>Show Pay with Amazon Button on Cart</label>
229
+ <comment><![CDATA[Only applies when OnePage Checkout is used, otherwise button is always shown.]]></comment>
230
+ <frontend_type>select</frontend_type>
231
+ <source_model>adminhtml/system_config_source_yesno</source_model>
232
+ <sort_order>75</sort_order>
233
+ <show_in_default>1</show_in_default>
234
+ <show_in_website>1</show_in_website>
235
+ <show_in_store>0</show_in_store>
236
+ <config_path>payment/amazon_payments/show_pay_cart</config_path>
237
+ </show_pay_cart>
238
+ <visible_on_product translate="label">
239
+ <label>Shortcut on Product View</label>
240
+ <comment><![CDATA[Pop-up must be set to "No" under "Login with Amazon" below.]]></comment>
241
+ <frontend_type>select</frontend_type>
242
+ <source_model>adminhtml/system_config_source_yesno</source_model>
243
+ <sort_order>80</sort_order>
244
+ <show_in_default>1</show_in_default>
245
+ <show_in_website>1</show_in_website>
246
+ <show_in_store>1</show_in_store>
247
+ <config_path>payment/amazon_payments/visible_on_product</config_path>
248
+ </visible_on_product>
249
+ <use_in_checkout translate="label">
250
+ <label>Display as Payment Option</label>
251
+ <comment><![CDATA[Add pay button under "Payment Information" during checkout. (Recommended flow is to display button before user enters billing and shipping information.)]]></comment>
252
+ <frontend_type>select</frontend_type>
253
+ <source_model>adminhtml/system_config_source_yesno</source_model>
254
+ <sort_order>85</sort_order>
255
+ <show_in_default>1</show_in_default>
256
+ <show_in_website>1</show_in_website>
257
+ <show_in_store>0</show_in_store>
258
+ <config_path>payment/amazon_payments/use_in_checkout</config_path>
259
+ </use_in_checkout>
260
+ <sort_order translate="label">
261
+ <label>Sort Order</label>
262
+ <frontend_type>text</frontend_type>
263
+ <sort_order>90</sort_order>
264
+ <show_in_default>1</show_in_default>
265
+ <show_in_website>1</show_in_website>
266
+ <show_in_store>0</show_in_store>
267
+ <frontend_class>validate-number</frontend_class>
268
+ <depends><use_in_checkout>1</use_in_checkout></depends>
269
+ <config_path>payment/amazon_payments/sort_order</config_path>
270
+ </sort_order>
271
+ <buttons type="group" translate="label">
272
+ <label>Button Styles</label>
273
+ <show_in_default>1</show_in_default>
274
+ <show_in_website>1</show_in_website>
275
+ <show_in_store>1</show_in_store>
276
+ <sort_order>95</sort_order>
277
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
278
+ </buttons>
279
+
280
+ <button_type translate="label">
281
+ <label>Button Label</label>
282
+ <frontend_type>select</frontend_type>
283
+ <source_model>amazon_payments/system_config_source_buttontype</source_model>
284
+ <sort_order>100</sort_order>
285
+ <show_in_default>1</show_in_default>
286
+ <show_in_website>1</show_in_website>
287
+ <show_in_store>1</show_in_store>
288
+ <config_path>payment/amazon_payments/button_type</config_path>
289
+ </button_type>
290
+ <button_color translate="label">
291
+ <label>Button Color</label>
292
+ <frontend_type>select</frontend_type>
293
+ <source_model>amazon_payments/system_config_source_buttoncolor</source_model>
294
+ <sort_order>105</sort_order>
295
+ <show_in_default>1</show_in_default>
296
+ <show_in_website>1</show_in_website>
297
+ <show_in_store>1</show_in_store>
298
+ <config_path>payment/amazon_payments/button_color</config_path>
299
+ </button_color>
300
+ <button_size translate="label">
301
+ <label>Button Size</label>
302
+ <frontend_type>select</frontend_type>
303
+ <source_model>amazon_payments/system_config_source_buttonsize</source_model>
304
+ <sort_order>110</sort_order>
305
+ <show_in_default>1</show_in_default>
306
+ <show_in_website>1</show_in_website>
307
+ <show_in_store>1</show_in_store>
308
+ <config_path>payment/amazon_payments/button_size</config_path>
309
+ </button_size>
310
+ <button_badge translate="label">
311
+ <label>Display Acceptance Badge</label>
312
+ <comment><![CDATA[Display "Amazon Payments" acceptance mark in right sidebar.]]></comment>
313
+ <frontend_type>select</frontend_type>
314
+ <source_model>adminhtml/system_config_source_yesno</source_model>
315
+ <sort_order>120</sort_order>
316
+ <show_in_default>1</show_in_default>
317
+ <show_in_website>1</show_in_website>
318
+ <show_in_store>0</show_in_store>
319
+ <config_path>payment/amazon_payments/button_badge</config_path>
320
+ </button_badge>
321
+
322
+
323
+ <ap_login type="group" translate="label">
324
+ <label>Login with Amazon</label>
325
+ <show_in_default>1</show_in_default>
326
+ <show_in_website>1</show_in_website>
327
+ <show_in_store>1</show_in_store>
328
+ <sort_order>130</sort_order>
329
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
330
+ </ap_login>
331
+
332
+ <enabled2 translate="label">
333
+ <label>Enabled</label>
334
+ <frontend_type>select</frontend_type>
335
+ <source_model>adminhtml/system_config_source_yesno</source_model>
336
+ <comment><![CDATA[Display "Login with Amazon" button on account pages and auto-create Magento accounts during checkout.]]></comment>
337
+ <sort_order>140</sort_order>
338
+ <show_in_default>1</show_in_default>
339
+ <show_in_website>1</show_in_website>
340
+ <show_in_store>0</show_in_store>
341
+ <config_path>amazon_login/settings/enabled</config_path>
342
+ </enabled2>
343
+ <popup translate="label">
344
+ <label>Pop-up</label>
345
+ <comment>
346
+ <![CDATA[Pop-up window or full-page redirect.]]>
347
+ </comment>
348
+ <frontend_type>select</frontend_type>
349
+ <source_model>adminhtml/system_config_source_yesno</source_model>
350
+ <sort_order>150</sort_order>
351
+ <show_in_default>1</show_in_default>
352
+ <show_in_website>1</show_in_website>
353
+ <show_in_store>1</show_in_store>
354
+ <config_path>amazon_login/settings/popup</config_path>
355
+ </popup>
356
+ <popupcomment>
357
+ <frontend_type>note</frontend_type>
358
+ <comment><model>amazon_payments/system_config_backend_popupcomment</model></comment>
359
+ <depends><popup>0</popup></depends>
360
+ <sort_order>160</sort_order>
361
+ <show_in_default>1</show_in_default>
362
+ <show_in_website>1</show_in_website>
363
+ <show_in_store>1</show_in_store>
364
+ </popupcomment>
365
+ <additional_scope translate="label" module="amazon_payments">
366
+ <label>Additional Access Scope</label>
367
+ <comment>
368
+ <![CDATA[Optional access scope strings during login.]]>
369
+ </comment>
370
+ <frontend_type>text</frontend_type>
371
+ <sort_order>170</sort_order>
372
+ <show_in_default>1</show_in_default>
373
+ <show_in_website>1</show_in_website>
374
+ <show_in_store>1</show_in_store>
375
+ <config_path>amazon_login/settings/additional_scope</config_path>
376
+ </additional_scope>
377
+
378
+
379
+ <ap_transaction type="group" translate="label">
380
+ <label>Transaction</label>
381
+ <show_in_default>1</show_in_default>
382
+ <show_in_website>1</show_in_website>
383
+ <show_in_store>1</show_in_store>
384
+ <sort_order>180</sort_order>
385
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
386
+ </ap_transaction>
387
+
388
+ <payment_action translate="label">
389
+ <label>Payment Action</label>
390
+ <frontend_type>select</frontend_type>
391
+ <source_model>amazon_payments/system_config_source_paymentaction</source_model>
392
+ <sort_order>190</sort_order>
393
+ <show_in_default>1</show_in_default>
394
+ <show_in_website>1</show_in_website>
395
+ <show_in_store>0</show_in_store>
396
+ <config_path>payment/amazon_payments/payment_action</config_path>
397
+ </payment_action>
398
+ <payment_action_none_note translate="label">
399
+ <frontend_type>note</frontend_type>
400
+ <comment><![CDATA[You have set orders to not have funds authorized, so you should set the New Order Status below to a custom status other than "Pending" or "Processing." Funds will need to be captured from a third-party system.]]></comment>
401
+ <sort_order>195</sort_order>
402
+ <show_in_default>1</show_in_default>
403
+ <show_in_website>1</show_in_website>
404
+ <show_in_store>0</show_in_store>
405
+ <depends><payment_action>new</payment_action></depends>
406
+ </payment_action_none_note>
407
+ <order_status translate="label">
408
+ <label>New Order Status</label>
409
+ <frontend_type>select</frontend_type>
410
+ <source_model>adminhtml/system_config_source_order_status_newprocessing</source_model>
411
+ <sort_order>200</sort_order>
412
+ <show_in_default>1</show_in_default>
413
+ <show_in_website>1</show_in_website>
414
+ <show_in_store>0</show_in_store>
415
+ <config_path>payment/amazon_payments/order_status</config_path>
416
+ </order_status>
417
+ <store_name translate="label">
418
+ <label>Email Store Name</label>
419
+ <frontend_type>text</frontend_type>
420
+ <comment><![CDATA[Store name to display in Amazon emails. If left blank, current Magento store name will be used.]]></comment>
421
+ <sort_order>205</sort_order>
422
+ <show_in_default>1</show_in_default>
423
+ <show_in_website>1</show_in_website>
424
+ <show_in_store>1</show_in_store>
425
+ <config_path>payment/amazon_payments/store_name</config_path>
426
+ </store_name>
427
+ <soft_descriptor translate="label">
428
+ <label>Soft Descriptor</label>
429
+ <frontend_type>text</frontend_type>
430
+ <comment><![CDATA[Billing descriptor to display on credit card statements. Limited to 16 characters. If left blank, current Magento store name will be used.]]></comment>
431
+ <validate>validate-length maximum-length-16</validate>
432
+ <sort_order>210</sort_order>
433
+ <show_in_default>1</show_in_default>
434
+ <show_in_website>1</show_in_website>
435
+ <show_in_store>1</show_in_store>
436
+ <config_path>payment/amazon_payments/soft_descriptor</config_path>
437
+ </soft_descriptor>
438
+
439
+ <is_async translate="label">
440
+ <label>Asynchronous Mode</label>
441
+ <comment><![CDATA[In asynchronous mode, the payment is returned as a Pending status instead of an immediate Open or Declined status. Customers will need to be notified of a Declined status.]]></comment>
442
+ <frontend_type>select</frontend_type>
443
+ <source_model>adminhtml/system_config_source_yesno</source_model>
444
+ <sort_order>220</sort_order>
445
+ <show_in_default>1</show_in_default>
446
+ <show_in_website>1</show_in_website>
447
+ <show_in_store>0</show_in_store>
448
+ <config_path>payment/amazon_payments/is_async</config_path>
449
+ </is_async>
450
+
451
+ <ap_developer type="group" translate="label">
452
+ <label>Developer</label>
453
+ <show_in_default>1</show_in_default>
454
+ <show_in_website>1</show_in_website>
455
+ <show_in_store>1</show_in_store>
456
+ <sort_order>225</sort_order>
457
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
458
+ </ap_developer>
459
+
460
+ <secure_cart translate="label">
461
+ <label>Secure Cart Page</label>
462
+ <comment><![CDATA[HTTPS is required to use the Amazon button on the cart page.]]></comment>
463
+ <frontend_type>select</frontend_type>
464
+ <source_model>adminhtml/system_config_source_yesno</source_model>
465
+ <sort_order>230</sort_order>
466
+ <show_in_default>1</show_in_default>
467
+ <show_in_website>1</show_in_website>
468
+ <show_in_store>0</show_in_store>
469
+ <config_path>payment/amazon_payments/secure_cart</config_path>
470
+ </secure_cart>
471
+ <debug translate="label">
472
+ <label>Debug Mode</label>
473
+ <comment>
474
+ <![CDATA[Save API responses to Magento log]]>
475
+ </comment>
476
+ <frontend_type>select</frontend_type>
477
+ <source_model>adminhtml/system_config_source_yesno</source_model>
478
+ <sort_order>240</sort_order>
479
+ <show_in_default>1</show_in_default>
480
+ <show_in_website>1</show_in_website>
481
+ <show_in_store>0</show_in_store>
482
+ <config_path>payment/amazon_payments/debug</config_path>
483
+ </debug>
484
+ <restricted_ips translate="label">
485
+ <label>Restrict by IP</label>
486
+ <comment>
487
+ <![CDATA[Display to only whitelisted IPs found in <br>Developer -> Developer Client Restrictions]]>
488
+ </comment>
489
+ <frontend_type>select</frontend_type>
490
+ <source_model>adminhtml/system_config_source_yesno</source_model>
491
+ <sort_order>250</sort_order>
492
+ <show_in_default>1</show_in_default>
493
+ <show_in_website>1</show_in_website>
494
+ <show_in_store>0</show_in_store>
495
+ <config_path>payment/amazon_payments/restricted_ips</config_path>
496
+ </restricted_ips>
497
+
498
+ </fields>
499
+ </amazon_payments>
500
+ </groups>
501
+ </payment>
502
+ </sections>
503
+ </config>
app/code/community/Amazon/Payments/sql/payments_setup/upgrade-1.3.0-1.4.0.php CHANGED
@@ -17,11 +17,11 @@ $db = $installer->getConnection();
17
 
18
  // Encrypt keys
19
  $select = $db->select()
20
- ->from('core_config_data')
21
  ->where('path IN (?)', array('payment/amazon_payments/access_secret', 'payment/amazon_payments/client_secret'));
22
 
23
  foreach ($db->fetchAll($select) as $row) {
24
- $db->update('core_config_data', array('value' => Mage::helper('core')->encrypt(trim($row['value']))), 'config_id=' . $row['config_id']);
25
  }
26
 
27
  $installer->endSetup();
17
 
18
  // Encrypt keys
19
  $select = $db->select()
20
+ ->from(Mage::getSingleton('core/resource')->getTableName('core_config_data'))
21
  ->where('path IN (?)', array('payment/amazon_payments/access_secret', 'payment/amazon_payments/client_secret'));
22
 
23
  foreach ($db->fetchAll($select) as $row) {
24
+ $db->update(Mage::getSingleton('core/resource')->getTableName('core_config_data'), array('value' => Mage::helper('core')->encrypt(trim($row['value']))), 'config_id=' . $row['config_id']);
25
  }
26
 
27
  $installer->endSetup();
app/code/community/Amazon/Payments/sql/payments_setup/upgrade-1.4.2-1.4.3.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Amazon Payments
4
+ *
5
+ * @category Amazon
6
+ * @package Amazon_Payments
7
+ * @copyright Copyright (c) 2014 Amazon.com
8
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
9
+ */
10
+
11
+
12
+ $installer = $this;
13
+
14
+ $installer->startSetup();
15
+
16
+ $amazon_token_table = $installer->getTable('amazon_payments/token');
17
+
18
+ if ($installer->getConnection()->isTableExists($amazon_token_table) != true) {
19
+ $amazon_table = $installer->getConnection()
20
+ ->newTable($amazon_token_table)
21
+ ->addColumn('token_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
22
+ 'identity' => true,
23
+ 'unsigned' => true,
24
+ 'nullable' => false,
25
+ 'primary' => true
26
+ ), 'Token ID')
27
+ ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array (
28
+ 'nullable' => true,
29
+ 'unsigned' => true
30
+ ), 'Customer Entity ID')
31
+ ->addColumn('amazon_uid', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array (
32
+ 'nullable' => false,
33
+ ), 'Amazon User ID')
34
+ ->addColumn('amazon_billing_agreement_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array (
35
+ 'nullable' => false,
36
+ ), 'Amazon Billing Agreement ID')
37
+ ->addColumn('shipping_method', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array (
38
+ 'nullable' => false,
39
+ ), 'Shipping Method')
40
+ ->addIndex($installer->getIdxName('amazon_payments_token', array('customer_id')), array('customer_id'))
41
+ ->addIndex($installer->getIdxName('amazon_payments_token', array('amazon_uid'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE), array('amazon_uid'));
42
+
43
+ $installer->getConnection()->createTable($amazon_table);
44
+
45
+ $installer->getConnection()->addConstraint(
46
+ 'fk_amazon_payments_token_customer_entity_id',
47
+ $installer->getTable('amazon_payments_token'),
48
+ 'customer_id',
49
+ $installer->getTable('customer/entity'),
50
+ 'entity_id',
51
+ 'cascade',
52
+ 'restrict'
53
+ );
54
+ }
55
+
56
+ $installer->endSetup();
app/design/adminhtml/default/default/template/amazon_payments/notifications.phtml CHANGED
@@ -15,7 +15,7 @@
15
 
16
  <div class="notification-global">
17
  <strong>
18
- To complete your Amazon Payments configuration, please set up <a href="https://sellercentral.amazon.com/" taget="_blank">your account</a> and add the API credentials <a href="<?php echo $this->getManageUrl(); ?>">here</a>.
19
  </strong>
20
  <span class="f-right"></span>
21
  </div>
@@ -27,7 +27,7 @@
27
 
28
  <div class="notification-global">
29
  <strong>
30
- Amazon Payments requires a <a href="https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility" target="_blank">patched Payments.php</a> file for Magento 1.5 compatibility.
31
  </strong>
32
  <span class="f-right"></span>
33
  </div>
15
 
16
  <div class="notification-global">
17
  <strong>
18
+ <?php echo $this->__('To complete your Amazon Payments configuration, please set up <a href="https://sellercentral.amazon.com/" taget="_blank">your account</a> and add the API credentials <a href="%s">here</a>.', $this->getManageUrl()); ?>
19
  </strong>
20
  <span class="f-right"></span>
21
  </div>
27
 
28
  <div class="notification-global">
29
  <strong>
30
+ <?php echo $this->__('Amazon Payments requires a <a href="https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility" target="_blank">patched Payments.php</a> file for Magento 1.5 compatibility.'); ?>
31
  </strong>
32
  <span class="f-right"></span>
33
  </div>
app/design/frontend/base/default/layout/amazon_payments.xml CHANGED
@@ -21,31 +21,24 @@
21
  <action method="addItem" ifconfig="payment/amazon_payments/enabled"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
22
  <action method="addItem" ifconfig="payment/amazon_payments/enabled"><type>js_css</type><name>prototype/windows/themes/alphacube.css</name></action>
23
  <action method="addItem"><type>skin_css</type><name>amazon_payments/css/popup_alphacube.css</name><params/></action>
24
- </reference>
25
-
26
- <reference name="checkout.cart">
27
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
 
28
 
29
- <!-- ifconfig only works with action -->
30
- <reference name="before_body_end">
31
- <action method="append" ifconfig="payment/amazon_payments/enabled">
32
- <block>amazon_payments.script</block>
33
- </action>
34
- </reference>
35
-
36
  </reference>
37
 
38
- <!-- To Move Amazon Payments button around on the cart page, change the after="" attribute to before="" in the below block tags -->
39
 
40
- <reference name="checkout.cart.top_methods">
41
- <!-- replace 'after="-"' with 'before="checkout.cart.methods.onepage.top"' to move the Amazon Payments button in front of the Checkout button -->
42
- <block type="amazon_payments/button" after="-" name="AmazonPayButtonTop" template="amazon_payments/button.phtml"/>
43
- </reference>
44
 
45
- <reference name="checkout.cart.methods">
46
- <!-- replace 'after="-"' with 'before="checkout.cart.methods.onepage.bottom"' to move the Amazon Payments button in front of the Checkout button -->
47
- <block type="amazon_payments/button" after="-" name="AmazonPayButtonMethod" template="amazon_payments/button.phtml"/>
48
- </reference>
49
 
50
  </checkout_cart_index>
51
 
@@ -59,6 +52,10 @@
59
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
60
  </reference>
61
 
 
 
 
 
62
  <reference name="checkout.onepage">
63
  <block type="amazon_payments/button" name="amazonpaymentsbutton" template="amazon_payments/onepage/button.phtml"/>
64
  </reference>
@@ -174,7 +171,11 @@
174
  <reference name="root">
175
  <action method="setTemplate"><template>page/1column.phtml</template></action>
176
  </reference>
 
 
 
177
  <reference name="content">
 
178
 
179
  <block type="amazon_payments/checkout" name="amazon_payments.checkout" template="amazon_payments/checkout.phtml">
180
 
@@ -182,13 +183,16 @@
182
  <block type="checkout/onepage_shipping_method_available" name="checkout.onepage.shipping_method.available" as="available" template="checkout/onepage/shipping_method/available.phtml"/>
183
  <block type="checkout/onepage_shipping_method_additional" name="checkout.onepage.shipping_method.additional" as="additional" template="checkout/onepage/shipping_method/additional.phtml"/>
184
  </block>
 
185
  <block type="checkout/onepage_review" name="checkout.onepage.review" as="review" template="checkout/onepage/review.phtml"/>
186
-
187
  </block>
188
  </reference>
189
 
190
  <reference name="head">
191
- <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
 
 
 
192
  </reference>
193
  </checkout_amazon_payments_index>
194
 
@@ -199,11 +203,18 @@
199
  <!-- Mage_Checkout -->
200
  <remove name="right"/>
201
  <remove name="left"/>
202
-
203
  <block type="checkout/onepage_shipping_method_available" name="root" output="toHtml" template="checkout/onepage/shipping_method/available.phtml"/>
204
-
205
  </checkout_amazon_payments_shippingmethod>
206
 
 
 
 
 
 
 
 
 
 
207
  <!--
208
  Amazon checkout shipping method additional
209
  -->
@@ -215,6 +226,7 @@
215
  <block type="checkout/onepage_shipping_method_additional" name="root" output="toHtml" template="checkout/onepage/shipping_method/additional.phtml">
216
  <action method="setDontDisplayContainer"><param>1</param></action>
217
  </block>
 
218
  </checkout_amazon_payments_additional>
219
 
220
  <!--
@@ -257,6 +269,17 @@
257
  -->
258
  <catalog_product_view>
259
 
 
 
 
 
 
 
 
 
 
 
 
260
  <block type="amazon_payments/button" name="addtocart-amazon-button" template="amazon_payments/button_shortcut.phtml" />
261
 
262
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
@@ -289,16 +312,56 @@
289
  Sidecart/Minicart Shortcut
290
  -->
291
  <default>
 
 
 
 
 
 
292
  <reference name="head">
293
- <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml">
294
- <action method="setIsDefault"><is_default>1</is_default></action>
295
- </block>
 
 
 
 
 
296
  </reference>
297
  <reference name="cart_sidebar.extra_actions">
298
- <block type="amazon_payments/button" name="AmazonPayButtonSideCart" template="amazon_payments/button.phtml"/>
 
 
299
  </reference>
300
  </default>
301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  <!--
303
  Acceptance Mark/Badge
304
  -->
@@ -327,6 +390,9 @@
327
  <reference name="head">
328
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
329
  </reference>
 
 
 
330
  </firecheckout_index_index>
331
 
332
  <!--
@@ -336,6 +402,9 @@
336
  <reference name="head">
337
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
338
  </reference>
 
 
 
339
  </opc_index_index>
340
 
341
  <!--
@@ -347,6 +416,10 @@
347
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
348
  </reference>
349
 
 
 
 
 
350
  <reference name="checkout.onepage">
351
  <block type="amazon_payments/button" name="amazonpaymentsbutton" template="amazon_payments/onepage/button.phtml"/>
352
  </reference>
@@ -380,6 +453,9 @@
380
  <reference name="head">
381
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
382
  </reference>
 
 
 
383
  <reference name="my.account.wrapper">
384
  <block type="amazon_payments/sales_view" template="amazon_payments/sales/order/amazon_wallet.phtml" before="info">
385
  <block type="amazon_payments/login_button" name="amazon_login.no-or" template="amazon_payments/login/button.phtml"/>
@@ -392,34 +468,34 @@
392
  Login
393
  -->
394
  <customer_account_login translate="label">
 
 
 
 
 
 
395
 
396
- <block type="amazon_payments/login_script" name="amazon_login.script" template="amazon_payments/login/script.phtml" />
397
- <block type="amazon_payments/login_button" name="amazon_login.button_login" template="amazon_payments/login/button.phtml" after="customer_form_login" />
398
 
399
  <!-- ifconfig only works with action -->
400
- <reference name="after_body_start">
401
- <action method="append" ifconfig="payment/amazon_payments/enabled">
402
- <block>amazon_login.script</block>
403
- </action>
404
- </reference>
405
-
406
  <reference name="content">
407
- <action method="append" ifconfig="payment/amazon_payments/enabled">
408
- <block>amazon_login.button_login</block>
409
  </action>
410
  </reference>
 
411
  </customer_account_login>
412
 
413
  <customer_account_create translate="label">
414
- <block type="amazon_payments/login_script" name="amazon_login.script" template="amazon_payments/login/script.phtml" />
415
- <block type="amazon_payments/login_button" name="amazon_login.button_create" template="amazon_payments/login/button.phtml" after="customer_form_login" />
416
-
417
- <reference name="after_body_start">
418
- <action method="append" ifconfig="payment/amazon_payments/enabled">
419
- <block>amazon_login.script</block>
420
- </action>
421
  </reference>
422
 
 
 
423
  <reference name="customer.form.register.fields.before">
424
  <action method="append" ifconfig="payment/amazon_payments/enabled">
425
  <block>amazon_login.button_create</block>
@@ -430,7 +506,7 @@
430
 
431
  <customer_account_logoutsuccess>
432
  <reference name="content">
433
- <block type="amazon_payments/login_script" name="amazon_login.script.logout" template="amazon_payments/login/script.phtml" />
434
  </reference>
435
  </customer_account_logoutsuccess>
436
 
21
  <action method="addItem" ifconfig="payment/amazon_payments/enabled"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
22
  <action method="addItem" ifconfig="payment/amazon_payments/enabled"><type>js_css</type><name>prototype/windows/themes/alphacube.css</name></action>
23
  <action method="addItem"><type>skin_css</type><name>amazon_payments/css/popup_alphacube.css</name><params/></action>
 
 
 
24
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
25
+ </reference>
26
 
27
+ <reference name="before_body_end">
28
+ <block type="amazon_payments/script" name="amazon_payments.script.async" template="amazon_payments/script_async.phtml" />
 
 
 
 
 
29
  </reference>
30
 
31
+ <!-- To Move Amazon Payments button around on the cart page, change the after="" attribute to before="" in the below block tags -->
32
 
33
+ <reference name="checkout.cart.top_methods">
34
+ <!-- replace 'after="-"' with 'before="checkout.cart.methods.onepage.top"' to move the Amazon Payments button in front of the Checkout button -->
35
+ <block type="amazon_payments/button" after="-" name="AmazonPayButtonTop" template="amazon_payments/button.phtml"/>
36
+ </reference>
37
 
38
+ <reference name="checkout.cart.methods">
39
+ <!-- replace 'after="-"' with 'before="checkout.cart.methods.onepage.bottom"' to move the Amazon Payments button in front of the Checkout button -->
40
+ <block type="amazon_payments/button" after="-" name="AmazonPayButtonMethod" template="amazon_payments/button.phtml"/>
41
+ </reference>
42
 
43
  </checkout_cart_index>
44
 
52
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
53
  </reference>
54
 
55
+ <reference name="before_body_end">
56
+ <block type="amazon_payments/script" name="amazon_payments.script.async" template="amazon_payments/script_async.phtml" />
57
+ </reference>
58
+
59
  <reference name="checkout.onepage">
60
  <block type="amazon_payments/button" name="amazonpaymentsbutton" template="amazon_payments/onepage/button.phtml"/>
61
  </reference>
171
  <reference name="root">
172
  <action method="setTemplate"><template>page/1column.phtml</template></action>
173
  </reference>
174
+
175
+
176
+
177
  <reference name="content">
178
+ <block type="core/messages" name="messages" as="messages"/>
179
 
180
  <block type="amazon_payments/checkout" name="amazon_payments.checkout" template="amazon_payments/checkout.phtml">
181
 
183
  <block type="checkout/onepage_shipping_method_available" name="checkout.onepage.shipping_method.available" as="available" template="checkout/onepage/shipping_method/available.phtml"/>
184
  <block type="checkout/onepage_shipping_method_additional" name="checkout.onepage.shipping_method.additional" as="additional" template="checkout/onepage/shipping_method/additional.phtml"/>
185
  </block>
186
+ <block type="checkout/cart_coupon" name="checkout.amazon_payments.coupon" as="coupon" template="amazon_payments/coupon.phtml"/>
187
  <block type="checkout/onepage_review" name="checkout.onepage.review" as="review" template="checkout/onepage/review.phtml"/>
 
188
  </block>
189
  </reference>
190
 
191
  <reference name="head">
192
+ <block type="amazon_payments/script" name="amazon_payments.script.checkout" template="amazon_payments/script.phtml" />
193
+ </reference>
194
+ <reference name="before_body_end">
195
+ <block type="amazon_payments/script" name="amazon_payments.script.async" template="amazon_payments/script_async.phtml" />
196
  </reference>
197
  </checkout_amazon_payments_index>
198
 
203
  <!-- Mage_Checkout -->
204
  <remove name="right"/>
205
  <remove name="left"/>
 
206
  <block type="checkout/onepage_shipping_method_available" name="root" output="toHtml" template="checkout/onepage/shipping_method/available.phtml"/>
 
207
  </checkout_amazon_payments_shippingmethod>
208
 
209
+ <!--
210
+ ShipperHQ
211
+ -->
212
+ <checkout_amazon_payments_shippingmethod_shipperhq>
213
+ <remove name="right"/>
214
+ <remove name="left"/>
215
+ <block type="shipperhq_frontend/checkout_onepage_shipping_method_available" name="root" output="toHtml" template="shipperhq/checkout/onepage/shipping_method/available.phtml"/>
216
+ </checkout_amazon_payments_shippingmethod_shipperhq>
217
+
218
  <!--
219
  Amazon checkout shipping method additional
220
  -->
226
  <block type="checkout/onepage_shipping_method_additional" name="root" output="toHtml" template="checkout/onepage/shipping_method/additional.phtml">
227
  <action method="setDontDisplayContainer"><param>1</param></action>
228
  </block>
229
+
230
  </checkout_amazon_payments_additional>
231
 
232
  <!--
269
  -->
270
  <catalog_product_view>
271
 
272
+ <reference name="head">
273
+ <action method="addJs" ifconfig="payment/amazon_payments/enabled"><script>prototype/window.js</script></action>
274
+ <action method="addItem" ifconfig="payment/amazon_payments/enabled"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
275
+ <action method="addItem" ifconfig="payment/amazon_payments/enabled"><type>js_css</type><name>prototype/windows/themes/alphacube.css</name></action>
276
+ <action method="addItem"><type>skin_css</type><name>amazon_payments/css/popup_alphacube.css</name><params/></action>
277
+ </reference>
278
+
279
+ <reference name="before_body_end">
280
+ <block type="amazon_payments/script" name="amazon_payments.script.async" template="amazon_payments/script_async.phtml" />
281
+ </reference>
282
+
283
  <block type="amazon_payments/button" name="addtocart-amazon-button" template="amazon_payments/button_shortcut.phtml" />
284
 
285
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
312
  Sidecart/Minicart Shortcut
313
  -->
314
  <default>
315
+ <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml">
316
+ <action method="setIsDefault"><is_default>1</is_default></action>
317
+ </block>
318
+ <block type="amazon_payments/script" name="amazon_payments.script.async" template="amazon_payments/script_async.phtml" />
319
+ <block type="amazon_payments/button" name="AmazonPayButtonSideCart" template="amazon_payments/button.phtml"/>
320
+
321
  <reference name="head">
322
+ <action method="append" ifconfig="payment/amazon_payments/show_in_minicart">
323
+ <block>amazon_payments.script</block>
324
+ </action>
325
+ </reference>
326
+ <reference name="before_body_end">
327
+ <action method="append" ifconfig="payment/amazon_payments/show_in_minicart">
328
+ <block>amazon_payments.script.async</block>
329
+ </action>
330
  </reference>
331
  <reference name="cart_sidebar.extra_actions">
332
+ <action method="append" ifconfig="payment/amazon_payments/show_in_minicart">
333
+ <block>AmazonPayButtonSideCart</block>
334
+ </action>
335
  </reference>
336
  </default>
337
 
338
+ <!--
339
+ Ajax cart for Token Payments
340
+ -->
341
+ <amazon_payments_token_ajaxcart>
342
+ <reference name="root">
343
+ <action method="setTemplate"><template>page/popup.phtml</template></action>
344
+ </reference>
345
+ <reference name="head">
346
+ <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
347
+ <action method="addItem"><type>skin_css</type><name>amazon_payments/css/popup_alphacube.css</name><params/></action>
348
+ </reference>
349
+ <reference name="before_body_end">
350
+ <block type="amazon_payments/script" name="amazon_payments.script.async" template="amazon_payments/script_async.phtml" />
351
+ </reference>
352
+
353
+ <reference name="content">
354
+ <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
355
+ <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
356
+ <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
357
+ <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
358
+ <action method="addItemRender"><type>bundle</type><block>bundle/checkout_cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
359
+ </block>
360
+
361
+ <block type="amazon_payments/button" name="addtocart-amazon-button" template="amazon_payments/button_shortcut_ajaxcart.phtml" />
362
+ </reference>
363
+ </amazon_payments_token_ajaxcart>
364
+
365
  <!--
366
  Acceptance Mark/Badge
367
  -->
390
  <reference name="head">
391
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
392
  </reference>
393
+ <reference name="before_body_end">
394
+ <block type="amazon_payments/script" name="amazon_payments.script.async" template="amazon_payments/script_async.phtml" />
395
+ </reference>
396
  </firecheckout_index_index>
397
 
398
  <!--
402
  <reference name="head">
403
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
404
  </reference>
405
+ <reference name="before_body_end">
406
+ <block type="amazon_payments/script" name="amazon_payments.script.async" template="amazon_payments/script_async.phtml" />
407
+ </reference>
408
  </opc_index_index>
409
 
410
  <!--
416
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
417
  </reference>
418
 
419
+ <reference name="before_body_end">
420
+ <block type="amazon_payments/script" name="amazon_payments.script.async" template="amazon_payments/script_async.phtml" />
421
+ </reference>
422
+
423
  <reference name="checkout.onepage">
424
  <block type="amazon_payments/button" name="amazonpaymentsbutton" template="amazon_payments/onepage/button.phtml"/>
425
  </reference>
453
  <reference name="head">
454
  <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
455
  </reference>
456
+ <reference name="before_body_end">
457
+ <block type="amazon_payments/script" name="amazon_payments.script.async" template="amazon_payments/script_async.phtml" />
458
+ </reference>
459
  <reference name="my.account.wrapper">
460
  <block type="amazon_payments/sales_view" template="amazon_payments/sales/order/amazon_wallet.phtml" before="info">
461
  <block type="amazon_payments/login_button" name="amazon_login.no-or" template="amazon_payments/login/button.phtml"/>
468
  Login
469
  -->
470
  <customer_account_login translate="label">
471
+ <reference name="head">
472
+ <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
473
+ </reference>
474
+ <reference name="before_body_end">
475
+ <block type="amazon_payments/script" name="amazon_payments.script.async" template="amazon_payments/script_async.phtml" />
476
+ </reference>
477
 
478
+ <block type="amazon_payments/login_button" name="amazon_login.button_create" template="amazon_payments/login/button.phtml" before="content" />
 
479
 
480
  <!-- ifconfig only works with action -->
 
 
 
 
 
 
481
  <reference name="content">
482
+ <action method="insert" ifconfig="payment/amazon_payments/enabled">
483
+ <block>amazon_login.button_create</block>
484
  </action>
485
  </reference>
486
+
487
  </customer_account_login>
488
 
489
  <customer_account_create translate="label">
490
+ <reference name="head">
491
+ <block type="amazon_payments/script" name="amazon_payments.script" template="amazon_payments/script.phtml" />
492
+ </reference>
493
+ <reference name="before_body_end">
494
+ <block type="amazon_payments/script" name="amazon_payments.script.async" template="amazon_payments/script_async.phtml" />
 
 
495
  </reference>
496
 
497
+ <block type="amazon_payments/login_button" name="amazon_login.button_create" template="amazon_payments/login/button.phtml" after="customer_form_login" />
498
+
499
  <reference name="customer.form.register.fields.before">
500
  <action method="append" ifconfig="payment/amazon_payments/enabled">
501
  <block>amazon_login.button_create</block>
506
 
507
  <customer_account_logoutsuccess>
508
  <reference name="content">
509
+ <block type="amazon_payments/login_script" name="amazon_login.script.logout" template="amazon_payments/login/script_logout.phtml" />
510
  </reference>
511
  </customer_account_logoutsuccess>
512
 
app/design/frontend/base/default/template/amazon_payments/button.phtml CHANGED
@@ -11,31 +11,46 @@
11
  ?>
12
  <?php if ($this->isAmazonPayButtonEnabled()): ?>
13
 
14
- <div id="<?php echo $this->getAmazonPayButtonId(); ?>" class="amazon-pay-button" style="float:right;margin-bottom:10px;"></div>
15
 
16
  <script type="text/javascript">
17
  var authRequest;
18
 
19
- var AmazonButtonOptions = {
20
- type: "<?php echo $this->getButtonType(); ?>",
21
- color: "<?php echo $this->getButtonColor(); ?>",
22
- size: "<?php echo $this->getButtonSize(); ?>",
23
- authorization: function() {
24
- loginOptions = {
25
- scope: "profile payments:widget payments:shipping_address<?php print $this->getAdditionalScope(); ?>",
26
- response_type: 'token',
27
- popup: <?php print $this->isPopup(); ?>
28
- };
29
-
30
- authRequest = amazon.Login.authorize (loginOptions, "<?php echo (!$this->isPopup()) ? $this->getLoginAuthUrl() : $this->getCheckoutUrl(); ?>");
31
- },
32
- onError: function(error) {
33
- console.log(error);
34
- }
35
- };
36
-
37
- OffAmazonPayments.Button("<?php echo $this->getAmazonPayButtonId(); ?>", "<?php echo $this->getSellerId(); ?>", AmazonButtonOptions);
38
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  </script>
40
 
41
  <?php endif; ?>
11
  ?>
12
  <?php if ($this->isAmazonPayButtonEnabled()): ?>
13
 
14
+ <div id="<?php echo $this->getAmazonPayButtonId(); ?>" class="amazon-pay-button" style="display:inline-block;margin:0 auto 10px;text-align:center;"></div>
15
 
16
  <script type="text/javascript">
17
  var authRequest;
18
 
19
+ AmazonPaymentsCallbacks["<?php echo $this->getAmazonPayButtonId(); ?>"] = function() {
20
+
21
+ var AmazonButtonOptions = {
22
+ type: "<?php echo $this->getButtonType(); ?>",
23
+ color: "<?php echo $this->getButtonColor(); ?>",
24
+ size: "<?php echo $this->getButtonSize(); ?>",
25
+ <?php if ($this->getLanguage()) : ?>
26
+ language: "<?php echo $this->getLanguage(); ?>",
27
+ <?php endif; ?>
28
+ authorization: function() {
29
+ loginOptions = {
30
+ scope: "profile payments:widget payments:shipping_address<?php print $this->getAdditionalScope(); ?>",
31
+ response_type: 'token',
32
+ popup: <?php print $this->isPopup(); ?>
33
+ };
34
+
35
+ authRequest = amazon.Login.authorize (loginOptions, "<?php echo (!$this->isPopup()) ? $this->getLoginAuthUrl() : $this->getCheckoutUrl(); ?>");
36
+ },
37
+
38
+ <?php if ($this->isTokenEnabled()) : ?>
39
+ agreementType: 'BillingAgreement',
40
+ onSignIn: function (billingAgreement) {
41
+ amazonBillingAgreementId = billingAgreement.getAmazonBillingAgreementId();
42
+ Mage.Cookies.set("amazonBillingAgreementId", amazonBillingAgreementId);
43
+ },
44
+ <?php endif; ?>
45
+
46
+ onError: function(error) {
47
+ console.log(error);
48
+ }
49
+ };
50
+
51
+ OffAmazonPayments.Button("<?php echo $this->getAmazonPayButtonId(); ?>", "<?php echo $this->getSellerId(); ?>", AmazonButtonOptions);
52
+
53
+ }
54
  </script>
55
 
56
  <?php endif; ?>
app/design/frontend/base/default/template/amazon_payments/button_shortcut.phtml CHANGED
@@ -14,76 +14,120 @@
14
  <div id="<?php echo $this->getAmazonPayButtonId(); ?>" style="clear:both;"></div>
15
 
16
  <script type="text/javascript">
17
- var authRequest;
18
-
19
- var AmazonButtonOptions = {
20
- type: "<?php echo $this->getButtonType(); ?>",
21
- color: "<?php echo $this->getButtonColor(); ?>",
22
- size: "<?php echo $this->getButtonSize(); ?>",
23
- authorization: function() {
24
- loginOptions = {
25
- scope: "profile payments:widget payments:shipping_address<?php print $this->getAdditionalScope(); ?>",
26
- response_type: 'token',
27
- popup: <?php print $this->isPopup(); ?>
28
- };
29
-
30
- authRequest = amazon.Login.authorize (loginOptions, "<?php echo !$this->isPopup() ? $this->getLoginAuthUrl() : $this->getCheckoutUrl(); ?>");
31
- },
32
- onError: function(error) {
33
- console.log(error);
34
- }
35
- };
36
-
37
- OffAmazonPayments.Button("<?php echo $this->getAmazonPayButtonId(); ?>", "<?php echo $this->getSellerId(); ?>", AmazonButtonOptions);
38
 
39
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
 
42
- <script type="text/javascript">
43
 
44
- // OffAmazonPayments.jQuery loaded by Amazon API
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
- var productAddToCartFormAmazon = new VarienForm('product_addtocart_form');
 
47
 
48
- productAddToCartFormAmazon.submit = function(button) {
49
- if (this.validator.validate()) {
50
- var form = this.form;
51
- var url = form.action;
 
 
 
 
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);
61
- }
62
- else {
63
- url = url.replace('https:', document.location.protocol);
64
- }
65
 
66
- // Add via Ajax and redirect to login/payment page
67
- OffAmazonPayments.jQuery.post(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
- }
76
- }.bind(productAddToCartFormAmazon);
77
 
78
 
79
- // Duplicate Amazon button
80
- OffAmazonPayments.jQuery("#<?php echo $this->getAmazonPayButtonId(); ?> img")
81
- .hide()
82
- .clone()
83
- .attr("id", "amazon-button-clone")
84
- .show()
85
- .appendTo("#<?php echo $this->getAmazonPayButtonId(); ?>")
86
- .click(productAddToCartFormAmazon.submit);
87
 
88
 
89
  </script>
14
  <div id="<?php echo $this->getAmazonPayButtonId(); ?>" style="clear:both;"></div>
15
 
16
  <script type="text/javascript">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
+ var AmazonConfirmModal = Class.create();
19
+
20
+ AmazonConfirmModal.prototype.show = function(url) {
21
+
22
+ this.oPopup = new Window({
23
+ id:'amazon_confirm_modal',
24
+ className: 'alphacube',
25
+ url: url,
26
+ width: 300,
27
+ height: 400,
28
+ minimizable: false,
29
+ maximizable: false,
30
+ showEffectOptions: {
31
+ duration: 0.4
32
+ },
33
+ hideEffectOptions:{
34
+ duration: 0.4
35
+ },
36
+ destroyOnClose: true,
37
+ onShow: function() { Event.observe($('overlay_modal'), 'click', function() { Windows.closeAll(); }) },
38
+ onClose: function() { $('overlay_modal').remove(); }
39
+ });
40
+ this.oPopup.setZIndex(100);
41
+ this.oPopup.showCenter(true);
42
+ }
43
 
44
 
45
+ var authRequest;
46
 
47
+ AmazonPaymentsCallbacks["<?php echo $this->getAmazonPayButtonId(); ?>"] = function() {
48
+
49
+ var AmazonButtonOptions = {
50
+ type: "<?php echo $this->getButtonType(); ?>",
51
+ color: "<?php echo $this->getButtonColor(); ?>",
52
+ size: "<?php echo $this->getButtonSize(); ?>",
53
+ <?php if ($this->getLanguage()) : ?>
54
+ language: "<?php echo $this->getLanguage(); ?>",
55
+ <?php endif; ?>
56
+ authorization: function() {
57
+ loginOptions = {
58
+ scope: "profile payments:widget payments:shipping_address<?php print $this->getAdditionalScope(); ?>",
59
+ response_type: 'token',
60
+ popup: <?php print $this->isPopup(); ?>,
61
+ state: 'shortcut'
62
+ };
63
+
64
+ authRequest = amazon.Login.authorize (loginOptions, "<?php echo !$this->isPopup() ? $this->getLoginAuthUrl() : $this->getCheckoutUrl(); ?>");
65
+ },
66
+ onError: function(error) {
67
+ console.log(error);
68
+ }
69
+ };
70
+
71
+ OffAmazonPayments.Button("<?php echo $this->getAmazonPayButtonId(); ?>", "<?php echo $this->getSellerId(); ?>", AmazonButtonOptions);
72
+
73
+ // jQuery wrapper -- OffAmazonPayments.jQuery loaded by Amazon API
74
+ (function($j) {
75
+ var productAddToCartFormAmazon = new VarienForm('product_addtocart_form');
76
+
77
+ productAddToCartFormAmazon.submit = function(button) {
78
+ if (this.validator.validate()) {
79
+ var form = this.form;
80
+ var url = form.action;
81
+
82
+ var e = null;
83
+
84
+ var data = $j(form).serialize();
85
+ data += '&isAjax=1';
86
+ $j('#ajax_loader').show();
87
+
88
+ if (document.location.protocol == 'https:') {
89
+ url = url.replace('http:', document.location.protocol);
90
+ }
91
+ else {
92
+ url = url.replace('https:', document.location.protocol);
93
+ }
94
+
95
+ // Add via Ajax and redirect to login/payment page
96
+ $j.post(url, data,
97
+ function(){
98
+ $j('#ajax_loader').hide();
99
+
100
+ <?php if ($this->isTokenEnabled()) : ?>
101
+ var amazonModal = new AmazonConfirmModal();
102
+ amazonModal.show('<?php print $this->getAjaxCartModalUrl(); ?>');
103
+ <?php else : ?>
104
+ $j("#<?php echo $this->getAmazonPayButtonId(); ?> img[id!='amazon-button-clone']").click();
105
+ <?php endif; ?>
106
+ }
107
+ );
108
 
109
+ }
110
+ }.bind(productAddToCartFormAmazon);
111
 
112
+ // Duplicate Amazon button
113
+ $j("#<?php echo $this->getAmazonPayButtonId(); ?> img")
114
+ .hide()
115
+ .clone()
116
+ .attr("id", "amazon-button-clone")
117
+ .show()
118
+ .appendTo("#<?php echo $this->getAmazonPayButtonId(); ?>")
119
+ .click(productAddToCartFormAmazon.submit);
120
 
 
121
 
122
+ })(OffAmazonPayments.jQuery);
123
+ }
 
124
 
125
+ </script>
 
 
 
 
 
126
 
 
 
 
 
 
 
 
 
127
 
128
+ <script type="text/javascript">
 
129
 
130
 
 
 
 
 
 
 
 
 
131
 
132
 
133
  </script>
app/design/frontend/base/default/template/amazon_payments/button_shortcut_ajaxcart.phtml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Amazon Payments
4
+ *
5
+ * @category Amazon
6
+ * @package Amazon_Payments
7
+ * @copyright Copyright (c) 2014 Amazon.com
8
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
9
+ */
10
+ ?>
11
+
12
+ <div id="<?php echo $this->getAmazonPayButtonId(); ?>" style="clear:both;"></div>
13
+
14
+ <script type="text/javascript">
15
+ var authRequest;
16
+
17
+ AmazonPaymentsCallbacks["<?php echo $this->getAmazonPayButtonId(); ?>"] = function() {
18
+ var AmazonButtonOptions = {
19
+ type: "<?php echo $this->getButtonType(); ?>",
20
+ color: "<?php echo $this->getButtonColor(); ?>",
21
+ size: "<?php echo $this->getButtonSize(); ?>",
22
+ authorization: function() {
23
+ loginOptions = {
24
+ scope: "profile payments:widget payments:shipping_address<?php print $this->getAdditionalScope(); ?>",
25
+ response_type: 'token',
26
+ popup: <?php print $this->isPopup(); ?>,
27
+ state: 'shortcut'
28
+ };
29
+
30
+ authRequest = amazon.Login.authorize (loginOptions, "<?php echo !$this->isPopup() ? $this->getLoginAuthUrl() : $this->getCheckoutUrl(); ?>");
31
+ },
32
+ onError: function(error) {
33
+ console.log(error);
34
+ }
35
+ };
36
+
37
+ OffAmazonPayments.Button("<?php echo $this->getAmazonPayButtonId(); ?>", "<?php echo $this->getSellerId(); ?>", AmazonButtonOptions);
38
+
39
+ // jQuery wrapper -- OffAmazonPayments.jQuery loaded by Amazon API
40
+ (function($j) {
41
+
42
+ // Open links in parent window of modal
43
+ $j("a").attr("target", "_top");
44
+
45
+ <?php if (!$this->isPopup()) : // Open Amazon Login in parent window (not Ajax iframe) ?>
46
+ // Duplicate Amazon button
47
+ $j("#<?php echo $this->getAmazonPayButtonId(); ?> img")
48
+ .hide()
49
+ .clone()
50
+ .attr("id", "amazon-button-clone")
51
+ .show()
52
+ .appendTo("#<?php echo $this->getAmazonPayButtonId(); ?>")
53
+ .click(function() {
54
+ $j(window.parent.document).find("#<?php echo $this->getAmazonPayButtonId(); ?> img[id!='amazon-button-clone']").click();
55
+ });
56
+ <?php endif; ?>
57
+
58
+ $j("#<?php echo $this->getAmazonPayButtonId(); ?>").click(function() {
59
+ $j(this).css("opacity", 0.33);
60
+ });
61
+
62
+ })(OffAmazonPayments.jQuery);
63
+ }
64
+
65
+ </script>
app/design/frontend/base/default/template/amazon_payments/checkout.phtml CHANGED
@@ -7,6 +7,7 @@
7
  * @copyright Copyright (c) 2014 Amazon.com
8
  * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
9
  */
 
10
  ?>
11
 
12
  <div id="amazon-checkout">
@@ -15,10 +16,9 @@
15
  <h1><?php echo $this->__('Checkout') ?></h1>
16
  </div>
17
 
18
- <?php echo $this->__('Login and Pay with Amazon uses information from your Amazon account to place your order.'); ?>
19
  <?php echo $this->__('Click <a href="#" id="amazon-cancel">here</a> to change your payment method.'); ?>
20
 
21
-
22
  <div id="checkout-amazon-payments">
23
  <div id="checkout-amazon-columns">
24
 
@@ -47,6 +47,14 @@
47
  <div id="amazon-widget-wallet"></div>
48
  </div>
49
 
 
 
 
 
 
 
 
 
50
  </div>
51
 
52
 
@@ -59,13 +67,13 @@
59
 
60
  <?php if ($this->helper('amazon_payments')->isAmazonSandbox()) : ?>
61
  <br />
62
- <h3>Authorization Sandbox Simulation:</h3>
63
  <textarea id="sandbox"></textarea>
64
- Example:
65
  <small>
66
  {"SandboxSimulation": {"State":"Declined", "ReasonCode":"InvalidPaymentMethod"}}
67
  <br />
68
- (<a href="https://payments.amazon.com/documentation/lpwa/201749840#201750790" target="_blank">More Info</a>)<br />
69
  </small>
70
 
71
 
@@ -90,20 +98,23 @@ var AmazonPaymentsMageCheckout = Class.create();
90
  AmazonPaymentsMageCheckout.prototype = {
91
  initialize: function(opts){
92
  this.opts = opts;
 
 
93
  this.hasPayment = false;
94
  this.hasReviewLoader = false;
95
- //this.setShippingMethod();
96
  },
97
 
98
- // Dynamically load shipping method HTML
99
- setShippingMethod: function() {
 
100
  if (this.opts.shippingMethod) {
101
  this.restrictPlaceOrder(true);
102
 
103
- var request = new Ajax.Request(this.opts.shippingMethod.url, {
104
  method: 'post',
105
- parameters: { "amazon_order_reference_id": this.amazonOrderReferenceId },
106
- onSuccess: this.renderShippingMethod.bindAsEventListener(this, this.opts.shippingMethod.id)
107
  });
108
  }
109
  else {
@@ -111,10 +122,38 @@ AmazonPaymentsMageCheckout.prototype = {
111
  }
112
  },
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  // Dynamically load review HTML
115
  setReview: function() {
116
- var btnSubmit = $$(".button.btn-checkout");
117
-
118
  var shippingMethod = $$('input:checked[type=radio][name=shipping_method]')[0];
119
 
120
  if (shippingMethod != undefined) {
@@ -141,44 +180,75 @@ AmazonPaymentsMageCheckout.prototype = {
141
  renderShippingMethod: function(transport, id) {
142
  $(id).update(transport.responseText);
143
 
144
- $$('input[type="radio"][name="shipping_method"]').each(function(el){
 
 
145
  Event.observe(el, 'change', this.setReview.bindAsEventListener(this));
146
- }, this);
 
 
 
 
 
 
 
 
 
 
 
147
 
148
- this.setReview();
149
  },
150
 
151
  renderReview: function(transport, id) {
152
  $(id).update(transport.responseText);
153
- $$(".button.btn-checkout").invoke('writeAttribute','onclick', 'amazonPaymentsMageCheckout.saveOrder()');
 
 
 
 
 
 
 
154
  this.agreementsForm = $('checkout-agreements')
155
  $("amz-review-loader").hide();
156
  this.restrictPlaceOrder(false);
157
  },
158
 
159
  saveOrder: function() {
 
 
 
 
 
 
 
 
160
  var params = {};
161
 
162
  if (this.agreementsForm) {
163
- params += '&'+Form.serialize(this.agreementsForm);
164
  }
 
165
  params.save = true;
166
 
167
- params.amazon_order_reference_id = this.amazonOrderReferenceId;
 
 
168
 
169
- var sandbox = $('sandbox');
170
- if (sandbox) {
171
- params.sandbox = sandbox.getValue();
172
- }
173
 
174
- this.restrictPlaceOrder(true);
175
- this.restrictWidgets(true);
 
 
176
 
177
- var request = new Ajax.Request(this.opts.save.url, {
178
- method: 'post',
179
- parameters: params,
180
- onSuccess: this.onSaveOrder.bindAsEventListener(this)
181
- });
 
 
 
182
  },
183
 
184
  onSaveOrder: function(transport) {
@@ -207,6 +277,12 @@ AmazonPaymentsMageCheckout.prototype = {
207
  if (typeof(msg)=='object') {
208
  msg = msg.join("\n");
209
  }
 
 
 
 
 
 
210
  if (msg) {
211
  alert(msg);
212
  }
@@ -219,7 +295,8 @@ AmazonPaymentsMageCheckout.prototype = {
219
  setTimeout(loadAmazonWallet, 2000); // Refresh Wallet
220
  }
221
 
222
- if (msg.indexOf("Declined") != -1) {
 
223
  this.restrictShipping();
224
  }
225
 
@@ -303,10 +380,16 @@ var opts = {
303
  url: "<?php echo $this->getUrl('checkout/amazon_payments/shippingMethod') ?>"
304
  },
305
  <?php endif; ?>
 
 
 
306
  review : {
307
  id: "checkout-review-load",
308
  url: "<?php echo $this->getUrl('checkout/amazon_payments/review') ?>"
309
  },
 
 
 
310
  save : {
311
  url: "<?php echo $this->getUrl('checkout/amazon_payments/saveOrder') ?>"
312
  }
@@ -334,31 +417,94 @@ var restrictInterval = setInterval(function() {
334
  }
335
  }
336
  }, 100);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  </script>
338
 
339
 
340
  <!-- Address Book Widget JS -->
341
  <script>
342
 
343
- new OffAmazonPayments.Widgets.AddressBook({
344
- sellerId: '<?php echo $this->getSellerId(); ?>',
345
- onOrderReferenceCreate: function(orderReference) {
346
- amazonPaymentsMageCheckout.amazonOrderReferenceId = orderReference.getAmazonOrderReferenceId();
347
- },
348
- onAddressSelect: function(orderReference) {
349
- amazonPaymentsMageCheckout.setShippingMethod();
350
- amazonPaymentsMageCheckout.hasPayment = false;
351
- },
352
- design: {
353
- designMode: 'responsive'
354
- },
355
- onError: function(error) {
356
- if (error.getErrorCode() == "BuyerSessionExpired") {
357
- window.top.location.href = '<?php echo $this->getUrl('checkout/amazon_payments/clear'); ?>';
 
 
 
 
358
  }
359
- console.log(error.getErrorMessage());
360
- }
361
- }).bind("amazon-widget-address");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
  </script>
363
 
364
 
@@ -366,19 +512,66 @@ new OffAmazonPayments.Widgets.AddressBook({
366
  <script>
367
  function loadAmazonWallet() {
368
  new OffAmazonPayments.Widgets.Wallet({
369
- sellerId: '<?php echo $this->getSellerId(); ?>',
 
 
 
370
  design: {
371
- designMode: 'responsive',
372
- },
 
 
 
 
 
 
 
 
 
 
 
373
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
374
  onPaymentSelect: function(orderReference) {
375
  amazonPaymentsMageCheckout.hasPayment = true;
376
  },
377
  onError: function(error) {
378
  console.log(error.getErrorMessage());
379
  }
380
- }).bind("amazon-widget-wallet");
381
  }
382
 
383
- loadAmazonWallet();
384
  </script>
 
 
 
7
  * @copyright Copyright (c) 2014 Amazon.com
8
  * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
9
  */
10
+
11
  ?>
12
 
13
  <div id="amazon-checkout">
16
  <h1><?php echo $this->__('Checkout') ?></h1>
17
  </div>
18
 
19
+ <?php echo $this->__('Amazon Payments uses information from your Amazon account to place your order.'); ?>
20
  <?php echo $this->__('Click <a href="#" id="amazon-cancel">here</a> to change your payment method.'); ?>
21
 
 
22
  <div id="checkout-amazon-payments">
23
  <div id="checkout-amazon-columns">
24
 
47
  <div id="amazon-widget-wallet"></div>
48
  </div>
49
 
50
+ <?php if ($this->isTokenEnabled()) : ?>
51
+ <div id="amazon-widget-consent"></div>
52
+ <?php endif; ?>
53
+
54
+ <?php if ($this->isShowCoupon()) : ?>
55
+ <?php echo $this->getChildHtml('coupon') ?>
56
+ <?php endif; ?>
57
+
58
  </div>
59
 
60
 
67
 
68
  <?php if ($this->helper('amazon_payments')->isAmazonSandbox()) : ?>
69
  <br />
70
+ <h3><?php echo $this->__('Authorization Sandbox Simulation:'); ?></h3>
71
  <textarea id="sandbox"></textarea>
72
+ <?php echo $this->__('Example:') ?>
73
  <small>
74
  {"SandboxSimulation": {"State":"Declined", "ReasonCode":"InvalidPaymentMethod"}}
75
  <br />
76
+ (<a href="https://payments.amazon.com/documentation/lpwa/201749840#201750790" target="_blank"><?php echo $this->__('More Info') ?></a>)<br />
77
  </small>
78
 
79
 
98
  AmazonPaymentsMageCheckout.prototype = {
99
  initialize: function(opts){
100
  this.opts = opts;
101
+ this.amazonBillingAgreementId = null;
102
+ this.amazonBillingAgreementConsent = false;
103
  this.hasPayment = false;
104
  this.hasReviewLoader = false;
105
+ this.hasHiddenShippingMethod = false;
106
  },
107
 
108
+ // Dynamically load shipping method and review HTML
109
+ // (Widget callback)
110
+ setAddress: function() {
111
  if (this.opts.shippingMethod) {
112
  this.restrictPlaceOrder(true);
113
 
114
+ var request = new Ajax.Request(this.opts.addressSelect.url, {
115
  method: 'post',
116
+ parameters: { "amazon_order_reference_id": this.amazonOrderReferenceId, "amazon_billing_agreement_id": this.amazonBillingAgreementId },
117
+ onSuccess: this.onSaveAddress.bindAsEventListener(this)
118
  });
119
  }
120
  else {
122
  }
123
  },
124
 
125
+ // Render shipping method and review at same time
126
+ onSaveAddress: function(transport) {
127
+ try{
128
+ response = eval('(' + transport.responseText + ')');
129
+ }
130
+ catch (e) {
131
+ response = {};
132
+ }
133
+
134
+ if (response.review) {
135
+ transport.hasReview = true;
136
+ transport.responseText = response.shipping_method;
137
+ this.renderShippingMethod(transport, this.opts.shippingMethod.id);
138
+
139
+ transport.responseText = response.review;
140
+ this.renderReview(transport, this.opts.review.id);
141
+ }
142
+ },
143
+
144
+ // Set additional options (e.g. gift message or EE gift wrapping)
145
+ setAdditional: function(parameters) {
146
+ this.restrictPlaceOrder(true);
147
+
148
+ var request = new Ajax.Request(this.opts.additional.url, {
149
+ method: 'post',
150
+ parameters: parameters,
151
+ onSuccess: this.renderReview.bindAsEventListener(this, this.opts.review.id)
152
+ });
153
+ },
154
+
155
  // Dynamically load review HTML
156
  setReview: function() {
 
 
157
  var shippingMethod = $$('input:checked[type=radio][name=shipping_method]')[0];
158
 
159
  if (shippingMethod != undefined) {
180
  renderShippingMethod: function(transport, id) {
181
  $(id).update(transport.responseText);
182
 
183
+ var elShippingMethods = $$('input[type="radio"][name="shipping_method"]');
184
+
185
+ elShippingMethods.each(function(el){
186
  Event.observe(el, 'change', this.setReview.bindAsEventListener(this));
187
+ }, this);
188
+
189
+
190
+ // Set shipping method if only one available and hidden
191
+ if (elShippingMethods.length == 1 && !this.hasHiddenShippingMethod) {
192
+ this.hasHiddenShippingMethod = true;
193
+ this.setReview();
194
+ }
195
+
196
+ if (!transport.hasReview) {
197
+ this.setReview();
198
+ }
199
 
 
200
  },
201
 
202
  renderReview: function(transport, id) {
203
  $(id).update(transport.responseText);
204
+
205
+ var btnSubmit = $$(".button.btn-checkout");
206
+
207
+ if (!btnSubmit.length) {
208
+ btnSubmit = $$('button[onclick*="review.save()"]');
209
+ }
210
+
211
+ btnSubmit.invoke('writeAttribute','onclick', 'amazonPaymentsMageCheckout.saveOrder()');
212
  this.agreementsForm = $('checkout-agreements')
213
  $("amz-review-loader").hide();
214
  this.restrictPlaceOrder(false);
215
  },
216
 
217
  saveOrder: function() {
218
+
219
+ <?php if ($this->isTokenRequired()) : ?>
220
+ if (!this.amazonBillingAgreementConsent) {
221
+ alert("Please check 'Use my selected payment method for future purchases and payments to this merchant' to complete this purchase.");
222
+ return;
223
+ }
224
+ <?php endif; ?>
225
+
226
  var params = {};
227
 
228
  if (this.agreementsForm) {
229
+ params = this.agreementsForm.serialize(true);
230
  }
231
+
232
  params.save = true;
233
 
234
+ params.amazon_order_reference_id = this.amazonOrderReferenceId;
235
+ params.amazon_billing_agreement_id = this.amazonBillingAgreementId;
236
+ params.amazon_billing_agreement_consent = this.amazonBillingAgreementConsent;
237
 
 
 
 
 
238
 
239
+ var sandbox = $('sandbox');
240
+ if (sandbox) {
241
+ params.sandbox = sandbox.getValue();
242
+ }
243
 
244
+ this.restrictPlaceOrder(true);
245
+ this.restrictWidgets(true);
246
+
247
+ var request = new Ajax.Request(this.opts.save.url, {
248
+ method: 'post',
249
+ parameters: params,
250
+ onSuccess: this.onSaveOrder.bindAsEventListener(this)
251
+ });
252
  },
253
 
254
  onSaveOrder: function(transport) {
277
  if (typeof(msg)=='object') {
278
  msg = msg.join("\n");
279
  }
280
+
281
+ // Clean BillingAgreement error message
282
+ if (msg.indexOf("BillingAgreement") != -1 && msg.indexOf("total authorization amount cannot exceed") != -1) {
283
+ msg = "You have exceeded your total authorization amount for this billing agreement period. Please contact the store manager."
284
+ }
285
+
286
  if (msg) {
287
  alert(msg);
288
  }
295
  setTimeout(loadAmazonWallet, 2000); // Refresh Wallet
296
  }
297
 
298
+ // InvalidPaymentMethod?
299
+ if (msg.indexOf("Amazon Wallet") != -1) {
300
  this.restrictShipping();
301
  }
302
 
380
  url: "<?php echo $this->getUrl('checkout/amazon_payments/shippingMethod') ?>"
381
  },
382
  <?php endif; ?>
383
+ additional : {
384
+ url: "<?php echo $this->getUrl('checkout/amazon_payments/additional') ?>"
385
+ },
386
  review : {
387
  id: "checkout-review-load",
388
  url: "<?php echo $this->getUrl('checkout/amazon_payments/review') ?>"
389
  },
390
+ addressSelect : {
391
+ url: "<?php echo $this->getUrl('checkout/amazon_payments/addressSelect') ?>"
392
+ },
393
  save : {
394
  url: "<?php echo $this->getUrl('checkout/amazon_payments/saveOrder') ?>"
395
  }
417
  }
418
  }
419
  }, 100);
420
+
421
+ // Additional form elements such as Gift Options
422
+ document.observe('dom:loaded', function(){
423
+ var addEls = $('checkout-shipping-method-additional-load').select('input', 'select', 'textarea');
424
+
425
+ addEls.each(function(elChange) {
426
+ //console.log(el);
427
+
428
+ Event.observe(elChange, 'change', function() {
429
+ var params = {};
430
+
431
+ addEls.each(function(el) {
432
+ if (el.type == "checkbox") {
433
+ if (el.checked) {
434
+ params[el.name] = el.value;
435
+ }
436
+ }
437
+ else if (el.options && (typeof params[el.name] == "undefined" || !params[el.name])) {
438
+
439
+ params[el.name] = el.options[el.selectedIndex].value;
440
+
441
+ }
442
+ else if (!params[el.name]) {
443
+ params[el.name] = el.value;
444
+ }
445
+ });
446
+ console.log(params);
447
+
448
+ //var value = el.value;
449
+
450
+ amazonPaymentsMageCheckout.setAdditional(params)
451
+
452
+ });
453
+ });
454
+ });
455
+
456
  </script>
457
 
458
 
459
  <!-- Address Book Widget JS -->
460
  <script>
461
 
462
+ var amazonBillingAgreementId;
463
+
464
+ var addressBookOpts = {
465
+ sellerId: '<?php echo $this->getSellerId(); ?>',
466
+ onOrderReferenceCreate: function(orderReference) {
467
+ amazonPaymentsMageCheckout.amazonOrderReferenceId = orderReference.getAmazonOrderReferenceId();
468
+ },
469
+ onAddressSelect: function(orderReference) {
470
+ amazonPaymentsMageCheckout.setAddress();
471
+ amazonPaymentsMageCheckout.hasPayment = false;
472
+ },
473
+ design: {
474
+ designMode: 'responsive'
475
+ },
476
+ onError: function(error) {
477
+ if (error.getErrorCode() == "BuyerSessionExpired") {
478
+ window.top.location.href = '<?php echo $this->getUrl('checkout/amazon_payments/clear'); ?>';
479
+ }
480
+ console.log(error.getErrorMessage());
481
  }
482
+ };
483
+
484
+
485
+ <?php if ($this->isTokenEnabled()) : ?>
486
+ amazonBillingAgreementId = Mage.Cookies.get("amazonBillingAgreementId");
487
+
488
+ if (amazonBillingAgreementId) {
489
+ addressBookOpts.agreementType = "BillingAgreement";
490
+ addressBookOpts.amazonBillingAgreementId = amazonBillingAgreementId;
491
+ }
492
+
493
+ addressBookOpts.onReady = function(billingAgreement) {
494
+ if (!amazonBillingAgreementId) {
495
+ amazonBillingAgreementId = billingAgreement.getAmazonBillingAgreementId();
496
+ }
497
+
498
+ amazonPaymentsMageCheckout.amazonBillingAgreementId = amazonBillingAgreementId;
499
+ loadAmazonWallet();
500
+ };
501
+ <?php endif; ?>
502
+
503
+
504
+ AmazonPaymentsCallbacks["widgets_address"] = function() {
505
+ new OffAmazonPayments.Widgets.AddressBook(addressBookOpts).bind("amazon-widget-address");
506
+ }
507
+
508
  </script>
509
 
510
 
512
  <script>
513
  function loadAmazonWallet() {
514
  new OffAmazonPayments.Widgets.Wallet({
515
+ <?php if ($this->isTokenEnabled()) : ?>
516
+ amazonBillingAgreementId: amazonBillingAgreementId,
517
+ <?php endif; ?>
518
+ sellerId: '<?php echo $this->getSellerId(); ?>',
519
  design: {
520
+ designMode: 'responsive',
521
+ },
522
+ onPaymentSelect: function(orderReference) {
523
+ <?php if ($this->isTokenEnabled()) : ?>
524
+ loadAmazonConsent();
525
+ <?php endif; ?>
526
+ amazonPaymentsMageCheckout.hasPayment = true;
527
+ },
528
+ onError: function(error) {
529
+ console.log(error.getErrorMessage());
530
+ }
531
+ }).bind("amazon-widget-wallet");
532
+ }
533
 
534
+ <?php if (!$this->isTokenEnabled()) : ?>
535
+ AmazonPaymentsCallbacks["widgets_wallet"] = function() {
536
+ loadAmazonWallet();
537
+ }
538
+ <?php endif; ?>
539
+
540
+ </script>
541
+
542
+ <?php if ($this->isTokenEnabled()) : ?>
543
+ <!-- Consent Widget JS -->
544
+ <script>
545
+ function loadAmazonConsent() {
546
+
547
+ new OffAmazonPayments.Widgets.Consent({
548
+ sellerId: '<?php echo $this->getSellerId(); ?>',
549
+ // amazonBillingAgreementId obtained from the Amazon Address Book widget.
550
+ amazonBillingAgreementId: amazonBillingAgreementId,
551
+ design: {
552
+ designMode: 'responsive'
553
+ },
554
+ onReady: function(billingAgreementConsentStatus){
555
+ // Called after widget renders
556
+ if (typeof billingAgreementConsentStatus != "undefined") {
557
+ amazonPaymentsMageCheckout.amazonBillingAgreementConsent = billingAgreementConsentStatus.getConsentStatus() == "true" ? true : false;
558
+ }
559
+ },
560
+ onConsent: function(billingAgreementConsentStatus) {
561
+ if (typeof billingAgreementConsentStatus != "undefined") {
562
+ amazonPaymentsMageCheckout.amazonBillingAgreementConsent = billingAgreementConsentStatus.getConsentStatus() == "true" ? true : false;
563
+ }
564
+ },
565
  onPaymentSelect: function(orderReference) {
566
  amazonPaymentsMageCheckout.hasPayment = true;
567
  },
568
  onError: function(error) {
569
  console.log(error.getErrorMessage());
570
  }
571
+ }).bind("amazon-widget-consent");
572
  }
573
 
 
574
  </script>
575
+
576
+ <?php endif; ?>
577
+
app/design/frontend/base/default/template/amazon_payments/coupon.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Amazon Payments
4
+ *
5
+ * @category Amazon
6
+ * @package Amazon_Payments
7
+ * @copyright Copyright (c) 2014 Amazon.com
8
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
9
+ */
10
+ ?>
11
+
12
+ <h2><?php echo $this->__('Discount Codes') ?></h2>
13
+
14
+ <form id="discount-coupon-form" action="<?php echo $this->getUrl('checkout/amazon_payments/couponPost') ?>" method="post">
15
+ <div class="discount">
16
+ <h2><?php echo $this->__('Discount Codes') ?></h2>
17
+ <div class="discount-form">
18
+ <label for="coupon_code"><?php echo $this->__('Enter your coupon code if you have one.') ?></label>
19
+ <input type="hidden" name="remove" id="remove-coupone" value="0" />
20
+ <div class="field-wrapper">
21
+ <input class="input-text" type="text" id="coupon_code" name="coupon_code" value="<?php echo $this->escapeHtml($this->getCouponCode()) ?>" />
22
+ <div class="button-wrapper">
23
+ <button type="button" title="<?php echo $this->__('Apply') ?>" class="button2" onclick="discountForm.submit(false)" value="<?php echo $this->__('Apply') ?>"><span><span><?php echo $this->__('Apply') ?></span></span></button>
24
+ <?php if(strlen($this->getCouponCode())): ?>
25
+ <button type="button" title="<?php echo $this->__('Cancel') ?>" class="button2 cancel-coupon" onclick="discountForm.submit(true)" value="<?php echo $this->__('Cancel') ?>"><span><span><?php echo $this->__('Cancel') ?></span></span>
26
+ </button>
27
+ <?php endif;?>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ </form>
33
+ <script type="text/javascript">
34
+ //<![CDATA[
35
+ var discountForm = new VarienForm('discount-coupon-form');
36
+ discountForm.submit = function (isRemove) {
37
+ if (isRemove) {
38
+ $('coupon_code').removeClassName('required-entry');
39
+ $('remove-coupone').value = "1";
40
+ } else {
41
+ $('coupon_code').addClassName('required-entry');
42
+ $('remove-coupone').value = "0";
43
+ }
44
+ return VarienForm.prototype.submit.bind(discountForm)();
45
+ }
46
+ //]]>
47
+ </script>
app/design/frontend/base/default/template/amazon_payments/login/button.phtml CHANGED
@@ -9,6 +9,8 @@
9
  */
10
  ?>
11
 
 
 
12
  <div id="amazon-buttons-wrapper" class="col2-set">
13
  <div class="col-1">
14
  <div class="amazon-login-button-wrapper">
@@ -21,7 +23,7 @@
21
  <?php if (!$this->isAmazonPaymentsEnabled()) : // Old embed method (does not require seller id) ?>
22
 
23
  <button class="amazon-login-button" style="cursor:pointer; background:none; border:0;">
24
- <img src="<?php echo $this->getButtonImage(); ?>" alt="Login with Amazon" border="0" />
25
  </button>
26
 
27
  <?php else : // Use Amazon Payments embed method ?>
@@ -31,25 +33,31 @@
31
  <script type="text/javascript">
32
  var authRequest;
33
 
34
- var AmazonButtonOptions = {
35
- type: "<?php echo $this->getButtonType(); ?>",
36
- color: "<?php echo $this->getButtonColor(); ?>",
37
- size: "<?php echo $this->getButtonSize(); ?>",
38
- authorization: function() {
39
- loginOptions = {
40
- scope: "profile payments:widget payments:shipping_address<?php print $this->getAdditionalScope(); ?>",
41
- response_type: 'token',
42
- popup: <?php print $this->isPopup(); ?>
43
- };
44
-
45
- authRequest = amazon.Login.authorize (loginOptions, "<?php echo (!$this->isPopup()) ? $this->getLoginAuthUrl() : $this->getCheckoutUrl(); ?>");
46
- },
47
- onError: function(error) {
48
- console.log(error);
49
- }
50
- };
51
-
52
- OffAmazonPayments.Button("amazon-login-button", "<?php echo $this->getSellerId(); ?>", AmazonButtonOptions);
 
 
 
 
 
 
53
 
54
  </script>
55
 
@@ -63,3 +71,5 @@
63
  </div>
64
  </div>
65
  </div>
 
 
9
  */
10
  ?>
11
 
12
+ <?php if ($this->isAmazonLoginEnabled()) : ?>
13
+
14
  <div id="amazon-buttons-wrapper" class="col2-set">
15
  <div class="col-1">
16
  <div class="amazon-login-button-wrapper">
23
  <?php if (!$this->isAmazonPaymentsEnabled()) : // Old embed method (does not require seller id) ?>
24
 
25
  <button class="amazon-login-button" style="cursor:pointer; background:none; border:0;">
26
+ <img src="<?php echo $this->getButtonImage(); ?>" alt="<?php echo $this->__('Login with Amazon'); ?>" border="0" />
27
  </button>
28
 
29
  <?php else : // Use Amazon Payments embed method ?>
33
  <script type="text/javascript">
34
  var authRequest;
35
 
36
+ AmazonPaymentsCallbacks["<?php echo $this->getAmazonPayButtonId(); ?>"] = function() {
37
+
38
+ var AmazonButtonOptions = {
39
+ type: "<?php echo $this->getButtonType(); ?>",
40
+ color: "<?php echo $this->getButtonColor(); ?>",
41
+ size: "<?php echo $this->getButtonSize(); ?>",
42
+ <?php if ($this->getLanguage()) : ?>
43
+ language: "<?php echo $this->getLanguage(); ?>",
44
+ <?php endif; ?>
45
+ authorization: function() {
46
+ loginOptions = {
47
+ scope: "profile payments:widget payments:shipping_address<?php print $this->getAdditionalScope(); ?>",
48
+ response_type: 'token',
49
+ popup: <?php print $this->isPopup(); ?>
50
+ };
51
+
52
+ authRequest = amazon.Login.authorize (loginOptions, "<?php echo (!$this->isPopup()) ? $this->getLoginAuthUrl() : $this->getCheckoutUrl(); ?>");
53
+ },
54
+ onError: function(error) {
55
+ console.log(error);
56
+ }
57
+ };
58
+
59
+ OffAmazonPayments.Button("amazon-login-button", "<?php echo $this->getSellerId(); ?>", AmazonButtonOptions);
60
+ }
61
 
62
  </script>
63
 
71
  </div>
72
  </div>
73
  </div>
74
+
75
+ <?php endif; ?>
app/design/frontend/base/default/template/amazon_payments/login/script.phtml DELETED
@@ -1,116 +0,0 @@
1
- <?php
2
- /**
3
- * Login with Amazon
4
- *
5
- * @category Amazon
6
- * @package Amazon_Payments
7
- * @copyright Copyright (c) 2014 Amazon.com
8
- * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
9
- */
10
- ?>
11
-
12
- <?php
13
- /**
14
- * @see https://images-na.ssl-images-amazon.com/images/G/01/lwa/dev/docs/website-sdk-reference._TTH_.pdf
15
- */
16
- ?>
17
-
18
- <?php if (!$this->isAmazonPaymentsEnabled() || $this->getNameInLayout() == 'amazon_login.script.logout') : ?>
19
-
20
- <div id="amazon-root"></div>
21
- <script type="text/javascript">
22
-
23
- window.onAmazonLoginReady = function() {
24
- <?php if ($this->isSandboxEnabled()) : ?>
25
- amazon.Login.setSandboxMode(true);
26
- <?php endif; ?>
27
-
28
- amazon.Login.setClientId('<?php echo $this->getClientId(); ?>');
29
-
30
- <?php if (!$this->isPopup()) : ?>
31
- amazon.Login.setUseCookie(true);
32
- <?php endif; ?>
33
- };
34
- (function(d) {
35
- var a = d.createElement('script'); a.type = 'text/javascript';
36
- a.async = true; a.id = 'amazon-login-sdk';
37
- a.src = 'https://api-cdn.amazon.com/sdk/login1.js';
38
- d.getElementById('amazon-root').appendChild(a);
39
- })(document);
40
-
41
-
42
-
43
- function amazonLoginAuthorize() {
44
- options = {
45
- scope : 'profile postal_code payments:shipping_address<?php print $this->getAdditionalScope(); ?>',
46
- response_type: 'token',
47
- popup: <?php print $this->isPopup(); ?>
48
- };
49
-
50
- <?php if ($this->isPopup()) : ?>
51
-
52
- var responseRedirect = function(response) {
53
- if (response.error) {
54
- console.log(response.error);
55
- }
56
- else {
57
- document.location.href = "<?php echo $this->getLoginAuthUrl(); ?>?token=" + response.access_token + "&referer=<?php echo Mage::helper('core')->urlEncode($this->helper('core/url')->getCurrentUrl())?>";
58
- }
59
- }
60
-
61
- <?php else: ?>
62
-
63
- var responseRedirect = "<?php echo $this->getLoginAuthUrl(); ?>";
64
-
65
- <?php endif; ?>
66
-
67
- amazon.Login.authorize(options, responseRedirect);
68
- }
69
-
70
- $$('.amazon-login-button').each(function(el) {
71
- el.observe('click', amazonLoginAuthorize);
72
- })
73
-
74
- </script>
75
-
76
-
77
- <?php else : // Amazon Payments is enabled ?>
78
-
79
- <script type='text/javascript'>
80
- window.onAmazonLoginReady = function() {
81
- amazon.Login.setClientId('<?php echo $this->getClientId(); ?>');
82
-
83
- <?php if (!$this->isPopup()) : ?>
84
- amazon.Login.setUseCookie(true);
85
- <?php endif; ?>
86
-
87
- };
88
-
89
- <?php if (!$this->isPopup()) : ?>
90
- src = '<?php echo $this->getWidgetsUrl(); ?>';
91
- <?php endif; ?>
92
-
93
- </script>
94
-
95
- <script type='text/javascript' src='<?php echo $this->getWidgetsUrl(); ?>'></script>
96
- <script>jQuery.noConflict();</script>
97
-
98
-
99
- <?php endif; ?>
100
-
101
-
102
-
103
- <?php if ($this->getNameInLayout() == 'amazon_login.script.logout') : ?>
104
-
105
- <script type="text/javascript">
106
- function amazonLogout() {
107
- amazon.Login.logout();
108
- document.cookie = "amazon_Login_accessToken=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
109
- }
110
-
111
- window.onAmazonLoginReady = amazonLogout; // If not loading Widget JS
112
- amazonLogout();
113
-
114
- </script>
115
-
116
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/amazon_payments/login/script_logout.phtml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Login with Amazon
4
+ *
5
+ * @category Amazon
6
+ * @package Amazon_Payments
7
+ * @copyright Copyright (c) 2014 Amazon.com
8
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
9
+ */
10
+ ?>
11
+
12
+
13
+ <script type="text/javascript">
14
+ function amazonLogout() {
15
+ amazon.Login.logout();
16
+ document.cookie = "amazon_Login_accessToken=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
17
+ }
18
+ window.onAmazonLoginReady = amazonLogout;
19
+ </script>
20
+
21
+ <script type='text/javascript' src='<?php echo $this->getWidgetsUrl(); ?>'></script>
22
+
app/design/frontend/base/default/template/amazon_payments/onepage/button.phtml CHANGED
@@ -15,25 +15,39 @@
15
  <script type="text/javascript">
16
  var authRequest;
17
 
18
- var AmazonButtonOptions = {
19
- type: "<?php echo ($this->isAmazonLoginEnabled()) ? 'LwA' : $this->getButtonType(); ?>",
20
- color: "<?php echo $this->getButtonColor(); ?>",
21
- size: "<?php echo $this->getButtonSize(); ?>",
22
- authorization: function() {
23
- loginOptions = {
24
- scope: "profile payments:widget payments:shipping_address<?php print $this->getAdditionalScope(); ?>",
25
- response_type: 'token',
26
- popup: <?php print $this->isPopup(); ?>
27
- };
28
-
29
- authRequest = amazon.Login.authorize (loginOptions, "<?php echo (!$this->isPopup()) ? $this->getLoginAuthUrl() : $this->getCheckoutUrl(); ?>");
30
- },
31
- onError: function(error) {
32
- console.log(error);
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  };
35
 
36
- OffAmazonPayments.Button("<?php echo $this->getAmazonPayButtonId(); ?>", "<?php echo $this->getSellerId(); ?>", AmazonButtonOptions);
37
  </script>
38
 
39
 
15
  <script type="text/javascript">
16
  var authRequest;
17
 
18
+ AmazonPaymentsCallbacks["<?php echo $this->getAmazonPayButtonId(); ?>"] = function() {
19
+
20
+ var AmazonButtonOptions = {
21
+ type: "<?php echo ($this->isAmazonLoginEnabled()) ? 'LwA' : $this->getButtonType(); ?>",
22
+ color: "<?php echo $this->getButtonColor(); ?>",
23
+ size: "<?php echo $this->getButtonSize(); ?>",
24
+ <?php if ($this->getLanguage()) : ?>
25
+ language: "<?php echo $this->getLanguage(); ?>",
26
+ <?php endif; ?>
27
+ authorization: function() {
28
+ loginOptions = {
29
+ scope: "profile payments:widget payments:shipping_address<?php print $this->getAdditionalScope(); ?>",
30
+ response_type: 'token',
31
+ popup: <?php print $this->isPopup(); ?>
32
+ };
33
+
34
+ authRequest = amazon.Login.authorize (loginOptions, "<?php echo (!$this->isPopup()) ? $this->getLoginAuthUrl() : $this->getCheckoutUrl(); ?>");
35
+ },
36
+ <?php if ($this->isTokenEnabled()) : ?>
37
+ agreementType: 'BillingAgreement',
38
+ onSignIn: function (billingAgreement) {
39
+ amazonBillingAgreementId = billingAgreement.getAmazonBillingAgreementId();
40
+ Mage.Cookies.set("amazonBillingAgreementId", amazonBillingAgreementId);
41
+ },
42
+ <?php endif; ?>
43
+ onError: function(error) {
44
+ console.log(error);
45
+ }
46
+ };
47
+
48
+ OffAmazonPayments.Button("<?php echo $this->getAmazonPayButtonId(); ?>", "<?php echo $this->getSellerId(); ?>", AmazonButtonOptions);
49
  };
50
 
 
51
  </script>
52
 
53
 
app/design/frontend/base/default/template/amazon_payments/onepage/widget.phtml CHANGED
@@ -14,18 +14,20 @@
14
  <input type="checkbox" style="display:none;"> <!-- MageMonkey Mailchimp compatibility (their JS requires a form element to dynamically append input element) -->
15
 
16
  <input type="hidden" name="amazon_order_reference_id" value="" />
 
 
17
  <input type="hidden" name="payment[method]" value="amazon_payments" />
18
 
19
 
20
  <?php if ($this->isShowShip()) : ?>
21
  <div id="amazon-widget-address-wrapper" class="amazon-widget-wrapper">
22
- <h3>Shipping Information</h3>
23
  <div id="amazon-widget-address"></div>
24
  </div>
25
  <?php endif; ?>
26
 
27
  <div id="amazon-widget-wallet-wrapper" class="amazon-widget-wrapper">
28
- <h3>Payment Information</h3>
29
  <div id="amazon-widget-wallet"></div>
30
  </div>
31
 
@@ -35,14 +37,17 @@
35
  <input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed" class="checkbox" />
36
  <label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
37
  </p>
38
-
39
- <?php endif ?>
40
 
41
  <?php echo $this->getAdditionalForm(); ?>
42
  </div>
43
 
 
 
 
 
44
  <div class="buttons-set" id="widget-buttons-container">
45
- <button type="button" title="<?php echo $this->__('Continue') ?>" class="button" onclick="amazonWidgetStep.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
46
  <span class="please-wait" id="widget-please-wait" style="display:none;">
47
  <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
48
  </span>
@@ -55,8 +60,6 @@
55
  <script type="text/javascript">
56
  //<![CDATA[
57
 
58
-
59
-
60
  var AmazonWidgetStep = Class.create();
61
  AmazonWidgetStep.prototype = {
62
  hasAddress: false,
@@ -78,9 +81,21 @@ AmazonWidgetStep.prototype = {
78
  $(this.form)["amazon_order_reference_id"].value = id;
79
  },
80
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  validate: function() {
82
  if (!$(this.form)["amazon_order_reference_id"].value) {
83
- alert("Amazon Order Reference ID required. Please try again.");
84
  return false;
85
  }
86
 
@@ -93,6 +108,14 @@ AmazonWidgetStep.prototype = {
93
  return false;
94
  }
95
 
 
 
 
 
 
 
 
 
96
  return true;
97
  },
98
 
@@ -101,6 +124,7 @@ AmazonWidgetStep.prototype = {
101
  if (checkout.loadWaiting!=false) return;
102
  if (this.validate()) {
103
  checkout.setLoadWaiting('widget');
 
104
  var request = new Ajax.Request(
105
  this.saveUrl,
106
  {
@@ -143,6 +167,15 @@ AmazonWidgetStep.prototype = {
143
  }
144
 
145
  checkout.setShippingMethod();
 
 
 
 
 
 
 
 
 
146
  }
147
  };
148
 
@@ -190,6 +223,12 @@ AmazonWidgetStep.prototype = {
190
  if (typeof(msg)=='object') {
191
  msg = msg.join("\n");
192
  }
 
 
 
 
 
 
193
  if (msg) {
194
  alert(msg);
195
  }
@@ -199,6 +238,7 @@ AmazonWidgetStep.prototype = {
199
  checkout.gotoSection("widget", true);
200
  setTimeout(loadAmazonWallet, 2000);
201
  }
 
202
  }
203
 
204
  if (response.update_section) {
@@ -227,24 +267,50 @@ AmazonWidgetStep.prototype = {
227
  <!-- Address Book Widget JS -->
228
  <script>
229
 
230
- new OffAmazonPayments.Widgets.AddressBook({
231
- sellerId: '<?php echo $this->getSellerId(); ?>',
232
- onOrderReferenceCreate: function(orderReference) {
233
- amazonWidgetStep.setAmazonOrderReferenceId(orderReference.getAmazonOrderReferenceId());
234
- },
235
- onAddressSelect: function(orderReference) {
236
- amazonWidgetStep.hasAddress = true;
237
- },
238
- design: {
239
- designMode: 'responsive'
240
- },
241
- onError: function(error) {
242
- if (error.getErrorCode() == "BuyerSessionExpired") {
243
- document.location.href = '<?php echo $this->getUrl('checkout/amazon_payments/clear'); ?>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  }
245
- console.log(error.getErrorMessage());
246
- }
247
- }).bind("amazon-widget-address");
 
 
 
 
 
 
 
248
  </script>
249
  <?php endif; ?>
250
 
@@ -254,27 +320,75 @@ new OffAmazonPayments.Widgets.AddressBook({
254
 
255
  function loadAmazonWallet() {
256
  new OffAmazonPayments.Widgets.Wallet({
257
- <?php if (!$this->isShowShip()) : ?>
258
- onOrderReferenceCreate: function(orderReference) {
259
- amazonWidgetStep.showShipping = false;
260
- amazonWidgetStep.setAmazonOrderReferenceId(orderReference.getAmazonOrderReferenceId());
261
- },
262
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
 
 
264
  sellerId: '<?php echo $this->getSellerId(); ?>',
265
- design: {
266
- designMode: 'responsive',
 
 
267
  },
268
-
269
- onPaymentSelect: function(orderReference) {
270
- amazonWidgetStep.hasPayment = true;
 
 
 
 
 
 
 
 
271
  },
272
  onError: function(error) {
273
  console.log(error.getErrorMessage());
274
  }
275
- }).bind("amazon-widget-wallet");
276
  }
277
- loadAmazonWallet();
 
 
278
  </script>
279
 
280
 
14
  <input type="checkbox" style="display:none;"> <!-- MageMonkey Mailchimp compatibility (their JS requires a form element to dynamically append input element) -->
15
 
16
  <input type="hidden" name="amazon_order_reference_id" value="" />
17
+ <input type="hidden" name="amazon_billing_agreement_id" value="" />
18
+ <input type="hidden" name="amazon_billing_agreement_consent" value="" />
19
  <input type="hidden" name="payment[method]" value="amazon_payments" />
20
 
21
 
22
  <?php if ($this->isShowShip()) : ?>
23
  <div id="amazon-widget-address-wrapper" class="amazon-widget-wrapper">
24
+ <h3><?php echo $this->__('Shipping Information') ?></h3>
25
  <div id="amazon-widget-address"></div>
26
  </div>
27
  <?php endif; ?>
28
 
29
  <div id="amazon-widget-wallet-wrapper" class="amazon-widget-wrapper">
30
+ <h3><?php echo $this->__('Payment Information') ?></h3>
31
  <div id="amazon-widget-wallet"></div>
32
  </div>
33
 
37
  <input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed" class="checkbox" />
38
  <label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
39
  </p>
40
+ <?php endif; ?>
 
41
 
42
  <?php echo $this->getAdditionalForm(); ?>
43
  </div>
44
 
45
+ <?php if ($this->isTokenEnabled()) : ?>
46
+ <div id="amazon-widget-consent"></div>
47
+ <?php endif; ?>
48
+
49
  <div class="buttons-set" id="widget-buttons-container">
50
+ <button type="button" title="<?php echo $this->__('Continue') ?>" class="button btn-widget-contd" onclick="amazonWidgetStep.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
51
  <span class="please-wait" id="widget-please-wait" style="display:none;">
52
  <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
53
  </span>
60
  <script type="text/javascript">
61
  //<![CDATA[
62
 
 
 
63
  var AmazonWidgetStep = Class.create();
64
  AmazonWidgetStep.prototype = {
65
  hasAddress: false,
81
  $(this.form)["amazon_order_reference_id"].value = id;
82
  },
83
 
84
+ setAmazonBillingAgreementId: function(id) {
85
+ $(this.form)["amazon_billing_agreement_id"].value = id;
86
+ },
87
+
88
+ setAmazonBillingAgreementConsent: function(hasConsent) {
89
+ $(this.form)["amazon_billing_agreement_consent"].value = hasConsent;
90
+ },
91
+
92
+ getAmazonBillingAgreementConsent: function() {
93
+ return $(this.form)["amazon_billing_agreement_consent"].value == "true" ? true : false;
94
+ },
95
+
96
  validate: function() {
97
  if (!$(this.form)["amazon_order_reference_id"].value) {
98
+ alert(Translator.translate('Amazon Order Reference ID required. Please try again.'));
99
  return false;
100
  }
101
 
108
  return false;
109
  }
110
 
111
+ <?php if ($this->isTokenRequired()) : ?>
112
+ if (!this.getAmazonBillingAgreementConsent()) {
113
+ alert("Please check 'Use my selected payment method for future purchases and payments to this merchant' to complete this purchase.");
114
+ return false;
115
+ }
116
+ <?php endif; ?>
117
+
118
+
119
  return true;
120
  },
121
 
124
  if (checkout.loadWaiting!=false) return;
125
  if (this.validate()) {
126
  checkout.setLoadWaiting('widget');
127
+
128
  var request = new Ajax.Request(
129
  this.saveUrl,
130
  {
167
  }
168
 
169
  checkout.setShippingMethod();
170
+ },
171
+
172
+ toggleOrderSubmit: function(isDisabled) {
173
+ var btn = $$(".btn-widget-contd");
174
+ if (isDisabled) {
175
+ btn.invoke('writeAttribute','disabled','disabled');
176
+ } else {
177
+ btn.invoke('removeAttribute','disabled');
178
+ }
179
  }
180
  };
181
 
223
  if (typeof(msg)=='object') {
224
  msg = msg.join("\n");
225
  }
226
+
227
+ // Clean BillingAgreement error message
228
+ if (msg.indexOf("BillingAgreement") != -1 && msg.indexOf("total authorization amount cannot exceed") != -1) {
229
+ msg = "You have exceeded your total authorization amount for this billing agreement period. Please contact the store manager."
230
+ }
231
+
232
  if (msg) {
233
  alert(msg);
234
  }
238
  checkout.gotoSection("widget", true);
239
  setTimeout(loadAmazonWallet, 2000);
240
  }
241
+
242
  }
243
 
244
  if (response.update_section) {
267
  <!-- Address Book Widget JS -->
268
  <script>
269
 
270
+ var amazonBillingAgreementId;
271
+
272
+ var addressBookOpts = {
273
+ sellerId: '<?php echo $this->getSellerId(); ?>',
274
+ onOrderReferenceCreate: function(orderReference) {
275
+ amazonWidgetStep.setAmazonOrderReferenceId(orderReference.getAmazonOrderReferenceId());
276
+ },
277
+ onAddressSelect: function(orderReference) {
278
+ amazonWidgetStep.toggleOrderSubmit(true);
279
+ amazonWidgetStep.hasAddress = true;
280
+ },
281
+ design: {
282
+ designMode: 'responsive'
283
+ },
284
+ onError: function(error) {
285
+ if (error.getErrorCode() == "BuyerSessionExpired") {
286
+ document.location.href = '<?php echo $this->getUrl('checkout/amazon_payments/clear'); ?>';
287
+ }
288
+ console.log(error.getErrorMessage());
289
+ }
290
+ };
291
+
292
+ <?php if ($this->isTokenEnabled()) : ?>
293
+ amazonBillingAgreementId = Mage.Cookies.get("amazonBillingAgreementId");
294
+
295
+ if (amazonBillingAgreementId) {
296
+ addressBookOpts.agreementType = "BillingAgreement";
297
+ addressBookOpts.amazonBillingAgreementId = amazonBillingAgreementId;
298
+ }
299
+
300
+ addressBookOpts.onReady = function(billingAgreement) {
301
+ if (!amazonBillingAgreementId) {
302
+ amazonBillingAgreementId = billingAgreement.getAmazonBillingAgreementId();
303
  }
304
+ amazonWidgetStep.setAmazonBillingAgreementId(amazonBillingAgreementId);
305
+ loadAmazonWallet();
306
+ };
307
+ <?php endif; ?>
308
+
309
+ AmazonPaymentsCallbacks["widgets_address"] = function() {
310
+ new OffAmazonPayments.Widgets.AddressBook(addressBookOpts).bind("amazon-widget-address");
311
+ }
312
+
313
+ amazonWidgetStep.toggleOrderSubmit(true);
314
  </script>
315
  <?php endif; ?>
316
 
320
 
321
  function loadAmazonWallet() {
322
  new OffAmazonPayments.Widgets.Wallet({
323
+ <?php if ($this->isTokenEnabled()) : ?>
324
+ amazonBillingAgreementId: amazonBillingAgreementId,
325
+ <?php endif; ?>
326
+
327
+ <?php if (!$this->isShowShip()) : ?>
328
+ onOrderReferenceCreate: function(orderReference) {
329
+ amazonWidgetStep.showShipping = false;
330
+ amazonWidgetStep.setAmazonOrderReferenceId(orderReference.getAmazonOrderReferenceId());
331
+ },
332
+ <?php endif; ?>
333
+
334
+ sellerId: '<?php echo $this->getSellerId(); ?>',
335
+ design: {
336
+ designMode: 'responsive',
337
+ },
338
+
339
+ onPaymentSelect: function(orderReference) {
340
+ amazonWidgetStep.hasPayment = true;
341
+ <?php if ($this->isTokenEnabled()) : ?>
342
+ loadAmazonConsent();
343
+ <?php else: ?>
344
+ amazonWidgetStep.toggleOrderSubmit(false);
345
+ <?php endif; ?>
346
+ },
347
+ onError: function(error) {
348
+ console.log(error.getErrorMessage());
349
+ }
350
+ }).bind("amazon-widget-wallet");
351
+ }
352
+
353
+ <?php if (!$this->isTokenEnabled()) : ?>
354
+ AmazonPaymentsCallbacks["widgets_wallet"] = function() {
355
+ loadAmazonWallet();
356
+ }
357
+ <?php endif; ?>
358
+
359
+
360
+ <?php if ($this->isTokenEnabled()) : ?>
361
+ <!-- Consent Widget JS -->
362
+ function loadAmazonConsent() {
363
+ amazonWidgetStep.toggleOrderSubmit(true);
364
 
365
+ new OffAmazonPayments.Widgets.Consent({
366
  sellerId: '<?php echo $this->getSellerId(); ?>',
367
+ // amazonBillingAgreementId obtained from the Amazon Address Book widget.
368
+ amazonBillingAgreementId: amazonBillingAgreementId,
369
+ design: {
370
+ designMode: 'responsive'
371
  },
372
+ onReady: function(billingAgreementConsentStatus){
373
+ // Called after widget renders
374
+ if (typeof billingAgreementConsentStatus != "undefined") {
375
+ amazonWidgetStep.setAmazonBillingAgreementConsent(billingAgreementConsentStatus.getConsentStatus());
376
+ }
377
+ amazonWidgetStep.toggleOrderSubmit(false);
378
+ },
379
+ onConsent: function(billingAgreementConsentStatus) {
380
+ if (typeof billingAgreementConsentStatus != "undefined") {
381
+ amazonWidgetStep.setAmazonBillingAgreementConsent(billingAgreementConsentStatus.getConsentStatus());
382
+ }
383
  },
384
  onError: function(error) {
385
  console.log(error.getErrorMessage());
386
  }
387
+ }).bind("amazon-widget-consent");
388
  }
389
+
390
+ <?php endif; ?>
391
+
392
  </script>
393
 
394
 
app/design/frontend/base/default/template/amazon_payments/script.phtml CHANGED
@@ -9,11 +9,7 @@
9
  */
10
  ?>
11
 
12
- <?php
13
- if (!Mage::helper('amazon_payments/data')->isEnabled()) {
14
- return;
15
- }
16
- ?>
17
 
18
  <script type='text/javascript'>
19
  window.onAmazonLoginReady = function() {
@@ -22,17 +18,22 @@
22
  <?php if (!$this->isPopup()) : ?>
23
  amazon.Login.setUseCookie(true);
24
  <?php endif; ?>
25
-
26
  };
27
 
28
  <?php if (!$this->isPopup()) : ?>
29
  src = '<?php echo $this->getWidgetsUrl(); ?>';
30
  <?php endif; ?>
31
 
 
 
 
 
 
 
 
 
32
  </script>
33
 
34
- <script type='text/javascript' src='<?php echo $this->getWidgetsUrl(); ?>'></script>
35
- <script>jQuery.noConflict();</script>
36
 
37
  <?php if ($this->showModal()) : ?>
38
 
@@ -85,8 +86,6 @@ AmazonModal.prototype.resize = function() {
85
  }
86
 
87
 
88
-
89
-
90
  document.observe("dom:loaded", function() {
91
  var amazonModal = new AmazonModal(1020);
92
  amazonModal.show('<?php print $this->getStandaloneUrl(); ?>?ajax=1&<?php print htmlentities($_SERVER['QUERY_STRING']); ?>');
@@ -95,4 +94,6 @@ document.observe("dom:loaded", function() {
95
 
96
  </script>
97
 
98
- <?php endif; ?>
 
 
9
  */
10
  ?>
11
 
12
+ <?php if ($this->isEnabled()) : ?>
 
 
 
 
13
 
14
  <script type='text/javascript'>
15
  window.onAmazonLoginReady = function() {
18
  <?php if (!$this->isPopup()) : ?>
19
  amazon.Login.setUseCookie(true);
20
  <?php endif; ?>
 
21
  };
22
 
23
  <?php if (!$this->isPopup()) : ?>
24
  src = '<?php echo $this->getWidgetsUrl(); ?>';
25
  <?php endif; ?>
26
 
27
+ // Async render callback
28
+ var AmazonPaymentsCallbacks = { };
29
+ window.onAmazonPaymentsReady = function() {
30
+ jQuery.noConflict();
31
+ for (var i in AmazonPaymentsCallbacks) {
32
+ AmazonPaymentsCallbacks[i]();
33
+ }
34
+ }
35
  </script>
36
 
 
 
37
 
38
  <?php if ($this->showModal()) : ?>
39
 
86
  }
87
 
88
 
 
 
89
  document.observe("dom:loaded", function() {
90
  var amazonModal = new AmazonModal(1020);
91
  amazonModal.show('<?php print $this->getStandaloneUrl(); ?>?ajax=1&<?php print htmlentities($_SERVER['QUERY_STRING']); ?>');
94
 
95
  </script>
96
 
97
+ <?php endif; ?>
98
+
99
+ <?php endif; // isEnabled ?>
app/design/frontend/base/default/template/amazon_payments/script_async.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Amazon Payments
4
+ *
5
+ * @category Amazon
6
+ * @package Amazon_Payments
7
+ * @copyright Copyright (c) 2014 Amazon.com
8
+ * @license http://opensource.org/licenses/Apache-2.0 Apache License, Version 2.0
9
+ */
10
+ ?>
11
+
12
+ <?php if ($this->isEnabled() && !$this->isLoaded()) : ?>
13
+
14
+ <script async='async' type='text/javascript' src='<?php echo $this->getWidgetsUrl(); ?>'></script>
15
+
16
+ <?php endif; ?>
app/locale/de_DE/Amazon_Diagnostics.csv ADDED
File without changes
app/locale/de_DE/Amazon_Login.csv ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ "Login with Amazon", "Login mit Amazon"
2
+ "The Amazon MWS Access Key is incorrect", "Der eingegebene MWS Access Key ist nicht korrekt"
3
+ "Unable to log in with Amazon", "Anmeldung mittels ""Login mit Amazon"" nicht möglich"
4
+ "OR", "ODER"
5
+ "Verify Your Account", "Ihr Konto verifizieren"
6
+ #adminhtml
7
+ "Default is Country Locale. Override with a value from ""<a href=""https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950"" target=""_blank"" class=""amzn-doc-link"">ENTER_LANGUAGE_PARAMETER</a>.", "Standard ist das die Locale des Landes. Überschreibbar mit einem Wert aus ""<a href=""https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950"" target=""_blank"" class=""amzn-doc-link"">Sprachparameter</a>."
8
+ "Additional Access Scope", "Zusätzliche Scopes"
9
+ "Optional access scope strings during login.", "Optionale Access Scopes für den Login."
app/locale/de_DE/Amazon_Payments.csv ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Amazon Payments uses information from your Amazon account to place your order.", "Amazon Payments verwendet Informationen aus Ihrem Amazon Account f&uuml;r Ihre Bestellung."
2
+ "Click <a href=""#"" id=""amazon-cancel"">here</a> to change your payment method.", "Klicken Sie <a href=""#"" id=""amazon-cancel"">hier</a> um die Zahlart zu wechseln."
3
+ "Change Payment Method", "Zahlart &auml;ndern"
4
+ "More Info", "Mehr Informationen"
5
+ "Example:", "Beispiel:"
6
+ "Pay with Amazon", "Bezahlen mit Amazon"
7
+ "Payment Declined By Amazon Payments", "Die Zahlung wurde von Amazon Payments abgelehnt"
8
+ "Please update your payment method below:", "Bitte &auml;ndern Sie Ihre Zahlart:"
9
+ "Please agree to all the terms and conditions before placing the order.", "Bitte stimmen Sie den Bedingungen zu, bevor Sie die Bestellung absetzen."
10
+ "There was an error processing your order. Please contact us or try again later.", "Bei der Verarbeitung der Bestellung trat ein Fehler auf. Bitte kontaktieren Sie uns oder versuchen es später erneut."
11
+ "Thank you for updating your payment method.", "Vielen Dank für die Aktualisierung der Zahlart."
12
+ "Please try another payment method.", "Bitte verwenden Sie eine andere Zahlart."
13
+ "OR", "ODER"
14
+ "Payment", "Zahlart"
15
+ "Order Summary", "Bestellübersicht"
16
+ "Amazon Order Reference ID required. Please try again.", "Amazon Order Reference ID wird benötigt. Bitte versuchen Sie es erneut."
17
+ "Please select a shipping address.", "Bitte wählen Sie eine Versandadresse."
18
+ "Please select a payment method.", "Bitte wählen Sie eine Zahlart."
19
+ #adminhtml
20
+ "Sync with Amazon", "Mit Amazon synchronisieren"
21
+ "Sync with Amazon: Authorization state is ""%s"".", "Mit Amazon synchronisieren: Autorisierungsstatus ist ""%s""."
22
+ " (Payment is currently authorizing. Please try again momentarily.)", " (Zahlung wird gerade autorisiert. Bitte versuchen Sie es später erneut.)"
23
+ " Order placed on hold due to ""%s"". Email sent to customer with link to order details page and instructions to update their payment method.", " Bestellung wurde auf ""on hold"" gesetzt. Grund: ""%s"". Eine E-Mail mit einem Link zur Bestelldetailseite und Instruktionen die Zahlart zu ändern wurde an den Kunden gesendet."
24
+ " Unable to create invoice due to Authorization Reason Code: %s", " Die Rechnung konnte nicht erstellt werden, ReasonCode der Autorisierung: %s"
25
+ "Amazon Payments requires a <a href=""https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility"" target=""_blank"">patched Payments.php</a> file for Magento 1.5 compatibility.", "Bezahlen mit Amazon benötigt ein <a href=""https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility"" target=""_blank"">angepasste Payments.php</a> für Magento 1.5 Unterstützung."
26
+ "To complete your Amazon Payments configuration, please set up <a href="https://sellercentral.amazon.com/" taget="_blank">your account</a> and add the API credentials <a href=""%s"">here</a>.", "Bitte estellen Sie <a href=""https://sellercentral.amazon.com/"" taget=""_blank"">ein Konto</a> und fügen Sie die API Zugangsdaten <a href=""%s"">hier</a> ein, um die Amazon Payments Konfiguration abzuschließen."
27
+ "Error: Please verify your Seller ID (alphanumeric characters only).", "Fehler: Bitte prüfen Sie Ihre Händler ID (nur alphanumerische Zeichen)."
28
+ "All of your Amazon API keys are correct.", "Alle Ihre Amazon API Daten sind korrekt."
29
+ "The Amazon MWS Access Key is incorrect.", "Der Amazon MWS Access Key ist nicht korrekt."
30
+ "The Amazon MWS Secret Key is incorrect.", "Der Amazon MWS Secret Key ist nicht korrekt."
31
+ "The Amazon Seller/Merchant ID is incorrect.", "Die Amazon Seller/Merchant ID ist nicht korrekt."
32
+ "The Amazon Seller/Merchant ID does not match the MWS keys provided.", "Die Amazon Seller/Merchant ID passt nicht zu den angegebenen MWS Schlüsseln."
33
+ "Gold", "Gold"
34
+ "Dark Gray", "Dunkelgrau"
35
+ "Light Gray", "Hellgrau"
36
+ "Pay", "Bezahlen"
37
+ "Amazon logo", "Amazon Logo"
38
+ "Small", "Klein"
39
+ "Medium", "Mittel"
40
+ "Large", "Groß"
41
+ "X-large", "Extra-Groß"
42
+ "Magento Core OnePage Checkout", "Magento Core OnePage Checkout"
43
+ "Amazon Standalone Checkout in a Modal Window", "Amazon Standalone Checkout in modalem Fenster"
44
+ "Amazon Standalone Checkout", "Amazon Standalone Checkout"
45
+ "Language", "Sprache"
46
+ "Region", "Region"
47
+ "Seller/Merchant ID", "Seller/Merchant ID"
48
+ "MWS Access Key", "MWS Access Key"
49
+ "MWS Secret Key", "MWS Secret Key"
50
+ "Checkout Configuration", "Checkout Konfiguration"
51
+ "Checkout Page Type", "Art des Checkouts"
52
+ "Show Pay with Amazon Button on Cart", "Bezahlen mit Amazon Button in Warenkorb zeigen"
53
+ "Pop-up must be set to ""No"" under Customers->Login with Amazon.", "Pop-up muss auf ""Nein"" unter Kunden->Login mit Amazon gesetzt sein."
54
+ "Only applies when OnePage Checkout is used, otherwise button is always shown.", "Greift nur, wenn OnePage Checkout verwendet wird, ansonsten wird der Button immer angezeigt."
55
+ "Secure Cart Page", "Gesicherte Warenkorb Seite"
56
+ "HTTPS is required to use the Amazon button on the cart page.", "HTTPS ist verpflichtend, um den Amazon Button im Warenkorb anuzuzeigen."
57
+ "Display as Payment Option", "Als Zahlart anzeigen"
58
+ "Add pay button under ""Payment Information"" during checkout. (Recommended flow is to display button before user enters billing and shipping information.)", "Bezahlen Button unter ""Zahlarten"" während des Checkouts. (Es wird empfohlen den Button anzuzeigen, bevor der Kunde manuell Informationen angeben muss.)"
59
+ "Asynchronous Mode", "Asynchroner Modus"
60
+ "In asynchronous mode, the payment is returned as a Pending status instead of an immediate Open or Declined status. Customers will need to be notified of a Declined status.", "Im asynchronen Moduswird der Status der Autorisierung als ""Pending"" anstatt direkt als ""Open"" oder ""Declined"" zur&uuml;ckgegeben. Kunden werden bei Ablehnungen automatisch informiert."
61
+ "Button Style", "Button Style"
62
+ "Button Label", "Beschriftung"
63
+ "Button Color", "Farbe"
64
+ "Button Size", "Größe"
65
+ "Display Acceptance Badge", "Acceptance Badge anzeigen"
66
+ "Display ""Amazon Payments"" acceptance mark in right sidebar.", """Amazon Payments"" Logo in rechter Sidebar anzeigen."
67
+ "Save API responses to Magento log", "API Antworten in Magento log speichern"
68
+ "Restrict by IP", "IP Beschränkung"
69
+ "Display to only whitelisted IPs found in Developer -> Developer Client Restrictions", "Button nur f&uuml;r unter ""Entwickleroptionen -> Entwickler Clientbeschr&auml;nkung"" eingetragene IPs anzeigen"
app/locale/de_DE/template/email/amazon_payments_async_decline_hard.html ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Bitte kontaktieren Sie uns wegen Ihrer Bestellung @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "htmlescape var=$customer.name":"Customer Name",
6
+ "var order url":"Order details URL"}
7
+ @-->
8
+
9
+ <!--@styles
10
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
11
+ @-->
12
+
13
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
15
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
16
+ <tr>
17
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
18
+ <!-- [ header starts here] -->
19
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
20
+ <tr>
21
+ <td valign="top">
22
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
23
+ </tr>
24
+ <!-- [ middle starts here] -->
25
+ <tr>
26
+ <td valign="top">
27
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Sehr geehrte(r) {{htmlescape var=$customer.name}},</h1>
28
+ <p style="font-size:12px; line-height:16px; margin:0;">Leider wurde die Zahlung zu Ihrer Bestellung in unserem Onlineshop {{var store.name}} von Amazon Payments zur�ckgewiesen.</p>
29
+ <p style="font-size:12px; line-height:16px; margin:0;">Bitte kontaktieren Sie uns bitte wahlweise per E-Mail <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> oder auch gerne per Telefon unter der Rufnummer {{config path='general/store_information/phone'}}.</p>
30
+ </td>
31
+ </tr>
32
+ <tr>
33
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
34
+ </tr>
35
+ </table>
36
+ </td>
37
+ </tr>
38
+ </table>
39
+ </div>
40
+ </body>
app/locale/de_DE/template/email/amazon_payments_async_decline_soft.html ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Zahlung abgelehnt: Bitte ändern Sie Ihre Zahlart für {{var store.name}}! @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "htmlescape var=$customer.name":"Customer Name",
6
+ "var order url":"Order details URL"}
7
+ @-->
8
+
9
+ <!--@styles
10
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
11
+ @-->
12
+
13
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
15
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
16
+ <tr>
17
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
18
+ <!-- [ header starts here] -->
19
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
20
+ <tr>
21
+ <td valign="top">
22
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
23
+ </tr>
24
+ <!-- [ middle starts here] -->
25
+ <tr>
26
+ <td valign="top">
27
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Sehr geehrte(r) {{htmlescape var=$customer.name}},</h1>
28
+ <p style="font-size:12px; line-height:16px; margin:0;">Leider wurde Ihre Bezahlung von Amazon Payments abgelehnt. Sie können unter <a href="{{var order_url}}">{{var order_url}}</a> die Zahlungsinformationen für Ihre Bestellung aktualisieren, indem Sie eine andere Zahlungsweise auswählen oder eine neue Zahlungsweise eingeben. Mit der neuen Zahlungsweise wird dann ein erneuter Zahlungsversuch vorgenommen und Sie erhalten eine Bestätigungsemail.</p>
29
+ <p style="font-size:12px; line-height:16px; margin:0;">Falls Sie Fragen oder Anregungen haben, kontaktieren Sie uns bitte wahlweise per E-Mail <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> oder auch gerne per Telefon unter der Rufnummer {{config path='general/store_information/phone'}}.</p>
30
+ </td>
31
+ </tr>
32
+ <tr>
33
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
34
+ </tr>
35
+ </table>
36
+ </td>
37
+ </tr>
38
+ </table>
39
+ </div>
40
+ </body>
app/locale/en_GB/Amazon_Diagnostics.csv ADDED
File without changes
app/locale/en_GB/Amazon_Login.csv ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ "Login with Amazon", "Login with Amazon"
2
+ "The Amazon MWS Access Key is incorrect", "The Amazon MWS Access Key is incorrect"
3
+ "Unable to log in with Amazon", "Unable to log in with Amazon"
4
+ "OR", "OR"
5
+ "Verify Your Account", "Verify Your Account"
6
+ #adminhtml
7
+ "Default is Country Locale. Override with a value from ""<a href=""https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950"" target=""_blank"" class=""amzn-doc-link"">ENTER_LANGUAGE_PARAMETER</a>.", "Default is Country Locale. Override with a value from ""<a href=""https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950"" target=""_blank"" class=""amzn-doc-link"">ENTER_LANGUAGE_PARAMETER</a>."
8
+ "Additional Access Scope", "Additional Access Scope"
9
+ "Optional access scope strings during login.", "Optional access scope strings during login."
app/locale/en_GB/Amazon_Payments.csv ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Amazon Payments uses information from your Amazon account to place your order.", "Amazon Payments uses information from your Amazon account to place your order."
2
+ "Click <a href=""#"" id=""amazon-cancel"">here</a> to change your payment method.", "Click <a href=""#"" id=""amazon-cancel"">here</a> to change your payment method."
3
+ "Change Payment Method", "Change Payment Method"
4
+ "More Info", "More Info"
5
+ "Example:", "Example:"
6
+ "Pay with Amazon", "Pay with Amazon"
7
+ "Payment Declined By Amazon Payments", "Payment Declined By Amazon Payments"
8
+ "Please update your payment method below:", "Please update your payment method below:"
9
+ "Please agree to all the terms and conditions before placing the order.", "Please agree to all the terms and conditions before placing the order."
10
+ "There was an error processing your order. Please contact us or try again later.", "There was an error processing your order. Please contact us or try again later."
11
+ "Thank you for updating your payment method.", "Thank you for updating your payment method."
12
+ "Please try another payment method.", "Please try another payment method."
13
+ "OR", "OR"
14
+ "Payment", "Payment"
15
+ "Order Summary", "Order Summary"
16
+ "Amazon Order Reference ID required. Please try again.", "Amazon Order Reference ID required. Please try again."
17
+ "Please select a shipping address.", "Please select a shipping address."
18
+ "Please select a payment method.", "Please select a payment method."
19
+ #adminhtml
20
+ "Sync with Amazon", "Sync with Amazon"
21
+ "Sync with Amazon: Authorization state is ""%s"".", "Sync with Amazon: Authorization state is ""%s""."
22
+ " (Payment is currently authorizing. Please try again momentarily.)", " (Payment is currently authorizing. Please try again momentarily.)"
23
+ " Order placed on hold due to ""%s"". Email sent to customer with link to order details page and instructions to update their payment method.", " Order placed on hold due to ""%s"". Email sent to customer with link to order details page and instructions to update their payment method."
24
+ " Unable to create invoice due to Authorization Reason Code: %s", " Unable to create invoice due to Authorization Reason Code: %s"
25
+ "Amazon Payments requires a <a href=""https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility"" target=""_blank"">patched Payments.php</a> file for Magento 1.5 compatibility.", "Amazon Payments requires a <a href=""https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility"" target=""_blank"">patched Payments.php</a> file for Magento 1.5 compatibility."
26
+ "To complete your Amazon Payments configuration, please set up <a href="https://sellercentral.amazon.com/" taget="_blank">your account</a> and add the API credentials <a href=""%s"">here</a>.", "To complete your Amazon Payments configuration, please set up <a href="https://sellercentral.amazon.com/" taget="_blank">your account</a> and add the API credentials <a href=""%s"">here</a>."
27
+ "Error: Please verify your Seller ID (alphanumeric characters only).", "Error: Please verify your Seller ID (alphanumeric characters only)."
28
+ "All of your Amazon API keys are correct.", "All of your Amazon API keys are correct."
29
+ "The Amazon MWS Access Key is incorrect.", "The Amazon MWS Access Key is incorrect."
30
+ "The Amazon MWS Secret Key is incorrect.", "The Amazon MWS Secret Key is incorrect."
31
+ "The Amazon Seller/Merchant ID is incorrect.", "The Amazon Seller/Merchant ID is incorrect."
32
+ "The Amazon Seller/Merchant ID does not match the MWS keys provided.", "The Amazon Seller/Merchant ID does not match the MWS keys provided."
33
+ "Gold", "Gold"
34
+ "Dark Gray", "Dark Gray"
35
+ "Light Gray", "Light Gray"
36
+ "Pay", "Pay"
37
+ "Amazon logo", "Amazon logo"
38
+ "Small", "Small"
39
+ "Medium", "Medium"
40
+ "Large", "Large"
41
+ "X-large", "X-large"
42
+ "Magento Core OnePage Checkout", "Magento Core OnePage Checkout"
43
+ "Amazon Standalone Checkout in a Modal Window", "Amazon Standalone Checkout in a Modal Window"
44
+ "Amazon Standalone Checkout", "Amazon Standalone Checkout"
45
+ "Language", "Language"
46
+ "Region", "Region"
47
+ "Seller/Merchant ID", "Seller/Merchant ID"
48
+ "MWS Access Key", "MWS Access Key"
49
+ "MWS Secret Key", "MWS Secret Key"
50
+ "Checkout Configuration", "Checkout Configuration"
51
+ "Checkout Page Type", "Checkout Page Type"
52
+ "Show Pay with Amazon Button on Cart", "Show Pay with Amazon Button on Cart"
53
+ "Pop-up must be set to ""No"" under Customers->Login with Amazon.", "Pop-up must be set to ""No"" under Customers->Login with Amazon."
54
+ "Only applies when OnePage Checkout is used, otherwise button is always shown.", "Only applies when OnePage Checkout is used, otherwise button is always shown."
55
+ "Secure Cart Page", "Secure Cart Page"
56
+ "HTTPS is required to use the Amazon button on the cart page.", "HTTPS is required to use the Amazon button on the cart page."
57
+ "Display as Payment Option", "Display as Payment Option"
58
+ "Add pay button under ""Payment Information"" during checkout. (Recommended flow is to display button before user enters billing and shipping information.)", "Add pay button under ""Payment Information"" during checkout. (Recommended flow is to display button before user enters billing and shipping information.)"
59
+ "Asynchronous Mode", "Asynchronous Mode"
60
+ "In asynchronous mode, the payment is returned as a Pending status instead of an immediate Open or Declined status. Customers will need to be notified of a Declined status.", "In asynchronous mode, the payment is returned as a Pending status instead of an immediate Open or Declined status. Customers will need to be notified of a Declined status."
61
+ "Button Style", "Button Style"
62
+ "Button Label", "Button Label"
63
+ "Button Color", "Button Color"
64
+ "Button Size", "Button Size"
65
+ "Display Acceptance Badge", "Display Acceptance Badge"
66
+ "Display ""Amazon Payments"" acceptance mark in right sidebar.", "Display ""Amazon Payments"" acceptance mark in right sidebar."
67
+ "Save API responses to Magento log", "Save API responses to Magento log"
68
+ "Restrict by IP", "Restrict by IP"
69
+ "Display to only whitelisted IPs found in Developer -> Developer Client Restrictions", "Display to only whitelisted IPs found in Developer -> Developer Client Restrictions"
app/locale/en_GB/template/email/amazon_payments_async_decline_soft.html ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Payment Declined: Please update your payment method on {{var store.name}}! @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "htmlescape var=$customer.name":"Customer Name",
6
+ "var order url":"Order details URL"}
7
+ @-->
8
+
9
+ <!--@styles
10
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
11
+ @-->
12
+
13
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
15
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
16
+ <tr>
17
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
18
+ <!-- [ header starts here] -->
19
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
20
+ <tr>
21
+ <td valign="top">
22
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0" /></a></td>
23
+ </tr>
24
+ <!-- [ middle starts here] -->
25
+ <tr>
26
+ <td valign="top">
27
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{htmlescape var=$customer.name}},</h1>
28
+ <p style="font-size:12px; line-height:16px; margin:0;">Amazon Payments non pu&ograve; elaborare il suo pagamento. Visiti la pagina dei dettagli dell'ordine usando il link qui sotto e aggiorni il metodo di pagamento:</p>
29
+ <p style="font-size:12px; line-height:16px; margin:1.5em; margin-right:0;"><a href="{{var order_url}}">{{var order_url}}</a></p>
30
+
31
+ <p style="font-size:12px; line-height:16px; margin:0;">In caso di dubbi o domande sul suo conto o su qualsiasi altro argomento, non esiti a contattarci all'indirizzo <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> o al numero {{config path='general/store_information/phone'}}.</p>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Grazie, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
36
+ </tr>
37
+ </table>
38
+ </td>
39
+ </tr>
40
+ </table>
41
+ </div>
42
+ </body>
app/locale/en_US/Amazon_Diagnostics.csv ADDED
File without changes
app/locale/en_US/Amazon_Login.csv ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ "Login with Amazon", "Login with Amazon"
2
+ "The Amazon MWS Access Key is incorrect", "The Amazon MWS Access Key is incorrect"
3
+ "Unable to log in with Amazon", "Unable to log in with Amazon"
4
+ "OR", "OR"
5
+ "Verify Your Account", "Verify Your Account"
6
+ #adminhtml
7
+ "Default is Country Locale. Override with a value from ""<a href=""https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950"" target=""_blank"" class=""amzn-doc-link"">ENTER_LANGUAGE_PARAMETER</a>.", "Default is Country Locale. Override with a value from ""<a href=""https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950"" target=""_blank"" class=""amzn-doc-link"">ENTER_LANGUAGE_PARAMETER</a>."
8
+ "Additional Access Scope", "Additional Access Scope"
9
+ "Optional access scope strings during login.", "Optional access scope strings during login."
app/locale/en_US/Amazon_Payments.csv ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Amazon Payments uses information from your Amazon account to place your order.", "Amazon Payments uses information from your Amazon account to place your order."
2
+ "Click <a href=""#"" id=""amazon-cancel"">here</a> to change your payment method.", "Click <a href=""#"" id=""amazon-cancel"">here</a> to change your payment method."
3
+ "Change Payment Method", "Change Payment Method"
4
+ "More Info", "More Info"
5
+ "Example:", "Example:"
6
+ "Pay with Amazon", "Pay with Amazon"
7
+ "Payment Declined By Amazon Payments", "Payment Declined By Amazon Payments"
8
+ "Please update your payment method below:", "Please update your payment method below:"
9
+ "Please agree to all the terms and conditions before placing the order.", "Please agree to all the terms and conditions before placing the order."
10
+ "There was an error processing your order. Please contact us or try again later.", "There was an error processing your order. Please contact us or try again later."
11
+ "Thank you for updating your payment method.", "Thank you for updating your payment method."
12
+ "Please try another payment method.", "Please try another payment method."
13
+ "OR", "OR"
14
+ "Payment", "Payment"
15
+ "Order Summary", "Order Summary"
16
+ "Amazon Order Reference ID required. Please try again.", "Amazon Order Reference ID required. Please try again."
17
+ "Please select a shipping address.", "Please select a shipping address."
18
+ "Please select a payment method.", "Please select a payment method."
19
+ #adminhtml
20
+ "Sync with Amazon", "Sync with Amazon"
21
+ "Sync with Amazon: Authorization state is ""%s"".", "Sync with Amazon: Authorization state is ""%s""."
22
+ " (Payment is currently authorizing. Please try again momentarily.)", " (Payment is currently authorizing. Please try again momentarily.)"
23
+ " Order placed on hold due to ""%s"". Email sent to customer with link to order details page and instructions to update their payment method.", " Order placed on hold due to ""%s"". Email sent to customer with link to order details page and instructions to update their payment method."
24
+ " Unable to create invoice due to Authorization Reason Code: %s", " Unable to create invoice due to Authorization Reason Code: %s"
25
+ "Amazon Payments requires a <a href=""https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility"" target=""_blank"">patched Payments.php</a> file for Magento 1.5 compatibility.", "Amazon Payments requires a <a href=""https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility"" target=""_blank"">patched Payments.php</a> file for Magento 1.5 compatibility."
26
+ "To complete your Amazon Payments configuration, please set up <a href="https://sellercentral.amazon.com/" taget="_blank">your account</a> and add the API credentials <a href=""%s"">here</a>.", "To complete your Amazon Payments configuration, please set up <a href="https://sellercentral.amazon.com/" taget="_blank">your account</a> and add the API credentials <a href=""%s"">here</a>."
27
+ "Error: Please verify your Seller ID (alphanumeric characters only).", "Error: Please verify your Seller ID (alphanumeric characters only)."
28
+ "All of your Amazon API keys are correct.", "All of your Amazon API keys are correct."
29
+ "The Amazon MWS Access Key is incorrect.", "The Amazon MWS Access Key is incorrect."
30
+ "The Amazon MWS Secret Key is incorrect.", "The Amazon MWS Secret Key is incorrect."
31
+ "The Amazon Seller/Merchant ID is incorrect.", "The Amazon Seller/Merchant ID is incorrect."
32
+ "The Amazon Seller/Merchant ID does not match the MWS keys provided.", "The Amazon Seller/Merchant ID does not match the MWS keys provided."
33
+ "Gold", "Gold"
34
+ "Dark Gray", "Dark Gray"
35
+ "Light Gray", "Light Gray"
36
+ "Pay", "Pay"
37
+ "Amazon logo", "Amazon logo"
38
+ "Small", "Small"
39
+ "Medium", "Medium"
40
+ "Large", "Large"
41
+ "X-large", "X-large"
42
+ "Magento Core OnePage Checkout", "Magento Core OnePage Checkout"
43
+ "Amazon Standalone Checkout in a Modal Window", "Amazon Standalone Checkout in a Modal Window"
44
+ "Amazon Standalone Checkout", "Amazon Standalone Checkout"
45
+ "Language", "Language"
46
+ "Region", "Region"
47
+ "Seller/Merchant ID", "Seller/Merchant ID"
48
+ "MWS Access Key", "MWS Access Key"
49
+ "MWS Secret Key", "MWS Secret Key"
50
+ "Checkout Configuration", "Checkout Configuration"
51
+ "Checkout Page Type", "Checkout Page Type"
52
+ "Show Pay with Amazon Button on Cart", "Show Pay with Amazon Button on Cart"
53
+ "Pop-up must be set to ""No"" under Customers->Login with Amazon.", "Pop-up must be set to ""No"" under Customers->Login with Amazon."
54
+ "Only applies when OnePage Checkout is used, otherwise button is always shown.", "Only applies when OnePage Checkout is used, otherwise button is always shown."
55
+ "Secure Cart Page", "Secure Cart Page"
56
+ "HTTPS is required to use the Amazon button on the cart page.", "HTTPS is required to use the Amazon button on the cart page."
57
+ "Display as Payment Option", "Display as Payment Option"
58
+ "Add pay button under ""Payment Information"" during checkout. (Recommended flow is to display button before user enters billing and shipping information.)", "Add pay button under ""Payment Information"" during checkout. (Recommended flow is to display button before user enters billing and shipping information.)"
59
+ "Asynchronous Mode", "Asynchronous Mode"
60
+ "In asynchronous mode, the payment is returned as a Pending status instead of an immediate Open or Declined status. Customers will need to be notified of a Declined status.", "In asynchronous mode, the payment is returned as a Pending status instead of an immediate Open or Declined status. Customers will need to be notified of a Declined status."
61
+ "Button Style", "Button Style"
62
+ "Button Label", "Button Label"
63
+ "Button Color", "Button Color"
64
+ "Button Size", "Button Size"
65
+ "Display Acceptance Badge", "Display Acceptance Badge"
66
+ "Display ""Amazon Payments"" acceptance mark in right sidebar.", "Display ""Amazon Payments"" acceptance mark in right sidebar."
67
+ "Save API responses to Magento log", "Save API responses to Magento log"
68
+ "Restrict by IP", "Restrict by IP"
69
+ "Display to only whitelisted IPs found in Developer -> Developer Client Restrictions", "Display to only whitelisted IPs found in Developer -> Developer Client Restrictions"
app/locale/en_US/template/email/amazon_payments_async_decline_soft.html CHANGED
@@ -19,20 +19,20 @@ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif;
19
  <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
20
  <tr>
21
  <td valign="top">
22
- <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
23
  </tr>
24
  <!-- [ middle starts here] -->
25
  <tr>
26
  <td valign="top">
27
  <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{htmlescape var=$customer.name}},</h1>
28
- <p style="font-size:12px; line-height:16px; margin:0;">Amazon Payments could not process your payment. Please visit your order details page below and update your payment method:</p>
29
  <p style="font-size:12px; line-height:16px; margin:1.5em; margin-right:0;"><a href="{{var order_url}}">{{var order_url}}</a></p>
30
 
31
- <p style="font-size:12px; line-height:16px; margin:0;">If you have any questions about your account or any other matter, please feel free to contact us at <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> or by phone at {{config path='general/store_information/phone'}}.</p>
32
  </td>
33
  </tr>
34
  <tr>
35
- <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
36
  </tr>
37
  </table>
38
  </td>
19
  <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
20
  <tr>
21
  <td valign="top">
22
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0" /></a></td>
23
  </tr>
24
  <!-- [ middle starts here] -->
25
  <tr>
26
  <td valign="top">
27
  <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{htmlescape var=$customer.name}},</h1>
28
+ <p style="font-size:12px; line-height:16px; margin:0;">Amazon Payments n'a pas pu traiter votre paiement. Consultez les d&eacute;tails de votre commande ci-dessous et mettez &agrave; jour votre mode de paiement&nbsp;:</p>
29
  <p style="font-size:12px; line-height:16px; margin:1.5em; margin-right:0;"><a href="{{var order_url}}">{{var order_url}}</a></p>
30
 
31
+ <p style="font-size:12px; line-height:16px; margin:0;">Pour toute question concernant votre compte ou tout autre sujet, n'h&eacute;sitez pas &agrave; nous contacter &agrave; l'adresse <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> ou par t&eacute;l&eacute;phone au {{config path='general/store_information/phone'}}.</p>
32
  </td>
33
  </tr>
34
  <tr>
35
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Merci encore, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
36
  </tr>
37
  </table>
38
  </td>
app/locale/es_ES/Amazon_Diagnostics.csv ADDED
File without changes
app/locale/es_ES/Amazon_Login.csv ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ "Login with Amazon", "Login con Amazon"
2
+ "The Amazon MWS Access Key is incorrect", "La clave de acceso a Amazon MWS es incorrecta"
3
+ "Unable to log in with Amazon," "No se puede iniciar sesi&oacute;n en Amazon"
4
+ "OR", "O BIEN"
5
+ "Verify Your Account", "Verifica tu cuenta"
6
+ #adminhtml,
7
+ "Default is Country Locale. Override with a value from ""<a href=""https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950"" target=""_blank"" class=""amzn-doc-link"">ENTER_LANGUAGE_PARAMETER</a>.", "La opci&oacute;n predeterminada es la configuraci&oacute;n regional del pa&iacute;s. Se sustituye con un valor de ""<a href=""https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950"" target=""_blank"" class=""amzn-doc-link"">ENTER_LANGUAGE_PARAMETER</a>."
8
+ "Additional Access Scope", "Alcance de acceso adicional"
9
+ "Optional access scope strings during login.", "Cadenas opcionales sobre alcance del acceso durante el inicio de sesi&oacute;n."
app/locale/es_ES/Amazon_Payments.csv ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Amazon Payments uses information from your Amazon account to place your order.", "Amazon Payments utiliza la informaci&oacute;n de tu cuenta de Amazon para realizar el pedido."
2
+ "Click <a href=""#"" id=""amazon-cancel"">here</a> to change your payment method.", "Haz clic <a href=""#"" id=""amazon-cancel"">aqu&iacute;</a> para cambiar el m&eacute;todo de pago."
3
+ "Change Payment Method", "Cambiar m&eacute;todo de pago"
4
+ "More Info", "M&aacute;s informaci&oacute;n"
5
+ "Example:", "Ejemplo:"
6
+ "Pay with Amazon", "Pagar con Amazon"
7
+ "Payment Declined By Amazon Payments", "Pago rechazado por Amazon Payments"
8
+ "Please update your payment method below:", "Actualiza el m&eacute;todo de pago a continuaci&oacute;n:"
9
+ "Please agree to all the terms and conditions before placing the order.", "Acepta los t&eacute;rminos y condiciones antes de realizar el pedido."
10
+ "There was an error processing your order. Please contact us or try again later.", "Se ha producido un error al procesar tu pedido. Ponte en contacto con nosotros o int&eacute;ntalo de nuevo m&aacute;s tarde."
11
+ "Thank you for updating your payment method.", "Gracias por actualizar el m&eacute;todo de pago."
12
+ "Please try another payment method.", "Prueba otro m&eacute;todo de pago."
13
+ "OR", "O BIEN"
14
+ "Payment", "Pago"
15
+ "Order Summary", "Resumen del pedido"
16
+ "Amazon Order Reference ID required. Please try again.", "Se necesita el n&uacute;mero de referencia de pedido de Amazon. Vuelve a intentarlo."
17
+ "Please select a shipping address.", "Selecciona una direcci&oacute;n de entrega."
18
+ "Please select a payment method.", "Selecciona un m&eacute;todo de pago."
19
+ #adminhtml,,
20
+ "Sync with Amazon", "Sincronizaci&oacute;n con Amazon"
21
+ "Sync with Amazon: Authorization state is ""%s"".", "Sincronizaci&oacute;n con Amazon: el estado de la autorizaci&oacute;n es ""%s""."
22
+ "(Payment is currently authorizing. Please try again momentarily.)", "(El pago se est&aacute; autorizando. Int&eacute;ntalo de nuevo m&aacute;s tarde.)"
23
+ "Order placed on hold due to ""%s"". Email sent to customer with link to order details page and instructions to update their payment method.", "Pedido retenido debido a ""%s"". Se ha enviado un correo electr&oacute;nico al cliente con un enlace a la p&aacute;gina de detalles del pedido e instrucciones para actualizar el m&eacute;todo de pago."
24
+ "Unable to create invoice due to Authorization Reason Code: %s", "No se puede crear la factura debido al c&oacute;digo de motivo para autorizaci&oacute;n: %s"
25
+ "Amazon Payments requires a <a href=""https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility"" target=""_blank"">patched Payments.php</a> file for Magento 1.5 compatibility.", "Amazon Payments requiere un archivo <a href=""https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility"" target=""_blank"">patched Payments.php</a> para garantizar la compatibilidad con Magento 1.5."
26
+ "To complete your Amazon Payments configuration, please set up <a href=""https://sellercentral.amazon.com/"" taget=""_blank"">your account</a> and add the API credentials <a href=""<?php echo $this->getManageUrl(); ?>"">here</a>.", "Para completar la configuraci&oacute;n de Amazon Payments, configura <a href=""https://sellercentral.amazon.com/"" taget=""_blank"">tu cuenta</a> y a&ntilde;ade las credenciales de API <a href=""<?php echo $this->getManageUrl(); ?>"">aqu&iacute;</a>."
27
+ "Error: Please verify your Seller ID (alphanumeric characters only).", "Error: comprueba tu identificador de vendedor (s&oacute;lo caracteres alfanum&eacute;ricos)."
28
+ "All of your Amazon API keys are correct.", "Todas tus claves de API de Amazon son correctas."
29
+ "The Amazon MWS Access Key is incorrect.", "La clave de acceso a Amazon MWS es incorrecta."
30
+ "The Amazon MWS Secret Key is incorrect.", "La clave secreta de Amazon MWS es incorrecta."
31
+ "The Amazon Seller/Merchant ID is incorrect.", "El identificador de vendedor de Amazon es incorrecto."
32
+ "The Amazon Seller/Merchant ID does not match the MWS keys provided.", "El identificador de vendedor de Amazon no coincide con las claves de MWS proporcionadas."
33
+ "Gold", "Dorado"
34
+ "Dark Gray", "Gris oscuro"
35
+ "Light Gray", "Gris claro"
36
+ "Pay", "Pagar"
37
+ "Amazon logo", "Logotipo de Amazon"
38
+ "Small", "Peque&ntilde;o"
39
+ "Medium", "Mediano"
40
+ "Large", "Grande"
41
+ "X-large", "Extra grande"
42
+ "Magento Core OnePage Checkout", "Magento Core OnePage Checkout"
43
+ "Amazon Standalone Checkout in a Modal Window", "Pago independiente de Amazon en una ventana de modo"
44
+ "Amazon Standalone Checkout", "Pago independiente de Amazon"
45
+ "Language", "Idioma"
46
+ "Region", "Regi&oacute;n"
47
+ "Seller/Merchant ID", "Identificador de vendedor"
48
+ "MWS Access Key", "Clave de acceso a MWS"
49
+ "MWS Secret Key", "Clave secreta de MWS"
50
+ "Checkout Configuration", "Configuraci&oacute;n de pago"
51
+ "Checkout Page Type", "Tipo de p&aacute;gina de pago"
52
+ "Show Pay with Amazon Button on Cart", "Mostrar el bot&oacute;n Pagar con Amazon en la cesta"
53
+ "Pop-up must be set to ""No"" under Customers->Login with Amazon.", "Configura el cuadro emergente como ""No"" en Clientes->Login con Amazon."
54
+ "Only applies when OnePage Checkout is used, otherwise button is always shown.", "S&oacute;lo se aplica cuando se utiliza el pago OnePage, de lo contrario el bot&oacute;n siempre se muestra."
55
+ "Secure Cart Page", "P&aacute;gina de cesta segura"
56
+ "HTTPS is required to use the Amazon button on the cart page.", "Se necesita HTTPS para utilizar el bot&oacute;n de Amazon en la p&aacute;gina de la cesta."
57
+ "Display as Payment Option", "Mostrar como opci&oacute;n de pago"
58
+ "Add pay button under ""Payment Information"" during checkout. (Recommended flow is to display button before user enters billing and shipping information.)", "A&ntilde;adir bot&oacute;n para pagar en ""Informaci&oacute;n de pago"" durante el pago. (El flujo recomendado es mostrar el bot&oacute;n antes de que el usuario acceda a la informaci&oacute;n de facturaci&oacute;n y env&iacute;o.)"
59
+ "Asynchronous Mode", "Modo as&iacute;ncrono"
60
+ "In asynchronous mode, the payment is returned as a Pending status instead of an immediate Open or Declined status. Customers will need to be notified of a Declined status.", "En el modo as&iacute;ncrono,"," el pago aparece con el estado Pendiente en lugar de Abierto o Rechazado al momento. Se deber&aacute; notificar a los clientes del estado Rechazado."
61
+ "Button Style", "Estilo del bot&oacute;n"
62
+ "Button Label", "Etiqueta del bot&oacute;n"
63
+ "Button Color", "Color del bot&oacute;n"
64
+ "Button Size", "Tama&ntilde;o del bot&oacute;n"
65
+ "Display Acceptance Badge", "Mostrar emblema de aceptaci&oacute;n"
66
+ "Display ""Amazon Payments"" acceptance mark in right sidebar.", "Mostrar marca de aceptaci&oacute;n de ""Amazon Payments"" en la barra lateral derecha."
67
+ "Save API responses to Magento log", "Guardar respuestas de API en el registro de Magento"
68
+ "Restrict by IP", "Restringir por IP"
69
+ "Display to only whitelisted IPs found in Developer -> Developer Client Restrictions", "Mostrar s&oacute;lo a las IP seguras encontradas en Desarrollador -> Restricciones de cliente de desarrolladores"
app/locale/es_ES/template/email/amazon_payments_async_decline_hard.html ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Por favor, cont�ctanos en referencia a tu pedido @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "htmlescape var=$customer.name":"Customer Name",
6
+ "var order url":"Order details URL"}
7
+ @-->
8
+
9
+ <!--@styles
10
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
11
+ @-->
12
+
13
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
15
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
16
+ <tr>
17
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
18
+ <!-- [ header starts here] -->
19
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
20
+ <tr>
21
+ <td valign="top">
22
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
23
+ </tr>
24
+ <!-- [ middle starts here] -->
25
+ <tr>
26
+ <td valign="top">
27
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{htmlescape var=$customer.name}},</h1>
28
+ <p style="font-size:12px; line-height:16px; margin:0;">Desgraciadamente, Amazon Payments ha rechazado el pago de tu pedido en nuestra tienda online {{var store.name}}. Por favor, ponte en contacto con nosotros.</p>
29
+ <p style="font-size:12px; line-height:16px; margin:0;"><a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> / {{config path='general/store_information/phone'}}.</p>
30
+ </td>
31
+ </tr>
32
+ <tr>
33
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
34
+ </tr>
35
+ </table>
36
+ </td>
37
+ </tr>
38
+ </table>
39
+ </div>
40
+ </body>
app/locale/es_ES/template/email/amazon_payments_async_decline_soft.html ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Payment Declined: Please update your payment method on {{var store.name}}! @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "htmlescape var=$customer.name":"Customer Name",
6
+ "var order url":"Order details URL"}
7
+ @-->
8
+
9
+ <!--@styles
10
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
11
+ @-->
12
+
13
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
15
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
16
+ <tr>
17
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
18
+ <!-- [ header starts here] -->
19
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
20
+ <tr>
21
+ <td valign="top">
22
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0" /></a></td>
23
+ </tr>
24
+ <!-- [ middle starts here] -->
25
+ <tr>
26
+ <td valign="top">
27
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{htmlescape var=$customer.name}},</h1>
28
+ <p style="font-size:12px; line-height:16px; margin:0;">Amazon Payments no ha podido procesar el pago. Visita la p&aacute;gina de detalles del pedido que aparece a continuaci&oacute;n y actualiza el m&eacute;todo de pago:</p>
29
+ <p style="font-size:12px; line-height:16px; margin:1.5em; margin-right:0;"><a href="{{var order_url}}">{{var order_url}}</a></p>
30
+
31
+ <p style="font-size:12px; line-height:16px; margin:0;">Si tienes alguna pregunta sobre tu cuenta o alg&uacute;n otro asunto, no dudes en contactar con nosotros a trav&eacute;s de <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> o por tel&eacute;fono en el {{config path='general/store_information/phone'}}.</p>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Gracias de nuevo, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
36
+ </tr>
37
+ </table>
38
+ </td>
39
+ </tr>
40
+ </table>
41
+ </div>
42
+ </body>
app/locale/fr_FR/Amazon_Diagnostics.csv ADDED
File without changes
app/locale/fr_FR/Amazon_Login.csv ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ "Login with Amazon", "Connectez-vous avec Amazon"
2
+ "The Amazon MWS Access Key is incorrect", "La cl&eacute; d'acc&egrave;s Amazon MWS est incorrecte"
3
+ "Unable to log in with Amazon", "Connexion &aacute; Amazon impossible"
4
+ "OR", "OU"
5
+ "Verify Your Account", "V&eacute;rifiez votre compte"
6
+ #adminhtml,
7
+ "Default is Country Locale. Override with a value from ""<a href=""https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950"" target=""_blank"" class=""amzn-doc-link"">ENTER_LANGUAGE_PARAMETER</a>.", "Le param&ecirc;tre par d&eacute;faut est d&eacute;fini sur Pays. Remplacer par une valeur de ""<a href=""https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950"" target=""_blank"" class=""amzn-doc-link"">ENTER_LANGUAGE_PARAMETER</a>."
8
+ "Additional Access Scope", "Niveau d'acc&egrave;s suppl&eacute;mentaire"
9
+ "Optional access scope strings during login.", "Cha&icirc;nes de niveau d'acc&egrave;s en option lors de la connexion."
app/locale/fr_FR/Amazon_Payments.csv ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Amazon Payments uses information from your Amazon account to place your order.", "Amazon Payments utilise les informations de votre compte Amazon pour passer vos commandes."
2
+ "Click <a href=""#"" id=""amazon-cancel"">here</a> to change your payment method.", "Cliquez <a href=""#"" id=""amazon-cancel"">ici</a> pour modifier votre mode de paiement."
3
+ "Change Payment Method", "Modifier le mode de paiement"
4
+ "More Info", "Plus d'infos"
5
+ "Example:", "Exemple:"
6
+ "Pay with Amazon", "Payez avec Amazon"
7
+ "Payment Declined By Amazon Payments", "Paiement rejet&eacute; par Amazon Payments"
8
+ "Please update your payment method below:", "Mettez &agrave; jour votre mode de paiement ci-dessous:"
9
+ "Please agree to all the terms and conditions before placing the order.", "Acceptez toutes les conditions g&eacute;n&eacute;rales avant de passer la commande."
10
+ "There was an error processing your order. Please contact us or try again later.", "Une erreur s'est produite lors du traitement de votre commande. Contactez-nous ou r&eacute;essayez plus tard."
11
+ "Thank you for updating your payment method.", "Merci d'avoir mis &agrave; jour votre mode de paiement."
12
+ "Please try another payment method.", "Essayez un autre mode de paiement."
13
+ "OR", "OU"
14
+ "Payment", "Paiement"
15
+ "Order Summary", "R&eacute;capitulatif de commande"
16
+ "Amazon Order Reference ID required. Please try again.", "ID r&eacute;f&eacute;rence de commande Amazon requis. Veuillez r&eacute;essayer."
17
+ "Please select a shipping address.", "S&eacute;lectionnez une adresse de livraison."
18
+ "Please select a payment method.", "S&eacute;lectionnez un mode de paiement."
19
+ #adminhtml,,
20
+ "Sync with Amazon", "Synchronisez avec Amazon"
21
+ "Sync with Amazon: Authorization state is ""%s"".", "Synchronisez avec Amazon: l'&eacute;tat de l'autorisation est ""%s""."
22
+ "(Payment is currently authorizing. Please try again momentarily.)", "(Le paiement est actuellement en attente d'autorisation. Veuillez r&eacute;essayer dans un instant.)"
23
+ "Order placed on hold due to ""%s"". Email sent to customer with link to order details page and instructions to update their payment method.", "Commande mise en attente pour cause de ""%s"". E-mail envoy&eacute; au client avec le lien vers la page des d&eacute;tails de la commande et les instructions de mise &agrave; jour du mode de paiement."
24
+ "Unable to create invoice due to Authorization Reason Code: %s", "Impossible de cr&eacute;er une facture en raison du code de motif d'autorisation: %s"
25
+ "Amazon Payments requires a <a href=""https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility"" target=""_blank"">patched Payments.php</a> file for Magento 1.5 compatibility.", "Amazon Payments requiert un fichier <a href=""https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility"" target=""_blank"">Payments.php</a> corrig&eacute; pour la compatibilit&eacute; Magento 1.5."
26
+ "To complete your Amazon Payments configuration, please set up <a href=""https://sellercentral.amazon.com/"" target=""_blank"">your account</a> and add the API credentials <a href=""%s"">here</a>.", "Pour terminer votre configuration Amazon Payments, param&eacute;trez <a href=""https://sellercentral.amazon.com/"" target=""_blank"">votre compte</a> et ajoutez les informations d'authentification <a href=""%s"">ici</a>."
27
+ "Error: Please verify your Seller ID (alphanumeric characters only).", "Erreur: v&eacute;rifiez votre identifiant vendeur (caract&egrave;res alphanum&eacute;riques uniquement)."
28
+ "All of your Amazon API keys are correct.", "Toutes vos cl&eacute;s API Amazon sont correctes."
29
+ "The Amazon MWS Access Key is incorrect.", "La cl&eacute; d'acc&egrave;s Amazon MWS est incorrecte."
30
+ "The Amazon MWS Secret Key is incorrect.", "La cl&eacute; secr&egrave;te Amazon MWS est incorrecte."
31
+ "The Amazon Seller/Merchant ID is incorrect.", "L'identifiant vendeur/marchand Amazon est incorrect."
32
+ "The Amazon Seller/Merchant ID does not match the MWS keys provided.", "L'identifiant vendeur/marchand Amazon ne correspond pas aux cl&eacute;s MWS fournies."
33
+ "Gold", "Or"
34
+ "Dark Gray", "Gris fonc&eacute;"
35
+ "Light Gray", "Gris clair"
36
+ "Pay", "Payer"
37
+ "Amazon logo", "Logo Amazon"
38
+ "Small", "Petit"
39
+ "Medium", "Moyen"
40
+ "Large", "Grand"
41
+ "X-large", "Extra-large"
42
+ "Magento Core OnePage Checkout", "Paiement Magento Core OnePage"
43
+ "Amazon Standalone Checkout in a Modal Window", "Paiement Amazon Standalone dans une fen&ecirc;tre modale"
44
+ "Amazon Standalone Checkout", "Paiement Amazon Standalone"
45
+ "Language", "Language"
46
+ "Region", "R&eacute;gion"
47
+ "Seller/Merchant ID", "Identifiant vendeur/marchand"
48
+ "MWS Access Key", "Cl&eacute; d'acc&egrave; s MWS"
49
+ "MWS Secret Key", "Cl&eacute; secr&egrave; te MWS"
50
+ "Checkout Configuration", "Configuration du paiement"
51
+ "Checkout Page Type", "Type de page pour le paiement"
52
+ "Show Pay with Amazon Button on Cart", "Afficher le bouton Payez avec Amazon sur le panier"
53
+ "Pop-up must be set to ""No"" under Customers->Login with Amazon.", "Les fen&ecirc;tres contextuelles doivent &ecirc;tre d&eacute;finies sur &laquo; Non &raquo; sous Clients &gt; Connectez-vous avec Amazon"
54
+ "Only applies when OnePage Checkout is used, otherwise button is always shown.", "S'applique uniquement lorsque le paiement OnePage est utilis&eacute;, dans le cas contraire, le bouton est toujours affich&eacute;."
55
+ "Secure Cart Page", "Page du panier s&eacute;curis&eacute;e"
56
+ "HTTPS is required to use the Amazon button on the cart page.", "Le protocole HTTPS est requis pour utiliser le bouton Amazon sur la page du panier."
57
+ "Display as Payment Option", "Afficher comme option de paiement"
58
+ "Add pay button under ""Payment Information"" during checkout. (Recommended flow is to display button before user enters billing and shipping information.)", "Ajouter un bouton Payer sous &laquo; Informations relatives au paiement &raquo; lors du paiement. (Il est conseill&eacute; d'afficher le bouton avant que l'utilisateur saisisse les informations d'exp&eacute;dition et de facturation.)"
59
+ "Asynchronous Mode", "Mode asynchrone"
60
+ "In asynchronous mode, the payment is returned as a Pending status instead of an immediate Open or Declined status. Customers will need to be notified of a Declined status.", "En mode asynchrone, le paiement retourne &agrave; l'&eacute;tat En attente plut&ocirc;t que d'afficher imm&eacute;diatement l'&eacute;tat Ouvert ou Rejet&eacute;. Les clients devront &ecirc;tre inform&eacute;s d'un &eacute;tat Rejet&eacute;."
61
+ "Button Style", "Style de bouton"
62
+ "Button Label", "Etiquette de bouton"
63
+ "Button Color", "Couleur de bouton"
64
+ "Button Size", "Taille de bouton"
65
+ "Display Acceptance Badge", "Afficher l'ic&ocirc;ne d'acceptation"
66
+ "Display ""Amazon Payments"" acceptance mark in right sidebar.", "Afficher la coche d'acceptation ""Amazon Payments"" dans la barre lat&eacute;rale de droite."
67
+ "Save API responses to Magento log", "Enregistrer les r&eacute;ponses de l'API dans le journal Magento"
68
+ "Restrict by IP", "Restreindre par IP"
69
+ "Display to only whitelisted IPs found in Developer -> Developer Client Restrictions", "Afficher uniquement aux IP plac&eacute;es sur liste blanche pr&eacute;sentes dans D&eacute;veloppeur &gt; Restrictions client d&eacute;veloppeur"
app/locale/fr_FR/template/email/amazon_payments_async_decline_hard.html ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Veuillez nous contacter pour votre commande @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "htmlescape var=$customer.name":"Customer Name",
6
+ "var order url":"Order details URL"}
7
+ @-->
8
+
9
+ <!--@styles
10
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
11
+ @-->
12
+
13
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
15
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
16
+ <tr>
17
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
18
+ <!-- [ header starts here] -->
19
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
20
+ <tr>
21
+ <td valign="top">
22
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
23
+ </tr>
24
+ <!-- [ middle starts here] -->
25
+ <tr>
26
+ <td valign="top">
27
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{htmlescape var=$customer.name}},</h1>
28
+ <p style="font-size:12px; line-height:16px; margin:0;">Malheureusement Amazon Payments n�a pas pu traier le paiement pour votre commande aupr�s de {{var store.name}}. Veuillez nous contacter concernant cette commande.</p>
29
+ <p style="font-size:12px; line-height:16px; margin:0;"><a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> / {{config path='general/store_information/phone'}}.</p>
30
+ </td>
31
+ </tr>
32
+ <tr>
33
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Meilleures salutations, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
34
+ </tr>
35
+ </table>
36
+ </td>
37
+ </tr>
38
+ </table>
39
+ </div>
40
+ </body>
app/locale/fr_FR/template/email/amazon_payments_async_decline_soft.html ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Payment Declined: Please update your payment method on {{var store.name}}! @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "htmlescape var=$customer.name":"Customer Name",
6
+ "var order url":"Order details URL"}
7
+ @-->
8
+
9
+ <!--@styles
10
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
11
+ @-->
12
+
13
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
15
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
16
+ <tr>
17
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
18
+ <!-- [ header starts here] -->
19
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
20
+ <tr>
21
+ <td valign="top">
22
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
23
+ </tr>
24
+ <!-- [ middle starts here] -->
25
+ <tr>
26
+ <td valign="top">
27
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{htmlescape var=$customer.name}},</h1>
28
+ <p style="font-size:12px; line-height:16px; margin:0;">Amazon Payments could not process your payment. Please visit your order details page below and update your payment method:</p>
29
+ <p style="font-size:12px; line-height:16px; margin:1.5em; margin-right:0;"><a href="{{var order_url}}">{{var order_url}}</a></p>
30
+
31
+ <p style="font-size:12px; line-height:16px; margin:0;">If you have any questions about your account or any other matter, please feel free to contact us at <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> or by phone at {{config path='general/store_information/phone'}}.</p>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
36
+ </tr>
37
+ </table>
38
+ </td>
39
+ </tr>
40
+ </table>
41
+ </div>
42
+ </body>
app/locale/it_IT/Amazon_Diagnostics.csv ADDED
File without changes
app/locale/it_IT/Amazon_Login.csv ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ "Login with Amazon", "Accedi con Amazon"
2
+ "The Amazon MWS Access Key is incorrect", "La chiave di accesso di Amazon MWS non &egrave; corretta"
3
+ "Unable to log in with Amazon", "Impossibile accedere con Amazon"
4
+ "OR", "O"
5
+ "Verify Your Account", "Verifica il tuo account"
6
+ #adminhtml,
7
+ "Default is Country Locale. Override with a value from ""<a href=""https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950"" target=""_blank"" class=""amzn-doc-link"">ENTER_LANGUAGE_PARAMETER</a>.", "Il valore predefinito &egrave; la lingua locale del paese. Puoi sostituirlo con un valore selezionato in ""<a href=""https://payments.amazon.co.uk/developer/documentation/lpwa/201749840#201749950"" target=""_blank"" class=""amzn-doc-link"">ENTER_LANGUAGE_PARAMETER</a>."
8
+ "Additional Access Scope", "Ambito di accesso aggiuntivo"
9
+ "Optional access scope strings during login.", "Stringhe di ambito di accesso opzionale durante l'accesso."
app/locale/it_IT/Amazon_Payments.csv ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Amazon Payments uses information from your Amazon account to place your order.", "Per effettuare gli ordini, Amazon Payments utilizza informazioni provenienti dal tuo account Amazon."
2
+ "Click <a href=""#"" id=""amazon-cancel"">here</a> to change your payment method.", "Clicca <a href=""#"" id=""amazon-cancel"">qui</a> per modificare il metodo di pagamento."
3
+ "Change Payment Method", "Modifica metodo di pagamento"
4
+ "More Info", "Maggiori informazioni"
5
+ "Example:", "Esempio:"
6
+ "Pay with Amazon", "Paga con Amazon"
7
+ "Payment Declined By Amazon Payments", "Pagamento rifiutato da Amazon Payments"
8
+ "Please update your payment method below:", "Aggiorna il metodo di pagamento di seguito:"
9
+ "Please agree to all the terms and conditions before placing the order.", "Prima di effettuare l'ordine, accetta tutti i termini e le condizioni."
10
+ "There was an error processing your order. Please contact us or try again later.", "Si &egrave; verificato un errore durante l'elaborazione dell'ordine. Contattaci o riprova pi&ugrave; tardi."
11
+ "Thank you for updating your payment method.", "Grazie per aver aggiornato il metodo di pagamento."
12
+ "Please try another payment method.", "Prova con un altro metodo di pagamento."
13
+ "OR", "O"
14
+ "Payment", "Pagamento"
15
+ "Order Summary", "Riepilogo ordine"
16
+ "Amazon Order Reference ID required. Please try again.", "Numero di riferimento dell'ordine Amazon necessario. Riprova."
17
+ "Please select a shipping address.", "Seleziona un indirizzo di spedizione."
18
+ "Please select a payment method.", "Seleziona un metodo di pagamento."
19
+ #adminhtml,,
20
+ "Sync with Amazon", "Sincronizza con Amazon"
21
+ "Sync with Amazon: Authorization state is ""%s"".", "Sincronizza con Amazon: lo stato dell'autorizzazione &egrave; ""%s""."
22
+ "(Payment is currently authorizing. Please try again momentarily.)", "(Il pagamento &egrave; in fase di autorizzazione. Riprova tra qualche minuto.)"
23
+ "Order placed on hold due to ""%s"". Email sent to customer with link to order details page and instructions to update their payment method.", "Ordine sospeso per ""%s"". E-mail inviata al cliente con link alla pagina dei dettagli dell'ordine e istruzioni per aggiornare il metodo di pagamento."
24
+ "Unable to create invoice due to Authorization Reason Code: %s", "Impossibile creare la fattura a causa del codice motivo autorizzazione: %s"
25
+ "Amazon Payments requires a <a href=""https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility"" target=""_blank"">patched Payments.php</a> file for Magento 1.5 compatibility.", "Amazon Payments richiede un file <a href=""https://github.com/amzn/amazon-payments-magento-plugin/wiki/Magento-1.5-Compatibility"" target=""_blank"">con patch Payments.php</a> per la compatibilit&agrave; con Magento 1.5."
26
+ "To complete your Amazon Payments configuration, please set up <a href=""https://sellercentral.amazon.com/"" taget=""_blank"">your account</a> and add the API credentials <a href=""%s"">here</a>.", "Per completare la configurazione di Amazon Payments, crea un <a href=""https://sellercentral.amazon.com/"" taget=""_blank"">conto</a> e aggiungi le credenziali API <a href=""%s"">qui</a>."
27
+ "Error: Please verify your Seller ID (alphanumeric characters only).", "Errore: verifica il tuo numero venditore (solo caratteri alfanumerici)."
28
+ "All of your Amazon API keys are correct.", "Tutte le tue chiavi API Amazon sono corrette."
29
+ "The Amazon MWS Access Key is incorrect.", "La chiave di accesso di Amazon MWS non &egrave; corretta."
30
+ "The Amazon MWS Secret Key is incorrect.", "La chiave segreta di Amazon MWS non &egrave; corretta."
31
+ "The Amazon Seller/Merchant ID is incorrect.", "Il numero venditore Amazon non &egrave; corretto."
32
+ "The Amazon Seller/Merchant ID does not match the MWS keys provided.", "Il numero venditore di Amazon non corrisponde alle chiavi MWS fornite."
33
+ "Gold", "Oro"
34
+ "Dark Gray", "Grigio scuro"
35
+ "Light Gray", "Grigio chiaro"
36
+ "Pay", "Paga"
37
+ "Amazon logo", "Logo Amazon"
38
+ "Small", "Piccolo"
39
+ "Medium", "Medio"
40
+ "Large", "Grande"
41
+ "X-large", "Molto grande"
42
+ "Magento Core OnePage Checkout", "Modulo principale One Page Checkout Magento"
43
+ "Amazon Standalone Checkout in a Modal Window", "Checkout indipendente Amazon in una finestra modale"
44
+ "Amazon Standalone Checkout", "Checkout indipendente Amazon"
45
+ "Language", "Lingua"
46
+ "Region", "Area geografica"
47
+ "Seller/Merchant ID", "Numero venditore"
48
+ "MWS Access Key", "Chiave di accesso MWS"
49
+ "MWS Secret Key", "Chiave segreta MWS"
50
+ "Checkout Configuration", "Configurazione checkout"
51
+ "Checkout Page Type", "Tipo pagina checkout"
52
+ "Show Pay with Amazon Button on Cart", "Mostra pulsante Paga con Amazon nel carrello"
53
+ "Pop-up must be set to ""No"" under Customers->Login with Amazon.", "Il popup deve essere impostato su ""No"" in Clienti->Accedi con Amazon."
54
+ "Only applies when OnePage Checkout is used, otherwise button is always shown.", "Si applica solo quando &egrave; utilizzato One Page Checkout, altrimenti il pulsante viene sempre visualizzato."
55
+ "Secure Cart Page", "Pagina carrello sicuro"
56
+ "HTTPS is required to use the Amazon button on the cart page.", "Per utilizzare il pulsante Amazon nella pagina del carrello, &egrave; necessario il protocollo HTTPS."
57
+ "Display as Payment Option", "Visualizza come opzione di pagamento"
58
+ "Add pay button under ""Payment Information"" during checkout. (Recommended flow is to display button before user enters billing and shipping information.)", "Aggiungi il pulsante di pagamento in ""Informazioni sul pagamento"" durante il checkout. (&Egrave; consigliabile che il pulsante venga visualizzato prima che l'utente immetta le informazioni di fatturazione e spedizione.)"
59
+ "Asynchronous Mode", "Modalit&agrave; asincrona"
60
+ "In asynchronous mode, the payment is returned as a Pending status instead of an immediate Open or Declined status. Customers will need to be notified of a Declined status.", "In modalit&agrave; asincrona, il pagamento viene restituito con stato In sospeso anzich&eacute; Aperto o Rifiutato. Ai clienti dovr&agrave; essere inviata notifica di un pagamento rifiutato."
61
+ "Button Style", "Stile pulsante"
62
+ "Button Label", "Etichetta pulsante"
63
+ "Button Color", "Colore pulsante"
64
+ "Button Size", "Dimensione pulsante"
65
+ "Display Acceptance Badge", "Visualizza simbolo di accettazione"
66
+ "Display ""Amazon Payments"" acceptance mark in right sidebar.", "Visualizza contrassegno di accettazione ""Amazon Payments"" nella barra laterale destra."
67
+ "Save API responses to Magento log", "Salva risposte API nel registro Magento"
68
+ "Restrict by IP", "Applica restrizioni per IP"
69
+ "Display to only whitelisted IPs found in Developer -> Developer Client Restrictions", "Visualizza solo per gli IP consentiti in Sviluppatore -> Restrizioni client sviluppatori"
app/locale/it_IT/template/email/amazon_payments_async_decline_hard.html ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject La preghiamo di contattarci per informazioni riguardo al suo ordine @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "htmlescape var=$customer.name":"Customer Name",
6
+ "var order url":"Order details URL"}
7
+ @-->
8
+
9
+ <!--@styles
10
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
11
+ @-->
12
+
13
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
15
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
16
+ <tr>
17
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
18
+ <!-- [ header starts here] -->
19
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
20
+ <tr>
21
+ <td valign="top">
22
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
23
+ </tr>
24
+ <!-- [ middle starts here] -->
25
+ <tr>
26
+ <td valign="top">
27
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{htmlescape var=$customer.name}},</h1>
28
+ <p style="font-size:12px; line-height:16px; margin:0;">Purtroppo Amazon Payments ha rifiutato il pagamento del suo ordine nel nostro negozio on-line {{var store.name}}.</p>
29
+ <p style="font-size:12px; line-height:16px; margin:0;">Non esiti a contattarci per ulteriori informazioni a riguardo. <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> / {{config path='general/store_information/phone'}}.</p>
30
+ </td>
31
+ </tr>
32
+ <tr>
33
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
34
+ </tr>
35
+ </table>
36
+ </td>
37
+ </tr>
38
+ </table>
39
+ </div>
40
+ </body>
app/locale/it_IT/template/email/amazon_payments_async_decline_soft.html ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Payment Declined: Please update your payment method on {{var store.name}}! @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "htmlescape var=$customer.name":"Customer Name",
6
+ "var order url":"Order details URL"}
7
+ @-->
8
+
9
+ <!--@styles
10
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
11
+ @-->
12
+
13
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
15
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
16
+ <tr>
17
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
18
+ <!-- [ header starts here] -->
19
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
20
+ <tr>
21
+ <td valign="top">
22
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
23
+ </tr>
24
+ <!-- [ middle starts here] -->
25
+ <tr>
26
+ <td valign="top">
27
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{htmlescape var=$customer.name}},</h1>
28
+ <p style="font-size:12px; line-height:16px; margin:0;">Amazon Payments could not process your payment. Please visit your order details page below and update your payment method:</p>
29
+ <p style="font-size:12px; line-height:16px; margin:1.5em; margin-right:0;"><a href="{{var order_url}}">{{var order_url}}</a></p>
30
+
31
+ <p style="font-size:12px; line-height:16px; margin:0;">If you have any questions about your account or any other matter, please feel free to contact us at <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> or by phone at {{config path='general/store_information/phone'}}.</p>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
36
+ </tr>
37
+ </table>
38
+ </td>
39
+ </tr>
40
+ </table>
41
+ </div>
42
+ </body>
lib/MarketplaceWebServiceSellers/Client.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /*******************************************************************************
3
  * Copyright 2009-2014 Amazon Services. 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: http://aws.amazon.com/apache2.0
8
- * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
  * specific language governing permissions and limitations under the License.
11
  *******************************************************************************
12
  * PHP Version 5
@@ -99,7 +99,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
99
 
100
  /**
101
  * List Marketplace Participations
102
- * Returns a list of marketplaces that the seller submitting the request can sell in,
103
  * and a list of participations that include seller-specific information in that marketplace.
104
  *
105
  * @param mixed $request array of parameters for MarketplaceWebServiceSellers_Model_ListMarketplaceParticipations request or MarketplaceWebServiceSellers_Model_ListMarketplaceParticipations object itself
@@ -143,7 +143,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
143
 
144
  /**
145
  * List Marketplace Participations By Next Token
146
- * Returns the next page of marketplaces and participations using the NextToken value
147
  * that was returned by your previous request to either ListMarketplaceParticipations or
148
  * ListMarketplaceParticipationsByNextToken.
149
  *
@@ -211,9 +211,15 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
211
  */
212
  public function __construct($awsAccessKeyId, $awsSecretAccessKey, $applicationName, $applicationVersion, $config = null)
213
  {
214
- iconv_set_encoding('output_encoding', 'UTF-8');
215
- iconv_set_encoding('input_encoding', 'UTF-8');
216
- iconv_set_encoding('internal_encoding', 'UTF-8');
 
 
 
 
 
 
217
 
218
  $this->_awsAccessKeyId = $awsAccessKeyId;
219
  $this->_awsSecretAccessKey = $awsSecretAccessKey;
@@ -230,7 +236,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
230
  $attributes = array ();
231
  }
232
 
233
- $this->_config['UserAgent'] =
234
  $this->constructUserAgentHeader($applicationName, $applicationVersion, $attributes);
235
  }
236
 
@@ -243,7 +249,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
243
  throw new InvalidArgumentException('$applicationVersion cannot be null');
244
  }
245
 
246
- $userAgent =
247
  $this->quoteApplicationName($applicationName)
248
  . '/'
249
  . $this->quoteApplicationVersion($applicationVersion);
@@ -450,7 +456,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
450
  curl_setopt($ch, CURLOPT_POST, true);
451
  curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
452
  curl_setopt($ch, CURLOPT_HTTPHEADER, $allHeadersStr);
453
- curl_setopt($ch, CURLOPT_HEADER, true);
454
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
455
  if ($config['ProxyHost'] != null && $config['ProxyPort'] != -1)
456
  {
@@ -475,11 +481,11 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
475
  curl_close($ch);
476
  return $this->_extractHeadersAndBody($response);
477
  }
478
-
479
  /**
480
  * This method will attempt to extract the headers and body of our response.
481
  * We need to split the raw response string by 2 'CRLF's. 2 'CRLF's should indicate the separation of the response header
482
- * from the response body. However in our case we have some circumstances (certain client proxies) that result in
483
  * multiple responses concatenated. We could encounter a response like
484
  *
485
  * HTTP/1.1 100 Continue
@@ -499,22 +505,22 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
499
  //First split by 2 'CRLF'
500
  $responseComponents = preg_split("/(?:\r?\n){2}/", $response);
501
  $body = null;
502
- for ($count = 0;
503
- $count < count($responseComponents) && $body == null;
504
  $count++) {
505
-
506
  $headers = $responseComponents[$count];
507
  $responseStatus = $this->_extractHttpStatusCode($headers);
508
-
509
- if($responseStatus != null &&
510
  $this->_httpHeadersHaveContent($headers)){
511
-
512
  $responseHeaderMetadata = $this->_extractResponseHeaderMetadata($headers);
513
  //The body will be the next item in the responseComponents array
514
  $body = $responseComponents[++$count];
515
  }
516
  }
517
-
518
  //If the body is null here then we were unable to parse the response and will throw an exception
519
  if($body == null){
520
  $exProps["Message"] = "Failed to parse valid HTTP response (" . $response . ")";
@@ -523,11 +529,11 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
523
  }
524
 
525
  return array(
526
- 'Status' => $responseStatus,
527
- 'ResponseBody' => $body,
528
  'ResponseHeaderMetadata' => $responseHeaderMetadata);
529
  }
530
-
531
  /**
532
  * parse the status line of a header string for the proper format and
533
  * return the status code
@@ -537,14 +543,14 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
537
  * returns String statusCode or null if the status line can't be parsed
538
  */
539
  private function _extractHttpStatusCode($headers){
540
- $statusCode = null;
541
  if (1 === preg_match("/(\\S+) +(\\d+) +([^\n\r]+)(?:\r?\n|\r)/", $headers, $matches)) {
542
  //The matches array [entireMatchString, protocol, statusCode, the rest]
543
- $statusCode = $matches[2];
544
  }
545
  return $statusCode;
546
  }
547
-
548
  /**
549
  * Tries to determine some valid headers indicating this response
550
  * has content. In this case
@@ -554,7 +560,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
554
  return (1 === preg_match("/[cC]ontent-[lL]ength: +(?:\\d+)(?:\\r?\\n|\\r|$)/", $headers) ||
555
  1 === preg_match("/Transfer-Encoding: +(?!identity[\r\n;= ])(?:[^\r\n]+)(?:\r?\n|\r|$)/i", $headers));
556
  }
557
-
558
  /**
559
  * extract a ResponseHeaderMetadata object from the raw headers
560
  */
@@ -579,7 +585,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
579
  }
580
  }
581
  }
582
-
583
  return new MarketplaceWebServiceSellers_Model_ResponseHeaderMetadata(
584
  $headers['x-mws-request-id'],
585
  $headers['x-mws-response-context'],
@@ -609,7 +615,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
609
  $delay = (int) (pow(4, $retries) * 100000);
610
  usleep($delay);
611
  return true;
612
- }
613
  return false;
614
  }
615
 
1
  <?php
2
  /*******************************************************************************
3
  * Copyright 2009-2014 Amazon Services. 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: http://aws.amazon.com/apache2.0
8
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
  * specific language governing permissions and limitations under the License.
11
  *******************************************************************************
12
  * PHP Version 5
99
 
100
  /**
101
  * List Marketplace Participations
102
+ * Returns a list of marketplaces that the seller submitting the request can sell in,
103
  * and a list of participations that include seller-specific information in that marketplace.
104
  *
105
  * @param mixed $request array of parameters for MarketplaceWebServiceSellers_Model_ListMarketplaceParticipations request or MarketplaceWebServiceSellers_Model_ListMarketplaceParticipations object itself
143
 
144
  /**
145
  * List Marketplace Participations By Next Token
146
+ * Returns the next page of marketplaces and participations using the NextToken value
147
  * that was returned by your previous request to either ListMarketplaceParticipations or
148
  * ListMarketplaceParticipationsByNextToken.
149
  *
211
  */
212
  public function __construct($awsAccessKeyId, $awsSecretAccessKey, $applicationName, $applicationVersion, $config = null)
213
  {
214
+ if (PHP_VERSION_ID < 50600) {
215
+ iconv_set_encoding('output_encoding', 'UTF-8');
216
+ iconv_set_encoding('input_encoding', 'UTF-8');
217
+ iconv_set_encoding('internal_encoding', 'UTF-8');
218
+ } else {
219
+ ini_set('output_encoding', 'UTF-8');
220
+ ini_set('input_encoding', 'UTF-8');
221
+ ini_set('default_charset', 'UTF-8');
222
+ }
223
 
224
  $this->_awsAccessKeyId = $awsAccessKeyId;
225
  $this->_awsSecretAccessKey = $awsSecretAccessKey;
236
  $attributes = array ();
237
  }
238
 
239
+ $this->_config['UserAgent'] =
240
  $this->constructUserAgentHeader($applicationName, $applicationVersion, $attributes);
241
  }
242
 
249
  throw new InvalidArgumentException('$applicationVersion cannot be null');
250
  }
251
 
252
+ $userAgent =
253
  $this->quoteApplicationName($applicationName)
254
  . '/'
255
  . $this->quoteApplicationVersion($applicationVersion);
456
  curl_setopt($ch, CURLOPT_POST, true);
457
  curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
458
  curl_setopt($ch, CURLOPT_HTTPHEADER, $allHeadersStr);
459
+ curl_setopt($ch, CURLOPT_HEADER, true);
460
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
461
  if ($config['ProxyHost'] != null && $config['ProxyPort'] != -1)
462
  {
481
  curl_close($ch);
482
  return $this->_extractHeadersAndBody($response);
483
  }
484
+
485
  /**
486
  * This method will attempt to extract the headers and body of our response.
487
  * We need to split the raw response string by 2 'CRLF's. 2 'CRLF's should indicate the separation of the response header
488
+ * from the response body. However in our case we have some circumstances (certain client proxies) that result in
489
  * multiple responses concatenated. We could encounter a response like
490
  *
491
  * HTTP/1.1 100 Continue
505
  //First split by 2 'CRLF'
506
  $responseComponents = preg_split("/(?:\r?\n){2}/", $response);
507
  $body = null;
508
+ for ($count = 0;
509
+ $count < count($responseComponents) && $body == null;
510
  $count++) {
511
+
512
  $headers = $responseComponents[$count];
513
  $responseStatus = $this->_extractHttpStatusCode($headers);
514
+
515
+ if($responseStatus != null &&
516
  $this->_httpHeadersHaveContent($headers)){
517
+
518
  $responseHeaderMetadata = $this->_extractResponseHeaderMetadata($headers);
519
  //The body will be the next item in the responseComponents array
520
  $body = $responseComponents[++$count];
521
  }
522
  }
523
+
524
  //If the body is null here then we were unable to parse the response and will throw an exception
525
  if($body == null){
526
  $exProps["Message"] = "Failed to parse valid HTTP response (" . $response . ")";
529
  }
530
 
531
  return array(
532
+ 'Status' => $responseStatus,
533
+ 'ResponseBody' => $body,
534
  'ResponseHeaderMetadata' => $responseHeaderMetadata);
535
  }
536
+
537
  /**
538
  * parse the status line of a header string for the proper format and
539
  * return the status code
543
  * returns String statusCode or null if the status line can't be parsed
544
  */
545
  private function _extractHttpStatusCode($headers){
546
+ $statusCode = null;
547
  if (1 === preg_match("/(\\S+) +(\\d+) +([^\n\r]+)(?:\r?\n|\r)/", $headers, $matches)) {
548
  //The matches array [entireMatchString, protocol, statusCode, the rest]
549
+ $statusCode = $matches[2];
550
  }
551
  return $statusCode;
552
  }
553
+
554
  /**
555
  * Tries to determine some valid headers indicating this response
556
  * has content. In this case
560
  return (1 === preg_match("/[cC]ontent-[lL]ength: +(?:\\d+)(?:\\r?\\n|\\r|$)/", $headers) ||
561
  1 === preg_match("/Transfer-Encoding: +(?!identity[\r\n;= ])(?:[^\r\n]+)(?:\r?\n|\r|$)/i", $headers));
562
  }
563
+
564
  /**
565
  * extract a ResponseHeaderMetadata object from the raw headers
566
  */
585
  }
586
  }
587
  }
588
+
589
  return new MarketplaceWebServiceSellers_Model_ResponseHeaderMetadata(
590
  $headers['x-mws-request-id'],
591
  $headers['x-mws-response-context'],
615
  $delay = (int) (pow(4, $retries) * 100000);
616
  usleep($delay);
617
  return true;
618
+ }
619
  return false;
620
  }
621
 
lib/MarketplaceWebServiceSellers/KeycheckClient.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /*******************************************************************************
3
  * Copyright 2009-2014 Amazon Services. 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: http://aws.amazon.com/apache2.0
8
- * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
  * specific language governing permissions and limitations under the License.
11
  *******************************************************************************
12
  * PHP Version 5
@@ -99,7 +99,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
99
 
100
  /**
101
  * List Marketplace Participations
102
- * Returns a list of marketplaces that the seller submitting the request can sell in,
103
  * and a list of participations that include seller-specific information in that marketplace.
104
  *
105
  * @param mixed $request array of parameters for MarketplaceWebServiceSellers_Model_ListMarketplaceParticipations request or MarketplaceWebServiceSellers_Model_ListMarketplaceParticipations object itself
@@ -143,7 +143,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
143
 
144
  /**
145
  * List Marketplace Participations By Next Token
146
- * Returns the next page of marketplaces and participations using the NextToken value
147
  * that was returned by your previous request to either ListMarketplaceParticipations or
148
  * ListMarketplaceParticipationsByNextToken.
149
  *
@@ -211,9 +211,15 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
211
  */
212
  public function __construct($awsAccessKeyId, $awsSecretAccessKey, $applicationName, $applicationVersion, $config = null)
213
  {
214
- iconv_set_encoding('output_encoding', 'UTF-8');
215
- iconv_set_encoding('input_encoding', 'UTF-8');
216
- iconv_set_encoding('internal_encoding', 'UTF-8');
 
 
 
 
 
 
217
 
218
  $this->_awsAccessKeyId = $awsAccessKeyId;
219
  $this->_awsSecretAccessKey = $awsSecretAccessKey;
@@ -230,7 +236,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
230
  $attributes = array ();
231
  }
232
 
233
- $this->_config['UserAgent'] =
234
  $this->constructUserAgentHeader($applicationName, $applicationVersion, $attributes);
235
  }
236
 
@@ -243,7 +249,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
243
  throw new InvalidArgumentException('$applicationVersion cannot be null');
244
  }
245
 
246
- $userAgent =
247
  $this->quoteApplicationName($applicationName)
248
  . '/'
249
  . $this->quoteApplicationVersion($applicationVersion);
@@ -450,7 +456,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
450
  curl_setopt($ch, CURLOPT_POST, true);
451
  curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
452
  curl_setopt($ch, CURLOPT_HTTPHEADER, $allHeadersStr);
453
- curl_setopt($ch, CURLOPT_HEADER, true);
454
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
455
  if ($config['ProxyHost'] != null && $config['ProxyPort'] != -1)
456
  {
@@ -475,11 +481,11 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
475
  curl_close($ch);
476
  return $this->_extractHeadersAndBody($response);
477
  }
478
-
479
  /**
480
  * This method will attempt to extract the headers and body of our response.
481
  * We need to split the raw response string by 2 'CRLF's. 2 'CRLF's should indicate the separation of the response header
482
- * from the response body. However in our case we have some circumstances (certain client proxies) that result in
483
  * multiple responses concatenated. We could encounter a response like
484
  *
485
  * HTTP/1.1 100 Continue
@@ -499,22 +505,22 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
499
  //First split by 2 'CRLF'
500
  $responseComponents = preg_split("/(?:\r?\n){2}/", $response);
501
  $body = null;
502
- for ($count = 0;
503
- $count < count($responseComponents) && $body == null;
504
  $count++) {
505
-
506
  $headers = $responseComponents[$count];
507
  $responseStatus = $this->_extractHttpStatusCode($headers);
508
-
509
- if($responseStatus != null &&
510
  $this->_httpHeadersHaveContent($headers)){
511
-
512
  $responseHeaderMetadata = $this->_extractResponseHeaderMetadata($headers);
513
  //The body will be the next item in the responseComponents array
514
  $body = $responseComponents[++$count];
515
  }
516
  }
517
-
518
  //If the body is null here then we were unable to parse the response and will throw an exception
519
  if($body == null){
520
  $exProps["Message"] = "Failed to parse valid HTTP response (" . $response . ")";
@@ -523,11 +529,11 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
523
  }
524
 
525
  return array(
526
- 'Status' => $responseStatus,
527
- 'ResponseBody' => $body,
528
  'ResponseHeaderMetadata' => $responseHeaderMetadata);
529
  }
530
-
531
  /**
532
  * parse the status line of a header string for the proper format and
533
  * return the status code
@@ -537,14 +543,14 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
537
  * returns String statusCode or null if the status line can't be parsed
538
  */
539
  private function _extractHttpStatusCode($headers){
540
- $statusCode = null;
541
  if (1 === preg_match("/(\\S+) +(\\d+) +([^\n\r]+)(?:\r?\n|\r)/", $headers, $matches)) {
542
  //The matches array [entireMatchString, protocol, statusCode, the rest]
543
- $statusCode = $matches[2];
544
  }
545
  return $statusCode;
546
  }
547
-
548
  /**
549
  * Tries to determine some valid headers indicating this response
550
  * has content. In this case
@@ -554,7 +560,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
554
  return (1 === preg_match("/[cC]ontent-[lL]ength: +(?:\\d+)(?:\\r?\\n|\\r|$)/", $headers) ||
555
  1 === preg_match("/Transfer-Encoding: +(?!identity[\r\n;= ])(?:[^\r\n]+)(?:\r?\n|\r|$)/i", $headers));
556
  }
557
-
558
  /**
559
  * extract a ResponseHeaderMetadata object from the raw headers
560
  */
@@ -579,7 +585,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
579
  }
580
  }
581
  }
582
-
583
  return new MarketplaceWebServiceSellers_Model_ResponseHeaderMetadata(
584
  $headers['x-mws-request-id'],
585
  $headers['x-mws-response-context'],
@@ -609,7 +615,7 @@ class MarketplaceWebServiceSellers_Client implements MarketplaceWebServiceSeller
609
  $delay = (int) (pow(4, $retries) * 100000);
610
  usleep($delay);
611
  return true;
612
- }
613
  return false;
614
  }
615
 
1
  <?php
2
  /*******************************************************************************
3
  * Copyright 2009-2014 Amazon Services. 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: http://aws.amazon.com/apache2.0
8
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
  * specific language governing permissions and limitations under the License.
11
  *******************************************************************************
12
  * PHP Version 5
99
 
100
  /**
101
  * List Marketplace Participations
102
+ * Returns a list of marketplaces that the seller submitting the request can sell in,
103
  * and a list of participations that include seller-specific information in that marketplace.
104
  *
105
  * @param mixed $request array of parameters for MarketplaceWebServiceSellers_Model_ListMarketplaceParticipations request or MarketplaceWebServiceSellers_Model_ListMarketplaceParticipations object itself
143
 
144
  /**
145
  * List Marketplace Participations By Next Token
146
+ * Returns the next page of marketplaces and participations using the NextToken value
147
  * that was returned by your previous request to either ListMarketplaceParticipations or
148
  * ListMarketplaceParticipationsByNextToken.
149
  *
211
  */
212
  public function __construct($awsAccessKeyId, $awsSecretAccessKey, $applicationName, $applicationVersion, $config = null)
213
  {
214
+ if (PHP_VERSION_ID < 50600) {
215
+ iconv_set_encoding('output_encoding', 'UTF-8');
216
+ iconv_set_encoding('input_encoding', 'UTF-8');
217
+ iconv_set_encoding('internal_encoding', 'UTF-8');
218
+ } else {
219
+ ini_set('output_encoding', 'UTF-8');
220
+ ini_set('input_encoding', 'UTF-8');
221
+ ini_set('default_charset', 'UTF-8');
222
+ }
223
 
224
  $this->_awsAccessKeyId = $awsAccessKeyId;
225
  $this->_awsSecretAccessKey = $awsSecretAccessKey;
236
  $attributes = array ();
237
  }
238
 
239
+ $this->_config['UserAgent'] =
240
  $this->constructUserAgentHeader($applicationName, $applicationVersion, $attributes);
241
  }
242
 
249
  throw new InvalidArgumentException('$applicationVersion cannot be null');
250
  }
251
 
252
+ $userAgent =
253
  $this->quoteApplicationName($applicationName)
254
  . '/'
255
  . $this->quoteApplicationVersion($applicationVersion);
456
  curl_setopt($ch, CURLOPT_POST, true);
457
  curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
458
  curl_setopt($ch, CURLOPT_HTTPHEADER, $allHeadersStr);
459
+ curl_setopt($ch, CURLOPT_HEADER, true);
460
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
461
  if ($config['ProxyHost'] != null && $config['ProxyPort'] != -1)
462
  {
481
  curl_close($ch);
482
  return $this->_extractHeadersAndBody($response);
483
  }
484
+
485
  /**
486
  * This method will attempt to extract the headers and body of our response.
487
  * We need to split the raw response string by 2 'CRLF's. 2 'CRLF's should indicate the separation of the response header
488
+ * from the response body. However in our case we have some circumstances (certain client proxies) that result in
489
  * multiple responses concatenated. We could encounter a response like
490
  *
491
  * HTTP/1.1 100 Continue
505
  //First split by 2 'CRLF'
506
  $responseComponents = preg_split("/(?:\r?\n){2}/", $response);
507
  $body = null;
508
+ for ($count = 0;
509
+ $count < count($responseComponents) && $body == null;
510
  $count++) {
511
+
512
  $headers = $responseComponents[$count];
513
  $responseStatus = $this->_extractHttpStatusCode($headers);
514
+
515
+ if($responseStatus != null &&
516
  $this->_httpHeadersHaveContent($headers)){
517
+
518
  $responseHeaderMetadata = $this->_extractResponseHeaderMetadata($headers);
519
  //The body will be the next item in the responseComponents array
520
  $body = $responseComponents[++$count];
521
  }
522
  }
523
+
524
  //If the body is null here then we were unable to parse the response and will throw an exception
525
  if($body == null){
526
  $exProps["Message"] = "Failed to parse valid HTTP response (" . $response . ")";
529
  }
530
 
531
  return array(
532
+ 'Status' => $responseStatus,
533
+ 'ResponseBody' => $body,
534
  'ResponseHeaderMetadata' => $responseHeaderMetadata);
535
  }
536
+
537
  /**
538
  * parse the status line of a header string for the proper format and
539
  * return the status code
543
  * returns String statusCode or null if the status line can't be parsed
544
  */
545
  private function _extractHttpStatusCode($headers){
546
+ $statusCode = null;
547
  if (1 === preg_match("/(\\S+) +(\\d+) +([^\n\r]+)(?:\r?\n|\r)/", $headers, $matches)) {
548
  //The matches array [entireMatchString, protocol, statusCode, the rest]
549
+ $statusCode = $matches[2];
550
  }
551
  return $statusCode;
552
  }
553
+
554
  /**
555
  * Tries to determine some valid headers indicating this response
556
  * has content. In this case
560
  return (1 === preg_match("/[cC]ontent-[lL]ength: +(?:\\d+)(?:\\r?\\n|\\r|$)/", $headers) ||
561
  1 === preg_match("/Transfer-Encoding: +(?!identity[\r\n;= ])(?:[^\r\n]+)(?:\r?\n|\r|$)/i", $headers));
562
  }
563
+
564
  /**
565
  * extract a ResponseHeaderMetadata object from the raw headers
566
  */
585
  }
586
  }
587
  }
588
+
589
  return new MarketplaceWebServiceSellers_Model_ResponseHeaderMetadata(
590
  $headers['x-mws-request-id'],
591
  $headers['x-mws-response-context'],
615
  $delay = (int) (pow(4, $retries) * 100000);
616
  usleep($delay);
617
  return true;
618
+ }
619
  return false;
620
  }
621
 
lib/MarketplaceWebServiceSellers/Model/ResponseHeaderMetaData.php CHANGED
@@ -29,12 +29,12 @@ class MarketplaceWebServiceSellers_Model_ResponseHeaderMetadata {
29
  private $metadata = array();
30
 
31
  public function __construct($requestId = null, $responseContext = null, $timestamp = null,
32
- $quotaMax = null, $quotaMax = null, $quotaResetsAt = null) {
33
  $this->metadata[self::REQUEST_ID] = $requestId;
34
  $this->metadata[self::RESPONSE_CONTEXT] = $responseContext;
35
  $this->metadata[self::TIMESTAMP] = $timestamp;
36
  $this->metadata[self::QUOTA_MAX] = $quotaMax;
37
- $this->metadata[self::QUOTA_REMAINING] = $quotaMax;
38
  $this->metadata[self::QUOTA_RESETS_AT] = $quotaResetsAt;
39
  }
40
 
29
  private $metadata = array();
30
 
31
  public function __construct($requestId = null, $responseContext = null, $timestamp = null,
32
+ $quotaMax = null, $quotaRemaining = null, $quotaResetsAt = null) {
33
  $this->metadata[self::REQUEST_ID] = $requestId;
34
  $this->metadata[self::RESPONSE_CONTEXT] = $responseContext;
35
  $this->metadata[self::TIMESTAMP] = $timestamp;
36
  $this->metadata[self::QUOTA_MAX] = $quotaMax;
37
+ $this->metadata[self::QUOTA_REMAINING] = $quotaRemaining;
38
  $this->metadata[self::QUOTA_RESETS_AT] = $quotaResetsAt;
39
  }
40
 
lib/OffAmazonPayments/HttpRequest/HttpException.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Exception thrown when an error is encountered with
20
+ * the curl http library
21
+ *
22
+ */
23
+ class OffAmazonPayments_HttpException
24
+ extends Exception
25
+ {
26
+ }
27
+ ?>
lib/OffAmazonPayments/HttpRequest/IHttpRequest.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ interface IHttpRequest {
19
+
20
+ /**
21
+ * Create a http get request for the resource
22
+ * at the given uri
23
+ *
24
+ * @param execute the underlying http request
25
+ *
26
+ * @return response header + body
27
+ */
28
+ public function execute();
29
+ };
30
+
31
+ ?>
lib/OffAmazonPayments/HttpRequest/IHttpRequestFactory.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ interface IHttpRequestFactory {
19
+
20
+ /**
21
+ * Create a http get request for the resource
22
+ * at the given uri
23
+ *
24
+ * @param url uniform resource locator to get
25
+ *
26
+ * @return IHttpRequest object
27
+ */
28
+ public function createGetRequest($url);
29
+
30
+ /**
31
+ * Create a http post request using to given
32
+ * given uri & body content
33
+ *
34
+ * @param url uniform resource locator to post
35
+ *
36
+ * @return IHttpRequest object
37
+ */
38
+ public function createPostRequest($url, $body);
39
+ };
40
+
41
+ ?>
lib/OffAmazonPayments/HttpRequest/Impl/HttpRequestCurlImpl.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 'OffAmazonPayments/HttpRequest/HttpException.php';
19
+ require_once 'OffAmazonPayments/HttpRequest/IHttpRequest.php';
20
+
21
+ class HttpRequestCurlImpl implements IHttpRequest
22
+ {
23
+
24
+ /**
25
+ * Reference to the underlying curl handle
26
+ */
27
+ private $_ch = null;
28
+
29
+ /*
30
+ * Default headers for curl requests
31
+ */
32
+ private $_headers = array(
33
+ 'Expect' => null // Don't expect 100 Continue
34
+ );
35
+
36
+ /**
37
+ * Create a new instane of the class + underlying curl handle
38
+ *
39
+ */
40
+ public function __construct()
41
+ {
42
+ $this->_ch = curl_init();
43
+ curl_setopt($this->_ch, CURLOPT_SSL_VERIFYPEER, true);
44
+ curl_setopt($this->_ch, CURLOPT_SSL_VERIFYHOST, 2);
45
+ curl_setopt($this->_ch, CURLOPT_HEADER, true);
46
+ curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, true);
47
+ }
48
+
49
+ /**
50
+ * Set the url for the curl handle
51
+ *
52
+ * @param url resource to request
53
+ */
54
+ public function setUrl($url) {
55
+ curl_setopt($this->_ch, CURLOPT_URL, $url);
56
+ }
57
+
58
+ /**
59
+ * Set the port for the curl handle
60
+ *
61
+ * @param port to use
62
+ */
63
+ public function setPort($port) {
64
+ curl_setopt($this->_ch, CURLOPT_PORT, $port);
65
+ }
66
+
67
+ /**
68
+ * Set the useragent for the curl handle
69
+ *
70
+ * @param userAgent for request
71
+ */
72
+ public function setUserAgent($userAgent) {
73
+ curl_setopt($this->_ch, CURLOPT_USERAGENT, $userAgent);
74
+ }
75
+
76
+ /**
77
+ * Make this request a post request with the given body
78
+ *
79
+ * @param body http POST request body
80
+ */
81
+ public function makePost($body) {
82
+ curl_setopt($this->_ch, CURLOPT_POST, true);
83
+ curl_setopt($this->_ch, CURLOPT_POSTFIELDS, $body);
84
+
85
+ array_push($this->_headers, 'Content-Type', "application/x-www-form-urlencoded; charset=utf-8");
86
+ }
87
+
88
+ /**
89
+ * Setup the ca bundle file
90
+ *
91
+ * @param caBundleFile file containing trusted ca certs
92
+ */
93
+ public function setCaBundleFile($caBundleFile)
94
+ {
95
+ curl_setopt($this->_ch, CURLOPT_CAINFO, $caBundleFile);
96
+ }
97
+
98
+ /**
99
+ * Setup the proxy hostname and port
100
+ *
101
+ * @param hostnameport username and password in <hostname>:<port> format
102
+ *
103
+ */
104
+ public function setupProxy($hostnameport)
105
+ {
106
+ curl_setopt($this->_ch, CURLOPT_PROXY, $hostnameport);
107
+ }
108
+
109
+ /**
110
+ * Setup the proxy username and password
111
+ *
112
+ * @param usernamepwd username and password in <username>:<password> format
113
+ *
114
+ */
115
+ public function setupProxyUsernameAndPassword($usernamepwd)
116
+ {
117
+ curl_setopt($this->_ch, CURLOPT_PROXYUSERPWD, $usernamepwd);
118
+ }
119
+
120
+ /**
121
+ * Create a http get request for the resource
122
+ * at the given uri
123
+ *
124
+ * @param execute the underlying http request
125
+ *
126
+ * @return response header + body
127
+ */
128
+ public function execute()
129
+ {
130
+ $this->setRequestHeaders();
131
+ $response = '';
132
+ if (!$response = curl_exec($this->_ch)) {
133
+ $errorNo = curl_error($this->_ch);
134
+ curl_close($this->_ch);
135
+ throw new OffAmazonPayments_HttpException($errorNo);
136
+ }
137
+
138
+ curl_close($this->_ch);
139
+
140
+ return $response;
141
+ }
142
+
143
+ /**
144
+ * Setup request header information
145
+ *
146
+ */
147
+ private function setRequestHeaders()
148
+ {
149
+ $allHeadersStr = array();
150
+ foreach($this->_headers as $name => $val) {
151
+ $str = $name . ": ";
152
+ if(isset($val)) {
153
+ $str = $str . $val;
154
+ }
155
+ $allHeadersStr[] = $str;
156
+ }
157
+
158
+ curl_setopt($this->_ch, CURLOPT_HTTPHEADER, $allHeadersStr);
159
+ }
160
+ };
161
+
162
+ ?>
lib/OffAmazonPayments/HttpRequest/Impl/HttpRequestFactoryCurlImpl.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 'OffAmazonPayments/HttpRequest/IHttpRequestFactory.php';
19
+ require_once 'OffAmazonPayments/HttpRequest/Impl/HttpRequestCurlImpl.php';
20
+ require_once 'OffAmazonPayments/OffAmazonPaymentsServiceUtils.php';
21
+ require_once 'OffAmazonPaymentsService/MerchantValues.php';
22
+
23
+ /**
24
+ * Wrapper to simplify curl functions for http get/set
25
+ *
26
+ */
27
+ class HttpRequestFactoryCurlImpl implements IHttpRequestFactory
28
+ {
29
+
30
+ /**
31
+ * Merchant values configuration instance
32
+ *
33
+ */
34
+ private $_merchantValues = null;
35
+
36
+
37
+ /**
38
+ * Create an instance of the client class
39
+ *
40
+ * @param instance of OffAmazonPayments_MerchantValues class
41
+ *
42
+ * @return void
43
+ */
44
+ public function __construct($merchantValues) {
45
+
46
+ if(!isset($merchantValues)) {
47
+ throw new InvalidArgumentException("merchantValue object not injected");
48
+ }
49
+
50
+ $this->_merchantValues = $merchantValues;
51
+ }
52
+
53
+ /**
54
+ * Create a http get request for the resource
55
+ * at the given uri
56
+ *
57
+ * @param url uniform resource locator to get
58
+ *
59
+ * @return HttpRequest object
60
+ */
61
+ public function createGetRequest($url)
62
+ {
63
+ return $this->createNewRequest($url);
64
+ }
65
+
66
+ /**
67
+ * Create a http post request using to given
68
+ * given uri & body content
69
+ *
70
+ * @param url uniform resource locator to post
71
+ *
72
+ * @return HttpRequest object
73
+ */
74
+ public function createPostRequest($url, $body)
75
+ {
76
+ $httpRequest = $this->createNewRequest($url);
77
+ $httpRequest->makePost($body);
78
+
79
+ return $httpRequest;
80
+ }
81
+
82
+ /**
83
+ * Create a new curl handle and set up with default
84
+ * options for all requests
85
+ *
86
+ * @param url resource to request
87
+ *
88
+ * @return curl handle
89
+ */
90
+ private function createNewRequest($url)
91
+ {
92
+ $httpRequest = new HttpRequestCurlImpl();
93
+
94
+ $parsedUrl = $this->_setupConnectionInfo($url);
95
+
96
+ $httpRequest->setUrl($parsedUrl['url']);
97
+ $httpRequest->setPort($parsedUrl['port']);
98
+ $httpRequest->setUserAgent($this->_merchantValues->getUserAgentString());
99
+
100
+ # if a ca bundle is configured, use it as opposed to the default ca
101
+ # configured for the server
102
+ if ($this->_merchantValues->isCaBundleConfigured()) {
103
+ $httpRequest->setCaBundleFile($this->_merchantValues->getCaBundleFile());
104
+ }
105
+
106
+ if ($this->_merchantValues->isProxyConfigured()) {
107
+ $this->setupProxyForCurl($httpRequest);
108
+ }
109
+
110
+ return $httpRequest;
111
+ }
112
+
113
+ /**
114
+ * Setup the connection parameters for the request
115
+ *
116
+ * @param url resource to request
117
+ *
118
+ */
119
+ private function _setupConnectionInfo($url)
120
+ {
121
+ $parsed_url = parse_url($url);
122
+
123
+ $uri = array_key_exists('path', $parsed_url) ? $parsed_url['path'] : null;
124
+ if (!isset($uri)) {
125
+ $uri = "/";
126
+ }
127
+
128
+ $scheme = '';
129
+
130
+ switch ($parsed_url['scheme']) {
131
+ case 'https':
132
+ $scheme = 'https://';
133
+ $port = array_key_exists('port', $parsed_url) && (isset($parsed_url['port'])) ? $parsed_url['port'] : 443;
134
+ break;
135
+ default:
136
+ $scheme = 'http://';
137
+ $port = array_key_exists('port', $parsed_url) && (isset($parsed_url['port'])) ? $parsed_url['port'] : 80;
138
+ }
139
+
140
+ $retVal = array(
141
+ 'port' => $port,
142
+ 'url' => $scheme . $parsed_url['host'] . $uri
143
+ );
144
+
145
+ return $retVal;
146
+ }
147
+
148
+ /**
149
+ * Setup proxy options for curl handle
150
+ *
151
+ * @param httpRequest httpRequestObject
152
+ *
153
+ */
154
+ private function setupProxyForCurl($httpRequest)
155
+ {
156
+ $proxy = $this->_merchantValues->getProxyHost() . ':' . $this->_merchantValues->getProxyPort();
157
+ $httpRequest->setupProxy($proxy);
158
+
159
+ if ($this->_merchantValues->isProxyAuthenticationConfigured()) {
160
+ $proxyUserPwd = $this->_merchantValues->getProxyUsername() . ':' . $this->_merchantValues->getProxyPassword();
161
+ $httpRequest->setupProxyUsernameAndPassword($proxyUserPwd);
162
+ }
163
+ }
164
+ }
165
+
166
+ ?>
lib/OffAmazonPayments/OffAmazonPaymentsServiceUtils.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ class OffAmazonPaymentsServiceUtils
19
+ {
20
+ const MWS_CLIENT_VERSION = '2013-01-01';
21
+ const APPLICATION_LIBRARY_VERSION = 'DEVELOPMENT-BUILD';
22
+
23
+ public function buildUserAgentString($applicationName, $applicationVersion, $attributes = null)
24
+ {
25
+ if (is_null($attributes)) {
26
+ $attributes = array ();
27
+ }
28
+
29
+ if (!array_key_exists("ApplicationLibraryVersion", $attributes)) {
30
+ array_push($attributes, "ApplicationLibraryVersion", self::APPLICATION_LIBRARY_VERSION);
31
+ }
32
+
33
+ return $this->constructUserAgentHeader($applicationName, $applicationVersion, $attributes);
34
+ }
35
+
36
+ private function constructUserAgentHeader($applicationName, $applicationVersion, $attributes)
37
+ {
38
+ $userAgent
39
+ = $this->quoteApplicationName($applicationName)
40
+ . '/'
41
+ . $this->quoteApplicationVersion($applicationVersion);
42
+
43
+ $userAgent .= ' (';
44
+ $userAgent .= 'Language=PHP/' . phpversion();
45
+ $userAgent .= '; ';
46
+ $userAgent .= 'Platform=' . php_uname('s') . '/' . php_uname('m') . '/' . php_uname('r');
47
+ $userAgent .= '; ';
48
+ $userAgent .= 'MWSClientVersion=' . self::MWS_CLIENT_VERSION;
49
+
50
+ foreach ($attributes as $key => $value) {
51
+ if (empty($value)) {
52
+ throw new InvalidArgumentException("value for $key cannot be null or empty");
53
+ }
54
+
55
+ $userAgent .= '; '
56
+ . $this->quoteAttributeName($key)
57
+ . '='
58
+ . $this->quoteAttributeValue($value);
59
+ }
60
+
61
+ $userAgent .= ')';
62
+
63
+ return $userAgent;
64
+ }
65
+
66
+ /**
67
+ * Collapse multiple whitespace characters into a single ' ' and backslash escape '\',
68
+ * and '/' characters from a string.
69
+ * @param $s
70
+ * @return string
71
+ */
72
+ private function quoteApplicationName($s) {
73
+ $quotedString = $this->collapseWhitespace($s);
74
+ $quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
75
+ $quotedString = preg_replace('/\//', '\\/', $quotedString);
76
+
77
+ return $quotedString;
78
+ }
79
+
80
+ /**
81
+ * Collapse multiple whitespace characters into a single ' ' and backslash escape '\',
82
+ * and '(' characters from a string.
83
+ *
84
+ * @param $s
85
+ * @return string
86
+ */
87
+ private function quoteApplicationVersion($s) {
88
+ $quotedString = $this->collapseWhitespace($s);
89
+ $quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
90
+ $quotedString = preg_replace('/\\(/', '\\(', $quotedString);
91
+
92
+ return $quotedString;
93
+ }
94
+
95
+ /**
96
+ * Collapse multiple whitespace characters into a single ' ' character.
97
+ * @param $s
98
+ * @return string
99
+ */
100
+ private function collapseWhitespace($s) {
101
+ return preg_replace('/ {2,}|\s/', ' ', $s);
102
+ }
103
+
104
+ /**
105
+ * Collapse multiple whitespace characters into a single ' ' and backslash escape '\',
106
+ * and '=' characters from a string.
107
+ *
108
+ * @param $s
109
+ * @return unknown_type
110
+ */
111
+ private function quoteAttributeName($s) {
112
+ $quotedString = $this->collapseWhitespace($s);
113
+ $quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
114
+ $quotedString = preg_replace('/\\=/', '\\=', $quotedString);
115
+
116
+ return $quotedString;
117
+ }
118
+
119
+ /**
120
+ * Collapse multiple whitespace characters into a single ' ' and backslash escape ';', '\',
121
+ * and ')' characters from a string.
122
+ *
123
+ * @param $s
124
+ * @return unknown_type
125
+ */
126
+ private function quoteAttributeValue($s) {
127
+ $quotedString = $this->collapseWhitespace($s);
128
+ $quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
129
+ $quotedString = preg_replace('/\\;/', '\\;', $quotedString);
130
+ $quotedString = preg_replace('/\\)/', '\\)', $quotedString);
131
+
132
+ return $quotedString;
133
+ }
134
+ }
135
+
136
+
137
+ ?>
lib/OffAmazonPaymentsNotifications/Impl/Certificate.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 'OffAmazonPaymentsNotifications/InvalidCertificateException.php';
19
+
20
+ /**
21
+ * Class to wrap a Certificate
22
+ *
23
+ */
24
+ class Certificate
25
+ {
26
+ /**
27
+ * Certificate as string (read from file/URL)
28
+ *
29
+ * @var string
30
+ */
31
+ private $_certificate;
32
+
33
+ /**
34
+ * Create a new instance of the certificate and
35
+ * wraps the contents in a class
36
+ *
37
+ * Throws an exception if the message is not valid
38
+ * as defined by the implementation of this class
39
+ *
40
+ * @param string $certificate a string pasred from file/URL
41
+ *
42
+ * @return new instance of concreate class
43
+ */
44
+ public function __construct($certificate)
45
+ {
46
+ $this->_certificate = $certificate;
47
+ }
48
+
49
+ /**
50
+ * Return the certificate string
51
+ *
52
+ * @return string of contents
53
+ */
54
+ public function getCertificate()
55
+ {
56
+ return $this->_certificate;
57
+ }
58
+
59
+ /**
60
+ * Extract the subject field from the certificate and return the contents
61
+ *
62
+ * @throws OffAmazonPaymentsNotifications_InvalidCertificateException if not found
63
+ *
64
+ * @return array of contents of the subject if found
65
+ */
66
+ public function getSubject()
67
+ {
68
+ $certInfo = openssl_x509_parse($this->_certificate, true);
69
+ $certSubject = $certInfo["subject"];
70
+
71
+ if (is_null($certSubject)) {
72
+ throw new OffAmazonPaymentsNotifications_InvalidCertificateException(
73
+ "Error with certificate - subject cannot be found"
74
+ );
75
+ }
76
+ return $certSubject;
77
+ }
78
+ }
79
+ ?>
lib/OffAmazonPaymentsNotifications/InvalidCertificateException.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Exception thrown when an error occurred in parsing the certificate
20
+ * received by the client library
21
+ *
22
+ */
23
+ class OffAmazonPaymentsNotifications_InvalidCertificateException
24
+ extends Exception
25
+ {
26
+ }
27
+ ?>
lib/OffAmazonPaymentsNotifications/Samples/.config.inc.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ </div>
32
+
33
+ <div>
34
+ <form name="input" action="AddressConsentSampleResult.php">
35
+ OrderReferenceId: <input type="text" name="orderReferenceId"/><br/><br/>
36
+ Access Token: <input type="text" name="accessToken"/><br/><br/>
37
+ <input type="submit" value="Submit"/>
38
+ </form>
39
+ </div>
40
+
41
+ </body>
42
+ </html>
lib/OffAmazonPaymentsNotifications/Samples/AddressConsentSampleResult.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @@ProductName@@
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 ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <style>
29
+ #AmazonAddressWidget {width: 400px; height: 228px;}
30
+ </style>
31
+ <script type="text/javascript">
32
+ window.onAmazonLoginReady = function () {
33
+ amazon.Login.setClientId('<?php print $merchantValues->getClientId(); ?>');
34
+ };
35
+ </script>
36
+ <script type="text/javascript" src=<?php print "'" . $merchantValues->getWidgetUrl() . "'"; ?> ></script>
37
+ </head>
38
+ <body>
39
+ <div id="AmazonAddressWidget"></div>
40
+
41
+ <p>Click <a id="WalletLink" href="">here</a> to go to the
42
+ wallet page once you have completed the signin</p>
43
+
44
+ <script type='text/javascript' >
45
+ function getParamFromQueryString(name, url) {
46
+ var regexString = "[\\?&]" + name + "=([^&#]*)";
47
+ var regex = new RegExp(regexString);
48
+ var results = regex.exec(url);
49
+
50
+ var result = null;
51
+
52
+ if (results != null && results.length >= 2 && results[1] != null) {
53
+ var result = results[1].replace("?" + name);
54
+ }
55
+
56
+ return result;
57
+ }
58
+
59
+ var url = window.location.href;
60
+ var session = getParamFromQueryString("session", url);
61
+ var access_token = getParamFromQueryString("access_token", url);
62
+
63
+ if (session == null && access_token == null) {
64
+ alert("Missing query string parameters from request, verify that session & access_token are present.");
65
+ }
66
+
67
+ new OffAmazonPayments.Widgets.AddressBook({
68
+ sellerId: <?php print "\"" . $merchantValues->getMerchantId() . "\""; ?>,
69
+ displayMode: 'Edit',
70
+ agreementType: 'BillingAgreement',
71
+ onBillingAgreementCreate: function(billingAgreement) {
72
+ session = billingAgreement.getAmazonBillingAgreementId();
73
+ document.getElementById("WalletLink").href = 'wallet.php' +
74
+ '?session=' + session + '&access_token=' + access_token;
75
+ },
76
+ design : {
77
+ designMode : 'responsive'
78
+ },
79
+ onAddressSelect: function(billingAgreement) {
80
+ //This is to trigger when a vaid shipping address is selected
81
+ },
82
+ onError: function(error) {
83
+ alert(error.getErrorCode() + ": " + error.getErrorMessage());
84
+ }
85
+ }).bind("AmazonAddressWidget");
86
+ </script>
87
+ </body>
88
+ </html>
lib/OffAmazonPaymentsNotifications/Samples/AutomaticPayments/signin.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ var path = location.pathname.replace(/[^\/]+.php/, "address.php");
47
+ amazon.Login.authorize({scope: "profile payments:widget payments:shipping_address"}, "https://" + location.host + path);
48
+ },
49
+ onError: function(error) {
50
+ alert(error.getErrorCode() + ": " + error.getMessage());
51
+ }
52
+ });
53
+ </script>
54
+ <p>Sign in with a test buyer account to redirect to the address widget page</p>
55
+ </body>
56
+ </html>
lib/OffAmazonPaymentsNotifications/Samples/AutomaticPayments/wallet.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <style>
29
+ #AmazonWalletWidget, #AmazonConsentWidget {width: 400px; height: 228px;}
30
+ </style>
31
+ <script type="text/javascript">
32
+ window.onAmazonLoginReady = function () {
33
+ amazon.Login.setClientId('<?php print $merchantValues->getClientId(); ?>');
34
+ };
35
+ </script>
36
+ <script type="text/javascript"
37
+ src=<?php print "'" . $merchantValues->getWidgetUrl() . "'"; ?>>
38
+ </script>
39
+ </head>
40
+ <body>
41
+ <div id="AmazonWalletWidget"></div>
42
+ <div id="AmazonConsentWidget"></div>
43
+ <div id="SessionInformation"></div>
44
+
45
+ <script type='text/javascript'>
46
+ function getParamFromQueryString(name, url) {
47
+ var regexString = "[\\?&]" + name + "=([^&#]*)";
48
+ var regex = new RegExp(regexString);
49
+ var results = regex.exec(url);
50
+
51
+ var result = null;
52
+
53
+ if (results != null && results.length >= 2 && results[1] != null ) {
54
+ var result = results[1].replace("?" + name);
55
+ }
56
+
57
+ return result;
58
+ }
59
+
60
+ var url = window.location.href;
61
+ var session = getParamFromQueryString("session", url);
62
+ var access_token = getParamFromQueryString("access_token", url);
63
+
64
+ if (session == null && access_token == null) {
65
+ alert("Missing query string parameters from request, verify that session & access_token are present.");
66
+ } else {
67
+ document.getElementById("SessionInformation").innerHTML = "Billing Agreement Number: " + session + "<p> Access Token : " + access_token;
68
+ }
69
+
70
+ new OffAmazonPayments.Widgets.Wallet({
71
+ sellerId: <?php print "\"" . $merchantValues->getMerchantId() . "\""; ?>,
72
+ amazonBillingAgreementId: session,
73
+ displayMode: 'Edit',
74
+ design : {
75
+ designMode : 'responsive'
76
+ },
77
+ onPaymentSelect: function (billingAgreement) {
78
+ // This is to trigger when a valid payment instrument is selected
79
+ },
80
+ onError: function (error) {
81
+ alert(error.getErrorCode() + ": " + error.getErrorMessage());
82
+ }
83
+ }).bind("AmazonWalletWidget");
84
+
85
+ new OffAmazonPayments.Widgets.Consent({
86
+ sellerId: <?php print "\"" . $merchantValues->getMerchantId() . "\""; ?>,
87
+ // amazonBillingAgreementId obtained from createBillingAgreement
88
+ amazonBillingAgreementId: session,
89
+ design : {
90
+ designMode : 'responsive'
91
+ },
92
+ onRender: function(billingAgreementConsentStatus){
93
+ // Called after widget renders
94
+ buyerBillingAgreementConsentStatus =
95
+ billingAgreementConsentStatus.getConsentStatus();
96
+ // getConsentStatus returns true or false
97
+ // true – checkbox is selected
98
+ },// false – checkbox is unselected - default
99
+ onConsent: function(billingAgreementConsentStatus) {
100
+ buyerBillingAgreementConsentStatus =
101
+ billingAgreementConsentStatus.getConsentStatus();
102
+ // getConsentStatus returns true or false
103
+ // true – checkbox is selected – buyer has consented
104
+ // false – checkbox is unselected – buyer has not consented
105
+ // Replace this code with the action that you want to perform
106
+ // after the consent checkbox is selected/unselected.
107
+ },
108
+ onError: function(error) {
109
+ }// your error handling code
110
+ }).bind("AmazonConsentWidget");
111
+ </script>
112
+ </body>
113
+ </html>
lib/OffAmazonPaymentsNotifications/Samples/AutomaticPaymentsSimpleCheckoutDataInput.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/OrderReferencePayments/address.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <style>
29
+ #AmazonAddressWidget {width: 400px; height: 228px;}
30
+ </style>
31
+ <script type="text/javascript">
32
+ window.onAmazonLoginReady = function () {
33
+ amazon.Login.setClientId('<?php print $merchantValues->getClientId(); ?>');
34
+ };
35
+ </script>
36
+ <script type="text/javascript" src=<?php print "'" . $merchantValues->getWidgetUrl() . "'"; ?> ></script>
37
+ </head>
38
+ <body>
39
+ <div id="AmazonAddressWidget"></div>
40
+
41
+ <p>Click <a id="WalletLink" href="">here</a> to go to the
42
+ wallet page once you have completed the signin</p>
43
+
44
+ <script type='text/javascript' >
45
+ function getParamFromQueryString(name, url) {
46
+ var regexString = "[\\?&]" + name + "=([^&#]*)";
47
+ var regex = new RegExp(regexString);
48
+ var results = regex.exec(url);
49
+
50
+ var result = null;
51
+
52
+ if (results != null && results.length >= 2 && results[1] != null) {
53
+ var result = results[1].replace("?" + name);
54
+ }
55
+
56
+ return result;
57
+ }
58
+
59
+ var url = window.location.href;
60
+ var session = getParamFromQueryString("session", url);
61
+ var access_token = getParamFromQueryString("access_token", url);
62
+
63
+ if (session == null && access_token == null) {
64
+ alert("Missing query string parameters from request, verify that session & access_token are present.");
65
+ }
66
+
67
+ new OffAmazonPayments.Widgets.AddressBook({
68
+ sellerId: <?php print "\"" . $merchantValues->getMerchantId() . "\""; ?>,
69
+ onOrderReferenceCreate: function(orderReference) {
70
+ session = orderReference.getAmazonOrderReferenceId();
71
+ document.getElementById("WalletLink").href = "wallet.php?session=" + session + "&access_token=" + access_token;
72
+ },
73
+ displayMode: 'Edit',
74
+ design : {
75
+ designMode : 'responsive'
76
+ },
77
+ onAddressSelect: function(orderReference) {
78
+ // This is to trigger when a valid shipping address is selected
79
+ },
80
+ onError: function(error) {
81
+ alert(error.getErrorCode() + ": " + error.getErrorMessage());
82
+ }
83
+ }).bind("AmazonAddressWidget");
84
+
85
+ </script>
86
+ </body>
87
+ </html>
lib/OffAmazonPaymentsNotifications/Samples/OrderReferencePayments/signin.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ OffAmazonPayments.Button("AmazonPayButton", "<?php print $merchantValues->getMerchantId(); ?>", {
41
+ type: "Pay",
42
+ authorization: function() {
43
+ var path = location.pathname.replace(/[^\/]+.php/, "address.php");
44
+ amazon.Login.authorize({scope: "profile payments:widget payments:shipping_address"}, "https://" + location.host + path);
45
+ },
46
+ onError: function(error) {
47
+ alert(error.getErrorCode() + ": " + error.getErrorMessage());
48
+ }
49
+ });
50
+ </script>
51
+ <p>Sign in with a test buyer account to redirect to the address widget page</p>
52
+ </body>
53
+ </html>
lib/OffAmazonPaymentsNotifications/Samples/OrderReferencePayments/wallet.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <style>
29
+ #AmazonWalletWidget {width: 400px; height: 228px;}
30
+ </style>
31
+ <script type="text/javascript">
32
+ window.onAmazonLoginReady = function () {
33
+ amazon.Login.setClientId('<?php print $merchantValues->getClientId(); ?>');
34
+ };
35
+ </script>
36
+ <script type="text/javascript"
37
+ src=<?php print "'" . $merchantValues->getWidgetUrl() . "'"; ?>>
38
+ </script>
39
+ </head>
40
+ <body>
41
+ <div id="AmazonWalletWidget"></div>
42
+ <div id="SessionInformation"></div>
43
+
44
+ <script type='text/javascript'>
45
+ function getParamFromQueryString(name, url) {
46
+ var regexString = "[\\?&]" + name + "=([^&#]*)";
47
+ var regex = new RegExp(regexString);
48
+ var results = regex.exec(url);
49
+
50
+ var result = null;
51
+
52
+ if (results != null && results.length >= 2 && results[1] != null ) {
53
+ var result = results[1].replace("?" + name);
54
+ }
55
+
56
+ return result;
57
+ }
58
+
59
+ var url = window.location.href;
60
+ var session = getParamFromQueryString("session", url);
61
+ var access_token = getParamFromQueryString("access_token", url);
62
+
63
+ if (session == null && access_token == null) {
64
+ alert("Missing query string parameters from request, verify that session & access_token are present.");
65
+ } else {
66
+ document.getElementById("SessionInformation").innerHTML = "Order Reference Number: " + session + "<p> Access Token : " + access_token;
67
+ }
68
+
69
+ new OffAmazonPayments.Widgets.Wallet({
70
+ sellerId: <?php print "\"" . $merchantValues->getMerchantId() . "\""; ?>,
71
+ displayMode: 'Edit',
72
+ design : {
73
+ designMode : 'responsive'
74
+ },
75
+ onPaymentSelect: function (orderReference) {
76
+ // This is to trigger when a valid shipping address is selected
77
+ },
78
+ onError: function (error) {
79
+ alert(error.getErrorCode() + ": " + error.getErrorMessage());
80
+ }
81
+ }).bind("AmazonWalletWidget");
82
+ </script>
83
+ </body>
84
+ </html>
lib/OffAmazonPaymentsNotifications/Samples/OrderReferenceSample.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/ProviderCheckoutDataInput.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>@@ProductName@@ PHP Sample Code</h1>
26
+
27
+ <br/>
28
+
29
+ <h2>Order Reference Samples</h2>
30
+
31
+ <p>Click <a href="OrderReferencePayments/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
+ <p>(Note: Billing Agreement Samples are only applicable in US and UK)</p>
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
+ <p>(Note: Provider Contract Samples are only applicable in US)</p>
57
+ <p>Click <a href="OrderReferencePayments/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 ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)/", "&nbsp;", $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/OffAmazonPaymentsService/Client.php CHANGED
@@ -970,6 +970,12 @@ class OffAmazonPaymentsService_Client implements OffAmazonPaymentsService_Interf
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())) {
970
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
971
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
972
 
973
+ if (defined('CURLOPT_IPRESOLVE'))
974
+ {
975
+ curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
976
+ }
977
+
978
+
979
  # if a ca bundle is configured, use it as opposed to the default ca
980
  # configured for the server
981
  if (!is_null($this->_merchantValues->getCaBundleFile())) {
lib/OffAmazonPaymentsService/MerchantValuesBuilder.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ require_once 'OffAmazonPaymentsService/OffAmazonPaymentsService.config.inc.php';
20
+ require_once 'OffAmazonPaymentsService/RegionSpecificProperties.php';
21
+ require_once 'OffAmazonPaymentsService/MerchantValues.php';
22
+
23
+ define('MERCHANT_ID', isset($merchantId) ? $merchantId : null);
24
+ define('ACCESS_KEY', isset($accessKey) ? $accessKey : null);
25
+ define('SECRET_KEY', isset($secretKey) ? $secretKey : null);
26
+ define('APPLICATION_NAME', isset($applicationName) ? $applicationName : null);
27
+ define('APPLICATION_VERSION', isset($applicationVersion) ? $applicationVersion : null);
28
+ define('REGION', isset($region) ? $region : null);
29
+ define('ENVIRONMENT', isset($environment) ? $environment : null);
30
+ define('SERVICE_URL', isset($serviceUrl) ? $serviceUrl : null);
31
+ define('WIDGET_URL', isset($widgetUrl) ? $widgetUrl : null);
32
+ define('CA_BUNDLEFILE', isset($caBundleFile) ? $caBundleFile : null);
33
+ define('CLIENT_ID', isset($clientId) ? $clientId : null);
34
+ define('PROXY_USERNAME', isset($proxyUsername) ? $proxyUsername : null);
35
+ define('PROXY_PASSWORD', isset($proxyPassword) ? $proxyPassword : null);
36
+ define('PROXY_HOST', isset($proxyHost) ? $proxyHost : null);
37
+ define('PROXY_PORT', isset($proxyPort) ? $proxyPort : null);
38
+ define('CN_NAME', isset($cnName) ? $cnName : null);
39
+
40
+ class OffAmazonPaymentsService_MerchantValuesBuilder
41
+ {
42
+ private $_config;
43
+
44
+ private $_regionSpecificProperties;
45
+
46
+ /**
47
+ * Provide a static function to access the constructor so
48
+ * that a fluent interface can be used to build the merchant
49
+ * values object
50
+ *
51
+ * @param config to use, default to null
52
+ *
53
+ * @return new instance of OffAmazonPaymentsService_MerchantValuesBuilder
54
+ */
55
+ public static function create($config = null) {
56
+ return new OffAmazonPaymentsService_MerchantValuesBuilder($config);
57
+ }
58
+
59
+ /**
60
+ * Create a new instance, using global configuraton
61
+ * values if no configuration is define
62
+ *
63
+ * @param config array of property values
64
+ *
65
+ */
66
+ private function __construct($config = null) {
67
+
68
+ if (isset($config)) {
69
+ $this->_config = $config;
70
+ } else {
71
+ $this->_config = array(
72
+ 'merchantId' => MERCHANT_ID,
73
+ 'accessKey' => ACCESS_KEY,
74
+ 'secretKey' => SECRET_KEY,
75
+ 'applicationName' => APPLICATION_NAME,
76
+ 'applicationVersion' => APPLICATION_VERSION,
77
+ 'region' => REGION,
78
+ 'environment' => ENVIRONMENT,
79
+ 'serviceUrl' => SERVICE_URL,
80
+ 'widgetUrl' => WIDGET_URL,
81
+ 'caBundleFile' => CA_BUNDLEFILE,
82
+ 'clientId' => CLIENT_ID,
83
+ 'proxyUsername' => PROXY_USERNAME,
84
+ 'proxyPassword' => PROXY_PASSWORD,
85
+ 'proxyHost' => PROXY_HOST,
86
+ 'proxyPort' => PROXY_PORT,
87
+ 'cnName' => CN_NAME
88
+ );
89
+ }
90
+
91
+ $this->_regionSpecificProperties = new OffAmazonPaymentsService_RegionSpecificProperties();
92
+ }
93
+
94
+ /**
95
+ * Setup the region specific properties file to use for the
96
+ * merchant values class
97
+ *
98
+ * @param OffAmazonPaymentsService_RegionSpecificProperties instance to use
99
+ *
100
+ * @return this
101
+ */
102
+ public function withRegionSpecificProperties(
103
+ $regionSpecificProperties)
104
+ {
105
+ $this->_regionSpecificProperties = $regionSpecificProperties;
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Create a new instance of the merchant values object
111
+ * with the configured properties
112
+ *
113
+ * @return OffAmazonPaymentsService_MerchantValues
114
+ */
115
+ public function build() {
116
+ return new OffAmazonPaymentsService_MerchantValues(
117
+ $this->_config,
118
+ $this->_regionSpecificProperties
119
+ );
120
+ }
121
+ }
122
+ ?>
lib/OffAmazonPaymentsService/Samples/.config.inc.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,366 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,337 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,368 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,337 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.4.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,62 +31,35 @@
31
  Keep your customers secure! Leverage the same user authentication system used on Amazon.com.&lt;/p&gt;&#xD;
32
  &#xD;
33
  </description>
34
- <notes>v1.4.0 Release&#xD;
35
- Enhancements:&#xD;
36
- - Enabled automated key exchange between Amazon and Magento for merchants&#xD;
37
- - New simplified and streamlined registration process to help merchants start making transactions sooner&#xD;
38
- - Redesigned UX to group and collapse settings&#xD;
39
- - Removed duplication of keys in the Login with Amazon settings&#xD;
40
  &#xD;
41
- Other Feature Additions:&#xD;
42
- - Now using randomized internal reference IDs (e.g. for re-authorizations)&#xD;
43
- &#xD;
44
- Pull Requests Merged:&#xD;
45
- #146 Update Shopping Cart Button Placement&#xD;
46
- #121 Override mage address validation and force Amazon address for shipping calculation&#xD;
47
- #143 Updates to Api.php&#xD;
48
- #164 Fixed call to a method on a non-object&#xD;
49
- #163 Fixed Content-Type header duplicate&#xD;
50
- #150 Added OneStepCheckout.com support&#xD;
51
- #188 Update modman paths&#xD;
52
- #192 Center the Amazon Badge just like Paypal is&#xD;
53
- #184 Fix where users were getting a Mixed Content warning on cart page&#xD;
54
- &#xD;
55
- Bug Fixes:&#xD;
56
- #139 Fix capture error when auth is greater than 7 days old&#xD;
57
- #132 Add 'None' (new) payment action&#xD;
58
- #151 Obey account sharing scope config&#xD;
59
- #152 Fix multi-site refund, cancel, async, etc.&#xD;
60
- #170 Billing address fixes&#xD;
61
- #156 Restrict/disable Amazon widgets during standalone checkout order placement&#xD;
62
- #162 Disable Place Order if no payment method set&#xD;
63
- #158 Improve async testing and declines&#xD;
64
- #157 Restrict address widget and shipping method if payment declined&#xD;
65
- #156 Disable iframe and divs for IE 10&#xD;
66
- #158 Add email template for async declines&#xD;
67
- #176 Don't redirect to secure cart if Amazon payment method is disabled&#xD;
68
- #175 Don't inject JS when payment method disabled&#xD;
69
- #158 Add wallet widget on order detail page for async declines&#xD;
70
- #180 Always display login button on Checkout page&#xD;
71
- #157 Disable shipping widget and method on declines&#xD;
72
- #158 Use 'Login with Amazon' button instead of 'Pay'&#xD;
73
- #131 Add Sync auth in front of Async auth&#xD;
74
- #157 remove exception message&#xD;
75
- #174 Add Pay with Amazon button in mini cart&#xD;
76
- #181 Close Amazon Order when order state changed to COMPLETE (e.g. when order is shipped)&#xD;
77
- #182 Add Login button to register/account creation page&#xD;
78
- #193 Change payment decline email to transactional email for cron compatibility&#xD;
79
- #161 Add jQuery.noConflict() to fix JS errors and conflicts with prototype&#xD;
80
- #197 Fix amazon account logout&#xD;
81
- #198 Fix JS error when shipping method is hidden (e.g. virtual products)&#xD;
82
- #140 Auth Decline Errors could be more user friendly&#xD;
83
- #190 Add hard decline email for async&#xD;
84
- #206 Remove Widgets.js if cart is empty or 'Display on Product Page' is set to No&#xD;
85
- </notes>
86
  <authors><author><name>Amazon Payments</name><user>payments-cp-devel</user><email>payments-cp-devel@amazon.com</email></author></authors>
87
- <date>2016-03-30</date>
88
- <time>21:18:30</time>
89
- <contents><target name="magecommunity"><dir name="Amazon"><dir name="Diagnostics"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="db8abb5277728f87d8c2c7a87b742fd1"/><file name="Textarea.php" hash="66064028ab9b3af0eaacc9610fccefea"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="e8800fc7aad8435830912270b9f8934d"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="DiagnosticsController.php" hash="5d617a0b551a91c70945f4d678ba5cb4"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="e05b867b605e5bf45d96b309deca3840"/><file name="config.xml" hash="2a8837903c46948e17d947eae1527fab"/><file name="system.xml" hash="c1a8d849fb7342cd122e0f445a8de117"/></dir></dir><dir name="Payments"><dir name="Block"><dir name="Adminhtml"><file name="Notifications.php" hash="793824c5014d1269f0aee1a795e948b9"/><dir name="System"><dir name="Config"><file name="Simplepathimport.php" hash="1f961d99dd02ea0b6ad886c7e65885cc"/></dir></dir></dir><file name="Button.php" hash="b9094d9f7fc1ba1affa6eca1c681844a"/><file name="Checkout.php" hash="532f647be6bd8ed047ae72d380461b7a"/><file name="Form.php" hash="d4de8f8cef523b792b31f2d7be157af3"/><file name="Link.php" hash="47c237fe4604333b2080588c5498a865"/><dir name="Login"><file name="Button.php" hash="4e2416622427848eb17785277f2bb300"/><file name="Script.php" hash="9e3f4503e5714958eb3417b56c7a6477"/><file name="Verify.php" hash="c0b4a13d81f2f67bb6f0448c54264aee"/></dir><dir name="Onepage"><file name="Progress.php" hash="ab5ba2e80b849d77f81f10d64e0a141c"/><file name="Widget.php" hash="fe33171163dad6751fef425a0d88adb5"/></dir><file name="Onepage.php" hash="1d865069483bbe776f511119e0e2252b"/><dir name="Review"><file name="Info.php" hash="8d3688c55137971b18aec41272cf13a6"/></dir><file name="Review.php" hash="d9cf9b6ef7d6f063a06e006e01f09513"/><dir name="Sales"><file name="View.php" hash="fe64b8167da350b68971766af740e4f5"/></dir><file name="Script.php" hash="0a5b1bb668a7feb89bf0252b00d48252"/></dir><dir name="Controller"><file name="Checkout.php" hash="52119513775ba46d484024d7059958bf"/></dir><dir name="Helper"><file name="Data.php" hash="1845612eff9ecb69234f7dfdb5e78a1f"/></dir><dir name="Model"><file name="Api.php" hash="5010e72a41d065fc73b546c9e0633c46"/><file name="Async.php" hash="2ce8391b42bd4cf46ec1388ae274e88d"/><file name="Config.php" hash="09d66f092432281ca4db266946debe53"/><file name="Customer.php" hash="974941930716e9f0626b75681f2f2aa6"/><file name="Login.php" hash="34865bdc03c1d686d31678f16cb9140b"/><dir name="Observer"><file name="Action.php" hash="496c68b07856a26615a6970ff1c6dba0"/><file name="Adminhtml.php" hash="54596e530f3cd3365b8c61313827c0b6"/><file name="Onepage.php" hash="7541e3931dcdaa334860840f2fb11b54"/><file name="Order.php" hash="6218558c5cc55834e61479175ed122bc"/></dir><dir name="Order"><file name="Creditmemo.php" hash="6732791d2839272564cf27ecda80707c"/></dir><file name="PaymentMethod.php" hash="6a0cd07cf5b90150337af861a0fdef7a"/><dir name="Resource"><file name="Login.php" hash="8651de25cb8340e03c46202d3ecb800e"/></dir><file name="SimplePath.php" hash="5799377f39b56e3684999a8f67deb504"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Enabled.php" hash="d7479a7d92fb02da7149ddc19f01e82c"/><file name="Popupcomment.php" hash="bed36a5f3b3794dec8f811592c8ce73c"/><file name="Simplepath.php" hash="789f5578e8613d30c501a89ba407fce5"/></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="602ecc788d8f5669ee0f000aebbf859a"/><file name="Region.php" hash="0718cf97d03a8c56c73fb7ea3a103bc5"/></dir></dir></dir><dir name="Type"><file name="Checkout.php" hash="204f358ef9d803f7a1b441cae558b638"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Amazon"><file name="PaymentsController.php" hash="9fafa9e25cc75eb637a9f987c199d85c"/><file name="SimplepathController.php" hash="39822de071eafeedea8876a9a5684e0a"/></dir></dir><file name="CheckoutController.php" hash="6d005be14745219d5f7d28d4c6f51a4b"/><file name="CustomerController.php" hash="c5a48e931491d27180668e06b1cf184f"/><file name="IndexController.php" hash="128f218a9e1bf4af4f7b380f14d87a52"/><file name="OnepageController.php" hash="c9d9afcb6f1e06af7689953922ff3138"/><file name="OrderController.php" hash="aa98666e5914d46e008a3dff746b1c31"/><file name="SimplepathController.php" hash="1f33a4362df4b7ff6a3504912ead329c"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3c56d63f30e0e5cc8c22d3686046631b"/><file name="config.xml" hash="fad9b03e8a6c4d222846343a8920df7a"/><file name="system.xml" hash="627f5db2754af7fb9c3c4d7caf24cbde"/></dir><dir name="sql"><dir name="payments_setup"><file name="install-0.1.0.php" hash="56cd481dd3c0b6e55c22c8cbbee67c28"/><file name="upgrade-1.3.0-1.4.0.php" hash="a246d714560a4fb187e055a82803f187"/></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><dir name="MarketplaceWebServiceSellers"><file name="Client.php" hash="9a9b59ba596e1b08d53dd3d07715fa3d"/><file name="Exception.php" hash="022774b205223fb2e09988a6881b57b0"/><file name="Interface.php" hash="8b5cef37a1c02865998510e07b3ad5f0"/><file name="KeycheckClient.php" hash="9a9b59ba596e1b08d53dd3d07715fa3d"/><dir name="Model"><file name="ListMarketplaceParticipationsRequest.php" hash="59e66ae0991177be83cefbcaa962b155"/><file name="ListMarketplaceParticipationsResponse.php" hash="16b6fed10df863cd5ad05c29f85bf920"/><file name="ListMarketplaceParticipationsResult.php" hash="daecc8554eef98039eba934ce51720e5"/><file name="ListMarketplaces.php" hash="151f584eb5e3cd24be59b2f1309fdf97"/><file name="ListParticipations.php" hash="d0179c65514949255db5a2ea2f1a4796"/><file name="Marketplace.php" hash="c234ffbd0c5f0250b9d448a0d8687d2b"/><file name="Participation.php" hash="50f95fa7c5398a1e8be70700103a754c"/><file name="ResponseHeaderMetaData.php" hash="516b66964035a6bfb40177f7d200ab9c"/><file name="ResponseMetaData.php" hash="3095644d4bd240ef6a6069f1f3f7bfde"/></dir><file name="Model.php" hash="1a27b28fc0e8a0fa60494c5847c51e7f"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="amazon_payments.xml" hash="b90e9bc0744abc0ee504dd0a882d1d22"/></dir><dir name="template"><dir name="amazon_payments"><file name="button.phtml" hash="59dc517bafe5ea4c3e35ed71d5ddf9ab"/><file name="notifications.phtml" hash="b94eb031ad1f207078fd705818641503"/><file name="textarea.phtml" hash="6045e3a122766622d18e8d7ad7239af4"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="amazon_payments.xml" hash="574978d4d851db8cf32b6a49058b0f42"/></dir><dir name="template"><dir name="amazon_payments"><file name="button.phtml" hash="8136f613215fbf17546331a5b2a8c4a5"/><file name="button_badge.phtml" hash="0631a879de25eacaa71da38c1e9ebd73"/><file name="button_shortcut.phtml" hash="08609929765e01f759d5259727d9dbe1"/><file name="cart.phtml" hash="20375f05aabc98f1384f1d7bf74750fc"/><file name="checkout.phtml" hash="abdd545c35e309fc3860f242fe3b6229"/><file name="form.phtml" hash="4cbc8e5d2d8c91fdb604c8f71b3cf51d"/><dir name="login"><file name="button.phtml" hash="6af0d50c67e8e9231ce1a58903a46cea"/><file name="logout.phtml" hash="dadc5dae9e6f650e2bff36e09ed9d4db"/><file name="script.phtml" hash="9325c457ad9f1e7b278c13a119030733"/><file name="script_authorize.phtml" hash="13b088811587395579e2f2412e50bec1"/><file name="verify.phtml" hash="10594cb55b719da4a5f75af3f52ef09e"/></dir><file name="mark.phtml" hash="f6fbeb5fbf57bd6fe177bf5cb54743ef"/><dir name="onepage"><file name="button.phtml" hash="d124d850223ca99e3e209c646da32d34"/><file name="login.phtml" hash="0bf0f852666f60f603268a5443dc2329"/><file name="login_cancel.phtml" hash="aaef9de126880e9bae5bfeaf26f517e7"/><dir name="progress"><file name="widget.phtml" hash="cc26b9857c9f95f5a239e0adb94f6c3e"/></dir><file name="widget.phtml" hash="b471d9dc25524dfb197b5d9d45823f83"/></dir><dir name="sales"><dir name="order"><file name="amazon_wallet.phtml" hash="fefafd36bd5df2e02ec020dd278fd947"/></dir></dir><file name="script.phtml" hash="409d39f1f1bb32d921ce506bc6cd40b3"/><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="7d68b8a77b862c61b6cb2dc9050d0c3b"/><file name="styles_onepage.css" hash="c59f7238c15f7e088e8587a65405a21b"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="amazonpayments"><file name="amazonpayments.js" hash="a359964bbc66633a29feba53740bc13b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Amazon_Payments.xml" hash="78ccdee9536630d55cab0a62a93945ef"/><file name="Amazon_Diagnostics.xml" hash="c56ca83a95a5a3f929fd2ad4e88bd518"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="amazon_payments_async_decline_hard.html" hash="fceca30d8dd084ccb7d4aac2f4512d05"/><file name="amazon_payments_async_decline_soft.html" hash="adfcf82d47d2c548694f74eb93993490"/></dir></dir></dir></target></contents>
90
  <compatible/>
91
  <dependencies><required><php><min>5.2.1</min><max>6.0.0</max></php></required></dependencies>
92
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>login_and_pay_for_magento</name>
4
+ <version>1.4.4</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.&lt;/p&gt;&#xD;
32
  &#xD;
33
  </description>
34
+ <notes>v1.4.4 Release&#xD;
35
+ Enhancements&#xD;
36
+ #294 Feature: Ability to add Coupon/Discount Code Field on Amazon Standalone Checkout&#xD;
37
+ #61 Enable tokenized payments&#xD;
38
+ #292 Change Widgets.js loading to async&#xD;
 
39
  &#xD;
40
+ Pull Requests Merged&#xD;
41
+ #270 Update Modman&#xD;
42
+ &#xD;
43
+ Issues Resolved&#xD;
44
+ #281 ShipStation Phone Number Issue&#xD;
45
+ #274 Problem using onestepcheckout&#xD;
46
+ #287 Customer verify redirect to empty cart&#xD;
47
+ #291 Fix check for enabled amazon login&#xD;
48
+ #295 Amazon Payments Diagnostics tool throwing exception&#xD;
49
+ #284 JQuery Conflict Render Unusable&#xD;
50
+ #261 Script Loading Issue&#xD;
51
+ #286 Logout Error&#xD;
52
+ #293 JS failing to Serialize form during SaveOrder function call&#xD;
53
+ #280 Double Redirect on Cart Page&#xD;
54
+ #271 Add secure URL from config files&#xD;
55
+ #264 Fix broken admin in Magento 1.6&#xD;
56
+ #272 Add Disable Login with Amazon functionality&#xD;
57
+ #255 Disable shipping widget during decline flow&#xD;
58
+ #263 Limit shipping to supported countries</notes>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  <authors><author><name>Amazon Payments</name><user>payments-cp-devel</user><email>payments-cp-devel@amazon.com</email></author></authors>
60
+ <date>2017-06-01</date>
61
+ <time>18:58:18</time>
62
+ <contents><target name="magecommunity"><dir name="Amazon"><dir name="Diagnostics"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="db8abb5277728f87d8c2c7a87b742fd1"/><file name="Textarea.php" hash="66064028ab9b3af0eaacc9610fccefea"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="e8800fc7aad8435830912270b9f8934d"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="DiagnosticsController.php" hash="80370967a5f8ade3581d451aad2b03f5"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="e05b867b605e5bf45d96b309deca3840"/><file name="config.xml" hash="2487745648032465bcfbfdadd3883deb"/><file name="system.xml" hash="c1a8d849fb7342cd122e0f445a8de117"/></dir></dir><dir name="Payments"><dir name="Block"><dir name="Adminhtml"><file name="Notifications.php" hash="793824c5014d1269f0aee1a795e948b9"/><dir name="System"><dir name="Config"><file name="Simplepathimport.php" hash="1f961d99dd02ea0b6ad886c7e65885cc"/></dir></dir></dir><file name="Button.php" hash="fb84ada728c67072cee0ba19a831e243"/><file name="Checkout.php" hash="04c58830da28d3d56b275a3a197d3b42"/><file name="Form.php" hash="d4de8f8cef523b792b31f2d7be157af3"/><file name="Link.php" hash="47c237fe4604333b2080588c5498a865"/><dir name="Login"><file name="Button.php" hash="b4704968c680bb662e084d10f919e0e4"/><file name="Script.php" hash="0f3dc04addf02c9a575d20a717b02d9a"/><file name="Verify.php" hash="c0b4a13d81f2f67bb6f0448c54264aee"/></dir><dir name="Onepage"><file name="Progress.php" hash="ab5ba2e80b849d77f81f10d64e0a141c"/><file name="Widget.php" hash="24bc3f92cc56b92ffde511aeec216a4e"/></dir><file name="Onepage.php" hash="f5ca3d8a3e796efb14cbc5d612753820"/><dir name="Review"><file name="Info.php" hash="8d3688c55137971b18aec41272cf13a6"/></dir><file name="Review.php" hash="d9cf9b6ef7d6f063a06e006e01f09513"/><dir name="Sales"><file name="View.php" hash="fe64b8167da350b68971766af740e4f5"/></dir><file name="Script.php" hash="5dae1c11ae5f51d84d394c02b4d0d05a"/></dir><dir name="Controller"><file name="Checkout.php" hash="4da26f0b1fb4521ef10f850718ca930e"/></dir><dir name="Helper"><file name="Data.php" hash="7bf1d9c7559f8a40593eaa82aa4cf137"/></dir><dir name="Model"><file name="Api.php" hash="d7940e1028455d1bbd2894d50a929219"/><file name="Async.php" hash="a8f9c504b15f5480d01e7b0284593ed1"/><file name="Config.php" hash="3c46d32b98b3705606c84adecf745d94"/><file name="Customer.php" hash="ef1104f523b3287926a6cda5712cb7ca"/><file name="Login.php" hash="90b9f46492b8970b45a625837fa10efa"/><dir name="Observer"><file name="Action.php" hash="52da80b3cca7ba7f876f32526cbded9c"/><file name="Adminhtml.php" hash="54596e530f3cd3365b8c61313827c0b6"/><file name="Onepage.php" hash="7541e3931dcdaa334860840f2fb11b54"/><file name="Order.php" hash="6218558c5cc55834e61479175ed122bc"/></dir><dir name="Order"><file name="Creditmemo.php" hash="6732791d2839272564cf27ecda80707c"/></dir><file name="PaymentMethod.php" hash="eec2b7c2ab129b7ded920dfe5a3e3488"/><dir name="Resource"><file name="Login.php" hash="8651de25cb8340e03c46202d3ecb800e"/><file name="Token.php" hash="ebdcde3f3ee9030795516bbf9d3f5aa4"/></dir><file name="SimplePath.php" hash="8e0e3a4ac4cc0379d35808d82ca6d509"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Enabled.php" hash="0b12269448f8a8c296e56d1cf60ca934"/><file name="Language.php" hash="fee7498f6e060acff2515406ba8004ac"/><file name="Localizecomment.php" hash="d3bcc242947057bc8862fe329e5a36e4"/><file name="Popupcomment.php" hash="00c0c75151b6ec533f6c058dd0dffb56"/><file name="Simplepath.php" hash="789f5578e8613d30c501a89ba407fce5"/></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="602ecc788d8f5669ee0f000aebbf859a"/><file name="Region.php" hash="365a28a0eefe1547c0d2b2b48246bf85"/></dir></dir></dir><file name="Token.php" hash="82d5db332b5de776842fceb26fa131d8"/><dir name="Type"><file name="Checkout.php" hash="15672a1ba52230f29f5a6d7dbe614efb"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Amazon"><file name="PaymentsController.php" hash="9fafa9e25cc75eb637a9f987c199d85c"/><file name="SimplepathController.php" hash="39822de071eafeedea8876a9a5684e0a"/></dir></dir><file name="CheckoutController.php" hash="220b8254369f0d9286b259048dba8d1b"/><file name="CustomerController.php" hash="6bbf673d97a58d387956cb4a4192b933"/><file name="IndexController.php" hash="6bd62f0989b414d679c6521273f55274"/><file name="OnepageController.php" hash="5dfb091b512c8d0fd2b57d2c8f26387c"/><file name="OrderController.php" hash="620a83e12d5d60f1572bfcc5c229b95b"/><file name="SimplepathController.php" hash="1f33a4362df4b7ff6a3504912ead329c"/><file name="TokenController.php" hash="7a2d777f1985c43d0fbdad07780fbdad"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3c56d63f30e0e5cc8c22d3686046631b"/><file name="config.xml" hash="956bbc2d46e047cd705a6cfcb941b79d"/><file name="system.xml" hash="d1e439ff8a29cc57333a8cd5fad05ca9"/><file name="system.xml-1.6" hash="d37b23fee01ced0653ff8b1fe2a2619b"/></dir><dir name="sql"><dir name="payments_setup"><file name="install-0.1.0.php" hash="56cd481dd3c0b6e55c22c8cbbee67c28"/><file name="upgrade-1.3.0-1.4.0.php" hash="354827788cc807d30fb342e542ddc146"/><file name="upgrade-1.4.2-1.4.3.php" hash="40890dd76d904cca6410b468aacdc7a7"/></dir></dir></dir></dir></target><target name="magelib"><dir name="OffAmazonPayments"><dir name="HttpRequest"><file name="HttpException.php" hash="251617a5cf07abe208218bee0537ba9d"/><file name="IHttpRequest.php" hash="7967182a4a954f87284fb7d55d86fdcf"/><file name="IHttpRequestFactory.php" hash="6b601eb08fe0ceb607dc861f16bd234b"/><dir name="Impl"><file name="HttpRequestCurlImpl.php" hash="ffeeb2eb8bf96979f7f8708476b1f6c0"/><file name="HttpRequestFactoryCurlImpl.php" hash="0c63cdec7e9afa9718a20fcaae19b001"/></dir></dir><file name="Model.php" hash="a608217f17166ba11901f5334ad445de"/><file name="OffAmazonPaymentsServiceUtils.php" hash="a42d8fabef96c6d16a81f01172ecdb91"/><file name=".autoloader.php" hash="193fddab8b5ca74646bb78243c0c7dda"/></dir><dir name="OffAmazonPaymentsNotifications"><file name="Client.php" hash="0ab53a8a0a0c069f13e1de3731eaebde"/><dir name="Impl"><file name="Certificate.php" hash="ee7d6dd611bdeaab422da1316936fe99"/><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="InvalidCertificateException.php" hash="41bd42da2146c9c6263ddabefd9bfa62"/><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="7cd87758b7526e35aaab1eca03ee7185"/><file name="AddressConsentSampleResult.php" hash="e0e43edc5605fc0a7133eb84ecc6d4f6"/><file name="AuthorizationNotificationSample.php" hash="6adb3c72895d7637feb34cf2e286d194"/><dir name="AutomaticPayments"><file name="address.php" hash="c5ac8c560c7ebcd0a836f9676e9633e2"/><file name="signin.php" hash="754dbae359198b25ef2c3df3c68a6f9c"/><file name="wallet.php" hash="f10a96da2e0751b8ecc79918ce1f05d6"/></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"/><dir name="OrderReferencePayments"><file name="address.php" hash="ccc1456cb0c6fa733d68961538ab39f0"/><file name="signin.php" hash="8e0c3133149dc4c0bb56f7ed50b70eae"/><file name="wallet.php" hash="9e1d18fc812ee441212a37e36844a9aa"/></dir><file name="OrderReferenceSample.php" hash="846e2a653f7b7da3d35ac5bdc2fd155d"/><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="747309be6c12e96af374c7a05f5d0432"/><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="63cfdb253838357a930cb769789af9fd"/><file name=".config.inc.php" hash="e53a346fea00eb06e67af3f1a2fed615"/></dir></dir><dir name="OffAmazonPaymentsService"><file name="Client.php" hash="066f7ee8b0fc84bbb286eba8215559a2"/><file name="Environments.php" hash="d84e7322b3394033b427f91be0a0abdb"/><file name="Exception.php" hash="dd85e54cfa5783c7ef7b1f93ca3995b2"/><file name="Interface.php" hash="ca1693109051f319740e4cd7e8ed4de7"/><file name="MerchantValues.php" hash="adb10859cd24d7ab62fecb3c0b67b90d"/><file name="MerchantValuesBuilder.php" hash="a19bf1f84beb98d69c744fc352b93904"/><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 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><dir name="MarketplaceWebServiceSellers"><file name="Client.php" hash="ddf4dfc12d04a9e1b114ac453a24113c"/><file name="Exception.php" hash="022774b205223fb2e09988a6881b57b0"/><file name="Interface.php" hash="8b5cef37a1c02865998510e07b3ad5f0"/><file name="KeycheckClient.php" hash="ddf4dfc12d04a9e1b114ac453a24113c"/><dir name="Model"><file name="ListMarketplaceParticipationsRequest.php" hash="59e66ae0991177be83cefbcaa962b155"/><file name="ListMarketplaceParticipationsResponse.php" hash="16b6fed10df863cd5ad05c29f85bf920"/><file name="ListMarketplaceParticipationsResult.php" hash="daecc8554eef98039eba934ce51720e5"/><file name="ListMarketplaces.php" hash="151f584eb5e3cd24be59b2f1309fdf97"/><file name="ListParticipations.php" hash="d0179c65514949255db5a2ea2f1a4796"/><file name="Marketplace.php" hash="c234ffbd0c5f0250b9d448a0d8687d2b"/><file name="Participation.php" hash="50f95fa7c5398a1e8be70700103a754c"/><file name="ResponseHeaderMetaData.php" hash="c6ebdd409fecab0a1e67e5f7f988fb25"/><file name="ResponseMetaData.php" hash="3095644d4bd240ef6a6069f1f3f7bfde"/></dir><file name="Model.php" hash="1a27b28fc0e8a0fa60494c5847c51e7f"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="amazon_payments.xml" hash="b90e9bc0744abc0ee504dd0a882d1d22"/></dir><dir name="template"><dir name="amazon_payments"><file name="button.phtml" hash="59dc517bafe5ea4c3e35ed71d5ddf9ab"/><file name="notifications.phtml" hash="e3a547835937af01fed5c56da7de0904"/><file name="textarea.phtml" hash="6045e3a122766622d18e8d7ad7239af4"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="amazon_payments.xml" hash="bc0fc43981490d3713750cad34ff06b8"/></dir><dir name="template"><dir name="amazon_payments"><file name="button.phtml" hash="2c5f3826624d5a8c799ccb2cb4acb558"/><file name="button_badge.phtml" hash="0631a879de25eacaa71da38c1e9ebd73"/><file name="button_shortcut.phtml" hash="96fc2ddd79b90121c94f6f379ddb62ff"/><file name="button_shortcut_ajaxcart.phtml" hash="a31d0bfb97c293583107a5a84014ed91"/><file name="cart.phtml" hash="20375f05aabc98f1384f1d7bf74750fc"/><file name="checkout.phtml" hash="99dfb2dc22d05e2ada952b49697cb94f"/><file name="coupon.phtml" hash="988bf4155562a39877ad6b624874cde2"/><file name="form.phtml" hash="4cbc8e5d2d8c91fdb604c8f71b3cf51d"/><dir name="login"><file name="button.phtml" hash="fe2eabf2c5998f1d001f301ea6ee0342"/><file name="logout.phtml" hash="dadc5dae9e6f650e2bff36e09ed9d4db"/><file name="script_authorize.phtml" hash="13b088811587395579e2f2412e50bec1"/><file name="script_logout.phtml" hash="e7c2b652a98f9e10fec143a34b7f43a2"/><file name="verify.phtml" hash="10594cb55b719da4a5f75af3f52ef09e"/></dir><file name="mark.phtml" hash="f6fbeb5fbf57bd6fe177bf5cb54743ef"/><dir name="onepage"><file name="button.phtml" hash="848a977a6c419da611835f850be61599"/><file name="login.phtml" hash="0bf0f852666f60f603268a5443dc2329"/><file name="login_cancel.phtml" hash="aaef9de126880e9bae5bfeaf26f517e7"/><dir name="progress"><file name="widget.phtml" hash="cc26b9857c9f95f5a239e0adb94f6c3e"/></dir><file name="widget.phtml" hash="17e06cdf6bb3b21bf641ca306c30637e"/></dir><dir name="sales"><dir name="order"><file name="amazon_wallet.phtml" hash="fefafd36bd5df2e02ec020dd278fd947"/></dir></dir><file name="script.phtml" hash="2ed703e1961736d5dd445933c27dee3c"/><file name="script_async.phtml" hash="99155ee0217ae7c4745952afddbef0c2"/><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="7c8b08079cc619d0f541b03d6d4846f4"/><file name="styles_checkout.css" hash="b3340f41f37e5e7876b025006af707af"/><file name="styles_onepage.css" hash="5b969e18347dd303bef0a01950add65c"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="amazonpayments"><file name="amazonpayments.js" hash="a359964bbc66633a29feba53740bc13b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Amazon_Payments.xml" hash="78ccdee9536630d55cab0a62a93945ef"/><file name="Amazon_Diagnostics.xml" hash="c56ca83a95a5a3f929fd2ad4e88bd518"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="amazon_payments_async_decline_hard.html" hash="fceca30d8dd084ccb7d4aac2f4512d05"/><file name="amazon_payments_async_decline_soft.html" hash="e783a72efc577a6abe2a6f456d87d4b9"/><file name="amazon_payments_async_decline_soft.html" hash="e783a72efc577a6abe2a6f456d87d4b9"/></dir></dir><file name="Amazon_Diagnostics.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="Amazon_Login.csv" hash="0cf0112b827fe88e5b6e29ef280810cb"/><file name="Amazon_Payments.csv" hash="c3e1b16aad6f4315734ad46b9f0235c8"/></dir><dir name="de_DE"><file name="Amazon_Diagnostics.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="Amazon_Login.csv" hash="094fd9cc5d735d31f3ff279c714fd659"/><file name="Amazon_Payments.csv" hash="e8caac41d310454c3c2d7bb0ceda43c6"/><dir name="template"><dir name="email"><file name="amazon_payments_async_decline_hard.html" hash="27e7c0ed584b6400bf6112e4e0842f2a"/><file name="amazon_payments_async_decline_soft.html" hash="7892e025621be685b83a16a605b42edf"/></dir></dir></dir><dir name="en_GB"><file name="Amazon_Diagnostics.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="Amazon_Login.csv" hash="0cf0112b827fe88e5b6e29ef280810cb"/><file name="Amazon_Payments.csv" hash="c3e1b16aad6f4315734ad46b9f0235c8"/><dir name="template"><dir name="email"><file name="amazon_payments_async_decline_soft.html" hash="e8f79ab606e1f646fcae645321fc6bce"/></dir></dir></dir><dir name="es_ES"><file name="Amazon_Diagnostics.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="Amazon_Login.csv" hash="4e266d945f265d5ec7c44a10f94e2c4b"/><file name="Amazon_Payments.csv" hash="77aedf703e1c2f0018b77fb2cf7af78c"/><dir name="template"><dir name="email"><file name="amazon_payments_async_decline_hard.html" hash="869f9e1b7e076321973a42361efc6c2c"/><file name="amazon_payments_async_decline_soft.html" hash="bf7cec8fde03957f6b986352a23ae4ec"/></dir></dir></dir><dir name="fr_FR"><file name="Amazon_Diagnostics.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="Amazon_Login.csv" hash="af246ef3b8f0161e4bbda0aa2503539f"/><file name="Amazon_Payments.csv" hash="983849ac038579bc3ab6f7fc0bf4b3cc"/><dir name="template"><dir name="email"><file name="amazon_payments_async_decline_hard.html" hash="0c5b2e12b1c49b2fe94f170d96cf4a1f"/><file name="amazon_payments_async_decline_soft.html" hash="adfcf82d47d2c548694f74eb93993490"/></dir></dir></dir><dir name="it_IT"><file name="Amazon_Diagnostics.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="Amazon_Login.csv" hash="d715a89243d474836eadc687d7895cc8"/><file name="Amazon_Payments.csv" hash="5037c124c00a6c0517f95ccb59a2efbc"/><dir name="template"><dir name="email"><file name="amazon_payments_async_decline_hard.html" hash="4098fd54e2b4a5c431c78dd7f90f81f3"/><file name="amazon_payments_async_decline_soft.html" hash="adfcf82d47d2c548694f74eb93993490"/></dir></dir></dir></target></contents>
63
  <compatible/>
64
  <dependencies><required><php><min>5.2.1</min><max>6.0.0</max></php></required></dependencies>
65
  </package>
skin/frontend/base/default/amazon_payments/css/popup_alphacube.css CHANGED
@@ -5,3 +5,9 @@
5
  #amazon_modal .alphacube_w, #amazon_modal .alphacube_e { width:1px; }
6
  /*#amazon_modal_row2 { position:relative; margin-top:-20px; }*/
7
  /*#amazon_modal_close { display:none; right:-6px; }*/
 
 
 
 
 
 
5
  #amazon_modal .alphacube_w, #amazon_modal .alphacube_e { width:1px; }
6
  /*#amazon_modal_row2 { position:relative; margin-top:-20px; }*/
7
  /*#amazon_modal_close { display:none; right:-6px; }*/
8
+
9
+ body.amazon-payments-token-ajaxcart .actions,
10
+ body.amazon-payments-token-ajaxcart .btn-remove,
11
+ body.amazon-payments-token-ajaxcart p.block-subtitle {
12
+ display:none;
13
+ }
skin/frontend/base/default/amazon_payments/css/styles_checkout.css CHANGED
@@ -41,6 +41,11 @@
41
  height: 250px;
42
  }
43
 
 
 
 
 
 
44
  .amazon-widget-wrapper {
45
  position:relative;
46
  }
41
  height: 250px;
42
  }
43
 
44
+ #amazon-widget-consent {
45
+ margin-top:2em;
46
+ max-width:100%;
47
+ height: 140px;
48
+
49
  .amazon-widget-wrapper {
50
  position:relative;
51
  }
skin/frontend/base/default/amazon_payments/css/styles_onepage.css CHANGED
@@ -36,6 +36,16 @@
36
  clear:both;
37
  }
38
 
 
 
 
 
 
 
 
 
 
 
39
  @media all and (max-width: 640px) {
40
  #amazon-widget-address-wrapper,
41
  #amazon-widget-wallet-wrapper {
36
  clear:both;
37
  }
38
 
39
+ #amazon-widget-consent {
40
+ clear:both;
41
+ height:100px;
42
+ width:98%;
43
+ }
44
+
45
+ #checkout-amazon-columns .f-left {
46
+ display:none;
47
+ }
48
+
49
  @media all and (max-width: 640px) {
50
  #amazon-widget-address-wrapper,
51
  #amazon-widget-wallet-wrapper {