Hps_Securesubmit - Version 1.2.0

Version Notes

Fix: card saving
Update: cleanup credit card payment class
Update: certification/test URL to support PCI 3.1
Feature: multishipping
Feature: Added advanced fraud logic and options for credit card payments
Feature: Heartland gift
Feature: PayPal support
Feature: MasterPass support

Download this release

Release Info

Developer Heartland Payment Systems
Extension Hps_Securesubmit
Version 1.2.0
Comparing to
See all releases


Code changes from version 1.0.7 to 1.2.0

Files changed (221) hide show
  1. app/code/community/Hps/Securesubmit/.DS_Store +0 -0
  2. app/code/community/Hps/Securesubmit/Block/Adminhtml/Paypal/Settlement/Report.php +6 -38
  3. app/code/community/Hps/Securesubmit/Block/Adminhtml/Paypal/Settlement/Report/Form.php +31 -0
  4. app/code/community/Hps/Securesubmit/Block/Adminhtml/Paypal/Settlement/Report/Form/Form.php +56 -0
  5. app/code/community/Hps/Securesubmit/Block/Adminhtml/Paypal/Settlement/Report/Grid.php +19 -18
  6. app/code/community/Hps/Securesubmit/Block/Form.php +7 -0
  7. app/code/community/Hps/Securesubmit/Block/Info.php +14 -2
  8. app/code/community/Hps/Securesubmit/Block/Masterpass/Client/Js.php +14 -0
  9. app/code/community/Hps/Securesubmit/Block/Masterpass/Connect.php +16 -0
  10. app/code/community/Hps/Securesubmit/Block/Masterpass/Form.php +81 -0
  11. app/code/community/Hps/Securesubmit/Block/Masterpass/Info.php +22 -0
  12. app/code/community/Hps/Securesubmit/Block/Masterpass/Review.php +218 -0
  13. app/code/community/Hps/Securesubmit/Block/Masterpass/Review/Billing.php +34 -0
  14. app/code/community/Hps/Securesubmit/Block/Masterpass/Review/Details.php +35 -0
  15. app/code/community/Hps/Securesubmit/Block/Masterpass/Review/Shipping.php +28 -0
  16. app/code/community/Hps/Securesubmit/Block/Paypal/Credit/Form.php +2 -2
  17. app/code/community/Hps/Securesubmit/Block/Paypal/Form.php +3 -12
  18. app/code/community/Hps/Securesubmit/Block/Paypal/Incontext/Js.php +28 -0
  19. app/code/community/Hps/Securesubmit/Block/Paypal/Info.php +1 -0
  20. app/code/community/Hps/Securesubmit/Block/Paypal/Shortcut.php +3 -34
  21. app/code/community/Hps/Securesubmit/Controller/Paypal/Abstract.php +0 -516
  22. app/code/community/Hps/Securesubmit/Helper/Altpayment/Abstract.php +416 -0
  23. app/code/community/Hps/Securesubmit/Helper/Data.php +21 -4
  24. app/code/community/Hps/Securesubmit/Helper/Masterpass.php +78 -0
  25. app/code/community/Hps/Securesubmit/Helper/Paypal.php +164 -0
  26. app/code/community/Hps/Securesubmit/Model/{Paypal → Altpayment}/Cart.php +2 -51
  27. app/code/community/Hps/Securesubmit/Model/Api/Abstract.php +0 -581
  28. app/code/community/Hps/Securesubmit/Model/Api/Paypal.php +0 -300
  29. app/code/community/Hps/Securesubmit/Model/Config.php +0 -1571
  30. app/code/community/Hps/Securesubmit/Model/Masterpass.php +347 -0
  31. app/code/community/Hps/Securesubmit/Model/Payment.php +388 -154
  32. app/code/community/Hps/Securesubmit/Model/Paypal.php +14 -7
  33. app/code/community/Hps/Securesubmit/Model/Paypal/Checkout.php +0 -1036
  34. app/code/community/Hps/Securesubmit/Model/Paypal/Credit.php +7 -1
  35. app/code/community/Hps/Securesubmit/Model/Resource/Setup.php +7 -1
  36. app/code/community/Hps/Securesubmit/Model/Resource/Storedcard.php +7 -1
  37. app/code/community/Hps/Securesubmit/Model/Resource/Storedcard/Collection.php +7 -1
  38. app/code/community/Hps/Securesubmit/Model/Source/Cctype.php +7 -0
  39. app/code/community/Hps/Securesubmit/Model/Source/PaymentAction.php +8 -1
  40. app/code/community/Hps/Securesubmit/Model/Storedcard.php +7 -0
  41. app/code/community/Hps/Securesubmit/Model/System/Config/Backend/Proxy.php +7 -0
  42. app/code/community/Hps/Securesubmit/controllers/Adminhtml/Hps/._.DS_Store +0 -0
  43. app/code/community/Hps/Securesubmit/controllers/Adminhtml/Hps/Paypal/ReportsController.php +96 -7
  44. app/code/community/Hps/Securesubmit/controllers/Adminhtml/StoredcardController.php +38 -0
  45. app/code/community/Hps/Securesubmit/controllers/GiftcardController.php +48 -0
  46. app/code/community/Hps/Securesubmit/controllers/MasterpassController.php +341 -0
  47. app/code/community/Hps/Securesubmit/controllers/PaypalController.php +386 -17
  48. app/code/community/Hps/Securesubmit/controllers/StoredcardController.php +52 -2
  49. app/code/community/Hps/Securesubmit/etc/config.xml +72 -3
  50. app/code/community/Hps/Securesubmit/etc/system.xml +396 -8
  51. app/code/community/Hps/Securesubmit/sql/hps_securesubmit_setup/install-1.0.0.php +7 -0
  52. app/code/community/Hps/Securesubmit/sql/hps_securesubmit_setup/mysql4-upgrade-1.0.1-1.1.0.php +1 -1
  53. app/code/community/Hps/Securesubmit/sql/hps_securesubmit_setup/mysql4-upgrade-1.1.0-1.2.0.php +37 -0
  54. app/design/adminhtml/default/default/template/securesubmit/form.phtml +78 -13
  55. app/design/frontend/base/default/layout/securesubmit.xml +143 -0
  56. app/design/frontend/base/default/template/securesubmit/form.phtml +54 -148
  57. app/design/frontend/base/default/template/securesubmit/masterpass/connect.phtml +23 -0
  58. app/design/frontend/base/default/template/securesubmit/masterpass/form.phtml +24 -0
  59. app/design/frontend/base/default/template/securesubmit/masterpass/js.phtml +5 -0
  60. app/design/frontend/base/default/template/securesubmit/masterpass/mark.phtml +4 -0
  61. app/design/frontend/base/default/template/securesubmit/masterpass/review.phtml +177 -0
  62. app/design/frontend/base/default/template/securesubmit/masterpass/review/details.phtml +64 -0
  63. app/design/frontend/base/default/template/securesubmit/masterpass/review/shipping/method.phtml +53 -0
  64. app/design/frontend/base/default/template/securesubmit/paypal/incontext/js.phtml +6 -0
  65. app/design/frontend/base/default/template/securesubmit/paypal/incontext/payment.phtml +52 -0
  66. app/design/frontend/base/default/template/securesubmit/storedcards.phtml +1 -1
  67. js/securesubmit/admin-checkout.js +53 -15
  68. js/securesubmit/checkout-form.js +85 -85
  69. js/securesubmit/masterpass/lightbox.js +119 -0
  70. js/securesubmit/paypal/incontext.js +104 -0
  71. js/securesubmit/secure.submit-1.0.1.js +2 -2
  72. lib/SecureSubmit/.DS_Store +0 -0
  73. lib/SecureSubmit/Hps.php +197 -37
  74. lib/SecureSubmit/README.md +1 -1
  75. lib/SecureSubmit/entities/HpsAccountVerify.php +0 -7
  76. lib/SecureSubmit/entities/HpsAddress.php +0 -9
  77. lib/SecureSubmit/entities/HpsAuthorization.php +0 -18
  78. lib/SecureSubmit/entities/HpsBatch.php +0 -8
  79. lib/SecureSubmit/entities/HpsCardHolder.php +0 -9
  80. lib/SecureSubmit/entities/HpsCharge.php +0 -7
  81. lib/SecureSubmit/entities/HpsChargeExceptions.php +0 -6
  82. lib/SecureSubmit/entities/HpsCreditCard.php +0 -27
  83. lib/SecureSubmit/entities/HpsItemChoiceTypePosResponseVer10Transaction.php +0 -63
  84. lib/SecureSubmit/entities/HpsRefund.php +0 -7
  85. lib/SecureSubmit/entities/HpsReportTransactionDetails.php +0 -14
  86. lib/SecureSubmit/entities/HpsReportTransactionSummary.php +0 -10
  87. lib/SecureSubmit/entities/HpsReversal.php +0 -13
  88. lib/SecureSubmit/entities/HpsTokenData.php +0 -11
  89. lib/SecureSubmit/entities/HpsTransaction.php +0 -111
  90. lib/SecureSubmit/entities/HpsTransactionDetails.php +0 -8
  91. lib/SecureSubmit/entities/HpsTransactionHeader.php +0 -9
  92. lib/SecureSubmit/entities/HpsTransactionType.php +0 -15
  93. lib/SecureSubmit/entities/HpsVoid.php +0 -7
  94. lib/SecureSubmit/infrastructure/AVSResponseCodeHandler.php +0 -49
  95. lib/SecureSubmit/infrastructure/ApiConnectionException.php +0 -4
  96. lib/SecureSubmit/infrastructure/AuthenticationException.php +0 -9
  97. lib/SecureSubmit/infrastructure/CardException.php +0 -13
  98. lib/SecureSubmit/infrastructure/Exceptions.json +0 -469
  99. lib/SecureSubmit/infrastructure/HpsConfiguration.php +0 -17
  100. lib/SecureSubmit/infrastructure/HpsException.php +0 -21
  101. lib/SecureSubmit/infrastructure/HpsExceptionMapper.php +0 -109
  102. lib/SecureSubmit/infrastructure/HpsSdkCodes.php +0 -14
  103. lib/SecureSubmit/infrastructure/InvalidRequestException.php +0 -10
  104. lib/SecureSubmit/services/HpsBatchService.php +0 -26
  105. lib/SecureSubmit/services/HpsChargeService.php +0 -602
  106. lib/SecureSubmit/services/HpsService.php +0 -129
  107. lib/SecureSubmit/services/HpsTokenService.php +0 -59
  108. {app/code/community/Hps/Securesubmit/controllers/Adminhtml/Hps → lib/SecureSubmit/src}/.DS_Store +0 -0
  109. lib/SecureSubmit/src/Abstractions/HpsAltPaymentServiceInterface.php +158 -0
  110. lib/SecureSubmit/src/Abstractions/HpsConfigInterface.php +11 -0
  111. lib/SecureSubmit/src/Abstractions/HpsGatewayServiceAbstract.php +4 -6
  112. lib/SecureSubmit/src/Abstractions/HpsGatewayServiceInterface.php +7 -0
  113. {app/design/frontend/base/default/template/securesubmit → lib/SecureSubmit/src/Entities}/.DS_Store +0 -0
  114. lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentAddToBatch.php +0 -14
  115. lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentAuth.php +1 -1
  116. lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentCapture.php +19 -0
  117. lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentCreateSession.php +1 -10
  118. lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentResponse.php +32 -0
  119. lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentReturn.php +1 -1
  120. lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentSale.php +1 -1
  121. lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentSessionInfo.php +1 -10
  122. lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentVoid.php +1 -1
  123. lib/SecureSubmit/src/Entities/AltPayment/HpsBuyerData.php +9 -0
  124. lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIAddOrderNumberResponse.php +9 -0
  125. lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIAuthenticateResponse.php +104 -0
  126. lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIAuthorizeResponse.php +74 -0
  127. lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIAuthresponseResponse.php +9 -0
  128. lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPICaptureResponse.php +9 -0
  129. lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPILookupResponse.php +19 -0
  130. lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIPreapprovalResponse.php +17 -0
  131. lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIRefundResponse.php +9 -0
  132. lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIResponse.php +42 -0
  133. lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIVoidResponse.php +9 -0
  134. lib/SecureSubmit/src/Entities/AltPayment/HpsOrderData.php +38 -0
  135. lib/SecureSubmit/src/Entities/AltPayment/HpsPaymentData.php +20 -0
  136. lib/SecureSubmit/src/Entities/AltPayment/HpsShippingInfo.php +15 -0
  137. lib/SecureSubmit/src/Entities/Credit/HpsCPCData.php +21 -3
  138. lib/SecureSubmit/src/Entities/Credit/HpsCreditCard.php +5 -4
  139. lib/SecureSubmit/src/Entities/Credit/HpsOfflineAuthorization.php +12 -0
  140. lib/SecureSubmit/src/Entities/Credit/HpsReportTransactionDetails.php +2 -0
  141. lib/SecureSubmit/src/Entities/Credit/HpsReportTransactionSummary.php +1 -1
  142. lib/SecureSubmit/src/Entities/Gift/HpsGiftCard.php +4 -3
  143. lib/SecureSubmit/src/Entities/Gift/HpsGiftCardActivate.php +1 -1
  144. lib/SecureSubmit/src/Entities/HpsDirectMarketData.php +8 -0
  145. lib/SecureSubmit/src/Entities/{Gift/HpsEncryptionData.php → HpsEncryptionData.php} +11 -10
  146. lib/SecureSubmit/src/Entities/HpsTrackData.php +13 -0
  147. lib/SecureSubmit/src/Entities/HpsTransactionStatus.php +31 -0
  148. lib/SecureSubmit/src/Entities/PayPlan/HpsPayPlanAmount.php +15 -0
  149. lib/SecureSubmit/src/Entities/PayPlan/HpsPayPlanPaymentMethod.php +6 -0
  150. lib/SecureSubmit/src/Entities/PayPlan/HpsPayPlanSchedule.php +5 -0
  151. lib/SecureSubmit/src/Entities/index.php +1 -1
  152. lib/SecureSubmit/src/Infrastructure/Enums/HpsCentinelCheckoutType.php +9 -0
  153. lib/SecureSubmit/src/Infrastructure/Enums/HpsExceptionCodes.php +6 -1
  154. lib/SecureSubmit/src/Infrastructure/Enums/HpsTrackDataMethod.php +7 -0
  155. lib/SecureSubmit/src/Infrastructure/HpsConfiguration.php +1 -1
  156. lib/SecureSubmit/src/Infrastructure/HpsProcessorError.php +8 -0
  157. lib/SecureSubmit/src/Infrastructure/Validation/HpsGatewayResponseValidation.php +0 -1
  158. lib/SecureSubmit/src/Infrastructure/Validation/HpsIssuerResponseValidation.php +47 -8
  159. lib/SecureSubmit/src/Infrastructure/Validation/HpsProcessorResponseValidation.php +1 -1
  160. lib/SecureSubmit/src/Infrastructure/index.php +1 -1
  161. lib/SecureSubmit/src/Services/Fluent/Gateway/Check/HpsCheckServiceOverrideBuilder.php +2 -2
  162. lib/SecureSubmit/src/Services/Fluent/Gateway/Check/HpsCheckServiceRecurringBuilder.php +107 -0
  163. lib/SecureSubmit/src/Services/Fluent/Gateway/Check/HpsCheckServiceReturnBuilder.php +2 -2
  164. lib/SecureSubmit/src/Services/Fluent/Gateway/Check/HpsCheckServiceSaleBuilder.php +16 -3
  165. lib/SecureSubmit/src/Services/Fluent/Gateway/Check/HpsCheckServiceVoidBuilder.php +14 -5
  166. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceAuthorizeBuilder.php +136 -25
  167. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceCaptureBuilder.php +24 -8
  168. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceChargeBuilder.php +130 -31
  169. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceCpcEditBuilder.php +8 -5
  170. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceEditBuilder.php +20 -7
  171. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceGetBuilder.php +11 -2
  172. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceListTransactionsBuilder.php +16 -6
  173. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceOfflineAuthBuilder.php +209 -0
  174. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceOfflineChargeBuilder.php +165 -0
  175. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServicePrepaidAddValueBuilder.php +112 -0
  176. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServicePrepaidBalanceInquiryBuilder.php +105 -0
  177. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceRecurringBuilder.php +162 -0
  178. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceRefundBuilder.php +56 -15
  179. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceReverseBuilder.php +50 -13
  180. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceVerifyBuilder.php +57 -8
  181. lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceVoidBuilder.php +7 -2
  182. lib/SecureSubmit/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceAliasBuilder.php +20 -6
  183. lib/SecureSubmit/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceSaleBuilder.php +27 -8
  184. lib/SecureSubmit/src/Services/Fluent/Gateway/HpsFluentCheckService.php +82 -12
  185. lib/SecureSubmit/src/Services/Fluent/Gateway/HpsFluentCreditService.php +179 -2
  186. lib/SecureSubmit/src/Services/Fluent/Gateway/HpsFluentGiftCardService.php +53 -5
  187. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanCustomerServiceAddBuilder.php +0 -76
  188. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanCustomerServiceDeleteBuilder.php +0 -76
  189. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanCustomerServiceEditBuilder.php +0 -122
  190. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanCustomerServiceGetBuilder.php +0 -76
  191. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanCustomerServiceSearchBuilder.php +0 -83
  192. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanPaymentMethodServiceAddBuilder.php +0 -75
  193. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanPaymentMethodServiceDeleteBuilder.php +0 -76
  194. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanPaymentMethodServiceEditBuilder.php +0 -122
  195. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanPaymentMethodServiceGetBuilder.php +0 -76
  196. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanPaymentMethodServiceSearchBuilder.php +0 -83
  197. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanScheduleServiceAddBuilder.php +0 -75
  198. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanScheduleServiceDeleteBuilder.php +0 -76
  199. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanScheduleServiceEditBuilder.php +0 -122
  200. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanScheduleServiceGetBuilder.php +0 -76
  201. lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanScheduleServiceSearchBuilder.php +0 -83
  202. lib/SecureSubmit/src/Services/Gateway/AltPayment/HpsAltPaymentService.php +27 -5
  203. lib/SecureSubmit/src/Services/Gateway/AltPayment/HpsMasterPassService.php +601 -0
  204. lib/SecureSubmit/src/Services/Gateway/HpsBatchService.php +1 -1
  205. lib/SecureSubmit/src/Services/Gateway/HpsCentinelGatewayService.php +52 -0
  206. lib/SecureSubmit/src/Services/Gateway/HpsCheckService.php +6 -2
  207. lib/SecureSubmit/src/Services/Gateway/HpsCreditService.php +19 -10
  208. lib/SecureSubmit/src/Services/Gateway/HpsDebitService.php +10 -5
  209. lib/SecureSubmit/src/Services/Gateway/HpsGiftCardService.php +7 -2
  210. lib/SecureSubmit/src/Services/Gateway/HpsPayPlanService.php +103 -0
  211. lib/SecureSubmit/src/Services/Gateway/HpsRestGatewayService.php +8 -4
  212. lib/SecureSubmit/src/Services/Gateway/HpsSoapGatewayService.php +91 -26
  213. lib/SecureSubmit/src/Services/Gateway/HpsTokenService.php +2 -2
  214. lib/SecureSubmit/src/Services/Gateway/PayPlan/HpsPayPlanCustomerService.php +21 -5
  215. lib/SecureSubmit/src/Services/Gateway/PayPlan/HpsPayPlanPaymentMethodService.php +41 -9
  216. lib/SecureSubmit/src/Services/Gateway/PayPlan/HpsPayPlanScheduleService.php +20 -5
  217. lib/SecureSubmit/src/Services/HpsCentinelConfig.php +27 -0
  218. lib/SecureSubmit/src/Services/HpsServicesConfig.php +5 -9
  219. lib/SecureSubmit/src/Services/index.php +1 -1
  220. lib/SecureSubmit/src/index.php +1 -1
  221. package.xml +13 -6
app/code/community/Hps/Securesubmit/.DS_Store DELETED
Binary file
app/code/community/Hps/Securesubmit/Block/Adminhtml/Paypal/Settlement/Report.php CHANGED
@@ -1,36 +1,4 @@
1
  <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magento.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magento.com for more information.
20
- *
21
- * @category Mage
22
- * @package Mage_Paypal
23
- * @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
- /**
28
- * Adminhtml paypal settlement reports grid block
29
- *
30
- * @category Mage
31
- * @package Mage_Paypal
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
  class Hps_Securesubmit_Block_Adminhtml_Paypal_Settlement_Report extends Mage_Adminhtml_Block_Widget_Grid_Container
35
  {
36
  /**
@@ -43,11 +11,11 @@ class Hps_Securesubmit_Block_Adminhtml_Paypal_Settlement_Report extends Mage_Adm
43
  $this->_headerText = Mage::helper('hps_securesubmit')->__('HPS PayPal Settlement Reports');
44
  parent::__construct();
45
  $this->_removeButton('add');
46
- // $message = Mage::helper('hps_securesubmit')->__('Connecting to PayPal SFTP server to fetch new reports. Are you sure you want to proceed?');
47
- // $this->_addButton('fetch', array(
48
- // 'label' => Mage::helper('hps_securesubmit')->__('Fetch Updates'),
49
- // 'onclick' => "confirmSetLocation('{$message}', '{$this->getUrl('*/*/fetch')}')",
50
- // 'class' => 'task'
51
- // ));
52
  }
53
  }
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  class Hps_Securesubmit_Block_Adminhtml_Paypal_Settlement_Report extends Mage_Adminhtml_Block_Widget_Grid_Container
3
  {
4
  /**
11
  $this->_headerText = Mage::helper('hps_securesubmit')->__('HPS PayPal Settlement Reports');
12
  parent::__construct();
13
  $this->_removeButton('add');
14
+ $message = Mage::helper('hps_securesubmit')->__('Fetching updates for all non-Completed transactions. Do you want to continue?');
15
+ $this->_addButton('fetch', array(
16
+ 'label' => Mage::helper('hps_securesubmit')->__('Fetch Updates'),
17
+ 'onclick' => "confirmSetLocation('{$message}', '{$this->getUrl('*/*/fetch')}')",
18
+ 'class' => 'task'
19
+ ));
20
  }
21
  }
app/code/community/Hps/Securesubmit/Block/Adminhtml/Paypal/Settlement/Report/Form.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Hps_Securesubmit_Block_Adminhtml_Paypal_Settlement_Report_Form extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->_controller = '';
9
+ $this->_headerText = Mage::helper('hps_securesubmit')->__('View Transaction');
10
+ $message = Mage::helper('hps_securesubmit')->__('Fetching updates for this transaction. Do you want to continue?');
11
+ $model = Mage::registry('current_transaction');
12
+ $url = $this->getUrl('*/*/fetch', array(
13
+ 'id' => $model->getRowId(),
14
+ ));
15
+ $this->_removeButton('reset')
16
+ ->_removeButton('delete')
17
+ ->_removeButton('save')
18
+ ->_addButton('fetch', array(
19
+ 'label' => Mage::helper('hps_securesubmit')->__('Fetch Updates'),
20
+ 'onclick' => "confirmSetLocation('{$message}', '{$url}')",
21
+ 'class' => 'task'
22
+ ));
23
+ }
24
+
25
+ protected function _prepareLayout()
26
+ {
27
+ parent::_prepareLayout();
28
+ $this->setChild('form', $this->getLayout()->createBlock('hps_securesubmit/adminhtml_paypal_settlement_report_form_form'));
29
+ return $this;
30
+ }
31
+ }
app/code/community/Hps/Securesubmit/Block/Adminhtml/Paypal/Settlement/Report/Form/Form.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Hps_Securesubmit_Block_Adminhtml_Paypal_Settlement_Report_Form_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $model = Mage::registry('current_transaction');
8
+
9
+ $form = new Varien_Data_Form();
10
+ $form->addField('row_id', 'label', array(
11
+ 'name' => 'row_id',
12
+ 'label' => Mage::helper('hps_securesubmit')->__('ID'),
13
+ 'title' => Mage::helper('hps_securesubmit')->__('ID'),
14
+ 'value' => $model->getData('row_id'),
15
+ ));
16
+ $form->addField('order_id', 'label', array(
17
+ 'name' => 'order_id',
18
+ 'label' => Mage::helper('hps_securesubmit')->__('Order ID'),
19
+ 'title' => Mage::helper('hps_securesubmit')->__('Order ID'),
20
+ 'value' => $model->getData('order_id'),
21
+ ));
22
+ $form->addField('payer_email', 'label', array(
23
+ 'name' => 'payer_email',
24
+ 'label' => Mage::helper('hps_securesubmit')->__('Payer Email'),
25
+ 'title' => Mage::helper('hps_securesubmit')->__('Payer Email'),
26
+ 'value' => $model->getData('payer_email'),
27
+ ));
28
+ $form->addField('transaction_id', 'label', array(
29
+ 'name' => 'transaction_id',
30
+ 'label' => Mage::helper('hps_securesubmit')->__('Transaction ID'),
31
+ 'title' => Mage::helper('hps_securesubmit')->__('Transaction ID'),
32
+ 'value' => $model->getData('transaction_id'),
33
+ ));
34
+ $form->addField('last_known_status', 'label', array(
35
+ 'name' => 'last_known_status',
36
+ 'label' => Mage::helper('hps_securesubmit')->__('Last Known Status'),
37
+ 'title' => Mage::helper('hps_securesubmit')->__('Last Known Status'),
38
+ 'value' => $model->getData('last_known_status'),
39
+ ));
40
+ $form->addField('created_time', 'label', array(
41
+ 'name' => 'created_time',
42
+ 'label' => Mage::helper('hps_securesubmit')->__('Creation Time'),
43
+ 'title' => Mage::helper('hps_securesubmit')->__('Creation Time'),
44
+ 'value' => $model->getData('created_time'),
45
+ ));
46
+ $form->addField('update_time', 'label', array(
47
+ 'name' => 'update_time',
48
+ 'label' => Mage::helper('hps_securesubmit')->__('Update Time'),
49
+ 'title' => Mage::helper('hps_securesubmit')->__('Update Time'),
50
+ 'value' => $model->getData('update_time'),
51
+ ));
52
+
53
+ $this->setForm($form);
54
+ return parent::_prepareForm();
55
+ }
56
+ }
app/code/community/Hps/Securesubmit/Block/Adminhtml/Paypal/Settlement/Report/Grid.php CHANGED
@@ -19,14 +19,14 @@ class Hps_Securesubmit_Block_Adminhtml_Paypal_Settlement_Report_Grid extends Mag
19
  $this->setSaveParametersInSession(true);
20
  $this->setUseAjax(true);
21
  }
22
-
23
  protected function _prepareCollection()
24
  {
25
  $collection = Mage::getModel('hps_securesubmit/report')->getCollection();
26
  $this->setCollection($collection);
27
  return parent::_prepareCollection();
28
  }
29
-
30
  protected function _prepareColumns()
31
  {
32
  $this->addColumn('row_id', array(
@@ -35,41 +35,34 @@ class Hps_Securesubmit_Block_Adminhtml_Paypal_Settlement_Report_Grid extends Mag
35
  'width' => '50px',
36
  'index' => 'row_id',
37
  ));
38
-
39
  $this->addColumn('order_id', array(
40
  'header' => Mage::helper('hps_securesubmit')->__('Order ID'),
41
  'align' => 'left',
42
  'width' => '80px',
43
  'index' => 'order_id',
44
  ));
45
-
46
  $this->addColumn('payer_email', array(
47
  'header' => Mage::helper('hps_securesubmit')->__('Payer Email'),
48
  'align' => 'left',
49
  'index' => 'payer_email',
50
  ));
51
-
52
- //$this->addColumn('invoice_id', array(
53
- // 'header' => Mage::helper('hps_securesubmit')->__('Invoice ID'),
54
- // 'align' => 'left',
55
- // 'width' => '80px',
56
- // 'index' => 'invoice_id',
57
- //));
58
-
59
  $this->addColumn('transaction_id', array(
60
  'header' => Mage::helper('hps_securesubmit')->__('Transaction ID'),
61
  'align' => 'left',
62
  'width' => '80px',
63
  'index' => 'transaction_id',
64
  ));
65
-
66
-
67
  $this->addColumn('last_known_status', array(
68
  'header' => Mage::helper('hps_securesubmit')->__('Last Known Status'),
69
  'align' => 'left',
70
  'index' => 'last_known_status',
71
  ));
72
-
73
  $this->addColumn('created_time', array(
74
  'header' => Mage::helper('hps_securesubmit')->__('Creation Time'),
75
  'align' => 'left',
@@ -78,7 +71,7 @@ class Hps_Securesubmit_Block_Adminhtml_Paypal_Settlement_Report_Grid extends Mag
78
  'default' => '--',
79
  'index' => 'created_time',
80
  ));
81
-
82
  $this->addColumn('update_time', array(
83
  'header' => Mage::helper('hps_securesubmit')->__('Update Time'),
84
  'align' => 'left',
@@ -86,8 +79,16 @@ class Hps_Securesubmit_Block_Adminhtml_Paypal_Settlement_Report_Grid extends Mag
86
  'type' => 'date',
87
  'default' => '--',
88
  'index' => 'update_time',
89
- ));
90
-
91
  return parent::_prepareColumns();
92
  }
 
 
 
 
 
 
 
 
93
  }
19
  $this->setSaveParametersInSession(true);
20
  $this->setUseAjax(true);
21
  }
22
+
23
  protected function _prepareCollection()
24
  {
25
  $collection = Mage::getModel('hps_securesubmit/report')->getCollection();
26
  $this->setCollection($collection);
27
  return parent::_prepareCollection();
28
  }
29
+
30
  protected function _prepareColumns()
31
  {
32
  $this->addColumn('row_id', array(
35
  'width' => '50px',
36
  'index' => 'row_id',
37
  ));
38
+
39
  $this->addColumn('order_id', array(
40
  'header' => Mage::helper('hps_securesubmit')->__('Order ID'),
41
  'align' => 'left',
42
  'width' => '80px',
43
  'index' => 'order_id',
44
  ));
45
+
46
  $this->addColumn('payer_email', array(
47
  'header' => Mage::helper('hps_securesubmit')->__('Payer Email'),
48
  'align' => 'left',
49
  'index' => 'payer_email',
50
  ));
51
+
 
 
 
 
 
 
 
52
  $this->addColumn('transaction_id', array(
53
  'header' => Mage::helper('hps_securesubmit')->__('Transaction ID'),
54
  'align' => 'left',
55
  'width' => '80px',
56
  'index' => 'transaction_id',
57
  ));
58
+
59
+
60
  $this->addColumn('last_known_status', array(
61
  'header' => Mage::helper('hps_securesubmit')->__('Last Known Status'),
62
  'align' => 'left',
63
  'index' => 'last_known_status',
64
  ));
65
+
66
  $this->addColumn('created_time', array(
67
  'header' => Mage::helper('hps_securesubmit')->__('Creation Time'),
68
  'align' => 'left',
71
  'default' => '--',
72
  'index' => 'created_time',
73
  ));
74
+
75
  $this->addColumn('update_time', array(
76
  'header' => Mage::helper('hps_securesubmit')->__('Update Time'),
77
  'align' => 'left',
79
  'type' => 'date',
80
  'default' => '--',
81
  'index' => 'update_time',
82
+ ));
83
+
84
  return parent::_prepareColumns();
85
  }
86
+
87
+ public function getRowUrl($row)
88
+ {
89
+ return $this->getUrl('*/*/view', array(
90
+ 'store' => $this->getRequest()->getParam('store'),
91
+ 'id' => $row->getId()
92
+ ));
93
+ }
94
  }
app/code/community/Hps/Securesubmit/Block/Form.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
  class Hps_SecureSubmit_Block_Form extends Mage_Payment_Block_Form_Ccsave
3
  {
4
  protected function _construct()
1
  <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
  class Hps_SecureSubmit_Block_Form extends Mage_Payment_Block_Form_Ccsave
10
  {
11
  protected function _construct()
app/code/community/Hps/Securesubmit/Block/Info.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
  class Hps_SecureSubmit_Block_Info extends Mage_Payment_Block_Info
3
  {
4
  protected function _prepareSpecificInformation($transport = null)
@@ -6,10 +13,15 @@ class Hps_SecureSubmit_Block_Info extends Mage_Payment_Block_Info
6
  $transport = parent::_prepareSpecificInformation($transport);
7
  $data = array();
8
  $info = $this->getInfo();
 
 
 
 
 
 
9
 
10
- $data[Mage::helper("payment")->__("Payment Type")] = "Secure Token";
11
 
12
  return $transport->setData(array_merge($data, $transport->getData()));
13
  }
14
  }
15
-
1
  <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
  class Hps_SecureSubmit_Block_Info extends Mage_Payment_Block_Info
10
  {
11
  protected function _prepareSpecificInformation($transport = null)
13
  $transport = parent::_prepareSpecificInformation($transport);
14
  $data = array();
15
  $info = $this->getInfo();
16
+ $additionalData = $info->getAdditionalData();
17
+ $gift = '';
18
+
19
+ if (strpos($additionalData, 'giftcard_number') !== false) {
20
+ $gift = "Gift Card & ";
21
+ }
22
 
23
+ $data[Mage::helper("payment")->__("Payment Type")] = $gift . "Credit Card ending in " . $info->getCcLast4() . " (" . $info->getCcExpMonth() . "/" . $info->getCcExpYear() . ")";
24
 
25
  return $transport->setData(array_merge($data, $transport->getData()));
26
  }
27
  }
 
app/code/community/Hps/Securesubmit/Block/Masterpass/Client/Js.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Hps_Securesubmit_Block_Masterpass_Client_Js extends Mage_Core_Block_Template
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->setTemplate('securesubmit/masterpass/js.phtml');
8
+ }
9
+
10
+ public function isSandbox()
11
+ {
12
+ return '1' === Mage::getStoreConfig('payment/hps_masterpass/use_sandbox');
13
+ }
14
+ }
app/code/community/Hps/Securesubmit/Block/Masterpass/Connect.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Hps_Securesubmit_Block_Masterpass_Connect extends Mage_Core_Block_Template
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ }
9
+
10
+ public function getLongAccessToken()
11
+ {
12
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
13
+ $customer = Mage::getModel('customer/customer')->load($customerId);
14
+ return $customer->getMasterpassLongAccessToken();
15
+ }
16
+ }
app/code/community/Hps/Securesubmit/Block/Masterpass/Form.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
+ class Hps_Securesubmit_Block_Masterpass_Form extends Mage_Payment_Block_Form
10
+ {
11
+ protected function _construct()
12
+ {
13
+ parent::_construct();
14
+ $mark = Mage::getConfig()->getBlockClassName('core/template');
15
+ $mark = new $mark;
16
+ $mark->setTemplate('securesubmit/masterpass/mark.phtml')
17
+ ->setMarkHref('http://www.mastercard.com/mc_us/wallet/learnmore/en')
18
+ ->setMarkSrc('https://www.mastercard.com/mc_us/wallet/img/en/US/mp_mc_acc_030px_gif.gif')
19
+ ; // known issue: code above will render only static mark image
20
+ $this->setTemplate('securesubmit/masterpass/form.phtml')
21
+ ->setMethodTitle('')
22
+ ->setMethodLabelAfterHtml($mark->toHtml())
23
+ ;
24
+ }
25
+
26
+ public function getCards()
27
+ {
28
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
29
+ if (!$customerId) {
30
+ return false;
31
+ }
32
+
33
+ $cards = $this->getSession()->getMasterPassCards();
34
+ if ($cards) {
35
+ return $cards;
36
+ }
37
+
38
+ $customer = Mage::getModel('customer/customer')->load($customerId);
39
+ $result = Mage::helper('hps_securesubmit/masterpass')
40
+ ->preApproval($customer->getMasterpassLongAccessToken());
41
+
42
+ if (!$result) {
43
+ return false;
44
+ }
45
+
46
+ $cards = $result->preCheckoutData->Cards->Card;
47
+ $cards = $this->responseCardsToObject($cards);
48
+ $customer->unsMasterpassLongAccessToken()
49
+ ->setMasterpassLongAccessToken((string)$result->longAccessToken)
50
+ ->save();
51
+
52
+ $this->getSession()->setMasterPassCards($cards);
53
+ $this->getSession()->setMasterPassWalletName((string)$result->preCheckoutData->WalletName);
54
+ $this->getSession()->setMasterPassWalletId((string)$result->preCheckoutData->ConsumerWalletId);
55
+ $this->getSession()->setMasterPassPreCheckoutTransactionId((string)$result->preCheckoutTransactionId);
56
+ return $cards;
57
+ }
58
+
59
+ protected function responseCardsToObject($resp)
60
+ {
61
+ $cards = array();
62
+ foreach ($resp as $card) {
63
+ $cards[] = (object)array(
64
+ 'CardHolderName' => (string)$card->CardHolderName,
65
+ 'CardId' => (string)$card->CardId,
66
+ 'LastFour' => (string)$card->LastFour,
67
+ 'CardAlias' => (string)$card->CardAlias,
68
+ 'SelectedAsDefault' => (string)$card->SelectedAsDefault,
69
+ 'BrandName' => (string)$card->BrandName,
70
+ 'ExpiryMonth' => (string)$card->ExpiryMonth,
71
+ 'ExpiryYear' => (string)$card->ExpiryYear,
72
+ );
73
+ }
74
+ return $cards;
75
+ }
76
+
77
+ protected function getSession()
78
+ {
79
+ return Mage::getSingleton('hps_securesubmit/session');
80
+ }
81
+ }
app/code/community/Hps/Securesubmit/Block/Masterpass/Info.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
+ class Hps_SecureSubmit_Block_Masterpass_Info extends Mage_Payment_Block_Info
10
+ {
11
+ protected function _prepareSpecificInformation($transport = null)
12
+ {
13
+ $transport = parent::_prepareSpecificInformation($transport);
14
+ $data = array();
15
+ $info = $this->getInfo();
16
+
17
+ $data[Mage::helper("payment")->__("Payment Type")] = "MasterPass";
18
+ //$data[Mage::helper('payment')->__('Email Address')] = print_r($info, true);
19
+
20
+ return $transport->setData(array_merge($data, $transport->getData()));
21
+ }
22
+ }
app/code/community/Hps/Securesubmit/Block/Masterpass/Review.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
+ /**
10
+ * MasterPass checkout block
11
+ */
12
+ class Hps_Securesubmit_Block_Masterpass_Review extends Mage_Core_Block_Template
13
+ {
14
+ /**
15
+ * @var Mage_Sales_Model_Quote
16
+ */
17
+ protected $_quote;
18
+
19
+ /**
20
+ * Currently selected shipping rate
21
+ *
22
+ * @var Mage_Sales_Model_Quote_Address_Rate
23
+ */
24
+ protected $_currentShippingRate = null;
25
+
26
+ /**
27
+ * Paypal action prefix
28
+ *
29
+ * @var string
30
+ */
31
+ protected $_paypalActionPrefix = 'paypal';
32
+
33
+ /**
34
+ * Quote object setter
35
+ *
36
+ * @param Mage_Sales_Model_Quote $quote
37
+ * @return Hps_Securesubmit_Block_Paypal_Review
38
+ */
39
+ public function setQuote(Mage_Sales_Model_Quote $quote)
40
+ {
41
+ $this->_quote = $quote;
42
+ return $this;
43
+ }
44
+
45
+ /**
46
+ * Return quote billing address
47
+ *
48
+ * @return Mage_Sales_Model_Quote_Address
49
+ */
50
+ public function getBillingAddress()
51
+ {
52
+ return $this->_quote->getBillingAddress();
53
+ }
54
+
55
+ /**
56
+ * Return quote shipping address
57
+ *
58
+ * @return Mage_Sales_Model_Quote_Address
59
+ */
60
+ public function getShippingAddress()
61
+ {
62
+ if ($this->_quote->getIsVirtual()) {
63
+ return false;
64
+ }
65
+ return $this->_quote->getShippingAddress();
66
+ }
67
+
68
+ /**
69
+ * Get HTML output for specified address
70
+ *
71
+ * @param Mage_Sales_Model_Quote_Address
72
+ * @return string
73
+ */
74
+ public function renderAddress($address)
75
+ {
76
+ return $address->getFormated(true);
77
+ }
78
+
79
+ /**
80
+ * Return carrier name from config, base on carrier code
81
+ *
82
+ * @param $carrierCode string
83
+ * @return string
84
+ */
85
+ public function getCarrierName($carrierCode)
86
+ {
87
+ if ($name = Mage::getStoreConfig("carriers/{$carrierCode}/title")) {
88
+ return $name;
89
+ }
90
+ return $carrierCode;
91
+ }
92
+
93
+ /**
94
+ * Get either shipping rate code or empty value on error
95
+ *
96
+ * @param Varien_Object $rate
97
+ * @return string
98
+ */
99
+ public function renderShippingRateValue(Varien_Object $rate)
100
+ {
101
+ if ($rate->getErrorMessage()) {
102
+ return '';
103
+ }
104
+ return $rate->getCode();
105
+ }
106
+
107
+ /**
108
+ * Get shipping rate code title and its price or error message
109
+ *
110
+ * @param Varien_Object $rate
111
+ * @param string $format
112
+ * @param string $inclTaxFormat
113
+ * @return string
114
+ */
115
+ public function renderShippingRateOption($rate, $format = '%s - %s%s', $inclTaxFormat = ' (%s %s)')
116
+ {
117
+ $renderedInclTax = '';
118
+ if ($rate->getErrorMessage()) {
119
+ $price = $rate->getErrorMessage();
120
+ } else {
121
+ $price = $this->_getShippingPrice($rate->getPrice(),
122
+ $this->helper('tax')->displayShippingPriceIncludingTax());
123
+
124
+ $incl = $this->_getShippingPrice($rate->getPrice(), true);
125
+ if (($incl != $price) && $this->helper('tax')->displayShippingBothPrices()) {
126
+ $renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl);
127
+ }
128
+ }
129
+ return sprintf($format, $this->escapeHtml($rate->getMethodTitle()), $price, $renderedInclTax);
130
+ }
131
+
132
+ /**
133
+ * Getter for current shipping rate
134
+ *
135
+ * @return Mage_Sales_Model_Quote_Address_Rate
136
+ */
137
+ public function getCurrentShippingRate()
138
+ {
139
+ return $this->_currentShippingRate;
140
+ }
141
+
142
+ /**
143
+ * Set paypal actions prefix
144
+ */
145
+ public function setPaypalActionPrefix($prefix)
146
+ {
147
+ $this->_paypalActionPrefix = $prefix;
148
+ }
149
+
150
+ /**
151
+ * Return formatted shipping price
152
+ *
153
+ * @param float $price
154
+ * @param bool $isInclTax
155
+ *
156
+ * @return bool
157
+ */
158
+ protected function _getShippingPrice($price, $isInclTax)
159
+ {
160
+ return $this->_formatPrice($this->helper('tax')->getShippingPrice($price, $isInclTax, $this->_address));
161
+ }
162
+
163
+ /**
164
+ * Format price base on store convert price method
165
+ *
166
+ * @param float $price
167
+ * @return string
168
+ */
169
+ protected function _formatPrice($price)
170
+ {
171
+ return $this->_quote->getStore()->convertPrice($price, true);
172
+ }
173
+
174
+ /**
175
+ * Retrieve payment method and assign additional template values
176
+ *
177
+ * @return Hps_Securesubmit_Block_Paypal_Review
178
+ */
179
+ protected function _beforeToHtml()
180
+ {
181
+ $methodInstance = $this->_quote->getPayment()->getMethodInstance();
182
+ $this->setPaymentMethodTitle($methodInstance->getTitle());
183
+
184
+ $this->setShippingRateRequired(true);
185
+ if ($this->_quote->getIsVirtual()) {
186
+ $this->setShippingRateRequired(false);
187
+ } else {
188
+ // prepare shipping rates
189
+ $this->_address = $this->_quote->getShippingAddress();
190
+ $groups = $this->_address->getGroupedAllShippingRates();
191
+ if ($groups && $this->_address) {
192
+ $this->setShippingRateGroups($groups);
193
+ // determine current selected code & name
194
+ foreach ($groups as $code => $rates) {
195
+ foreach ($rates as $rate) {
196
+ if ($this->_address->getShippingMethod() == $rate->getCode()) {
197
+ $this->_currentShippingRate = $rate;
198
+ break(2);
199
+ }
200
+ }
201
+ }
202
+ }
203
+
204
+ $canEditShippingAddress = $this->_quote->getMayEditShippingAddress() && $this->_quote->getPayment()
205
+ ->getAdditionalInformation(Hps_Securesubmit_Model_Paypal_Checkout::PAYMENT_INFO_BUTTON) == 1;
206
+ // misc shipping parameters
207
+ $this->setShippingMethodSubmitUrl($this->getUrl("securesubmit/masterpass/saveShippingMethod"))
208
+ ->setCanEditShippingAddress($canEditShippingAddress)
209
+ ->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod())
210
+ ;
211
+ }
212
+
213
+ $this->setEditUrl($this->getUrl("securesubmit/masterpass/edit"))
214
+ ->setPlaceOrderUrl($this->getUrl("securesubmit/masterpass/placeOrder"));
215
+
216
+ return parent::_beforeToHtml();
217
+ }
218
+ }
app/code/community/Hps/Securesubmit/Block/Masterpass/Review/Billing.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
+ class Hps_Securesubmit_Block_Masterpass_Review_Billing extends Mage_Checkout_Block_Onepage_Billing
10
+ {
11
+ /**
12
+ * Return Sales Quote Address model
13
+ *
14
+ * @return Mage_Sales_Model_Quote_Address
15
+ */
16
+ public function getAddress()
17
+ {
18
+ if (is_null($this->_address)) {
19
+ if ($this->isCustomerLoggedIn() || $this->getQuote()->getBillingAddress()) {
20
+ $this->_address = $this->getQuote()->getBillingAddress();
21
+ if (!$this->_address->getFirstname()) {
22
+ $this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname());
23
+ }
24
+ if (!$this->_address->getLastname()) {
25
+ $this->_address->setLastname($this->getQuote()->getCustomer()->getLastname());
26
+ }
27
+ } else {
28
+ $this->_address = Mage::getModel('sales/quote_address');
29
+ }
30
+ }
31
+
32
+ return $this->_address;
33
+ }
34
+ }
app/code/community/Hps/Securesubmit/Block/Masterpass/Review/Details.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
+ class Hps_Securesubmit_Block_Masterpass_Review_Details extends Mage_Checkout_Block_Cart_Totals
10
+ {
11
+ protected $_address;
12
+
13
+ /**
14
+ * Return review shipping address
15
+ *
16
+ * @return Mage_Sales_Model_Order_Address
17
+ */
18
+ public function getAddress()
19
+ {
20
+ if (empty($this->_address)) {
21
+ $this->_address = $this->getQuote()->getShippingAddress();
22
+ }
23
+ return $this->_address;
24
+ }
25
+
26
+ /**
27
+ * Return review quote totals
28
+ *
29
+ * @return array
30
+ */
31
+ public function getTotals()
32
+ {
33
+ return $this->getQuote()->getTotals();
34
+ }
35
+ }
app/code/community/Hps/Securesubmit/Block/Masterpass/Review/Shipping.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
+ class Hps_Securesubmit_Block_Masterpass_Review_Shipping extends Mage_Checkout_Block_Onepage_Shipping
10
+ {
11
+ /**
12
+ * Return Sales Quote Address model (shipping address)
13
+ *
14
+ * @return Mage_Sales_Model_Quote_Address
15
+ */
16
+ public function getAddress()
17
+ {
18
+ if (is_null($this->_address)) {
19
+ if ($this->isCustomerLoggedIn() || $this->getQuote()->getShippingAddress()) {
20
+ $this->_address = $this->getQuote()->getShippingAddress();
21
+ } else {
22
+ $this->_address = Mage::getModel('sales/quote_address');
23
+ }
24
+ }
25
+
26
+ return $this->_address;
27
+ }
28
+ }
app/code/community/Hps/Securesubmit/Block/Paypal/Credit/Form.php CHANGED
@@ -9,7 +9,7 @@
9
  /**
10
  * PayPal Credit payment form
11
  */
12
- class Hps_Securesubmit_Block_Credit_Form extends Hps_Securesubmit_Block_Paypal_Form
13
  {
14
  /**
15
  * Payment method code
@@ -33,7 +33,7 @@ class Hps_Securesubmit_Block_Credit_Form extends Hps_Securesubmit_Block_Paypal_F
33
  ->setPaymentWhatIs('See terms');
34
  $this->setTemplate('paypal/payment/redirect.phtml')
35
  ->setRedirectMessage(
36
- Mage::helper('paypal')->__('You will be redirected to the PayPal website.')
37
  )
38
  ->setMethodTitle('') // Output PayPal mark, omit title
39
  ->setMethodLabelAfterHtml($mark->toHtml());
9
  /**
10
  * PayPal Credit payment form
11
  */
12
+ class Hps_Securesubmit_Block_Paypal_Credit_Form extends Hps_Securesubmit_Block_Paypal_Form
13
  {
14
  /**
15
  * Payment method code
33
  ->setPaymentWhatIs('See terms');
34
  $this->setTemplate('paypal/payment/redirect.phtml')
35
  ->setRedirectMessage(
36
+ Mage::helper('hps_securesubmit')->__('You will be redirected to the PayPal website.')
37
  )
38
  ->setMethodTitle('') // Output PayPal mark, omit title
39
  ->setMethodLabelAfterHtml($mark->toHtml());
app/code/community/Hps/Securesubmit/Block/Paypal/Form.php CHANGED
@@ -17,29 +17,20 @@ class Hps_Securesubmit_Block_Paypal_Form extends Mage_Payment_Block_Form
17
  */
18
  protected $_methodCode = 'hps_paypal';
19
 
20
- /**
21
- * Config model instance
22
- *
23
- * @var Hps_Securesubmit_Model_Config
24
- */
25
- protected $_config;
26
-
27
  /**
28
  * Set template and redirect message
29
  */
30
  protected function _construct()
31
  {
32
- $this->_config = Mage::getModel('paypal/config')->setMethod($this->getMethodCode());
33
- $locale = Mage::app()->getLocale();
34
  $mark = Mage::getConfig()->getBlockClassName('core/template');
35
  $mark = new $mark;
36
  $mark->setTemplate('paypal/payment/mark.phtml')
37
- ->setPaymentAcceptanceMarkHref($this->_config->getPaymentMarkWhatIsPaypalUrl($locale))
38
- ->setPaymentAcceptanceMarkSrc($this->_config->getPaymentMarkImageUrl($locale->getLocaleCode()))
39
  ; // known issue: code above will render only static mark image
40
  $this->setTemplate('paypal/payment/redirect.phtml')
41
  ->setRedirectMessage(
42
- Mage::helper('paypal')->__('You will be redirected to the PayPal website.')
43
  )
44
  ->setMethodTitle('') // Output PayPal mark, omit title
45
  ->setMethodLabelAfterHtml($mark->toHtml())
17
  */
18
  protected $_methodCode = 'hps_paypal';
19
 
 
 
 
 
 
 
 
20
  /**
21
  * Set template and redirect message
22
  */
23
  protected function _construct()
24
  {
 
 
25
  $mark = Mage::getConfig()->getBlockClassName('core/template');
26
  $mark = new $mark;
27
  $mark->setTemplate('paypal/payment/mark.phtml')
28
+ ->setPaymentAcceptanceMarkHref('https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside')
29
+ ->setPaymentAcceptanceMarkSrc('https://www.paypalobjects.com/webstatic/en_US/i/buttons/pp-acceptance-medium.png')
30
  ; // known issue: code above will render only static mark image
31
  $this->setTemplate('paypal/payment/redirect.phtml')
32
  ->setRedirectMessage(
33
+ Mage::helper('hps_securesubmit')->__('You will be redirected to the PayPal website.')
34
  )
35
  ->setMethodTitle('') // Output PayPal mark, omit title
36
  ->setMethodLabelAfterHtml($mark->toHtml())
app/code/community/Hps/Securesubmit/Block/Paypal/Incontext/Js.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Hps_Securesubmit_Block_Paypal_Incontext_Js extends Mage_Core_Block_Template
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->setTemplate('securesubmit/paypal/incontext/js.phtml');
8
+ }
9
+
10
+ public function getConfig()
11
+ {
12
+ $env = 'sandbox';
13
+ $privateKey = Mage::getStoreConfig('payment/hps_paypal/secretapikey');
14
+ if (strpos($privateKey, '_prod_') !== false) {
15
+ $env = 'production';
16
+ }
17
+
18
+ return json_encode(array(
19
+ 'env' => $env,
20
+ 'bmlUrl' => $this->getUrl('securesubmit/paypal/incontextCredit', array(
21
+ 'button' => 1,
22
+ )),
23
+ 'stdUrl' => $this->getUrl('securesubmit/paypal/incontext', array(
24
+ 'button' => 1,
25
+ )),
26
+ ));
27
+ }
28
+ }
app/code/community/Hps/Securesubmit/Block/Paypal/Info.php CHANGED
@@ -15,6 +15,7 @@ class Hps_SecureSubmit_Block_Paypal_Info extends Mage_Payment_Block_Info
15
  $info = $this->getInfo();
16
 
17
  $data[Mage::helper("payment")->__("Payment Type")] = "PayPal";
 
18
 
19
  return $transport->setData(array_merge($data, $transport->getData()));
20
  }
15
  $info = $this->getInfo();
16
 
17
  $data[Mage::helper("payment")->__("Payment Type")] = "PayPal";
18
+ //$data[Mage::helper('payment')->__('Email Address')] = print_r($info, true);
19
 
20
  return $transport->setData(array_merge($data, $transport->getData()));
21
  }
app/code/community/Hps/Securesubmit/Block/Paypal/Shortcut.php CHANGED
@@ -69,23 +69,6 @@ class Hps_Securesubmit_Block_Paypal_Shortcut extends Mage_Core_Block_Template
69
 
70
  // check visibility on cart or product page
71
  $context = $isInCatalog ? 'visible_on_product' : 'visible_on_cart';
72
- // if (!$config->$context) {
73
- // $this->_shouldRender = false;
74
- // return $result;
75
- // }
76
-
77
- // if ($isInCatalog) {
78
- // /** @var Mage_Catalog_Model_Product $currentProduct */
79
- // $currentProduct = Mage::registry('current_product');
80
- // if (!is_null($currentProduct)) {
81
- // $price = (float)$currentProduct->getFinalPrice();
82
- // $typeInstance = $currentProduct->getTypeInstance();
83
- // if (empty($price) && !$currentProduct->isSuper() && !$typeInstance->canConfigure($currentProduct)) {
84
- // $this->_shouldRender = false;
85
- // return $result;
86
- // }
87
- // }
88
- // }
89
 
90
  // validate minimum quote amount and validate quote for zero grandtotal
91
  if (null !== $quote && (!$quote->validateMinimumAmount()
@@ -107,21 +90,7 @@ class Hps_Securesubmit_Block_Paypal_Shortcut extends Mage_Core_Block_Template
107
 
108
  $this->_getBmlShortcut($quote);
109
 
110
- // use static image if in catalog
111
- // if ($isInCatalog || null === $quote) {
112
- // $this->setImageUrl($config->getExpressCheckoutShortcutImageUrl(Mage::app()->getLocale()->getLocaleCode()));
113
- // } else {
114
- $this->setImageUrl('https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-medium.png');
115
- // }
116
-
117
- // // ask whether to create a billing agreement
118
- // $customerId = Mage::getSingleton('customer/session')->getCustomerId(); // potential issue for caching
119
- // if (Mage::helper('paypal')->shouldAskToCreateBillingAgreement($config, $customerId)) {
120
- // $this->setConfirmationUrl($this->getUrl($this->_startAction,
121
- // array(Hps_Securesubmit_Model_Paypal_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1)
122
- // ));
123
- // $this->setConfirmationMessage(Mage::helper('paypal')->__('Would you like to sign a billing agreement to streamline further purchases with PayPal?'));
124
- // }
125
 
126
  return $result;
127
  }
@@ -133,7 +102,7 @@ class Hps_Securesubmit_Block_Paypal_Shortcut extends Mage_Core_Block_Template
133
  */
134
  protected function _getBmlShortcut($quote)
135
  {
136
- $bml = Mage::helper('payment')->getMethodInstance('hps_paypal_bml');
137
  $isBmlEnabled = $bml && $bml->isAvailable($quote);
138
  $this->setBmlShortcutHtmlId($this->helper('core')->uniqHash('hps_shortcut_bml_'))
139
  ->setBmlCheckoutUrl($this->getUrl('securesubmit/paypal/credit/button/1'))
@@ -141,7 +110,7 @@ class Hps_Securesubmit_Block_Paypal_Shortcut extends Mage_Core_Block_Template
141
  ->setMarketMessage('https://www.paypalobjects.com/webstatic/en_US/btn/btn_bml_text.png')
142
  ->setMarketMessageUrl('https://www.securecheckout.billmelater.com/paycapture-content/'
143
  . 'fetch?hash=AU826TU8&content=/bmlweb/ppwpsiw.html')
144
- ->setIsBmlEnabled(true);
145
  return $this;
146
  }
147
 
69
 
70
  // check visibility on cart or product page
71
  $context = $isInCatalog ? 'visible_on_product' : 'visible_on_cart';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  // validate minimum quote amount and validate quote for zero grandtotal
74
  if (null !== $quote && (!$quote->validateMinimumAmount()
90
 
91
  $this->_getBmlShortcut($quote);
92
 
93
+ $this->setImageUrl('https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-medium.png');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
  return $result;
96
  }
102
  */
103
  protected function _getBmlShortcut($quote)
104
  {
105
+ $bml = Mage::helper('payment')->getMethodInstance('hps_paypal_credit');
106
  $isBmlEnabled = $bml && $bml->isAvailable($quote);
107
  $this->setBmlShortcutHtmlId($this->helper('core')->uniqHash('hps_shortcut_bml_'))
108
  ->setBmlCheckoutUrl($this->getUrl('securesubmit/paypal/credit/button/1'))
110
  ->setMarketMessage('https://www.paypalobjects.com/webstatic/en_US/btn/btn_bml_text.png')
111
  ->setMarketMessageUrl('https://www.securecheckout.billmelater.com/paycapture-content/'
112
  . 'fetch?hash=AU826TU8&content=/bmlweb/ppwpsiw.html')
113
+ ->setIsBmlEnabled(Mage::getStoreConfig('payment/hps_paypal_credit/active'));
114
  return $this;
115
  }
116
 
app/code/community/Hps/Securesubmit/Controller/Paypal/Abstract.php DELETED
@@ -1,516 +0,0 @@
1
- <?php
2
- /**
3
- * @category Hps
4
- * @package Hps_Securesubmit
5
- * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
- * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
- */
8
-
9
- /**
10
- * Abstract PayPal Checkout Controller
11
- */
12
- abstract class Hps_Securesubmit_Controller_Paypal_Abstract extends Mage_Core_Controller_Front_Action
13
- {
14
- /**
15
- * @var Hps_Securesubmit_Model_Paypal_Checkout
16
- */
17
- protected $_checkout = null;
18
-
19
- /**
20
- * @var Hps_Securesubmit_Model_Config
21
- */
22
- protected $_config = null;
23
-
24
- /**
25
- * @var Mage_Sales_Model_Quote
26
- */
27
- protected $_quote = false;
28
-
29
- /**
30
- * Instantiate config
31
- */
32
- protected function _construct()
33
- {
34
- parent::_construct();
35
- $this->_config = Mage::getModel($this->_configType, array($this->_configMethod));
36
- }
37
-
38
- /**
39
- * Start PayPal Checkout by requesting initial token and dispatching customer to PayPal
40
- */
41
- public function startAction()
42
- {
43
- try {
44
- $this->_initCheckout();
45
-
46
- if ($this->_getQuote()->getIsMultiShipping()) {
47
- $this->_getQuote()->setIsMultiShipping(false);
48
- $this->_getQuote()->removeAllAddresses();
49
- }
50
-
51
- $customer = Mage::getSingleton('customer/session')->getCustomer();
52
- $quoteCheckoutMethod = $this->_getQuote()->getCheckoutMethod();
53
- if ($customer && $customer->getId()) {
54
- $this->_checkout->setCustomerWithAddressChange(
55
- $customer, $this->_getQuote()->getBillingAddress(), $this->_getQuote()->getShippingAddress()
56
- );
57
- } elseif ((!$quoteCheckoutMethod
58
- || $quoteCheckoutMethod != Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER)
59
- && !Mage::helper('checkout')->isAllowedGuestCheckout(
60
- $this->_getQuote(),
61
- $this->_getQuote()->getStoreId()
62
- )) {
63
- Mage::getSingleton('core/session')->addNotice(
64
- Mage::helper('paypal')->__('To proceed to Checkout, please log in using your email address.')
65
- );
66
- $this->redirectLogin();
67
- Mage::getSingleton('customer/session')
68
- ->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_current' => true)));
69
- return;
70
- }
71
-
72
- $button = (bool)$this->getRequest()->getParam('button');
73
- $credit = (bool)$this->getRequest()->getParam('credit');
74
- $token = $this->_checkout->start(Mage::getUrl('*/*/return'), Mage::getUrl('*/*/cancel'), array(
75
- 'button' => $button,
76
- 'credit' => $credit,
77
- ));
78
- if ($token && $url = $this->_checkout->getRedirectUrl()) {
79
- $this->_initToken($token);
80
- $this->getResponse()->setRedirect($url);
81
- return;
82
- }
83
- } catch (Mage_Core_Exception $e) {
84
- // print_r($e->getMessage());die();
85
- $this->_getCheckoutSession()->addError($e->getMessage());
86
- Mage::log(Mage::helper('hps_securesubmit')->__("Error creating PayPal session: %s", $e->getMessage()), Zend_Log::WARN);
87
- } catch (Exception $e) {
88
- // print_r($e->getMessage());die();
89
- $this->_getCheckoutSession()->addError($this->__('Unable to start PayPal Checkout.'));
90
- Mage::logException($e);
91
- Mage::log(Mage::helper('hps_securesubmit')->__("Error creating PayPal session: %s", $e->getMessage()), Zend_Log::WARN);
92
- }
93
- $this->_redirect('checkout/cart');
94
- }
95
-
96
- /**
97
- * Return shipping options items for shipping address from request
98
- */
99
- public function shippingOptionsCallbackAction()
100
- {
101
- try {
102
- $quoteId = $this->getRequest()->getParam('quote_id');
103
- $this->_quote = Mage::getModel('sales/quote')->load($quoteId);
104
- $this->_initCheckout();
105
- $response = $this->_checkout->getShippingOptionsCallbackResponse($this->getRequest()->getParams());
106
- $this->getResponse()->setBody($response);
107
- } catch (Exception $e) {
108
- Mage::logException($e);
109
- }
110
- }
111
-
112
- /**
113
- * Cancel PayPal Checkout
114
- */
115
- public function cancelAction()
116
- {
117
- try {
118
- $this->_initToken(false);
119
- // TODO verify if this logic of order cancelation is deprecated
120
- // if there is an order - cancel it
121
- $orderId = $this->_getCheckoutSession()->getLastOrderId();
122
- $order = ($orderId) ? Mage::getModel('sales/order')->load($orderId) : false;
123
- if ($order && $order->getId() && $order->getQuoteId() == $this->_getCheckoutSession()->getQuoteId()) {
124
- $order->cancel()->save();
125
- $this->_getCheckoutSession()
126
- ->unsLastQuoteId()
127
- ->unsLastSuccessQuoteId()
128
- ->unsLastOrderId()
129
- ->unsLastRealOrderId()
130
- ->addSuccess($this->__('PayPal Checkout and Order have been canceled.'))
131
- ;
132
- } else {
133
- $this->_getCheckoutSession()->addSuccess($this->__('PayPal Checkout has been canceled.'));
134
- }
135
- } catch (Mage_Core_Exception $e) {
136
- $this->_getCheckoutSession()->addError($e->getMessage());
137
- } catch (Exception $e) {
138
- $this->_getCheckoutSession()->addError($this->__('Unable to cancel PayPal Checkout.'));
139
- Mage::logException($e);
140
- }
141
-
142
- $this->_redirect('checkout/cart');
143
- }
144
-
145
- /**
146
- * Return from PayPal and dispatch customer to order review page
147
- */
148
- public function returnAction()
149
- {
150
- if ($this->getRequest()->getParam('retry_authorization') == 'true'
151
- && is_array($this->_getCheckoutSession()->getPaypalTransactionData())
152
- ) {
153
- $this->_forward('placeOrder');
154
- return;
155
- }
156
- try {
157
- $token = $this->getRequest()->getParam('token');
158
- $payerId = $this->getRequest()->getParam('PayerID');
159
- $this->_getCheckoutSession()->unsPaypalTransactionData();
160
- $this->_checkout = $this->_initCheckout();
161
- $token = $this->_initToken();
162
- $this->_checkout->returnFromPaypal($token, $payerId);
163
- $this->_getSession()->setPayPalPayerId($payerId);
164
-
165
- if ($this->_checkout->canSkipOrderReviewStep()) {
166
- $this->_forward('placeOrder');
167
- } else {
168
- $this->_redirect('*/*/review');
169
- }
170
-
171
- return;
172
- } catch (Mage_Core_Exception $e) {
173
- die();
174
- Mage::getSingleton('checkout/session')->addError($e->getMessage());
175
- }
176
- catch (Exception $e) {
177
- die();
178
- Mage::getSingleton('checkout/session')->addError($this->__('Unable to process PayPal Checkout approval.'));
179
- Mage::logException($e);
180
- }
181
- $this->_redirect('checkout/cart');
182
- }
183
-
184
- /**
185
- * Review order after returning from PayPal
186
- */
187
- public function reviewAction()
188
- {
189
- try {
190
- $this->_initCheckout();
191
- $token = $this->_initToken();
192
- $this->_checkout->prepareOrderReview($token);
193
- $this->loadLayout();
194
- $this->_initLayoutMessages('paypal/session');
195
- $reviewBlock = $this->getLayout()->getBlock('hps.securesubmit.paypal.review');
196
- $reviewBlock->setQuote($this->_getQuote());
197
- $reviewBlock->getChild('details')->setQuote($this->_getQuote());
198
- if ($reviewBlock->getChild('shipping_method')) {
199
- $reviewBlock->getChild('shipping_method')->setQuote($this->_getQuote());
200
- }
201
- $this->renderLayout();
202
- return;
203
- }
204
- catch (Mage_Core_Exception $e) {
205
- Mage::getSingleton('checkout/session')->addError($e->getMessage());
206
- }
207
- catch (Exception $e) {
208
- Mage::getSingleton('checkout/session')->addError(
209
- $this->__('Unable to initialize PayPal Checkout review.')
210
- );
211
- Mage::logException($e);
212
- }
213
- $this->_redirect('checkout/cart');
214
- }
215
-
216
- /**
217
- * Dispatch customer back to PayPal for editing payment information
218
- */
219
- public function editAction()
220
- {
221
- try {
222
- $this->getResponse()->setRedirect($this->_config->getPayPalCheckoutEditUrl($this->_initToken()));
223
- }
224
- catch (Mage_Core_Exception $e) {
225
- $this->_getSession()->addError($e->getMessage());
226
- $this->_redirect('*/*/review');
227
- }
228
- }
229
-
230
- /**
231
- * Update shipping method (combined action for ajax and regular request)
232
- */
233
- public function saveShippingMethodAction()
234
- {
235
- try {
236
- $isAjax = $this->getRequest()->getParam('isAjax');
237
- $this->_initCheckout();
238
- $this->_checkout->updateShippingMethod($this->getRequest()->getParam('shipping_method'));
239
- if ($isAjax) {
240
- $this->loadLayout('hps_securesubmit_paypal_review_details');
241
- $this->getResponse()->setBody($this->getLayout()->getBlock('root')
242
- ->setQuote($this->_getQuote())
243
- ->toHtml());
244
- return;
245
- }
246
- } catch (Mage_Core_Exception $e) {
247
- $this->_getSession()->addError($e->getMessage());
248
- } catch (Exception $e) {
249
- $this->_getSession()->addError($this->__('Unable to update shipping method.'));
250
- Mage::logException($e);
251
- }
252
- if ($isAjax) {
253
- $this->getResponse()->setBody('<script type="text/javascript">window.location.href = '
254
- . Mage::getUrl('*/*/review') . ';</script>');
255
- } else {
256
- $this->_redirect('*/*/review');
257
- }
258
- }
259
-
260
- /**
261
- * Update Order (combined action for ajax and regular request)
262
- */
263
- public function updateShippingMethodsAction()
264
- {
265
- try {
266
- $this->_initCheckout();
267
- $this->_checkout->prepareOrderReview($this->_initToken());
268
- $this->loadLayout('hps_securesubmit_paypal_review');
269
-
270
- $this->getResponse()->setBody($this->getLayout()->getBlock('express.review.shipping.method')
271
- ->setQuote($this->_getQuote())
272
- ->toHtml());
273
- return;
274
- } catch (Mage_Core_Exception $e) {
275
- $this->_getSession()->addError($e->getMessage());
276
- } catch (Exception $e) {
277
- $this->_getSession()->addError($this->__('Unable to update shipping method.'));
278
- Mage::logException($e);
279
- }
280
- $this->getResponse()->setBody('<script type="text/javascript">window.location.href = '
281
- . Mage::getUrl('*/*/review') . ';</script>');
282
- }
283
-
284
- /**
285
- * Submit the order
286
- */
287
- public function placeOrderAction()
288
- {
289
- try {
290
- $requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();
291
- if ($requiredAgreements) {
292
- $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
293
- if (array_diff($requiredAgreements, $postedAgreements)) {
294
- Mage::throwException(Mage::helper('paypal')->__('Please agree to all the terms and conditions before placing the order.'));
295
- }
296
- }
297
- $this->_initCheckout();
298
- $this->_checkout->place($this->_initToken());
299
-
300
- // prepare session to success or cancellation page
301
- $session = $this->_getCheckoutSession();
302
- $session->clearHelperData();
303
-
304
- // "last successful quote"
305
- $quoteId = $this->_getQuote()->getId();
306
- $session->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId);
307
-
308
- // an order may be created
309
- $order = $this->_checkout->getOrder();
310
- if ($order) {
311
- $session->setLastOrderId($order->getId())
312
- ->setLastRealOrderId($order->getIncrementId());
313
- // as well a billing agreement can be created
314
- $agreement = $this->_checkout->getBillingAgreement();
315
- if ($agreement) {
316
- $session->setLastBillingAgreementId($agreement->getId());
317
- }
318
- }
319
-
320
- // recurring profiles may be created along with the order or without it
321
- $profiles = $this->_checkout->getRecurringPaymentProfiles();
322
- if ($profiles) {
323
- $ids = array();
324
- foreach($profiles as $profile) {
325
- $ids[] = $profile->getId();
326
- }
327
- $session->setLastRecurringProfileIds($ids);
328
- }
329
-
330
- // redirect if PayPal specified some URL (for example, to Giropay bank)
331
- $url = $this->_checkout->getRedirectUrl();
332
- if ($url) {
333
- $this->getResponse()->setRedirect($url);
334
- return;
335
- }
336
- $this->_initToken(false); // no need in token anymore
337
- $this->_redirect('checkout/onepage/success');
338
- return;
339
- } catch (Hps_Securesubmit_Model_Api_ProcessableException $e) {
340
- // print_r($e);die();
341
- $this->_processPaypalApiError($e);
342
- } catch (Mage_Core_Exception $e) {
343
- // print_r($e);die();
344
- Mage::helper('checkout')->sendPaymentFailedEmail($this->_getQuote(), $e->getMessage());
345
- $this->_getSession()->addError($e->getMessage());
346
- $this->_redirect('*/*/review');
347
- } catch (Exception $e) {
348
- // print_r($e);die();
349
- Mage::helper('checkout')->sendPaymentFailedEmail(
350
- $this->_getQuote(),
351
- $this->__('Unable to place the order.')
352
- );
353
- $this->_getSession()->addError($this->__('Unable to place the order.'));
354
- Mage::logException($e);
355
- $this->_redirect('*/*/review');
356
- }
357
- }
358
-
359
- /**
360
- * Process PayPal API's processable errors
361
- *
362
- * @param Hps_Securesubmit_Model_Api_ProcessableException $exception
363
- * @throws Hps_Securesubmit_Model_Api_ProcessableException
364
- */
365
- protected function _processPaypalApiError($exception)
366
- {
367
- switch ($exception->getCode()) {
368
- case Hps_Securesubmit_Model_Api_ProcessableException::API_MAX_PAYMENT_ATTEMPTS_EXCEEDED:
369
- case Hps_Securesubmit_Model_Api_ProcessableException::API_TRANSACTION_EXPIRED:
370
- $this->getResponse()->setRedirect(
371
- $this->_getQuote()->getPayment()->getCheckoutRedirectUrl()
372
- );
373
- break;
374
- case Hps_Securesubmit_Model_Api_ProcessableException::API_DO_EXPRESS_CHECKOUT_FAIL:
375
- $this->_redirectSameToken();
376
- break;
377
- case Hps_Securesubmit_Model_Api_ProcessableException::API_UNABLE_TRANSACTION_COMPLETE:
378
- if ($this->_config->getPaymentAction() == Mage_Payment_Model_Method_Abstract::ACTION_ORDER) {
379
- $paypalTransactionData = $this->_getCheckoutSession()->getPaypalTransactionData();
380
- $this->getResponse()->setRedirect(
381
- $this->_config->getPayPalCheckoutOrderUrl($paypalTransactionData['transaction_id'])
382
- );
383
- } else {
384
- $this->_redirectSameToken();
385
- }
386
- break;
387
- default:
388
- $this->_redirectToCartAndShowError($exception->getUserMessage());
389
- break;
390
- }
391
-
392
- }
393
-
394
- /**
395
- * Redirect customer back to PayPal with the same token
396
- */
397
- protected function _redirectSameToken()
398
- {
399
- $token = $this->_initToken();
400
- $this->getResponse()->setRedirect(
401
- $this->_config->getPayPalCheckoutStartUrl($token)
402
- );
403
- }
404
-
405
- /**
406
- * Redirect customer to shopping cart and show error message
407
- *
408
- * @param string $errorMessage
409
- */
410
- protected function _redirectToCartAndShowError($errorMessage)
411
- {
412
- $cart = Mage::getSingleton('checkout/cart');
413
- $cart->getCheckoutSession()->addError($errorMessage);
414
- $this->_redirect('checkout/cart');
415
- }
416
-
417
- /**
418
- * Instantiate quote and checkout
419
- *
420
- * @return Hps_Securesubmit_Model_Paypal_Checkout
421
- * @throws Mage_Core_Exception
422
- */
423
- protected function _initCheckout()
424
- {
425
- $quote = $this->_getQuote();
426
- if (!$quote->hasItems() || $quote->getHasError()) {
427
- $this->getResponse()->setHeader('HTTP/1.1','403 Forbidden');
428
- Mage::throwException(Mage::helper('paypal')->__('Unable to initialize PayPal Checkout.'));
429
- }
430
- $this->_checkout = Mage::getSingleton($this->_checkoutType, array(
431
- 'config' => $this->_config,
432
- 'quote' => $quote,
433
- ));
434
-
435
- return $this->_checkout;
436
- }
437
-
438
- /**
439
- * Search for proper checkout token in request or session or (un)set specified one
440
- * Combined getter/setter
441
- *
442
- * @param string $setToken
443
- * @return Hps_Securesubmit_PaypalController|string
444
- */
445
- protected function _initToken($setToken = null)
446
- {
447
- if (null !== $setToken) {
448
- if (false === $setToken) {
449
- // security measure for avoid unsetting token twice
450
- if (!$this->_getSession()->getPayPalCheckoutToken()) {
451
- Mage::throwException($this->__('PayPal Checkout Token does not exist.'));
452
- }
453
- $this->_getSession()->unsPayPalCheckoutToken();
454
- } else {
455
- $this->_getSession()->setPayPalCheckoutToken($setToken);
456
- }
457
- return $this;
458
- }
459
- if ($setToken = $this->getRequest()->getParam('token')) {
460
- if ($setToken !== $this->_getSession()->getPayPalCheckoutToken()) {
461
- Mage::throwException($this->__('Wrong PayPal Checkout Token specified.'));
462
- }
463
- } else {
464
- $setToken = $this->_getSession()->getPayPalCheckoutToken();
465
- }
466
- return $setToken;
467
- }
468
-
469
- /**
470
- * PayPal session instance getter
471
- *
472
- * @return Mage_PayPal_Model_Session
473
- */
474
- private function _getSession()
475
- {
476
- return Mage::getSingleton('hps_securesubmit/session');
477
- }
478
-
479
- /**
480
- * Return checkout session object
481
- *
482
- * @return Mage_Checkout_Model_Session
483
- */
484
- protected function _getCheckoutSession()
485
- {
486
- return Mage::getSingleton('checkout/session');
487
- }
488
-
489
- /**
490
- * Return checkout quote object
491
- *
492
- * @return Mage_Sales_Model_Quote
493
- */
494
- private function _getQuote()
495
- {
496
- if (!$this->_quote) {
497
- $this->_quote = $this->_getCheckoutSession()->getQuote();
498
- }
499
- return $this->_quote;
500
- }
501
-
502
- /**
503
- * Redirect to login page
504
- *
505
- */
506
- public function redirectLogin()
507
- {
508
- $this->setFlag('', 'no-dispatch', true);
509
- $this->getResponse()->setRedirect(
510
- Mage::helper('core/url')->addRequestParam(
511
- Mage::helper('customer')->getLoginUrl(),
512
- array('context' => 'checkout')
513
- )
514
- );
515
- }
516
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Hps/Securesubmit/Helper/Altpayment/Abstract.php ADDED
@@ -0,0 +1,416 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+ require_once Mage::getBaseDir('lib').DS.'SecureSubmit'.DS.'Hps.php';
9
+
10
+ class Hps_Securesubmit_Helper_Altpayment_Abstract extends Mage_Core_Helper_Abstract
11
+ {
12
+ protected $_methodCode = null;
13
+
14
+ public function start($quote, $returnUrl = null, $cancelUrl = null, $credit = false)
15
+ {
16
+ $quote->collectTotals();
17
+
18
+ if (!$credit && !$quote->getGrandTotal() && !$quote->hasNominalItems()) {
19
+ Mage::throwException(Mage::helper('hps_securesubmit')->__($this->_methodCode . ' does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process.'));
20
+ }
21
+
22
+ $quote->reserveOrderId()->save();
23
+
24
+ return $this->startCheckout(
25
+ $quote,
26
+ $returnUrl,
27
+ $cancelUrl,
28
+ $credit
29
+ );
30
+ }
31
+
32
+ public function startCheckout(
33
+ $quote,
34
+ $returnUrl,
35
+ $cancelUrl,
36
+ $credit = null
37
+ ) {
38
+ $amount = $quote->getBaseGrandTotal();
39
+ $currency = $quote->getBaseCurrencyCode();
40
+ $address = null;
41
+ // supress or export shipping address
42
+ if ($quote->getIsVirtual()) {
43
+ $this->setRequireBillingAddress(1);
44
+ $this->setSuppressShipping(true);
45
+ } else {
46
+ $address = $quote->getShippingAddress();
47
+ $isOverriden = 0;
48
+ if (true === $address->validate()) {
49
+ $isOverriden = 1;
50
+ }
51
+ $quote->getPayment()->setAdditionalInformation(
52
+ 'shipping_overriden',
53
+ $isOverriden
54
+ );
55
+ $quote->getPayment()->save();
56
+ }
57
+
58
+ // add line items
59
+ $cart = Mage::getModel('hps_securesubmit/altpayment_cart', array($quote));
60
+ $totals = $cart->getTotals();
61
+
62
+ $buyer = new HpsBuyerData();
63
+ $buyer->returnUrl = $returnUrl;
64
+ $buyer->cancelUrl = $cancelUrl;
65
+ $buyer->credit = $credit;
66
+ if ($quote->getBillingAddress()) {
67
+ $billingAddress = $quote->getBillingAddress();
68
+ $regionModel = Mage::getModel('directory/region')->load($billingAddress->getRegionId());
69
+ $buyer->address = new HpsAddress();
70
+ $buyer->name = $billingAddress->getFirstname() . ' ' . $billingAddress->getMiddlename() . ' ' . $billingAddress->getLastname();
71
+ $buyer->address = new HpsAddress();
72
+ $buyer->address->address = $billingAddress->getData('street');
73
+ $buyer->address->city = $billingAddress->getCity();
74
+ $buyer->address->state = $regionModel->getCode();
75
+ $buyer->address->zip = $billingAddress->getPostcode();
76
+ $buyer->address->country = $billingAddress->getCountryId();
77
+ }
78
+
79
+ $payment = new HpsPaymentData();
80
+ $payment->subtotal = sprintf("%0.2f", round($totals[Hps_Securesubmit_Model_Altpayment_Cart::TOTAL_SUBTOTAL], 3));
81
+ $payment->shippingAmount = sprintf("%0.2f", round($totals[Hps_Securesubmit_Model_Altpayment_Cart::TOTAL_SHIPPING], 3));
82
+ $payment->taxAmount = sprintf("%0.2f", round($totals[Hps_Securesubmit_Model_Altpayment_Cart::TOTAL_TAX], 3));
83
+ $payment->paymentType = (Mage::getStoreConfig('payment/' . $this->_methodCode . '/payment_action') == 'authorize_capture'
84
+ ? 'Sale' : 'Authorization');
85
+
86
+ $discount = 0;
87
+ if (isset($totals[Hps_Securesubmit_Model_Altpayment_Cart::TOTAL_DISCOUNT])) {
88
+ $discount = sprintf("-%0.2f", round($totals[Hps_Securesubmit_Model_Altpayment_Cart::TOTAL_DISCOUNT], 3));
89
+ $payment->subtotal += $discount;
90
+ }
91
+
92
+ // import/suppress shipping address, if any
93
+ $shippingInfo = null;
94
+ if ($address !== null && $address->getRegionId() !== null) {
95
+ $regionModel = Mage::getModel('directory/region')->load($address->getRegionId());
96
+ $shippingInfo = new HpsShippingInfo();
97
+ $shippingInfo->name = $address->getFirstname() . ' ' . $address->getMiddlename() . ' ' . $address->getLastname();
98
+ $shippingInfo->address = new HpsAddress();
99
+ $shippingInfo->address->address = $address->getData('street');
100
+ $shippingInfo->address->city = $address->getCity();
101
+ $shippingInfo->address->state = $regionModel->getCode();
102
+ $shippingInfo->address->zip = $address->getPostcode();
103
+ $shippingInfo->address->country = $address->getCountryId();
104
+
105
+ if ($address->getEmail()) {
106
+ $buyer->emailAddress = $address->getEmail();
107
+ }
108
+ }
109
+
110
+ $lineItems = $this->exportLineItems($cart);
111
+
112
+ if ($discount != 0) {
113
+ $discountItem = new HpsLineItem();
114
+ $discountItem->name = 'Discount';
115
+ $discountItem->number = 'discount';
116
+ $discountItem->amount = $discount;
117
+ $lineItems[] = $discountItem;
118
+ unset($discountItem);
119
+ }
120
+
121
+ $orderData = new HpsOrderData();
122
+ $orderData->orderNumber = str_shuffle('abcdefghijklmnopqrstuvwxyz');
123
+ $orderData->ipAddress = $_SERVER['REMOTE_ADDR'];
124
+ $orderData->browserHeader = $_SERVER['HTTP_ACCEPT'];
125
+ $orderData->userAgent = $_SERVER['HTTP_USER_AGENT'];
126
+ $orderData->originUrl = $returnUrl;
127
+ $orderData->termUrl = $cancelUrl;
128
+ $orderData->checkoutType = HpsCentinelCheckoutType::LIGHTBOX;
129
+
130
+ if ($credit) {
131
+ $orderData->checkoutType = HpsCentinelCheckoutType::PAIRING;
132
+ }
133
+
134
+ return $this->getService()->createSession(
135
+ $amount,
136
+ $currency,
137
+ $buyer,
138
+ $payment,
139
+ $shippingInfo,
140
+ $lineItems,
141
+ $orderData
142
+ );
143
+ }
144
+
145
+ public function prepareOrderReview($quote)
146
+ {
147
+ $quote->setMayEditShippingAddress(false);
148
+ $quote->setMayEditShippingMethod(
149
+ '' == $quote->getPayment()->getAdditionalInformation('shipping_method')
150
+ );
151
+ $this->ignoreAddressValidation($quote);
152
+ $quote->collectTotals()->save();
153
+ }
154
+
155
+ /**
156
+ * Place the order when customer returned from altpayment service
157
+ * Until this moment all quote data must be valid
158
+ *
159
+ * @param string $token
160
+ * @param string $shippingMethodCode
161
+ */
162
+ public function place($quote, $token, $shippingMethodCode = null)
163
+ {
164
+ if ($shippingMethodCode) {
165
+ $this->updateShippingMethod($shippingMethodCode);
166
+ }
167
+
168
+ $isNewCustomer = false;
169
+ switch ($this->getCheckoutMethod($quote)) {
170
+ case Mage_Checkout_Model_Type_Onepage::METHOD_GUEST:
171
+ $quote = $this->_prepareGuestQuote($quote);
172
+ break;
173
+ case Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER:
174
+ $quote = $this->_prepareNewCustomerQuote($quote);
175
+ $isNewCustomer = true;
176
+ break;
177
+ default:
178
+ $quote = $this->_prepareCustomerQuote($quote);
179
+ break;
180
+ }
181
+
182
+ $this->ignoreAddressValidation($quote);
183
+ $quote->collectTotals();
184
+ $service = Mage::getModel('sales/service_quote', $quote);
185
+ $service->submitAll();
186
+ $quote->save();
187
+
188
+ if ($isNewCustomer) {
189
+ try {
190
+ $this->_involveNewCustomer();
191
+ } catch (Exception $e) {
192
+ Mage::logException($e);
193
+ }
194
+ }
195
+
196
+ /** @var $order Mage_Sales_Model_Order */
197
+ $order = $service->getOrder();
198
+ if (!$order) {
199
+ return false;
200
+ }
201
+
202
+ switch ($order->getState()) {
203
+ // even after placement altpayment service can disallow to authorize/capture,
204
+ // but will wait until bank transfers money
205
+ case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
206
+ // TODO
207
+ break;
208
+ // regular placement, when everything is ok
209
+ case Mage_Sales_Model_Order::STATE_PROCESSING:
210
+ case Mage_Sales_Model_Order::STATE_COMPLETE:
211
+ case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
212
+ $order->sendNewOrderEmail();
213
+ break;
214
+ }
215
+ return $order;
216
+ }
217
+
218
+ public function authenticate(
219
+ $orderId,
220
+ $oauthToken,
221
+ $oauthVerifier,
222
+ $payload,
223
+ $resourceUrl,
224
+ $orderData = null
225
+ ) {
226
+ return $this->getService()->authenticate(
227
+ $orderId,
228
+ $oauthToken,
229
+ $oauthVerifier,
230
+ $payload,
231
+ $resourceUrl,
232
+ $orderData
233
+ );
234
+ }
235
+
236
+ /**
237
+ * Make sure addresses will be saved without validation errors
238
+ */
239
+ public function ignoreAddressValidation($quote)
240
+ {
241
+ $quote->getBillingAddress()->setShouldIgnoreValidation(true);
242
+ if (!$quote->getIsVirtual()) {
243
+ $quote->getShippingAddress()->setShouldIgnoreValidation(true);
244
+ }
245
+ }
246
+
247
+ /**
248
+ * Get checkout method
249
+ *
250
+ * @return string
251
+ */
252
+ protected function getCheckoutMethod($quote)
253
+ {
254
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
255
+ return Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER;
256
+ }
257
+ if (!$quote->getCheckoutMethod()) {
258
+ if (Mage::helper('checkout')->isAllowedGuestCheckout($quote)) {
259
+ $quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST);
260
+ } else {
261
+ $quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER);
262
+ }
263
+ }
264
+ return $quote->getCheckoutMethod();
265
+ }
266
+
267
+ protected function getCheckoutDetails($token)
268
+ {
269
+ return $this->getService()->sessionInfo($token);
270
+ }
271
+
272
+ /**
273
+ * Prepare quote for guest checkout order submit
274
+ */
275
+ protected function _prepareGuestQuote($quote)
276
+ {
277
+ $quote->setCustomerId(null)
278
+ ->setCustomerEmail($quote->getBillingAddress()->getEmail())
279
+ ->setCustomerIsGuest(true)
280
+ ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
281
+ return $quote;
282
+ }
283
+
284
+ /**
285
+ * Checks if customer with email coming from Express checkout exists
286
+ *
287
+ * @return int
288
+ */
289
+ protected function _lookupCustomerId($quote)
290
+ {
291
+ return Mage::getModel('customer/customer')
292
+ ->setWebsiteId(Mage::app()->getWebsite()->getId())
293
+ ->loadByEmail($quote->getCustomerEmail())
294
+ ->getId();
295
+ }
296
+
297
+ /**
298
+ * Prepare quote for customer registration and customer order submit
299
+ * and restore magento customer data from quote
300
+ */
301
+ protected function _prepareNewCustomerQuote($quote)
302
+ {
303
+ $billing = $quote->getBillingAddress();
304
+ $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
305
+
306
+ $customerId = $this->_lookupCustomerId($quote);
307
+ if ($customerId) {
308
+ Mage::getSingleton('customer/session')->loginById($customerId);
309
+ return $this->_prepareCustomerQuote($quote);
310
+ }
311
+
312
+ $customer = $quote->getCustomer();
313
+ /** @var $customer Mage_Customer_Model_Customer */
314
+ $customerBilling = $billing->exportCustomerAddress();
315
+ $customer->addAddress($customerBilling);
316
+ $billing->setCustomerAddress($customerBilling);
317
+ $customerBilling->setIsDefaultBilling(true);
318
+ if ($shipping && !$shipping->getSameAsBilling()) {
319
+ $customerShipping = $shipping->exportCustomerAddress();
320
+ $customer->addAddress($customerShipping);
321
+ $shipping->setCustomerAddress($customerShipping);
322
+ $customerShipping->setIsDefaultShipping(true);
323
+ } elseif ($shipping) {
324
+ $customerBilling->setIsDefaultShipping(true);
325
+ }
326
+
327
+ if ($quote->getCustomerDob() && !$billing->getCustomerDob()) {
328
+ $billing->setCustomerDob($quote->getCustomerDob());
329
+ }
330
+
331
+ if ($quote->getCustomerTaxvat() && !$billing->getCustomerTaxvat()) {
332
+ $billing->setCustomerTaxvat($quote->getCustomerTaxvat());
333
+ }
334
+
335
+ if ($quote->getCustomerGender() && !$billing->getCustomerGender()) {
336
+ $billing->setCustomerGender($quote->getCustomerGender());
337
+ }
338
+
339
+ Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer);
340
+ $customer->setEmail($quote->getCustomerEmail());
341
+ $customer->setPrefix($quote->getCustomerPrefix());
342
+ $customer->setFirstname($quote->getCustomerFirstname());
343
+ $customer->setMiddlename($quote->getCustomerMiddlename());
344
+ $customer->setLastname($quote->getCustomerLastname());
345
+ $customer->setSuffix($quote->getCustomerSuffix());
346
+ $customer->setPassword($customer->decryptPassword($quote->getPasswordHash()));
347
+ $customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
348
+ $customer->save();
349
+ $quote->setCustomer($customer);
350
+
351
+ return $quote;
352
+ }
353
+
354
+ /**
355
+ * Prepare quote for customer order submit
356
+ */
357
+ protected function _prepareCustomerQuote($quote)
358
+ {
359
+ $billing = $quote->getBillingAddress();
360
+ $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
361
+
362
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
363
+ if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
364
+ $customerBilling = $billing->exportCustomerAddress();
365
+ $customer->addAddress($customerBilling);
366
+ $billing->setCustomerAddress($customerBilling);
367
+ }
368
+ if ($shipping && ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling())
369
+ || (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook()))) {
370
+ $customerShipping = $shipping->exportCustomerAddress();
371
+ $customer->addAddress($customerShipping);
372
+ $shipping->setCustomerAddress($customerShipping);
373
+ }
374
+
375
+ if (isset($customerBilling) && !$customer->getDefaultBilling()) {
376
+ $customerBilling->setIsDefaultBilling(true);
377
+ }
378
+ if ($shipping && isset($customerBilling) && !$customer->getDefaultShipping() && $shipping->getSameAsBilling()) {
379
+ $customerBilling->setIsDefaultShipping(true);
380
+ } elseif ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
381
+ $customerShipping->setIsDefaultShipping(true);
382
+ }
383
+ $quote->setCustomer($customer);
384
+
385
+ return $quote;
386
+ }
387
+
388
+ protected function exportLineItems($cart)
389
+ {
390
+ if (!$cart) {
391
+ return;
392
+ }
393
+
394
+ // add cart line items
395
+ $items = $cart->getItems();
396
+ if (empty($items)) {
397
+ return;
398
+ }
399
+
400
+ $result = array();
401
+ foreach ($items as $item) {
402
+ $lineItem = new HpsLineItem();
403
+ $lineItem->number = $item->getDataUsingMethod('id');
404
+ $lineItem->quantity = $item->getDataUsingMethod('qty');
405
+ $lineItem->name = $item->getDataUsingMethod('name');
406
+ $lineItem->amount = $item->getDataUsingMethod('amount');
407
+ $result[] = $lineItem;
408
+ }
409
+ return $result;
410
+ }
411
+
412
+ protected function getService()
413
+ {
414
+ throw new Exception('AltPayment service not configured');
415
+ }
416
+ }
app/code/community/Hps/Securesubmit/Helper/Data.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
  class Hps_Securesubmit_Helper_Data extends Mage_Core_Helper_Abstract
3
  {
4
  const XML_PATH_PAYMENT_HPS_SECURESUBMIT_USE_HTTP_PROXY = 'payment/hps_securesubmit/use_http_proxy';
@@ -16,14 +23,24 @@ class Hps_Securesubmit_Helper_Data extends Mage_Core_Helper_Abstract
16
  return $cardCollection;
17
  }
18
 
19
- public function saveMultiToken($token,$cardData,$cardType)
 
 
 
 
 
 
 
20
  {
21
  $_session = Mage::getSingleton('customer/session');
22
  $_loggedIn = $_session->isLoggedIn();
23
 
24
- if($_loggedIn){
25
- $_customerId = $_session->getCustomer()->getId();
26
-
 
 
 
27
  $storedCard = Mage::getModel('hps_securesubmit/storedcard');
28
  $storedCard->setDt(Varien_Date::now())
29
  ->setCustomerId($_customerId)
1
  <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
  class Hps_Securesubmit_Helper_Data extends Mage_Core_Helper_Abstract
10
  {
11
  const XML_PATH_PAYMENT_HPS_SECURESUBMIT_USE_HTTP_PROXY = 'payment/hps_securesubmit/use_http_proxy';
23
  return $cardCollection;
24
  }
25
 
26
+ /**
27
+ * @param string $token
28
+ * @param HpsCreditCard $cardData
29
+ * @param string $cardType
30
+ * @param integer|null $customerId
31
+ * @return Hps_Securesubmit_Model_Storedcard
32
+ */
33
+ public function saveMultiToken($token,$cardData,$cardType, $customerId = null)
34
  {
35
  $_session = Mage::getSingleton('customer/session');
36
  $_loggedIn = $_session->isLoggedIn();
37
 
38
+ if($_loggedIn || $customerId != null){
39
+ if($customerId == null){
40
+ $_customerId = $_session->getCustomer()->getId();
41
+ }else{
42
+ $_customerId = $customerId;
43
+ }
44
  $storedCard = Mage::getModel('hps_securesubmit/storedcard');
45
  $storedCard->setDt(Varien_Date::now())
46
  ->setCustomerId($_customerId)
app/code/community/Hps/Securesubmit/Helper/Masterpass.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+ require_once Mage::getBaseDir('lib').DS.'SecureSubmit'.DS.'Hps.php';
9
+
10
+ class Hps_Securesubmit_Helper_Masterpass extends Hps_Securesubmit_Helper_Altpayment_Abstract
11
+ {
12
+ protected $_methodCode = 'hps_masterpass';
13
+
14
+ public function returnFromMasterPass(
15
+ $status,
16
+ $orderId,
17
+ $oauthToken,
18
+ $oauthVerifier,
19
+ $payload,
20
+ $checkoutResourceUrl,
21
+ $pairingToken,
22
+ $pairingVerifier
23
+ ) {
24
+ $data = null;
25
+
26
+ try {
27
+ $orderData = new HpsOrderData();
28
+ $orderData->transactionStatus = $status;
29
+ if ($pairingToken !== '' && $pairingVerifier !== '') {
30
+ $orderData->pairingToken = $pairingToken;
31
+ $orderData->pairingVerifier = $pairingVerifier;
32
+ $orderData->checkoutType = HpsCentinelCheckoutType::PAIRING_CHECKOUT;
33
+ }
34
+
35
+ // Authenticate the request with the information we've gathered
36
+ $response = $this->getService()->authenticate(
37
+ $orderId,
38
+ $oauthToken,
39
+ $oauthVerifier,
40
+ $payload,
41
+ $checkoutResourceUrl,
42
+ $orderData
43
+ );
44
+
45
+ if ('0' !== $response->errorNumber) {
46
+ throw new Exception();
47
+ }
48
+
49
+ $data = (object)array_merge((array)$response, array(
50
+ 'status' => $status,
51
+ ));
52
+ } catch (Exception $e) {
53
+ $data = false;
54
+ }
55
+ return $data;
56
+ }
57
+
58
+ public function preApproval($longAccessToken = '')
59
+ {
60
+ if ($longAccessToken == '') {
61
+ return false;
62
+ }
63
+
64
+ return $this->getService()->preApproval($longAccessToken);
65
+ }
66
+
67
+ protected function getService()
68
+ {
69
+ $config = new HpsCentinelConfig();
70
+ if (!Mage::getStoreConfig('payment/hps_masterpass/use_sandbox')) {
71
+ $config->serviceUri = "https://api-uat.heartlandportico.com/paymentserver.v1/PosGatewayService.asmx";
72
+ }
73
+ $config->processorId = Mage::getStoreConfig('payment/hps_masterpass/processor_id');
74
+ $config->merchantId = Mage::getStoreConfig('payment/hps_masterpass/merchant_id');
75
+ $config->transactionPwd = Mage::getStoreConfig('payment/hps_masterpass/transaction_pwd');
76
+ return new HpsMasterPassService($config);
77
+ }
78
+ }
app/code/community/Hps/Securesubmit/Helper/Paypal.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+ require_once Mage::getBaseDir('lib').DS.'SecureSubmit'.DS.'Hps.php';
9
+
10
+ class Hps_Securesubmit_Helper_Paypal extends Hps_Securesubmit_Helper_Altpayment_Abstract
11
+ {
12
+ protected $_methodCode = 'hps_paypal';
13
+
14
+ /**
15
+ * Reserve order ID for specified quote and start checkout on PayPal
16
+ *
17
+ * @param string $returnUrl
18
+ * @param string $cancelUrl
19
+ * @param array|null $params
20
+ * @return mixed
21
+ */
22
+ public function start($quote, $returnUrl, $cancelUrl, $params = null)
23
+ {
24
+ $button = null;
25
+ $credit = null;
26
+ if (!empty($params)) {
27
+ if (isset($params['button'])) {
28
+ $button = $params['button'];
29
+ }
30
+ if (isset($params['credit'])) {
31
+ $credit = $params['credit'];
32
+ }
33
+ }
34
+
35
+ $response = parent::start($quote, $returnUrl, $cancelUrl, $credit);
36
+
37
+ $token = $response->sessionId;
38
+ $this->_redirectUrl = $response->redirectUrl;
39
+
40
+ // Set flag that we came from Express Checkout button
41
+ if (!empty($button)) {
42
+ $quote->getPayment()->setAdditionalInformation('button', 1);
43
+ } elseif ($quote->getPayment()->hasAdditionalInformation('button')) {
44
+ $quote->getPayment()->unsAdditionalInformation('button');
45
+ }
46
+
47
+ // Set flag that we came from Credit Checkout button
48
+ $quote->getPayment()->setAdditionalInformation('code', $this->_methodCode);
49
+ if (!empty($credit)) {
50
+ $quote->getPayment()->setAdditionalInformation('credit', 1);
51
+ $quote->getPayment()->setAdditionalInformation('code', $this->_methodCode . '_credit');
52
+ } elseif ($quote->getPayment()->hasAdditionalInformation('credit')) {
53
+ $quote->getPayment()->unsAdditionalInformation('credit');
54
+ $quote->getPayment()->setAdditionalInformation('code', $this->_methodCode);
55
+ }
56
+
57
+ $quote->getPayment()->save();
58
+ return $token;
59
+ }
60
+
61
+ /**
62
+ * Update quote when returned from PayPal
63
+ * rewrite billing address by paypal
64
+ * save old billing address for new customer
65
+ * export shipping address in case address absence
66
+ *
67
+ * @param string $token
68
+ */
69
+ public function returnFromPaypal($quote, $token, $payerId)
70
+ {
71
+ $response = $this->getCheckoutDetails($token);
72
+
73
+ $this->ignoreAddressValidation($quote);
74
+ $shippingAddress = null;
75
+ $billingAddress = null;
76
+
77
+ // import shipping address
78
+ $exportedShippingAddress = $response->shipping;
79
+ if (!$quote->getIsVirtual()) {
80
+ $shippingAddress = $quote->getShippingAddress();
81
+ if ($shippingAddress) {
82
+ if ($exportedShippingAddress
83
+ && $quote->getPayment()->getAdditionalInformation('button') == 1
84
+ ) {
85
+ $regionModel = Mage::getModel('directory/region')->loadByCode($exportedShippingAddress->address->state, $exportedShippingAddress->address->country);
86
+ $shippingAddress->setData('street', $exportedShippingAddress->address->address);
87
+ $shippingAddress->setCity($exportedShippingAddress->address->city);
88
+ $shippingAddress->setRegionId($regionModel->getId());
89
+ $shippingAddress->setPostcode($exportedShippingAddress->address->zip);
90
+ $shippingAddress->setCountryId($exportedShippingAddress->address->country);
91
+ $shippingAddress->setPrefix(null);
92
+ $shippingAddress->setFirstname($response->buyer->firstName);
93
+ $shippingAddress->setMiddlename(null);
94
+ $shippingAddress->setLastname($response->buyer->lastName);
95
+ $shippingAddress->setEmail($response->buyer->emailAddress);
96
+ $shippingAddress->setSuffix(null);
97
+ $shippingAddress->setCollectShippingRates(true);
98
+ $shippingAddress->setSameAsBilling(0);
99
+ }
100
+ }
101
+ }
102
+
103
+ // import billing address
104
+ $portBillingFromShipping = $quote->getPayment()->getAdditionalInformation('button') == 1
105
+ && !$quote->isVirtual();
106
+ if ($portBillingFromShipping) {
107
+ $billingAddress = clone $shippingAddress;
108
+ $billingAddress->unsAddressId()
109
+ ->unsAddressType();
110
+ $data = $billingAddress->getData();
111
+ $data['save_in_address_book'] = 0;
112
+ $quote->getBillingAddress()->addData($data);
113
+ $quote->getShippingAddress()->setSameAsBilling(1);
114
+ } else {
115
+ $billingAddress = $quote->getBillingAddress();
116
+ }
117
+ $quote->setBillingAddress($billingAddress);
118
+ $quote->save();
119
+
120
+ // import payment info
121
+ $payment = $quote->getPayment();
122
+ $payment->setMethod($payment->getAdditionalInformation('code'));
123
+ $payment->setAdditionalInformation('payer_id', $payerId)
124
+ ->setAdditionalInformation('checkout_token', $token)
125
+ ;
126
+ $quote->collectTotals()->save();
127
+ }
128
+
129
+ public function getRedirectUrl()
130
+ {
131
+ return $this->_redirectUrl;
132
+ }
133
+
134
+ /**
135
+ * Check whether order review has enough data to initialize
136
+ *
137
+ * @param $token
138
+ * @throws Mage_Core_Exception
139
+ */
140
+ public function prepareOrderReview($quote, $token = null)
141
+ {
142
+ $payment = $quote->getPayment();
143
+ if (!$payment || !$payment->getAdditionalInformation('payer_id')) {
144
+ Mage::throwException(Mage::helper('hps_securesubmit')->__('Payer is not identified.'));
145
+ }
146
+ parent::prepareOrderReview($quote);
147
+ }
148
+
149
+ protected function getService()
150
+ {
151
+ $config = new HpsServicesConfig();
152
+ if (Mage::getStoreConfig('payment/hps_paypal/use_sandbox')) {
153
+ $config->username = Mage::getStoreConfig('payment/hps_paypal/username');
154
+ $config->password = Mage::getStoreConfig('payment/hps_paypal/password');
155
+ $config->deviceId = Mage::getStoreConfig('payment/hps_paypal/device_id');
156
+ $config->licenseId = Mage::getStoreConfig('payment/hps_paypal/license_id');
157
+ $config->siteId = Mage::getStoreConfig('payment/hps_paypal/site_id');
158
+ $config->soapServiceUri = "https://api-uat.heartlandportico.com/paymentserver.v1/PosGatewayService.asmx";
159
+ } else {
160
+ $config->secretApiKey = Mage::getStoreConfig('payment/hps_paypal/secretapikey');
161
+ }
162
+ return new HpsPayPalService($config);
163
+ }
164
+ }
app/code/community/Hps/Securesubmit/Model/{Paypal → Altpayment}/Cart.php RENAMED
@@ -6,22 +6,13 @@
6
  * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
  */
8
 
9
- /**
10
- * PayPal-specific model for shopping cart items and totals
11
- * The main idea is to accommodate all possible totals into PayPal-compatible 4 totals and line items
12
- */
13
- class Hps_Securesubmit_Model_Paypal_Cart
14
  {
15
- /**
16
- * Totals that PayPal suppports when passing shopping cart
17
- *
18
- * @var string
19
- */
20
  const TOTAL_SUBTOTAL = 'subtotal';
21
  const TOTAL_DISCOUNT = 'discount';
22
  const TOTAL_TAX = 'tax';
23
  const TOTAL_SHIPPING = 'shipping';
24
-
25
  /**
26
  * Order or quote instance
27
  *
@@ -29,7 +20,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
29
  * @var Mage_Sales_Model_Quote
30
  */
31
  protected $_salesEntity = null;
32
-
33
  /**
34
  * Rendered cart items
35
  * Array of Varien_Objects
@@ -37,7 +27,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
37
  * @var array
38
  */
39
  protected $_items = array();
40
-
41
  /**
42
  * Rendered cart totals
43
  * Associative array with the keys from constants above
@@ -45,7 +34,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
45
  * @var array
46
  */
47
  protected $_totals = array();
48
-
49
  /**
50
  * Set of optional descriptions for the item that may replace a total and composed of several amounts
51
  * Array of strings
@@ -53,28 +41,24 @@ class Hps_Securesubmit_Model_Paypal_Cart
53
  * @var array
54
  */
55
  protected $_totalLineItemDescriptions = array();
56
-
57
  /**
58
  * Lazy initialization indicator for rendering
59
  *
60
  * @var bool
61
  */
62
  protected $_shouldRender = true;
63
-
64
  /**
65
  * Validation result for the rendered cart items
66
  *
67
  * @var bool
68
  */
69
  protected $_areItemsValid = false;
70
-
71
  /**
72
  * Validation result for the rendered totals
73
  *
74
  * @var bool
75
  */
76
  protected $_areTotalsValid = false;
77
-
78
  /**
79
  * Whether to render discount total as a line item
80
  * Use case: WPP
@@ -82,7 +66,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
82
  * @var bool
83
  */
84
  protected $_isDiscountAsItem = false;
85
-
86
  /**
87
  * Whether to render shipping total as a line item
88
  * Use case: WPS
@@ -90,7 +73,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
90
  * @var bool
91
  */
92
  protected $_isShippingAsItem = false;
93
-
94
  /**
95
  * Require instance of an order or a quote
96
  *
@@ -106,7 +88,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
106
  throw new Exception('Invalid sales entity provided.');
107
  }
108
  }
109
-
110
  /**
111
  * Getter for the current sales entity
112
  *
@@ -117,7 +98,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
117
  {
118
  return $this->_salesEntity;
119
  }
120
-
121
  /**
122
  * Render and get line items
123
  * By default returns false if the items are invalid
@@ -133,7 +113,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
133
  }
134
  return $this->_items;
135
  }
136
-
137
  /**
138
  * Render and get totals
139
  * If the totals are invalid for any reason, they will be merged into one amount (subtotal is utilized for it)
@@ -145,7 +124,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
145
  public function getTotals($mergeDiscount = false)
146
  {
147
  $this->_render();
148
-
149
  // cut down totals to one total if they are invalid
150
  if (!$this->_areTotalsValid) {
151
  $totals = array(
@@ -168,7 +146,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
168
  }
169
  return $this->_totals;
170
  }
171
-
172
  /**
173
  * Add a line item
174
  *
@@ -192,7 +169,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
192
  $this->_items[] = $item;
193
  return $item;
194
  }
195
-
196
  /**
197
  * Remove item from cart by identifier
198
  *
@@ -209,7 +185,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
209
  }
210
  return false;
211
  }
212
-
213
  /**
214
  * Compound the specified amount with the specified total
215
  *
@@ -229,7 +204,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
229
  }
230
  return $this;
231
  }
232
-
233
  /**
234
  * Get/Set whether to render the discount total as a line item
235
  *
@@ -240,7 +214,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
240
  {
241
  return $this->_totalAsItem('_isDiscountAsItem', $setValue);
242
  }
243
-
244
  /**
245
  * Get/Set whether to render the discount total as a line item
246
  *
@@ -251,7 +224,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
251
  {
252
  return $this->_totalAsItem('_isShippingAsItem', $setValue);
253
  }
254
-
255
  /**
256
  * (re)Render all items and totals
257
  */
@@ -260,7 +232,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
260
  if (!$this->_shouldRender) {
261
  return;
262
  }
263
-
264
  // regular items from the sales entity
265
  $this->_items = array();
266
  foreach ($this->_salesEntity->getAllItems() as $item) {
@@ -270,7 +241,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
270
  }
271
  end($this->_items);
272
  $lastRegularItemKey = key($this->_items);
273
-
274
  // regular totals
275
  $shippingDescription = '';
276
  if ($this->_salesEntity instanceof Mage_Sales_Model_Order) {
@@ -295,15 +265,12 @@ class Hps_Securesubmit_Model_Paypal_Cart
295
  $this->_applyHiddenTaxWorkaround($address);
296
  }
297
  $originalDiscount = $this->_totals[self::TOTAL_DISCOUNT];
298
-
299
  // arbitrary items, total modifications
300
  Mage::dispatchEvent('paypal_prepare_line_items', array('paypal_cart' => $this));
301
-
302
  // distinguish original discount among the others
303
  if ($originalDiscount > 0.0001 && isset($this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT])) {
304
  $this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT][] = Mage::helper('sales')->__('Discount (%s)', Mage::app()->getStore()->convertPrice($originalDiscount, true, false));
305
  }
306
-
307
  // discount, shipping as items
308
  if ($this->_isDiscountAsItem && $this->_totals[self::TOTAL_DISCOUNT]) {
309
  $this->addItem(Mage::helper('paypal')->__('Discount'), 1, -1.00 * $this->_totals[self::TOTAL_DISCOUNT],
@@ -316,23 +283,19 @@ class Hps_Securesubmit_Model_Paypal_Cart
316
  $shippingItemId
317
  );
318
  }
319
-
320
  // compound non-regular items into subtotal
321
  foreach ($this->_items as $key => $item) {
322
  if ($key > $lastRegularItemKey && $item->getAmount() != 0) {
323
  $this->_totals[self::TOTAL_SUBTOTAL] += $item->getAmount();
324
  }
325
  }
326
-
327
  $this->_validate();
328
  // if cart items are invalid, prepare cart for transfer without line items
329
  if (!$this->_areItemsValid) {
330
  $this->removeItem($shippingItemId);
331
  }
332
-
333
  $this->_shouldRender = false;
334
  }
335
-
336
  /**
337
  * Merge multiple descriptions by a total code into a string
338
  *
@@ -356,7 +319,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
356
  }
357
  return implode($glue, $result);
358
  }
359
-
360
  /**
361
  * Check the line items and totals according to PayPal business logic limitations
362
  */
@@ -364,9 +326,7 @@ class Hps_Securesubmit_Model_Paypal_Cart
364
  {
365
  $this->_areItemsValid = true;
366
  $this->_areTotalsValid = false;
367
-
368
  $referenceAmount = $this->_salesEntity->getBaseGrandTotal();
369
-
370
  $itemsSubtotal = 0;
371
  foreach ($this->_items as $i) {
372
  $itemsSubtotal = $itemsSubtotal + $i['qty'] * $i['amount'];
@@ -387,17 +347,14 @@ class Hps_Securesubmit_Model_Paypal_Cart
387
  $adjustment = $sum - $referenceAmount;
388
  $this->_totals[self::TOTAL_SUBTOTAL] = $this->_totals[self::TOTAL_SUBTOTAL] - $adjustment;
389
  }
390
-
391
  // PayPal requires to have discount less than items subtotal
392
  if (!$this->_isDiscountAsItem) {
393
  $this->_areTotalsValid = round($this->_totals[self::TOTAL_DISCOUNT], 4) < round($itemsSubtotal, 4);
394
  } else {
395
  $this->_areTotalsValid = $itemsSubtotal > 0.00001;
396
  }
397
-
398
  $this->_areItemsValid = $this->_areItemsValid && $this->_areTotalsValid;
399
  }
400
-
401
  /**
402
  * Check whether items are valid
403
  *
@@ -407,7 +364,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
407
  {
408
  return $this->_areItemsValid;
409
  }
410
-
411
  /**
412
  * Add a usual line item with amount and qty
413
  *
@@ -431,17 +387,14 @@ class Hps_Securesubmit_Model_Paypal_Cart
431
  $subAggregatedLabel = ' x' . $qty;
432
  $qty = 1;
433
  }
434
-
435
  // aggregate item price if item qty * price does not match row total
436
  if (($amount * $qty) != $salesItem->getBaseRowTotal()) {
437
  $amount = (float) $salesItem->getBaseRowTotal();
438
  $subAggregatedLabel = ' x' . $qty;
439
  $qty = 1;
440
  }
441
-
442
  return $this->addItem($salesItem->getName() . $subAggregatedLabel, $qty, $amount, $salesItem->getSku());
443
  }
444
-
445
  /**
446
  * Get/Set for the specified variable.
447
  * If the value changes, the re-rendering is commenced
@@ -461,7 +414,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
461
  }
462
  return $this->$var;
463
  }
464
-
465
  /**
466
  * Add "hidden" discount and shipping tax
467
  *
@@ -488,7 +440,6 @@ class Hps_Securesubmit_Model_Paypal_Cart
488
  $this->_totals[self::TOTAL_TAX] += (float)$salesEntity->getBaseHiddenTaxAmount();
489
  $this->_totals[self::TOTAL_TAX] += (float)$salesEntity->getBaseShippingHiddenTaxAmount();
490
  }
491
-
492
  /**
493
  * Check whether any item has negative amount
494
  *
6
  * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
  */
8
 
9
+ class Hps_Securesubmit_Model_Altpayment_Cart
 
 
 
 
10
  {
11
+
 
 
 
 
12
  const TOTAL_SUBTOTAL = 'subtotal';
13
  const TOTAL_DISCOUNT = 'discount';
14
  const TOTAL_TAX = 'tax';
15
  const TOTAL_SHIPPING = 'shipping';
 
16
  /**
17
  * Order or quote instance
18
  *
20
  * @var Mage_Sales_Model_Quote
21
  */
22
  protected $_salesEntity = null;
 
23
  /**
24
  * Rendered cart items
25
  * Array of Varien_Objects
27
  * @var array
28
  */
29
  protected $_items = array();
 
30
  /**
31
  * Rendered cart totals
32
  * Associative array with the keys from constants above
34
  * @var array
35
  */
36
  protected $_totals = array();
 
37
  /**
38
  * Set of optional descriptions for the item that may replace a total and composed of several amounts
39
  * Array of strings
41
  * @var array
42
  */
43
  protected $_totalLineItemDescriptions = array();
 
44
  /**
45
  * Lazy initialization indicator for rendering
46
  *
47
  * @var bool
48
  */
49
  protected $_shouldRender = true;
 
50
  /**
51
  * Validation result for the rendered cart items
52
  *
53
  * @var bool
54
  */
55
  protected $_areItemsValid = false;
 
56
  /**
57
  * Validation result for the rendered totals
58
  *
59
  * @var bool
60
  */
61
  protected $_areTotalsValid = false;
 
62
  /**
63
  * Whether to render discount total as a line item
64
  * Use case: WPP
66
  * @var bool
67
  */
68
  protected $_isDiscountAsItem = false;
 
69
  /**
70
  * Whether to render shipping total as a line item
71
  * Use case: WPS
73
  * @var bool
74
  */
75
  protected $_isShippingAsItem = false;
 
76
  /**
77
  * Require instance of an order or a quote
78
  *
88
  throw new Exception('Invalid sales entity provided.');
89
  }
90
  }
 
91
  /**
92
  * Getter for the current sales entity
93
  *
98
  {
99
  return $this->_salesEntity;
100
  }
 
101
  /**
102
  * Render and get line items
103
  * By default returns false if the items are invalid
113
  }
114
  return $this->_items;
115
  }
 
116
  /**
117
  * Render and get totals
118
  * If the totals are invalid for any reason, they will be merged into one amount (subtotal is utilized for it)
124
  public function getTotals($mergeDiscount = false)
125
  {
126
  $this->_render();
 
127
  // cut down totals to one total if they are invalid
128
  if (!$this->_areTotalsValid) {
129
  $totals = array(
146
  }
147
  return $this->_totals;
148
  }
 
149
  /**
150
  * Add a line item
151
  *
169
  $this->_items[] = $item;
170
  return $item;
171
  }
 
172
  /**
173
  * Remove item from cart by identifier
174
  *
185
  }
186
  return false;
187
  }
 
188
  /**
189
  * Compound the specified amount with the specified total
190
  *
204
  }
205
  return $this;
206
  }
 
207
  /**
208
  * Get/Set whether to render the discount total as a line item
209
  *
214
  {
215
  return $this->_totalAsItem('_isDiscountAsItem', $setValue);
216
  }
 
217
  /**
218
  * Get/Set whether to render the discount total as a line item
219
  *
224
  {
225
  return $this->_totalAsItem('_isShippingAsItem', $setValue);
226
  }
 
227
  /**
228
  * (re)Render all items and totals
229
  */
232
  if (!$this->_shouldRender) {
233
  return;
234
  }
 
235
  // regular items from the sales entity
236
  $this->_items = array();
237
  foreach ($this->_salesEntity->getAllItems() as $item) {
241
  }
242
  end($this->_items);
243
  $lastRegularItemKey = key($this->_items);
 
244
  // regular totals
245
  $shippingDescription = '';
246
  if ($this->_salesEntity instanceof Mage_Sales_Model_Order) {
265
  $this->_applyHiddenTaxWorkaround($address);
266
  }
267
  $originalDiscount = $this->_totals[self::TOTAL_DISCOUNT];
 
268
  // arbitrary items, total modifications
269
  Mage::dispatchEvent('paypal_prepare_line_items', array('paypal_cart' => $this));
 
270
  // distinguish original discount among the others
271
  if ($originalDiscount > 0.0001 && isset($this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT])) {
272
  $this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT][] = Mage::helper('sales')->__('Discount (%s)', Mage::app()->getStore()->convertPrice($originalDiscount, true, false));
273
  }
 
274
  // discount, shipping as items
275
  if ($this->_isDiscountAsItem && $this->_totals[self::TOTAL_DISCOUNT]) {
276
  $this->addItem(Mage::helper('paypal')->__('Discount'), 1, -1.00 * $this->_totals[self::TOTAL_DISCOUNT],
283
  $shippingItemId
284
  );
285
  }
 
286
  // compound non-regular items into subtotal
287
  foreach ($this->_items as $key => $item) {
288
  if ($key > $lastRegularItemKey && $item->getAmount() != 0) {
289
  $this->_totals[self::TOTAL_SUBTOTAL] += $item->getAmount();
290
  }
291
  }
 
292
  $this->_validate();
293
  // if cart items are invalid, prepare cart for transfer without line items
294
  if (!$this->_areItemsValid) {
295
  $this->removeItem($shippingItemId);
296
  }
 
297
  $this->_shouldRender = false;
298
  }
 
299
  /**
300
  * Merge multiple descriptions by a total code into a string
301
  *
319
  }
320
  return implode($glue, $result);
321
  }
 
322
  /**
323
  * Check the line items and totals according to PayPal business logic limitations
324
  */
326
  {
327
  $this->_areItemsValid = true;
328
  $this->_areTotalsValid = false;
 
329
  $referenceAmount = $this->_salesEntity->getBaseGrandTotal();
 
330
  $itemsSubtotal = 0;
331
  foreach ($this->_items as $i) {
332
  $itemsSubtotal = $itemsSubtotal + $i['qty'] * $i['amount'];
347
  $adjustment = $sum - $referenceAmount;
348
  $this->_totals[self::TOTAL_SUBTOTAL] = $this->_totals[self::TOTAL_SUBTOTAL] - $adjustment;
349
  }
 
350
  // PayPal requires to have discount less than items subtotal
351
  if (!$this->_isDiscountAsItem) {
352
  $this->_areTotalsValid = round($this->_totals[self::TOTAL_DISCOUNT], 4) < round($itemsSubtotal, 4);
353
  } else {
354
  $this->_areTotalsValid = $itemsSubtotal > 0.00001;
355
  }
 
356
  $this->_areItemsValid = $this->_areItemsValid && $this->_areTotalsValid;
357
  }
 
358
  /**
359
  * Check whether items are valid
360
  *
364
  {
365
  return $this->_areItemsValid;
366
  }
 
367
  /**
368
  * Add a usual line item with amount and qty
369
  *
387
  $subAggregatedLabel = ' x' . $qty;
388
  $qty = 1;
389
  }
 
390
  // aggregate item price if item qty * price does not match row total
391
  if (($amount * $qty) != $salesItem->getBaseRowTotal()) {
392
  $amount = (float) $salesItem->getBaseRowTotal();
393
  $subAggregatedLabel = ' x' . $qty;
394
  $qty = 1;
395
  }
 
396
  return $this->addItem($salesItem->getName() . $subAggregatedLabel, $qty, $amount, $salesItem->getSku());
397
  }
 
398
  /**
399
  * Get/Set for the specified variable.
400
  * If the value changes, the re-rendering is commenced
414
  }
415
  return $this->$var;
416
  }
 
417
  /**
418
  * Add "hidden" discount and shipping tax
419
  *
440
  $this->_totals[self::TOTAL_TAX] += (float)$salesEntity->getBaseHiddenTaxAmount();
441
  $this->_totals[self::TOTAL_TAX] += (float)$salesEntity->getBaseShippingHiddenTaxAmount();
442
  }
 
443
  /**
444
  * Check whether any item has negative amount
445
  *
app/code/community/Hps/Securesubmit/Model/Api/Abstract.php DELETED
@@ -1,581 +0,0 @@
1
- <?php
2
- /**
3
- * @category Hps
4
- * @package Hps_Securesubmit
5
- * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
- * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
- */
8
-
9
- /**
10
- * Abstract class for Paypal API wrappers
11
- *
12
- * @author Magento Core Team <core@magentocommerce.com>
13
- */
14
- abstract class Hps_Securesubmit_Model_Api_Abstract extends Varien_Object
15
- {
16
- /**
17
- * Config instance
18
- * @var Hps_Securesubmit_Model_Config
19
- */
20
- protected $_config = null;
21
-
22
- /**
23
- * Global private to public interface map
24
- * @var array
25
- */
26
- protected $_globalMap = array();
27
-
28
- /**
29
- * Filter callbacks for exporting $this data to API call
30
- *
31
- * @var array
32
- */
33
- protected $_exportToRequestFilters = array();
34
-
35
- /**
36
- * Filter callbacks for importing API result to $this data
37
- *
38
- * @var array
39
- */
40
- protected $_importFromRequestFilters = array();
41
-
42
- /**
43
- * Line items export to request mapping settings
44
- * @var array
45
- */
46
- protected $_lineItemExportItems = array();
47
- protected $_lineItemExportItemsFilters = array();
48
- protected $_lineItemTotalExportMap = array();
49
-
50
- /**
51
- * PayPal shopping cart instance
52
- *
53
- * @var Hps_Securesubmit_Model_Paypal_Cart
54
- */
55
- protected $_cart = null;
56
-
57
- /**
58
- * Shipping options export to request mapping settings
59
- * @var array
60
- */
61
- protected $_shippingOptionsExportItemsFormat = array();
62
-
63
- /**
64
- * Imported recurring profiles array
65
- *
66
- * @var array
67
- */
68
- protected $_recurringPaymentProfiles = array();
69
-
70
- /**
71
- * Fields that should be replaced in debug with '***'
72
- *
73
- * @var array
74
- */
75
- protected $_debugReplacePrivateDataKeys = array();
76
-
77
- /**
78
- * Return Paypal Api user name based on config data
79
- *
80
- * @return string
81
- */
82
- public function getApiUsername()
83
- {
84
- return $this->_config->apiUsername;
85
- }
86
-
87
- /**
88
- * Return Paypal Api password based on config data
89
- *
90
- * @return string
91
- */
92
- public function getApiPassword()
93
- {
94
- return $this->_config->apiPassword;
95
- }
96
-
97
- /**
98
- * Return Paypal Api signature based on config data
99
- *
100
- * @return string
101
- */
102
- public function getApiSignature()
103
- {
104
- return $this->_config->apiSignature;
105
- }
106
-
107
- /**
108
- * Return Paypal Api certificate based on config data
109
- *
110
- * @return string
111
- */
112
- public function getApiCertificate()
113
- {
114
- return $this->_config->getApiCertificate();
115
- }
116
-
117
- /**
118
- * BN code getter
119
- *
120
- * @return string
121
- */
122
- public function getBuildNotationCode()
123
- {
124
- return $this->_config->getBuildNotationCode();
125
- }
126
-
127
- /**
128
- * Return Paypal Api proxy status based on config data
129
- *
130
- * @return bool
131
- */
132
- public function getUseProxy()
133
- {
134
- return $this->_getDataOrConfig('use_proxy', false);
135
- }
136
-
137
- /**
138
- * Return Paypal Api proxy host based on config data
139
- *
140
- * @return string
141
- */
142
- public function getProxyHost()
143
- {
144
- return $this->_getDataOrConfig('proxy_host', '127.0.0.1');
145
- }
146
-
147
- /**
148
- * Return Paypal Api proxy port based on config data
149
- *
150
- * @return string
151
- */
152
- public function getProxyPort()
153
- {
154
- return $this->_getDataOrConfig('proxy_port', '808');
155
- }
156
-
157
- /**
158
- * @deprecated after 1.4.1.0
159
- *
160
- * @return bool
161
- */
162
- public function getDebug()
163
- {
164
- return $this->getDebugFlag();
165
- }
166
-
167
- /**
168
- * PayPal page CSS getter
169
- *
170
- * @return string
171
- */
172
- public function getPageStyle()
173
- {
174
- return $this->_getDataOrConfig('page_style');
175
- }
176
-
177
- /**
178
- * PayPal page header image URL getter
179
- *
180
- * @return string
181
- */
182
- public function getHdrimg()
183
- {
184
- return $this->_getDataOrConfig('paypal_hdrimg');
185
- }
186
-
187
- /**
188
- * PayPal page header border color getter
189
- *
190
- * @return string
191
- */
192
- public function getHdrbordercolor()
193
- {
194
- return $this->_getDataOrConfig('paypal_hdrbordercolor');
195
- }
196
-
197
- /**
198
- * PayPal page header background color getter
199
- *
200
- * @return string
201
- */
202
- public function getHdrbackcolor()
203
- {
204
- return $this->_getDataOrConfig('paypal_hdrbackcolor');
205
- }
206
-
207
- /**
208
- * PayPal page "payflow color" (?) getter
209
- *
210
- * @return string
211
- */
212
- public function getPayflowcolor()
213
- {
214
- return $this->_getDataOrConfig('paypal_payflowcolor');
215
- }
216
-
217
- /**
218
- * Payment action getter
219
- *
220
- * @return string
221
- */
222
- public function getPaymentAction()
223
- {
224
- return $this->_getDataOrConfig('payment_action');
225
- }
226
-
227
- /**
228
- * PayPal merchant email getter
229
- */
230
- public function getBusinessAccount()
231
- {
232
- return $this->_getDataOrConfig('business_account');
233
- }
234
-
235
- /**
236
- * Import $this public data to specified object or array
237
- *
238
- * @param array|Varien_Object $to
239
- * @param array $publicMap
240
- * @return array|Varien_Object
241
- */
242
- public function &import($to, array $publicMap = array())
243
- {
244
- return Varien_Object_Mapper::accumulateByMap(array($this, 'getDataUsingMethod'), $to, $publicMap);
245
- }
246
-
247
- /**
248
- * Export $this public data from specified object or array
249
- *
250
- * @param array|Varien_Object $from
251
- * @param array $publicMap
252
- * @return Hps_Securesubmit_Model_Api_Abstract
253
- */
254
- public function export($from, array $publicMap = array())
255
- {
256
- Varien_Object_Mapper::accumulateByMap($from, array($this, 'setDataUsingMethod'), $publicMap);
257
- return $this;
258
- }
259
-
260
- /**
261
- * Set PayPal cart instance
262
- *
263
- * @param Hps_Securesubmit_Model_Paypal_Cart $cart
264
- * @return Hps_Securesubmit_Model_Api_Abstract
265
- */
266
- public function setPaypalCart(Hps_Securesubmit_Model_Paypal_Cart $cart)
267
- {
268
- $this->_cart = $cart;
269
- return $this;
270
- }
271
-
272
- /**
273
- * Config instance setter
274
- * @param Hps_Securesubmit_Model_Config $config
275
- * @return Hps_Securesubmit_Model_Api_Abstract
276
- */
277
- public function setConfigObject(Hps_Securesubmit_Model_Config $config)
278
- {
279
- $this->_config = $config;
280
- return $this;
281
- }
282
-
283
- /**
284
- * Current locale code getter
285
- *
286
- * @return string
287
- */
288
- public function getLocaleCode()
289
- {
290
- return Mage::app()->getLocale()->getLocaleCode();
291
- }
292
-
293
- /**
294
- * Always take into accoun
295
- */
296
- public function getFraudManagementFiltersEnabled()
297
- {
298
- return 1;
299
- }
300
-
301
- /**
302
- * Set recurring profiles
303
- *
304
- * @param array $items
305
- * @return Hps_Securesubmit_Model_Api_Abstract
306
- */
307
- public function addRecurringPaymentProfiles(array $items)
308
- {
309
- if ($items) {
310
- $this->_recurringPaymentProfiles = $items;
311
- }
312
- return $this;
313
- }
314
-
315
- /**
316
- * Export $this public data to private request array
317
- *
318
- * @param array $internalRequestMap
319
- * @param array $request
320
- * @return array
321
- */
322
- protected function &_exportToRequest(array $privateRequestMap, array $request = array())
323
- {
324
- $map = array();
325
- foreach ($privateRequestMap as $key) {
326
- if (isset($this->_globalMap[$key])) {
327
- $map[$this->_globalMap[$key]] = $key;
328
- }
329
- }
330
- $result = Varien_Object_Mapper::accumulateByMap(array($this, 'getDataUsingMethod'), $request, $map);
331
- foreach ($privateRequestMap as $key) {
332
- if (isset($this->_exportToRequestFilters[$key]) && isset($result[$key])) {
333
- $callback = $this->_exportToRequestFilters[$key];
334
- $privateKey = $result[$key];
335
- $publicKey = $map[$this->_globalMap[$key]];
336
- $result[$key] = call_user_func(array($this, $callback), $privateKey, $publicKey);
337
- }
338
- }
339
- return $result;
340
- }
341
-
342
- /**
343
- * Import $this public data from a private response array
344
- *
345
- * @param array $privateResponseMap
346
- * @param array $response
347
- */
348
- protected function _importFromResponse(array $privateResponseMap, array $response)
349
- {
350
- $map = array();
351
- foreach ($privateResponseMap as $key) {
352
- if (isset($this->_globalMap[$key])) {
353
- $map[$key] = $this->_globalMap[$key];
354
- }
355
- if (isset($response[$key]) && isset($this->_importFromRequestFilters[$key])) {
356
- $callback = $this->_importFromRequestFilters[$key];
357
- $response[$key] = call_user_func(array($this, $callback), $response[$key], $key, $map[$key]);
358
- }
359
- }
360
- Varien_Object_Mapper::accumulateByMap($response, array($this, 'setDataUsingMethod'), $map);
361
- }
362
-
363
- /**
364
- * Prepare line items request
365
- *
366
- * Returns true if there were line items added
367
- *
368
- * @param array &$request
369
- * @param int $i
370
- * @return true|bool
371
- */
372
- protected function _exportLineItems()
373
- {
374
- if (!$this->_cart) {
375
- return;
376
- }
377
-
378
- // add cart line items
379
- $items = $this->_cart->getItems();
380
- if (empty($items) || !$this->getIsLineItemsEnabled()) {
381
- return;
382
- }
383
- $result = array();
384
- foreach ($items as $item) {
385
- $lineItem = new HpsLineItem();
386
- foreach ($this->_lineItemExportItems as $publicKey) {
387
- $value = $item->getDataUsingMethod($publicKey);
388
- switch ($publicKey) {
389
- case 'id':
390
- $lineItem->number = $value;
391
- break;
392
- case 'qty':
393
- $lineItem->quantity = $value;
394
- break;
395
- default:
396
- $lineItem->$publicKey = $value;
397
- break;
398
- }
399
- }
400
- $result[] = $lineItem;
401
- }
402
- return $result;
403
- }
404
-
405
- /**
406
- * Prepare shipping options request
407
- * Returns false if there are no shipping options
408
- *
409
- * @param array &$request
410
- * @param int $i
411
- * @return bool
412
- */
413
- protected function _exportShippingOptions(array &$request, $i = 0)
414
- {
415
- $options = $this->getShippingOptions();
416
- if (empty($options)) {
417
- return false;
418
- }
419
- foreach ($options as $option) {
420
- foreach ($this->_shippingOptionsExportItemsFormat as $publicKey => $privateFormat) {
421
- $value = $option->getDataUsingMethod($publicKey);
422
- if (is_float($value)) {
423
- $value = $this->_filterAmount($value);
424
- }
425
- if (is_bool($value)) {
426
- $value = $this->_filterBool($value);
427
- }
428
- $request[sprintf($privateFormat, $i)] = $value;
429
- }
430
- $i++;
431
- }
432
- return true;
433
- }
434
-
435
- /**
436
- * Filter amounts in API calls
437
- * @param float|string $value
438
- * @return string
439
- */
440
- protected function _filterAmount($value)
441
- {
442
- return sprintf('%.2F', $value);
443
- }
444
-
445
- /**
446
- * Filter boolean values in API calls
447
- *
448
- * @param mixed $value
449
- * @return string
450
- */
451
- protected function _filterBool($value)
452
- {
453
- return ($value) ? 'true' : 'false';
454
- }
455
-
456
- /**
457
- * Filter int values in API calls
458
- *
459
- * @param mixed $value
460
- * @return int
461
- */
462
- protected function _filterInt($value)
463
- {
464
- return (int)$value;
465
- }
466
-
467
- /**
468
- * Unified getter that looks in data or falls back to config
469
- *
470
- * @param string $key
471
- * @param mixed $default
472
- * @return mixed
473
- */
474
- protected function _getDataOrConfig($key, $default = null)
475
- {
476
- if ($this->hasData($key)) {
477
- return $this->getData($key);
478
- }
479
- return $this->_config->$key ? $this->_config->$key : $default;
480
- }
481
-
482
-
483
- /**
484
- * region_id workaround: PayPal requires state code, try to find one in the address
485
- *
486
- * @param Varien_Object $address
487
- * @return string
488
- */
489
- protected function _lookupRegionCodeFromAddress(Varien_Object $address)
490
- {
491
- if ($regionId = $address->getData('region_id')) {
492
- $region = Mage::getModel('directory/region')->load($regionId);
493
- if ($region->getId()) {
494
- return $region->getCode();
495
- }
496
- }
497
- return '';
498
- }
499
-
500
- /**
501
- * Street address workaround: divides address lines into parts by specified keys
502
- * (keys should go as 3rd, 4th[...] parameters)
503
- *
504
- * @param Varien_Object $address
505
- * @param array $request
506
- */
507
- protected function _importStreetFromAddress(Varien_Object $address, array &$to)
508
- {
509
- $keys = func_get_args(); array_shift($keys); array_shift($keys);
510
- $street = $address->getStreet();
511
- if (!$keys || !$street || !is_array($street)) {
512
- return;
513
- }
514
-
515
- $street = Mage::helper('customer/address')
516
- ->convertStreetLines($address->getStreet(), count($keys));
517
-
518
- $i = 0;
519
- foreach ($keys as $key) {
520
- $to[$key] = isset($street[$i]) ? $street[$i]: '';
521
- $i++;
522
- }
523
- }
524
-
525
- /**
526
- * Build query string from request
527
- *
528
- * @param array $request
529
- * @return string
530
- */
531
- protected function _buildQuery($request)
532
- {
533
- return http_build_query($request);
534
- }
535
-
536
- /**
537
- * Filter qty in API calls
538
- * Paypal note: The value for quantity must be a positive integer. Null, zero, or negative numbers are not allowed.
539
- *
540
- * @param float|string|int $value
541
- * @return string
542
- */
543
- protected function _filterQty($value)
544
- {
545
- return intval($value);
546
- }
547
-
548
- /**
549
- * Log debug data to file
550
- *
551
- * @param mixed $debugData
552
- */
553
- protected function _debug($debugData)
554
- {
555
- if ($this->getDebugFlag()) {
556
- Mage::getModel('core/log_adapter', 'payment_' . $this->_config->getMethodCode() . '.log')
557
- ->setFilterDataKeys($this->_debugReplacePrivateDataKeys)
558
- ->log($debugData);
559
- }
560
- }
561
-
562
- /**
563
- * Define if debugging is enabled
564
- *
565
- * @return bool
566
- */
567
- public function getDebugFlag()
568
- {
569
- return $this->_config->debug;
570
- }
571
-
572
- /**
573
- * Check whether API certificate authentication should be used
574
- *
575
- * @return bool
576
- */
577
- public function getUseCertAuthentication()
578
- {
579
- return (bool)$this->_config->apiAuthentication;
580
- }
581
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Hps/Securesubmit/Model/Api/Paypal.php DELETED
@@ -1,300 +0,0 @@
1
- <?php
2
-
3
- require_once Mage::getBaseDir('lib').DS.'SecureSubmit'.DS.'Hps.php';
4
- /**
5
- * @category Hps
6
- * @package Hps_Securesubmit
7
- * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
8
- * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
9
- */
10
-
11
- /**
12
- * NVP API wrappers model
13
- * @TODO: move some parts to abstract, don't hesitate to throw exceptions on api calls
14
- */
15
- class Hps_Securesubmit_Model_Api_Paypal extends Hps_Securesubmit_Model_Api_Abstract
16
- {
17
- /**
18
- * Filter callbacks for preparing internal amounts to NVP request
19
- *
20
- * @var array
21
- */
22
- protected $_exportToRequestFilters = array(
23
- 'AMT' => '_filterAmount',
24
- 'ITEMAMT' => '_filterAmount',
25
- 'TRIALAMT' => '_filterAmount',
26
- 'SHIPPINGAMT' => '_filterAmount',
27
- 'TAXAMT' => '_filterAmount',
28
- 'INITAMT' => '_filterAmount',
29
- 'CREDITCARDTYPE' => '_filterCcType',
30
- 'AUTOBILLAMT' => '_filterBillFailedLater',
31
- 'BILLINGPERIOD' => '_filterPeriodUnit',
32
- 'TRIALBILLINGPERIOD' => '_filterPeriodUnit',
33
- 'FAILEDINITAMTACTION' => '_filterInitialAmountMayFail',
34
- 'BILLINGAGREEMENTSTATUS' => '_filterBillingAgreementStatus',
35
- 'NOSHIPPING' => '_filterInt',
36
- );
37
-
38
- protected $_importFromRequestFilters = array(
39
- 'REDIRECTREQUIRED' => '_filterToBool',
40
- 'SUCCESSPAGEREDIRECTREQUESTED' => '_filterToBool',
41
- 'PAYMENTSTATUS' => '_filterPaymentStatusFromNvpToInfo',
42
- );
43
-
44
- /**
45
- * SetExpressCheckout request/response map
46
- * @var array
47
- */
48
- protected $_setExpressCheckoutRequest = array(
49
- 'PAYMENTACTION', 'AMT', 'CURRENCYCODE', 'RETURNURL', 'CANCELURL', 'INVNUM', 'SOLUTIONTYPE', 'NOSHIPPING',
50
- 'GIROPAYCANCELURL', 'GIROPAYSUCCESSURL', 'BANKTXNPENDINGURL',
51
- 'PAGESTYLE', 'HDRIMG', 'HDRBORDERCOLOR', 'HDRBACKCOLOR', 'PAYFLOWCOLOR', 'LOCALECODE',
52
- 'BILLINGTYPE', 'SUBJECT', 'ITEMAMT', 'SHIPPINGAMT', 'TAXAMT', 'REQBILLINGADDRESS',
53
- 'USERSELECTEDFUNDINGSOURCE'
54
- );
55
- protected $_setExpressCheckoutResponse = array('TOKEN');
56
-
57
- /**
58
- * GetExpressCheckoutDetails request/response map
59
- * @var array
60
- */
61
- protected $_getExpressCheckoutDetailsRequest = array('TOKEN', 'SUBJECT',);
62
-
63
- /**
64
- * Line items export mapping settings
65
- * @var array
66
- */
67
- protected $_lineItemExportItems = array(
68
- 'id',
69
- 'name',
70
- 'qty',
71
- 'amount',
72
- );
73
-
74
- /**
75
- * SetExpressCheckout call
76
- * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout
77
- * TODO: put together style and giropay settings
78
- */
79
- public function callSetExpressCheckout($credit = null)
80
- {
81
- $this->_prepareExpressCheckoutCallRequest($this->_setExpressCheckoutRequest);
82
- $request = $this->_exportToRequest($this->_setExpressCheckoutRequest);
83
-
84
- $amount = $this->getAmount();
85
- $currency = $this->getCurrencyCode();
86
- $totals = $this->_cart->getTotals();
87
-
88
- $buyer = new HpsBuyerData();
89
- $buyer->returnUrl = $this->getReturnUrl();
90
- $buyer->cancelUrl = $this->getCancelUrl();
91
- $buyer->credit = $credit;
92
-
93
- $payment = new HpsPaymentData();
94
- $payment->subtotal = $totals[Mage_Paypal_Model_Cart::TOTAL_SUBTOTAL];
95
- $payment->shippingAmount = $totals[Mage_Paypal_Model_Cart::TOTAL_SHIPPING];
96
- $payment->taxAmount = $totals[Mage_Paypal_Model_Cart::TOTAL_TAX];
97
- $payment->paymentType = (Mage::getStoreConfig('payment/hps_paypal/payment_action') == 'authorize_capture'
98
- ? 'Sale' : 'Authorization');
99
-
100
- // import/suppress shipping address, if any
101
- $options = $this->getShippingOptions();
102
- $shippingInfo = null;
103
- if ($this->getAddress()) {
104
- $a = $this->getAddress();
105
- $regionModel = Mage::getModel('directory/region')->load($a->getRegionId());
106
- $shippingInfo = new HpsShippingInfo();
107
- $shippingInfo->name = $a->getFirstname() . ' ' . $a->getMiddlename() . ' ' . $a->getLastname();
108
- $shippingInfo->address = new HpsAddress();
109
- $shippingInfo->address->address = $a->getData('street');
110
- $shippingInfo->address->city = $a->getCity();
111
- $shippingInfo->address->state = $regionModel->getCode();
112
- $shippingInfo->address->zip = $a->getPostcode();
113
- $shippingInfo->address->country = $a->getCountryId();
114
-
115
- if ($a->getEmail()) {
116
- $buyer->emailAddress = $a->getEmail();
117
- }
118
- } elseif ($options && (count($options) <= 10)) { // doesn't support more than 10 shipping options
119
- // $request['CALLBACK'] = $this->getShippingOptionsCallbackUrl();
120
- // $request['CALLBACKTIMEOUT'] = 6; // max value
121
- // $request['MAXAMT'] = $request['AMT'] + 999.00; // it is impossible to calculate max amount
122
- // $this->_exportShippingOptions($request);
123
- }
124
-
125
- $lineItems = $this->_exportLineItems();
126
-
127
- $config = new HpsServicesConfig();
128
- if (Mage::getStoreConfig('payment/hps_paypal/use_sandbox')) {
129
- $config->username = Mage::getStoreConfig('payment/hps_paypal/username');
130
- $config->password = Mage::getStoreConfig('payment/hps_paypal/password');
131
- $config->deviceId = Mage::getStoreConfig('payment/hps_paypal/device_id');
132
- $config->licenseId = Mage::getStoreConfig('payment/hps_paypal/license_id');
133
- $config->siteId = Mage::getStoreConfig('payment/hps_paypal/site_id');
134
- $config->soapServiceUri = "https://posgateway.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx";
135
- //$config->soapServiceUri = "https://api-uat.heartlandportico.com/paymentserver.v1/PosGatewayService.asmx";
136
- //$config->soapServiceUri = "https://api-uat.heartlandportico.com/paymentserver.HotFix/POSGatewayService.asmx";
137
- } else {
138
- $config->secretApiKey = Mage::getStoreConfig('payment/hps_paypal/secretapikey');
139
- }
140
-
141
- $paypalService = new HpsPayPalService($config);
142
- $response = $paypalService->createSession($amount, $currency, $buyer, $payment, $shippingInfo, $lineItems);
143
-
144
- $this->token = $response->sessionId;
145
- return $response;
146
- }
147
-
148
- /**
149
- * GetExpressCheckoutDetails call
150
- * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetExpressCheckoutDetails
151
- */
152
- function callGetExpressCheckoutDetails()
153
- {
154
- $this->_prepareExpressCheckoutCallRequest($this->_getExpressCheckoutDetailsRequest);
155
- $request = $this->_exportToRequest($this->_getExpressCheckoutDetailsRequest);
156
-
157
- $token = $this->getToken();
158
-
159
- $config = new HpsServicesConfig();
160
- if (Mage::getStoreConfig('payment/hps_paypal/use_sandbox')) {
161
- $config->username = Mage::getStoreConfig('payment/hps_paypal/username');
162
- $config->password = Mage::getStoreConfig('payment/hps_paypal/password');
163
- $config->deviceId = Mage::getStoreConfig('payment/hps_paypal/device_id');
164
- $config->licenseId = Mage::getStoreConfig('payment/hps_paypal/license_id');
165
- $config->siteId = Mage::getStoreConfig('payment/hps_paypal/site_id');
166
- $config->soapServiceUri = "https://posgateway.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx";
167
- //$config->soapServiceUri = "https://api-uat.heartlandportico.com/paymentserver.v1/PosGatewayService.asmx";
168
- //$config->soapServiceUri = "https://api-uat.heartlandportico.com/paymentserver.HotFix/POSGatewayService.asmx";
169
- } else {
170
- $config->secretApiKey = Mage::getStoreConfig('payment/hps_paypal/secretapikey');
171
- }
172
-
173
- $paypalService = new HpsPayPalService($config);
174
- $response = $paypalService->sessionInfo($token);
175
-
176
- return $response;
177
- }
178
-
179
- /**
180
- * Filter for credit card type
181
- *
182
- * @param string $value
183
- * @return string
184
- */
185
- protected function _filterCcType($value)
186
- {
187
- if (isset($this->_supportedCcTypes[$value])) {
188
- return $this->_supportedCcTypes[$value];
189
- }
190
- return '';
191
- }
192
-
193
- /**
194
- * Filter for true/false values (converts to boolean)
195
- *
196
- * @param mixed $value
197
- * @return mixed
198
- */
199
- protected function _filterToBool($value)
200
- {
201
- if ('false' === $value || '0' === $value) {
202
- return false;
203
- } elseif ('true' === $value || '1' === $value) {
204
- return true;
205
- }
206
- return $value;
207
- }
208
-
209
- /**
210
- * Filter for 'AUTOBILLAMT'
211
- *
212
- * @param string $value
213
- * @return string
214
- */
215
- protected function _filterBillFailedLater($value)
216
- {
217
- return $value ? 'AddToNextBilling' : 'NoAutoBill';
218
- }
219
-
220
- /**
221
- * Filter for 'BILLINGPERIOD' and 'TRIALBILLINGPERIOD'
222
- *
223
- * @param string $value
224
- * @return string
225
- */
226
- protected function _filterPeriodUnit($value)
227
- {
228
- switch ($value) {
229
- case 'day': return 'Day';
230
- case 'week': return 'Week';
231
- case 'semi_month': return 'SemiMonth';
232
- case 'month': return 'Month';
233
- case 'year': return 'Year';
234
- }
235
- }
236
-
237
- /**
238
- * Filter for 'FAILEDINITAMTACTION'
239
- *
240
- * @param string $value
241
- * @return string
242
- */
243
- protected function _filterInitialAmountMayFail($value)
244
- {
245
- return $value ? 'ContinueOnFailure' : 'CancelOnFailure';
246
- }
247
-
248
- /**
249
- * Filter for billing agreement status
250
- *
251
- * @param string $value
252
- * @return string
253
- */
254
- protected function _filterBillingAgreementStatus($value)
255
- {
256
- switch ($value) {
257
- case 'canceled': return 'Canceled';
258
- case 'active': return 'Active';
259
- }
260
- }
261
-
262
- /**
263
- * Convert payment status from NVP format to paypal/info model format
264
- *
265
- * @param string $value
266
- * @return string|null
267
- */
268
- protected function _filterPaymentStatusFromNvpToInfo($value)
269
- {
270
- switch ($value) {
271
- case 'None': return Hps_Securesubmit_Model_Info::PAYMENTSTATUS_NONE;
272
- case 'Completed': return Hps_Securesubmit_Model_Info::PAYMENTSTATUS_COMPLETED;
273
- case 'Denied': return Hps_Securesubmit_Model_Info::PAYMENTSTATUS_DENIED;
274
- case 'Expired': return Hps_Securesubmit_Model_Info::PAYMENTSTATUS_EXPIRED;
275
- case 'Failed': return Hps_Securesubmit_Model_Info::PAYMENTSTATUS_FAILED;
276
- case 'In-Progress': return Hps_Securesubmit_Model_Info::PAYMENTSTATUS_INPROGRESS;
277
- case 'Pending': return Hps_Securesubmit_Model_Info::PAYMENTSTATUS_PENDING;
278
- case 'Refunded': return Hps_Securesubmit_Model_Info::PAYMENTSTATUS_REFUNDED;
279
- case 'Partially-Refunded': return Hps_Securesubmit_Model_Info::PAYMENTSTATUS_REFUNDEDPART;
280
- case 'Reversed': return Hps_Securesubmit_Model_Info::PAYMENTSTATUS_REVERSED;
281
- case 'Canceled-Reversal': return Hps_Securesubmit_Model_Info::PAYMENTSTATUS_UNREVERSED;
282
- case 'Processed': return Hps_Securesubmit_Model_Info::PAYMENTSTATUS_PROCESSED;
283
- case 'Voided': return Hps_Securesubmit_Model_Info::PAYMENTSTATUS_VOIDED;
284
- }
285
- }
286
-
287
- /**
288
- * Check the EC request against unilateral payments mode and remove the SUBJECT if needed
289
- *
290
- * @param &array $requestFields
291
- */
292
- protected function _prepareExpressCheckoutCallRequest(&$requestFields)
293
- {
294
- if (!$this->_config->shouldUseUnilateralPayments()) {
295
- if ($key = array_search('SUBJECT', $requestFields)) {
296
- unset($requestFields[$key]);
297
- }
298
- }
299
- }
300
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Hps/Securesubmit/Model/Config.php DELETED
@@ -1,1571 +0,0 @@
1
- <?php
2
- /**
3
- * @category Hps
4
- * @package Hps_Securesubmit
5
- * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
- * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
- */
8
-
9
- /**
10
- * Config model that is aware of all Hps_Securesubmit payment methods
11
- * Works with PayPal-specific system configuration
12
- */
13
- class Hps_Securesubmit_Model_Config
14
- {
15
- /**
16
- * PayPal Standard
17
- * @var string
18
- */
19
- const METHOD_WPS = 'paypal_standard';
20
-
21
- /**
22
- * US locale
23
- */
24
- const LOCALE_US = 'en_US';
25
-
26
- /**
27
- * PayPal Website Payments Pro - Express Checkout
28
- * @var string
29
- */
30
- const METHOD_WPP_EXPRESS = 'paypal_express';
31
-
32
- /**
33
- * PayPal Bill Me Later - Express Checkout
34
- * @var string
35
- */
36
- const METHOD_BML = 'paypal_express_bml';
37
-
38
- /**
39
- * PayPal Website Payments Pro - Direct Payments
40
- * @var string
41
- */
42
- const METHOD_WPP_DIRECT = 'paypal_direct';
43
-
44
- /**
45
- * Direct Payments (Payflow Edition)
46
- * @var string
47
- */
48
- const METHOD_WPP_PE_DIRECT = 'paypaluk_direct';
49
-
50
- /**
51
- * PayPal Bill Me Later - Express Checkout (Payflow Edition)
52
- * @var string
53
- */
54
- const METHOD_WPP_PE_BML = 'paypaluk_express_bml';
55
-
56
- /**
57
- * Express Checkout (Payflow Edition)
58
- * @var string
59
- */
60
- const METHOD_WPP_PE_EXPRESS = 'paypaluk_express';
61
-
62
- /**
63
- * Payflow Pro Gateway
64
- * @var string
65
- */
66
- const METHOD_PAYFLOWPRO = 'verisign';
67
-
68
- const METHOD_PAYFLOWLINK = 'payflow_link';
69
- const METHOD_PAYFLOWADVANCED = 'payflow_advanced';
70
-
71
- const METHOD_HOSTEDPRO = 'hosted_pro';
72
-
73
- const METHOD_BILLING_AGREEMENT = 'paypal_billing_agreement';
74
-
75
- /**
76
- * Buttons and images
77
- * @var string
78
- */
79
- const EC_FLAVOR_DYNAMIC = 'dynamic';
80
- const EC_FLAVOR_STATIC = 'static';
81
- const EC_BUTTON_TYPE_SHORTCUT = 'ecshortcut';
82
- const EC_BUTTON_TYPE_MARK = 'ecmark';
83
- const PAYMENT_MARK_37x23 = '37x23';
84
- const PAYMENT_MARK_50x34 = '50x34';
85
- const PAYMENT_MARK_60x38 = '60x38';
86
- const PAYMENT_MARK_180x113 = '180x113';
87
-
88
- const DEFAULT_LOGO_TYPE = 'wePrefer_150x60';
89
-
90
- /**
91
- * Payment actions
92
- * @var string
93
- */
94
- const PAYMENT_ACTION_SALE = 'Sale';
95
- const PAYMENT_ACTION_ORDER = 'Order';
96
- const PAYMENT_ACTION_AUTH = 'Authorization';
97
-
98
- /**
99
- * Authorization amounts for Account Verification
100
- *
101
- * @deprecated since 1.6.2.0
102
- * @var int
103
- */
104
- const AUTHORIZATION_AMOUNT_ZERO = 0;
105
- const AUTHORIZATION_AMOUNT_ONE = 1;
106
- const AUTHORIZATION_AMOUNT_FULL = 2;
107
-
108
- /**
109
- * Require Billing Address
110
- * @var int
111
- */
112
- const REQUIRE_BILLING_ADDRESS_NO = 0;
113
- const REQUIRE_BILLING_ADDRESS_ALL = 1;
114
- const REQUIRE_BILLING_ADDRESS_VIRTUAL = 2;
115
-
116
- /**
117
- * Fraud management actions
118
- * @var string
119
- */
120
- const FRAUD_ACTION_ACCEPT = 'Acept';
121
- const FRAUD_ACTION_DENY = 'Deny';
122
-
123
- /**
124
- * Refund types
125
- * @var string
126
- */
127
- const REFUND_TYPE_FULL = 'Full';
128
- const REFUND_TYPE_PARTIAL = 'Partial';
129
-
130
- /**
131
- * Express Checkout flows
132
- * @var string
133
- */
134
- const EC_SOLUTION_TYPE_SOLE = 'Sole';
135
- const EC_SOLUTION_TYPE_MARK = 'Mark';
136
-
137
- /**
138
- * Payment data transfer methods (Standard)
139
- *
140
- * @var string
141
- */
142
- const WPS_TRANSPORT_IPN = 'ipn';
143
- const WPS_TRANSPORT_PDT = 'pdt';
144
- const WPS_TRANSPORT_IPN_PDT = 'ipn_n_pdt';
145
-
146
- /**
147
- * Billing Agreement Signup
148
- *
149
- * @var string
150
- */
151
- const EC_BA_SIGNUP_AUTO = 'auto';
152
- const EC_BA_SIGNUP_ASK = 'ask';
153
- const EC_BA_SIGNUP_NEVER = 'never';
154
-
155
- /**
156
- * Config path for enabling/disabling order review step in express checkout
157
- */
158
- const XML_PATH_PAYPAL_EXPRESS_SKIP_ORDER_REVIEW_STEP_FLAG = 'payment/paypal_express/skip_order_review_step';
159
-
160
- /**
161
- * Default URL for centinel API (PayPal Direct)
162
- *
163
- * @var string
164
- */
165
- public $centinelDefaultApiUrl = 'https://paypal.cardinalcommerce.com/maps/txns.asp';
166
-
167
- /**
168
- * Current payment method code
169
- * @var string
170
- */
171
- protected $_methodCode = null;
172
-
173
- /**
174
- * Current store id
175
- *
176
- * @var int
177
- */
178
- protected $_storeId = null;
179
-
180
- /**
181
- * Instructions for generating proper BN code
182
- *
183
- * @var array
184
- */
185
- protected $_buildNotationPPMap = array(
186
- 'paypal_standard' => 'WPS',
187
- 'paypal_express' => 'EC',
188
- 'paypal_direct' => 'DP',
189
- 'paypaluk_express' => 'EC',
190
- 'paypaluk_direct' => 'DP',
191
- );
192
-
193
- /**
194
- * Style system config map (Express Checkout)
195
- *
196
- * @var array
197
- */
198
- protected $_ecStyleConfigMap = array(
199
- 'page_style' => 'page_style',
200
- 'paypal_hdrimg' => 'hdrimg',
201
- 'paypal_hdrbordercolor' => 'hdrbordercolor',
202
- 'paypal_hdrbackcolor' => 'hdrbackcolor',
203
- 'paypal_payflowcolor' => 'payflowcolor',
204
- );
205
-
206
- /**
207
- * Currency codes supported by PayPal methods
208
- *
209
- * @var array
210
- */
211
- protected $_supportedCurrencyCodes = array('AUD', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN',
212
- 'NOK', 'NZD', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'USD', 'TWD', 'THB');
213
-
214
- /**
215
- * Merchant country supported by PayPal
216
- *
217
- * @var array
218
- */
219
- protected $_supportedCountryCodes = array(
220
- 'AE','AR','AT','AU','BE','BG','BR','CA','CH','CL','CR','CY','CZ','DE','DK','DO','EC','EE','ES','FI','FR','GB',
221
- 'GF','GI','GP','GR','HK','HU','ID','IE','IL','IN','IS','IT','JM','JP','KR','LI','LT','LU','LV','MQ','MT','MX',
222
- 'MY','NL','NO','NZ','PH','PL','PT','RE','RO','SE','SG','SI','SK','SM','TH','TR','TW','US','UY','VE','VN','ZA');
223
-
224
- /**
225
- * Buyer country supported by PayPal
226
- *
227
- * @var array
228
- */
229
- protected $_supportedBuyerCountryCodes = array(
230
- 'AF ', 'AX ', 'AL ', 'DZ ', 'AS ', 'AD ', 'AO ', 'AI ', 'AQ ', 'AG ', 'AR ', 'AM ', 'AW ', 'AU ', 'AT ', 'AZ ',
231
- 'BS ', 'BH ', 'BD ', 'BB ', 'BY ', 'BE ', 'BZ ', 'BJ ', 'BM ', 'BT ', 'BO ', 'BA ', 'BW ', 'BV ', 'BR ', 'IO ',
232
- 'BN ', 'BG ', 'BF ', 'BI ', 'KH ', 'CM ', 'CA ', 'CV ', 'KY ', 'CF ', 'TD ', 'CL ', 'CN ', 'CX ', 'CC ', 'CO ',
233
- 'KM ', 'CG ', 'CD ', 'CK ', 'CR ', 'CI ', 'HR ', 'CU ', 'CY ', 'CZ ', 'DK ', 'DJ ', 'DM ', 'DO ', 'EC ', 'EG ',
234
- 'SV ', 'GQ ', 'ER ', 'EE ', 'ET ', 'FK ', 'FO ', 'FJ ', 'FI ', 'FR ', 'GF ', 'PF ', 'TF ', 'GA ', 'GM ', 'GE ',
235
- 'DE ', 'GH ', 'GI ', 'GR ', 'GL ', 'GD ', 'GP ', 'GU ', 'GT ', 'GG ', 'GN ', 'GW ', 'GY ', 'HT ', 'HM ', 'VA ',
236
- 'HN ', 'HK ', 'HU ', 'IS ', 'IN ', 'ID ', 'IR ', 'IQ ', 'IE ', 'IM ', 'IL ', 'IT ', 'JM ', 'JP ', 'JE ', 'JO ',
237
- 'KZ ', 'KE ', 'KI ', 'KP ', 'KR ', 'KW ', 'KG ', 'LA ', 'LV ', 'LB ', 'LS ', 'LR ', 'LY ', 'LI ', 'LT ', 'LU ',
238
- 'MO ', 'MK ', 'MG ', 'MW ', 'MY ', 'MV ', 'ML ', 'MT ', 'MH ', 'MQ ', 'MR ', 'MU ', 'YT ', 'MX ', 'FM ', 'MD ',
239
- 'MC ', 'MN ', 'MS ', 'MA ', 'MZ ', 'MM ', 'NA ', 'NR ', 'NP ', 'NL ', 'AN ', 'NC ', 'NZ ', 'NI ', 'NE ', 'NG ',
240
- 'NU ', 'NF ', 'MP ', 'NO ', 'OM ', 'PK ', 'PW ', 'PS ', 'PA ', 'PG ', 'PY ', 'PE ', 'PH ', 'PN ', 'PL ', 'PT ',
241
- 'PR ', 'QA ', 'RE ', 'RO ', 'RU ', 'RW ', 'SH ', 'KN ', 'LC ', 'PM ', 'VC ', 'WS ', 'SM ', 'ST ', 'SA ', 'SN ',
242
- 'CS ', 'SC ', 'SL ', 'SG ', 'SK ', 'SI ', 'SB ', 'SO ', 'ZA ', 'GS ', 'ES ', 'LK ', 'SD ', 'SR ', 'SJ ', 'SZ ',
243
- 'SE ', 'CH ', 'SY ', 'TW ', 'TJ ', 'TZ ', 'TH ', 'TL ', 'TG ', 'TK ', 'TO ', 'TT ', 'TN ', 'TR ', 'TM ', 'TC ',
244
- 'TV ', 'UG ', 'UA ', 'AE ', 'GB ', 'US ', 'UM ', 'UY ', 'UZ ', 'VU ', 'VE ', 'VN ', 'VG ', 'VI ', 'WF ', 'EH ',
245
- 'YE ', 'ZM ', 'ZW'
246
- );
247
-
248
- /**
249
- * Locale codes supported by misc images (marks, shortcuts etc)
250
- *
251
- * @var array
252
- * @link https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECButtonIntegration#id089QD0O0TX4__id08AH904I0YK
253
- */
254
- protected $_supportedImageLocales = array('de_DE', 'en_AU', 'en_GB', self::LOCALE_US,
255
- 'es_ES', 'es_XC', 'fr_FR', 'fr_XC', 'it_IT', 'ja_JP', 'nl_NL', 'pl_PL', 'zh_CN', 'zh_XC',
256
- );
257
-
258
- /**
259
- * Set method and store id, if specified
260
- *
261
- * @param array $params
262
- */
263
- public function __construct($params = array())
264
- {
265
- if ($params) {
266
- $method = array_shift($params);
267
- $this->setMethod($method);
268
- if ($params) {
269
- $storeId = array_shift($params);
270
- $this->setStoreId($storeId);
271
- }
272
- }
273
- }
274
-
275
- /**
276
- * Method code setter
277
- *
278
- * @param string|Mage_Payment_Model_Method_Abstract $method
279
- * @return Hps_Securesubmit_Model_Config
280
- */
281
- public function setMethod($method)
282
- {
283
- if ($method instanceof Mage_Payment_Model_Method_Abstract) {
284
- $this->_methodCode = $method->getCode();
285
- } elseif (is_string($method)) {
286
- $this->_methodCode = $method;
287
- }
288
- return $this;
289
- }
290
-
291
- /**
292
- * Payment method instance code getter
293
- *
294
- * @return string
295
- */
296
- public function getMethodCode()
297
- {
298
- return $this->_methodCode;
299
- }
300
-
301
- /**
302
- * Store ID setter
303
- *
304
- * @param int $storeId
305
- * @return Hps_Securesubmit_Model_Config
306
- */
307
- public function setStoreId($storeId)
308
- {
309
- $this->_storeId = (int)$storeId;
310
- return $this;
311
- }
312
-
313
- /**
314
- * Check whether method active in configuration and supported for merchant country or not
315
- *
316
- * @param string $method Method code
317
- * @return bool
318
- */
319
- public function isMethodActive($method)
320
- {
321
- if ($this->isMethodSupportedForCountry($method)
322
- && Mage::getStoreConfigFlag("payment/{$method}/active", $this->_storeId)
323
- ) {
324
- return true;
325
- }
326
- return false;
327
- }
328
-
329
- /**
330
- * Check whether method available for checkout or not
331
- * Logic based on merchant country, methods dependence
332
- *
333
- * @param string $method Method code
334
- * @return bool
335
- */
336
- public function isMethodAvailable($methodCode = null)
337
- {
338
- if ($methodCode === null) {
339
- $methodCode = $this->getMethodCode();
340
- }
341
-
342
- $result = true;
343
-
344
- if (!$this->isMethodActive($methodCode)) {
345
- $result = false;
346
- }
347
-
348
- switch ($methodCode) {
349
- case self::METHOD_WPS:
350
- if (!$this->businessAccount) {
351
- $result = false;
352
- break;
353
- }
354
- // check for direct payments dependence
355
- if ($this->isMethodActive(self::METHOD_WPP_DIRECT)
356
- || $this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) {
357
- $result = false;
358
- }
359
- break;
360
- case self::METHOD_WPP_EXPRESS:
361
- // check for direct payments dependence
362
- if ($this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) {
363
- $result = false;
364
- } elseif ($this->isMethodActive(self::METHOD_WPP_DIRECT)) {
365
- $result = true;
366
- }
367
- break;
368
- case self::METHOD_BML:
369
- // check for express payments dependence
370
- if (!$this->isMethodActive(self::METHOD_WPP_EXPRESS)) {
371
- $result = false;
372
- }
373
- break;
374
- case self::METHOD_WPP_PE_EXPRESS:
375
- // check for direct payments dependence
376
- if ($this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) {
377
- $result = true;
378
- } elseif (!$this->isMethodActive(self::METHOD_WPP_PE_DIRECT)
379
- && !$this->isMethodActive(self::METHOD_PAYFLOWPRO)) {
380
- $result = false;
381
- }
382
- break;
383
- case self::METHOD_WPP_PE_BML:
384
- // check for express payments dependence
385
- if (!$this->isMethodActive(self::METHOD_WPP_PE_EXPRESS)) {
386
- $result = false;
387
- }
388
- break;
389
- case self::METHOD_BILLING_AGREEMENT:
390
- $result = $this->isWppApiAvailabe();
391
- break;
392
- case self::METHOD_WPP_DIRECT:
393
- case self::METHOD_WPP_PE_DIRECT:
394
- break;
395
- }
396
- return $result;
397
- }
398
-
399
- /**
400
- * Config field magic getter
401
- * The specified key can be either in camelCase or under_score format
402
- * Tries to map specified value according to set payment method code, into the configuration value
403
- * Sets the values into public class parameters, to avoid redundant calls of this method
404
- *
405
- * @param string $key
406
- * @return string|null
407
- */
408
- public function __get($key)
409
- {
410
- $underscored = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $key));
411
- $value = Mage::getStoreConfig($this->_getSpecificConfigPath($underscored), $this->_storeId);
412
- $value = $this->_prepareValue($underscored, $value);
413
- $this->$key = $value;
414
- $this->$underscored = $value;
415
- return $value;
416
- }
417
-
418
- /**
419
- * Perform additional config value preparation and return new value if needed
420
- *
421
- * @param string $key Underscored key
422
- * @param string $value Old value
423
- * @return string Modified value or old value
424
- */
425
- protected function _prepareValue($key, $value)
426
- {
427
- // Always set payment action as "Sale" for Unilateral payments in EC
428
- if ($key == 'payment_action'
429
- && $value != self::PAYMENT_ACTION_SALE
430
- && $this->_methodCode == self::METHOD_WPP_EXPRESS
431
- && $this->shouldUseUnilateralPayments())
432
- {
433
- return self::PAYMENT_ACTION_SALE;
434
- }
435
- return $value;
436
- }
437
-
438
- /**
439
- * Return merchant country codes supported by PayPal
440
- *
441
- * @return array
442
- */
443
- public function getSupportedMerchantCountryCodes()
444
- {
445
- return $this->_supportedCountryCodes;
446
- }
447
-
448
- /**
449
- * Return buyer country codes supported by PayPal
450
- *
451
- * @return array
452
- */
453
- public function getSupportedBuyerCountryCodes()
454
- {
455
- return $this->_supportedBuyerCountryCodes;
456
- }
457
-
458
- /**
459
- * Return merchant country code, use default country if it not specified in General settings
460
- *
461
- * @return string
462
- */
463
- public function getMerchantCountry()
464
- {
465
- $countryCode = Mage::getStoreConfig($this->_mapGeneralFieldset('merchant_country'), $this->_storeId);
466
- if (!$countryCode) {
467
- $countryCode = Mage::helper('core')->getDefaultCountry($this->_storeId);
468
- }
469
- return $countryCode;
470
- }
471
-
472
- /**
473
- * Check whether method supported for specified country or not
474
- * Use $_methodCode and merchant country by default
475
- *
476
- * @return bool
477
- */
478
- public function isMethodSupportedForCountry($method = null, $countryCode = null)
479
- {
480
- if ($method === null) {
481
- $method = $this->getMethodCode();
482
- }
483
- if ($countryCode === null) {
484
- $countryCode = $this->getMerchantCountry();
485
- }
486
- $countryMethods = $this->getCountryMethods($countryCode);
487
- if (in_array($method, $countryMethods)) {
488
- return true;
489
- }
490
- return false;
491
- }
492
-
493
- /**
494
- * Return list of allowed methods for specified country iso code
495
- *
496
- * @param string $countryCode 2-letters iso code
497
- * @return array
498
- */
499
- public function getCountryMethods($countryCode = null)
500
- {
501
- $countryMethods = array(
502
- 'other' => array(
503
- self::METHOD_WPS,
504
- self::METHOD_WPP_EXPRESS,
505
- self::METHOD_BILLING_AGREEMENT,
506
- ),
507
- 'US' => array(
508
- self::METHOD_PAYFLOWADVANCED,
509
- self::METHOD_WPP_DIRECT,
510
- self::METHOD_WPS,
511
- self::METHOD_PAYFLOWPRO,
512
- self::METHOD_PAYFLOWLINK,
513
- self::METHOD_WPP_EXPRESS,
514
- self::METHOD_BML,
515
- self::METHOD_BILLING_AGREEMENT,
516
- self::METHOD_WPP_PE_EXPRESS,
517
- self::METHOD_WPP_PE_BML,
518
- ),
519
- 'CA' => array(
520
- self::METHOD_WPP_DIRECT,
521
- self::METHOD_WPS,
522
- self::METHOD_PAYFLOWPRO,
523
- self::METHOD_PAYFLOWLINK,
524
- self::METHOD_WPP_EXPRESS,
525
- self::METHOD_BILLING_AGREEMENT,
526
- ),
527
- 'GB' => array(
528
- self::METHOD_WPP_DIRECT,
529
- self::METHOD_WPS,
530
- self::METHOD_WPP_PE_DIRECT,
531
- self::METHOD_HOSTEDPRO,
532
- self::METHOD_WPP_EXPRESS,
533
- self::METHOD_BILLING_AGREEMENT,
534
- self::METHOD_WPP_PE_EXPRESS,
535
- ),
536
- 'AU' => array(
537
- self::METHOD_WPS,
538
- self::METHOD_PAYFLOWPRO,
539
- self::METHOD_HOSTEDPRO,
540
- self::METHOD_WPP_EXPRESS,
541
- self::METHOD_BILLING_AGREEMENT,
542
- ),
543
- 'NZ' => array(
544
- self::METHOD_WPS,
545
- self::METHOD_PAYFLOWPRO,
546
- self::METHOD_WPP_EXPRESS,
547
- self::METHOD_BILLING_AGREEMENT,
548
- ),
549
- 'JP' => array(
550
- self::METHOD_WPS,
551
- self::METHOD_HOSTEDPRO,
552
- self::METHOD_WPP_EXPRESS,
553
- self::METHOD_BILLING_AGREEMENT,
554
- ),
555
- 'FR' => array(
556
- self::METHOD_WPS,
557
- self::METHOD_HOSTEDPRO,
558
- self::METHOD_WPP_EXPRESS,
559
- self::METHOD_BILLING_AGREEMENT,
560
- ),
561
- 'IT' => array(
562
- self::METHOD_WPS,
563
- self::METHOD_HOSTEDPRO,
564
- self::METHOD_WPP_EXPRESS,
565
- self::METHOD_BILLING_AGREEMENT,
566
- ),
567
- 'ES' => array(
568
- self::METHOD_WPS,
569
- self::METHOD_HOSTEDPRO,
570
- self::METHOD_WPP_EXPRESS,
571
- self::METHOD_BILLING_AGREEMENT,
572
- ),
573
- 'HK' => array(
574
- self::METHOD_WPS,
575
- self::METHOD_HOSTEDPRO,
576
- self::METHOD_WPP_EXPRESS,
577
- self::METHOD_BILLING_AGREEMENT,
578
- ),
579
- );
580
- if ($countryCode === null) {
581
- return $countryMethods;
582
- }
583
- return isset($countryMethods[$countryCode]) ? $countryMethods[$countryCode] : $countryMethods['other'];
584
- }
585
-
586
- /**
587
- * Return start url for PayPal Basic
588
- *
589
- * @param string $token
590
- * @return string
591
- */
592
- public function getPayPalBasicStartUrl($token)
593
- {
594
- $params = array(
595
- 'cmd' => '_express-checkout',
596
- 'token' => $token,
597
- );
598
-
599
- if ($this->isOrderReviewStepDisabled()) {
600
- $params['useraction'] = 'commit';
601
- }
602
-
603
- return $this->getPaypalUrl($params);
604
- }
605
-
606
- /**
607
- * Check whether order review step enabled in configuration
608
- *
609
- * @return bool
610
- */
611
- public function isOrderReviewStepDisabled()
612
- {
613
- return Mage::getStoreConfigFlag(self::XML_PATH_PAYPAL_EXPRESS_SKIP_ORDER_REVIEW_STEP_FLAG);
614
- }
615
-
616
- /**
617
- * Get url for dispatching customer to express checkout start
618
- *
619
- * @param string $token
620
- * @return string
621
- */
622
- public function getExpressCheckoutStartUrl($token)
623
- {
624
- return $this->getPaypalUrl(array(
625
- 'cmd' => '_express-checkout',
626
- 'token' => $token,
627
- ));
628
- }
629
-
630
- /**
631
- * Get url for dispatching customer to checkout retrial
632
- *
633
- * @param string $orderId
634
- * @return string
635
- */
636
- public function getExpressCheckoutOrderUrl($orderId)
637
- {
638
- return $this->getPaypalUrl(array(
639
- 'cmd' => '_express-checkout',
640
- 'order_id' => $orderId,
641
- ));
642
- }
643
-
644
- /**
645
- * Get url that allows to edit checkout details on paypal side
646
- *
647
- * @param $token
648
- * @return string
649
- */
650
- public function getExpressCheckoutEditUrl($token)
651
- {
652
- return $this->getPaypalUrl(array(
653
- 'cmd' => '_express-checkout',
654
- 'useraction' => 'continue',
655
- 'token' => $token,
656
- ));
657
- }
658
-
659
- /**
660
- * Get url for additional actions that PayPal may require customer to do after placing the order.
661
- * For instance, redirecting customer to bank for payment confirmation.
662
- *
663
- * @param string $token
664
- * @return string
665
- */
666
- public function getExpressCheckoutCompleteUrl($token)
667
- {
668
- return $this->getPaypalUrl(array(
669
- 'cmd' => '_complete-express-checkout',
670
- 'token' => $token,
671
- ));
672
- }
673
-
674
- /**
675
- * Retrieve url for initialization of billing agreement
676
- *
677
- * @param string $token
678
- * @return string
679
- */
680
- public function getStartBillingAgreementUrl($token)
681
- {
682
- return $this->getPaypalUrl(array(
683
- 'cmd' => '_customer-billing-agreement',
684
- 'token' => $token,
685
- ));
686
- }
687
-
688
- /**
689
- * PayPal web URL generic getter
690
- *
691
- * @param array $params
692
- * @return string
693
- */
694
- public function getPaypalUrl(array $params = array())
695
- {
696
- return sprintf('https://www.%spaypal.com/cgi-bin/webscr%s',
697
- $this->sandboxFlag ? 'sandbox.' : '',
698
- $params ? '?' . http_build_query($params) : ''
699
- );
700
- }
701
-
702
- /**
703
- * Whether Express Checkout button should be rendered dynamically
704
- *
705
- * @return bool
706
- */
707
- public function areButtonsDynamic()
708
- {
709
- return $this->buttonFlavor === self::EC_FLAVOR_DYNAMIC;
710
- }
711
-
712
- /**
713
- * Express checkout shortcut pic URL getter
714
- * PayPal will ignore "pal", if there is no total amount specified
715
- *
716
- * @param string $localeCode
717
- * @param float $orderTotal
718
- * @param string $pal encrypted summary about merchant
719
- * @see Paypal_Model_Api_Nvp::callGetPalDetails()
720
- */
721
- public function getExpressCheckoutShortcutImageUrl($localeCode, $orderTotal = null, $pal = null)
722
- {
723
- $country = Mage::getStoreConfig(Hps_Securesubmit_Helper_Data::MERCHANT_COUNTRY_CONFIG_PATH);
724
- if ($country == Hps_Securesubmit_Helper_Data::US_COUNTRY
725
- && ($this->areButtonsDynamic() || $this->buttonType != self::EC_BUTTON_TYPE_MARK)
726
- ) {
727
- return 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-medium.png';
728
- }
729
- if ($this->areButtonsDynamic()) {
730
- return $this->_getDynamicImageUrl(self::EC_BUTTON_TYPE_SHORTCUT, $localeCode, $orderTotal, $pal);
731
- }
732
- if ($this->buttonType === self::EC_BUTTON_TYPE_MARK) {
733
- return $this->getPaymentMarkImageUrl($localeCode);
734
- }
735
- return sprintf('https://www.paypal.com/%s/i/btn/btn_xpressCheckout.gif',
736
- $this->_getSupportedLocaleCode($localeCode));
737
- }
738
-
739
- /**
740
- * Get PayPal "mark" image URL
741
- * Supposed to be used on payment methods selection
742
- * $staticSize is applicable for static images only
743
- *
744
- * @param string $localeCode
745
- * @param float $orderTotal
746
- * @param string $pal
747
- * @param string $staticSize
748
- */
749
- public function getPaymentMarkImageUrl($localeCode, $orderTotal = null, $pal = null, $staticSize = null)
750
- {
751
- $country = Mage::getStoreConfig(Hps_Securesubmit_Helper_Data::MERCHANT_COUNTRY_CONFIG_PATH);
752
- if ($country == Hps_Securesubmit_Helper_Data::US_COUNTRY) {
753
- return 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/pp-acceptance-medium.png';
754
- }
755
- if ($this->areButtonsDynamic()) {
756
- return $this->_getDynamicImageUrl(self::EC_BUTTON_TYPE_MARK, $localeCode, $orderTotal, $pal);
757
- }
758
-
759
- if (null === $staticSize) {
760
- $staticSize = $this->paymentMarkSize;
761
- }
762
- switch ($staticSize) {
763
- case self::PAYMENT_MARK_37x23:
764
- case self::PAYMENT_MARK_50x34:
765
- case self::PAYMENT_MARK_60x38:
766
- case self::PAYMENT_MARK_180x113:
767
- break;
768
- default:
769
- $staticSize = self::PAYMENT_MARK_37x23;
770
- }
771
- return sprintf('https://www.paypal.com/%s/i/logo/PayPal_mark_%s.gif',
772
- $this->_getSupportedLocaleCode($localeCode), $staticSize);
773
- }
774
-
775
- /**
776
- * Get "What Is PayPal" localized URL
777
- * Supposed to be used with "mark" as popup window
778
- *
779
- * @param Mage_Core_Model_Locale $locale
780
- */
781
- public function getPaymentMarkWhatIsPaypalUrl(Mage_Core_Model_Locale $locale = null)
782
- {
783
- $countryCode = 'US';
784
- if (null !== $locale) {
785
- $shouldEmulate = (null !== $this->_storeId) && (Mage::app()->getStore()->getId() != $this->_storeId);
786
- if ($shouldEmulate) {
787
- $locale->emulate($this->_storeId);
788
- }
789
- $countryCode = $locale->getLocale()->getRegion();
790
- if ($shouldEmulate) {
791
- $locale->revert();
792
- }
793
- }
794
- return sprintf('https://www.paypal.com/%s/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside',
795
- strtolower($countryCode)
796
- );
797
- }
798
-
799
- /**
800
- * Getter for Solution banner images
801
- *
802
- * @param string $localeCode
803
- * @param bool $isVertical
804
- * @param bool $isEcheck
805
- */
806
- public function getSolutionImageUrl($localeCode, $isVertical = false, $isEcheck = false)
807
- {
808
- return sprintf('https://www.paypal.com/%s/i/bnr/%s_solution_PP%s.gif',
809
- $this->_getSupportedLocaleCode($localeCode),
810
- $isVertical ? 'vertical' : 'horizontal', $isEcheck ? 'eCheck' : ''
811
- );
812
- }
813
-
814
- /**
815
- * Getter for Payment form logo images
816
- *
817
- * @param string $localeCode
818
- */
819
- public function getPaymentFormLogoUrl($localeCode)
820
- {
821
- $locale = $this->_getSupportedLocaleCode($localeCode);
822
-
823
- $imageType = 'logo';
824
- $domain = 'paypal.com';
825
- list (,$country) = explode('_', $locale);
826
- $countryPrefix = $country . '/';
827
-
828
- switch ($locale) {
829
- case 'en_GB':
830
- $imageName = 'horizontal_solution_PP';
831
- $imageType = 'bnr';
832
- $countryPrefix = '';
833
- break;
834
- case 'de_DE':
835
- $imageName = 'lockbox_150x47';
836
- break;
837
- case 'fr_FR':
838
- $imageName = 'bnr_horizontal_solution_PP_327wx80h';
839
- $imageType = 'bnr';
840
- $locale = self::LOCALE_US;
841
- $domain = 'paypalobjects.com';
842
- break;
843
- case 'it_IT':
844
- $imageName = 'bnr_horizontal_solution_PP_178wx80h';
845
- $imageType = 'bnr';
846
- $domain = 'paypalobjects.com';
847
- break;
848
- default:
849
- $imageName='PayPal_mark_60x38';
850
- $countryPrefix = '';
851
- break;
852
- }
853
- return sprintf('https://www.%s/%s/%si/%s/%s.gif', $domain, $locale, $countryPrefix, $imageType, $imageName);
854
- }
855
-
856
- /**
857
- * Return supported types for PayPal logo
858
- *
859
- * @return array
860
- */
861
- public function getAdditionalOptionsLogoTypes()
862
- {
863
- return array(
864
- 'wePrefer_150x60' => Mage::helper('paypal')->__('We prefer PayPal (150 X 60)'),
865
- 'wePrefer_150x40' => Mage::helper('paypal')->__('We prefer PayPal (150 X 40)'),
866
- 'nowAccepting_150x60' => Mage::helper('paypal')->__('Now accepting PayPal (150 X 60)'),
867
- 'nowAccepting_150x40' => Mage::helper('paypal')->__('Now accepting PayPal (150 X 40)'),
868
- 'paymentsBy_150x60' => Mage::helper('paypal')->__('Payments by PayPal (150 X 60)'),
869
- 'paymentsBy_150x40' => Mage::helper('paypal')->__('Payments by PayPal (150 X 40)'),
870
- 'shopNowUsing_150x60' => Mage::helper('paypal')->__('Shop now using (150 X 60)'),
871
- 'shopNowUsing_150x40' => Mage::helper('paypal')->__('Shop now using (150 X 40)'),
872
- );
873
- }
874
-
875
- /**
876
- * Return PayPal logo URL with additional options
877
- *
878
- * @param string $localeCode Supported locale code
879
- * @param string $type One of supported logo types
880
- * @return string|bool Logo Image URL or false if logo disabled in configuration
881
- */
882
- public function getAdditionalOptionsLogoUrl($localeCode, $type = false)
883
- {
884
- $configType = Mage::getStoreConfig($this->_mapGenericStyleFieldset('logo'), $this->_storeId);
885
- if (!$configType) {
886
- return false;
887
- }
888
- $type = $type ? $type : $configType;
889
- $locale = $this->_getSupportedLocaleCode($localeCode);
890
- $supportedTypes = array_keys($this->getAdditionalOptionsLogoTypes());
891
- if (!in_array($type, $supportedTypes)) {
892
- $type = self::DEFAULT_LOGO_TYPE;
893
- }
894
- return sprintf('https://www.paypalobjects.com/%s/i/bnr/bnr_%s.gif', $locale, $type);
895
- }
896
-
897
- /**
898
- * BN code getter
899
- *
900
- * @return mixed
901
- */
902
- public function getBuildNotationCode()
903
- {
904
- return Mage::getStoreConfig("paypal/bncode", $this->_storeId);
905
- }
906
-
907
- /**
908
- * Express Checkout button "flavors" source getter
909
- *
910
- * @return array
911
- */
912
- public function getExpressCheckoutButtonFlavors()
913
- {
914
- return array(
915
- self::EC_FLAVOR_DYNAMIC => Mage::helper('paypal')->__('Dynamic'),
916
- self::EC_FLAVOR_STATIC => Mage::helper('paypal')->__('Static'),
917
- );
918
- }
919
-
920
- /**
921
- * Express Checkout button types source getter
922
- *
923
- * @return array
924
- */
925
- public function getExpressCheckoutButtonTypes()
926
- {
927
- return array(
928
- self::EC_BUTTON_TYPE_SHORTCUT => Mage::helper('paypal')->__('Shortcut'),
929
- self::EC_BUTTON_TYPE_MARK => Mage::helper('paypal')->__('Acceptance Mark Image'),
930
- );
931
- }
932
-
933
- /**
934
- * Payment actions source getter
935
- *
936
- * @return array
937
- */
938
- public function getPaymentActions()
939
- {
940
- $paymentActions = array(
941
- self::PAYMENT_ACTION_AUTH => Mage::helper('paypal')->__('Authorization'),
942
- self::PAYMENT_ACTION_SALE => Mage::helper('paypal')->__('Sale')
943
- );
944
- if (!is_null($this->_methodCode) && $this->_methodCode == self::METHOD_WPP_EXPRESS) {
945
- $paymentActions[self::PAYMENT_ACTION_ORDER] = Mage::helper('paypal')->__('Order');
946
- }
947
- return $paymentActions;
948
- }
949
-
950
- /**
951
- * Require Billing Address source getter
952
- *
953
- * @return array
954
- */
955
- public function getRequireBillingAddressOptions()
956
- {
957
- return array(
958
- self::REQUIRE_BILLING_ADDRESS_ALL => Mage::helper('paypal')->__('Yes'),
959
- self::REQUIRE_BILLING_ADDRESS_NO => Mage::helper('paypal')->__('No'),
960
- self::REQUIRE_BILLING_ADDRESS_VIRTUAL => Mage::helper('paypal')->__('For Virtual Quotes Only'),
961
- );
962
- }
963
-
964
- /**
965
- * Mapper from PayPal-specific payment actions to Magento payment actions
966
- *
967
- * @return string|null
968
- */
969
- public function getPaymentAction()
970
- {
971
- switch ($this->paymentAction) {
972
- case self::PAYMENT_ACTION_AUTH:
973
- return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
974
- case self::PAYMENT_ACTION_SALE:
975
- return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE;
976
- case self::PAYMENT_ACTION_ORDER:
977
- return Mage_Payment_Model_Method_Abstract::ACTION_ORDER;
978
- }
979
- }
980
-
981
- /**
982
- * Returns array of possible Authorization Amounts for Account Verification
983
- *
984
- * @deprecated since 1.6.2.0
985
- * @return array
986
- */
987
- public function getAuthorizationAmounts()
988
- {
989
- return array();
990
- }
991
-
992
- /**
993
- * Express Checkout "solution types" source getter
994
- * "sole" = "Express Checkout for Auctions" - PayPal allows guest checkout
995
- * "mark" = "Normal Express Checkout" - PayPal requires to checkout with PayPal buyer account only
996
- *
997
- * @return array
998
- */
999
- public function getExpressCheckoutSolutionTypes()
1000
- {
1001
- return array(
1002
- self::EC_SOLUTION_TYPE_SOLE => Mage::helper('paypal')->__('Yes'),
1003
- self::EC_SOLUTION_TYPE_MARK => Mage::helper('paypal')->__('No'),
1004
- );
1005
- }
1006
-
1007
- /**
1008
- * Retrieve express checkout billing agreement signup options
1009
- *
1010
- * @return array
1011
- */
1012
- public function getExpressCheckoutBASignupOptions()
1013
- {
1014
- return array(
1015
- self::EC_BA_SIGNUP_AUTO => Mage::helper('paypal')->__('Auto'),
1016
- self::EC_BA_SIGNUP_ASK => Mage::helper('paypal')->__('Ask Customer'),
1017
- self::EC_BA_SIGNUP_NEVER => Mage::helper('paypal')->__('Never')
1018
- );
1019
- }
1020
-
1021
- /**
1022
- * Whether to ask customer to create billing agreements
1023
- * Unilateral payments are incompatible with the billing agreements
1024
- *
1025
- * @return bool
1026
- */
1027
- public function shouldAskToCreateBillingAgreement()
1028
- {
1029
- return ($this->allow_ba_signup === self::EC_BA_SIGNUP_ASK) && !$this->shouldUseUnilateralPayments();
1030
- }
1031
-
1032
- /**
1033
- * Check whether only Unilateral payments (Accelerated Boarding) possible for Express method or not
1034
- *
1035
- * @return bool
1036
- */
1037
- public function shouldUseUnilateralPayments()
1038
- {
1039
- return $this->business_account && !$this->isWppApiAvailabe();
1040
- }
1041
-
1042
- /**
1043
- * Check whether WPP API credentials are available for this method
1044
- *
1045
- * @return bool
1046
- */
1047
- public function isWppApiAvailabe()
1048
- {
1049
- return $this->api_username && $this->api_password && ($this->api_signature || $this->api_cert);
1050
- }
1051
-
1052
- /**
1053
- * Payment data delivery methods getter for PayPal Standard
1054
- *
1055
- * @return array
1056
- */
1057
- public function getWpsPaymentDeliveryMethods()
1058
- {
1059
- return array(
1060
- self::WPS_TRANSPORT_IPN => Mage::helper('adminhtml')->__('IPN (Instant Payment Notification) Only'),
1061
- // not supported yet:
1062
- // self::WPS_TRANSPORT_PDT => Mage::helper('adminhtml')->__('PDT (Payment Data Transfer) Only'),
1063
- // self::WPS_TRANSPORT_IPN_PDT => Mage::helper('adminhtml')->__('Both IPN and PDT'),
1064
- );
1065
- }
1066
-
1067
- /**
1068
- * Return list of supported credit card types by Paypal Direct gateway
1069
- *
1070
- * @return array
1071
- */
1072
- public function getWppCcTypesAsOptionArray()
1073
- {
1074
- $model = Mage::getModel('payment/source_cctype')->setAllowedTypes(array('AE', 'VI', 'MC', 'SM', 'SO', 'DI'));
1075
- return $model->toOptionArray();
1076
- }
1077
-
1078
- /**
1079
- * Return list of supported credit card types by Paypal Direct (Payflow Edition) gateway
1080
- *
1081
- * @return array
1082
- */
1083
- public function getWppPeCcTypesAsOptionArray()
1084
- {
1085
- $model = Mage::getModel('payment/source_cctype')->setAllowedTypes(array('VI', 'MC', 'SM', 'SO', 'OT', 'AE'));
1086
- return $model->toOptionArray();
1087
- }
1088
-
1089
- /**
1090
- * Return list of supported credit card types by Payflow Pro gateway
1091
- *
1092
- * @return array
1093
- */
1094
- public function getPayflowproCcTypesAsOptionArray()
1095
- {
1096
- $model = Mage::getModel('payment/source_cctype')->setAllowedTypes(array('AE', 'VI', 'MC', 'JCB', 'DI'));
1097
- return $model->toOptionArray();
1098
- }
1099
-
1100
- /**
1101
- * Check whether the specified payment method is a CC-based one
1102
- *
1103
- * @param string $code
1104
- * @return bool
1105
- */
1106
- public static function getIsCreditCardMethod($code)
1107
- {
1108
- switch ($code) {
1109
- case self::METHOD_WPP_DIRECT:
1110
- case self::METHOD_WPP_PE_DIRECT:
1111
- case self::METHOD_PAYFLOWPRO:
1112
- case self::METHOD_PAYFLOWLINK:
1113
- case self::METHOD_PAYFLOWADVANCED:
1114
- case self::METHOD_HOSTEDPRO:
1115
- return true;
1116
- }
1117
- return false;
1118
- }
1119
-
1120
- /**
1121
- * Check whether specified currency code is supported
1122
- *
1123
- * @param string $code
1124
- * @return bool
1125
- */
1126
- public function isCurrencyCodeSupported($code)
1127
- {
1128
- if (in_array($code, $this->_supportedCurrencyCodes)) {
1129
- return true;
1130
- }
1131
- if ($this->getMerchantCountry() == 'BR' && $code == 'BRL') {
1132
- return true;
1133
- }
1134
- if ($this->getMerchantCountry() == 'MY' && $code == 'MYR') {
1135
- return true;
1136
- }
1137
- return false;
1138
- }
1139
-
1140
- /**
1141
- * Export page style current settings to specified object
1142
- *
1143
- * @param Varien_Object $to
1144
- */
1145
- public function exportExpressCheckoutStyleSettings(Varien_Object $to)
1146
- {
1147
- foreach ($this->_ecStyleConfigMap as $key => $exportKey) {
1148
- if ($this->$key) {
1149
- $to->setData($exportKey, $this->$key);
1150
- }
1151
- }
1152
- }
1153
-
1154
- /**
1155
- * Dynamic PayPal image URL getter
1156
- * Also can render dynamic Acceptance Mark
1157
- *
1158
- * @param string $type
1159
- * @param string $localeCode
1160
- * @param float $orderTotal
1161
- * @param string $pal
1162
- */
1163
- protected function _getDynamicImageUrl($type, $localeCode, $orderTotal, $pal)
1164
- {
1165
- $params = array(
1166
- 'cmd' => '_dynamic-image',
1167
- 'buttontype' => $type,
1168
- 'locale' => $this->_getSupportedLocaleCode($localeCode),
1169
- );
1170
- if ($orderTotal) {
1171
- $params['ordertotal'] = sprintf('%.2F', $orderTotal);
1172
- if ($pal) {
1173
- $params['pal'] = $pal;
1174
- }
1175
- }
1176
- return sprintf('https://fpdbs%s.paypal.com/dynamicimageweb?%s',
1177
- $this->sandboxFlag ? '.sandbox' : '', http_build_query($params)
1178
- );
1179
- }
1180
-
1181
- /**
1182
- * Check whether specified locale code is supported. Fallback to en_US
1183
- *
1184
- * @param string $localeCode
1185
- * @return string
1186
- */
1187
- protected function _getSupportedLocaleCode($localeCode = null)
1188
- {
1189
- if (!$localeCode || !in_array($localeCode, $this->_supportedImageLocales)) {
1190
- return self::LOCALE_US;
1191
- }
1192
- return $localeCode;
1193
- }
1194
-
1195
- /**
1196
- * Map any supported payment method into a config path by specified field name
1197
- *
1198
- * @param string $fieldName
1199
- * @return string|null
1200
- */
1201
- protected function _getSpecificConfigPath($fieldName)
1202
- {
1203
- $path = null;
1204
- switch ($this->_methodCode) {
1205
- case self::METHOD_WPS:
1206
- $path = $this->_mapStandardFieldset($fieldName);
1207
- break;
1208
- case self::METHOD_BML:
1209
- $path = $this->_mapBmlFieldset($fieldName);
1210
- break;
1211
- case self::METHOD_WPP_PE_BML:
1212
- $path = $this->_mapBmlUkFieldset($fieldName);
1213
- break;
1214
- case self::METHOD_WPP_EXPRESS:
1215
- case self::METHOD_WPP_PE_EXPRESS:
1216
- $path = $this->_mapExpressFieldset($fieldName);
1217
- break;
1218
- case self::METHOD_WPP_DIRECT:
1219
- case self::METHOD_WPP_PE_DIRECT:
1220
- $path = $this->_mapDirectFieldset($fieldName);
1221
- break;
1222
- case self::METHOD_BILLING_AGREEMENT:
1223
- case self::METHOD_HOSTEDPRO:
1224
- $path = $this->_mapMethodFieldset($fieldName);
1225
- break;
1226
- }
1227
-
1228
- if ($path === null) {
1229
- switch ($this->_methodCode) {
1230
- case self::METHOD_WPP_EXPRESS:
1231
- case self::METHOD_BML:
1232
- case self::METHOD_WPP_DIRECT:
1233
- case self::METHOD_BILLING_AGREEMENT:
1234
- case self::METHOD_HOSTEDPRO:
1235
- $path = $this->_mapWppFieldset($fieldName);
1236
- break;
1237
- case self::METHOD_WPP_PE_EXPRESS:
1238
- case self::METHOD_WPP_PE_DIRECT:
1239
- case self::METHOD_PAYFLOWADVANCED:
1240
- case self::METHOD_PAYFLOWLINK:
1241
- $path = $this->_mapWpukFieldset($fieldName);
1242
- break;
1243
- }
1244
- }
1245
-
1246
- if ($path === null) {
1247
- $path = $this->_mapGeneralFieldset($fieldName);
1248
- }
1249
- if ($path === null) {
1250
- $path = $this->_mapGenericStyleFieldset($fieldName);
1251
- }
1252
- return $path;
1253
- }
1254
-
1255
- /**
1256
- * Check wheter specified country code is supported by build notation codes for specific countries
1257
- *
1258
- * @param $code
1259
- * @return string|null
1260
- */
1261
- private function _matchBnCountryCode($code)
1262
- {
1263
- switch ($code) {
1264
- // GB == UK
1265
- case 'GB':
1266
- return 'UK';
1267
- // Australia, Austria, Belgium, Canada, China, France, Germany, Hong Kong, Italy
1268
- case 'AU': case 'AT': case 'BE': case 'CA': case 'CN': case 'FR': case 'DE': case 'HK': case 'IT':
1269
- // Japan, Mexico, Netherlands, Poland, Singapore, Spain, Switzerland, United Kingdom, United States
1270
- case 'JP': case 'MX': case 'NL': case 'PL': case 'SG': case 'ES': case 'CH': case 'UK': case 'US':
1271
- return $code;
1272
- }
1273
- }
1274
-
1275
- /**
1276
- * Map PayPal Standard config fields
1277
- *
1278
- * @param string $fieldName
1279
- * @return string|null
1280
- */
1281
- protected function _mapStandardFieldset($fieldName)
1282
- {
1283
- switch ($fieldName)
1284
- {
1285
- case 'line_items_summary':
1286
- case 'sandbox_flag':
1287
- return 'payment/' . self::METHOD_WPS . "/{$fieldName}";
1288
- default:
1289
- return $this->_mapMethodFieldset($fieldName);
1290
- }
1291
- }
1292
-
1293
- /**
1294
- * Map PayPal Express config fields
1295
- *
1296
- * @param string $fieldName
1297
- * @return string|null
1298
- */
1299
- protected function _mapExpressFieldset($fieldName)
1300
- {
1301
- switch ($fieldName)
1302
- {
1303
- case 'transfer_shipping_options':
1304
- case 'solution_type':
1305
- case 'visible_on_cart':
1306
- case 'visible_on_product':
1307
- case 'require_billing_address':
1308
- case 'authorization_honor_period':
1309
- case 'order_valid_period':
1310
- case 'child_authorization_number':
1311
- case 'allow_ba_signup':
1312
- return "payment/{$this->_methodCode}/{$fieldName}";
1313
- default:
1314
- return $this->_mapMethodFieldset($fieldName);
1315
- }
1316
- }
1317
-
1318
- /**
1319
- * Map PayPal Express Bill Me Later config fields
1320
- *
1321
- * @param string $fieldName
1322
- * @return string|null
1323
- */
1324
- protected function _mapBmlFieldset($fieldName)
1325
- {
1326
- switch ($fieldName)
1327
- {
1328
- case 'allow_ba_signup':
1329
- return "payment/" . self::METHOD_WPP_EXPRESS . "/{$fieldName}";
1330
- default:
1331
- return $this->_mapExpressFieldset($fieldName);
1332
- }
1333
- }
1334
-
1335
- /**
1336
- * Map PayPal Express Bill Me Later config fields (Payflow Edition)
1337
- *
1338
- * @param string $fieldName
1339
- * @return string|null
1340
- */
1341
- protected function _mapBmlUkFieldset($fieldName)
1342
- {
1343
- switch ($fieldName)
1344
- {
1345
- case 'allow_ba_signup':
1346
- return "payment/" . self::METHOD_WPP_PE_EXPRESS . "/{$fieldName}";
1347
- default:
1348
- return $this->_mapExpressFieldset($fieldName);
1349
- }
1350
- }
1351
-
1352
- /**
1353
- * Map PayPal Direct config fields
1354
- *
1355
- * @param string $fieldName
1356
- * @return string|null
1357
- */
1358
- protected function _mapDirectFieldset($fieldName)
1359
- {
1360
- switch ($fieldName)
1361
- {
1362
- case 'useccv':
1363
- case 'centinel':
1364
- case 'centinel_is_mode_strict':
1365
- case 'centinel_api_url':
1366
- return "payment/{$this->_methodCode}/{$fieldName}";
1367
- default:
1368
- return $this->_mapMethodFieldset($fieldName);
1369
- }
1370
- }
1371
-
1372
- /**
1373
- * Map PayPal Website Payments Pro common config fields
1374
- *
1375
- * @param string $fieldName
1376
- * @return string|null
1377
- */
1378
- protected function _mapWppFieldset($fieldName)
1379
- {
1380
- switch ($fieldName)
1381
- {
1382
- case 'api_authentication':
1383
- case 'api_username':
1384
- case 'api_password':
1385
- case 'api_signature':
1386
- case 'api_cert':
1387
- case 'sandbox_flag':
1388
- case 'use_proxy':
1389
- case 'proxy_host':
1390
- case 'proxy_port':
1391
- case 'button_flavor':
1392
- return "paypal/wpp/{$fieldName}";
1393
- default:
1394
- return null;
1395
- }
1396
- }
1397
-
1398
- /**
1399
- * Map PayPal Website Payments Pro common config fields
1400
- *
1401
- * @param string $fieldName
1402
- * @return string|null
1403
- */
1404
- protected function _mapWpukFieldset($fieldName)
1405
- {
1406
- $pathPrefix = 'paypal/wpuk';
1407
- // Use PUMP credentials from Verisign for EC when Direct Payments are unavailable
1408
- if ($this->_methodCode == self::METHOD_WPP_PE_EXPRESS
1409
- && !$this->isMethodAvailable(self::METHOD_WPP_PE_DIRECT)) {
1410
- $pathPrefix = 'payment/verisign';
1411
- } elseif ($this->_methodCode == self::METHOD_PAYFLOWADVANCED
1412
- || $this->_methodCode == self::METHOD_PAYFLOWLINK
1413
- ) {
1414
- $pathPrefix = 'payment/' . $this->_methodCode;
1415
- }
1416
- switch ($fieldName) {
1417
- case 'partner':
1418
- case 'user':
1419
- case 'vendor':
1420
- case 'pwd':
1421
- case 'sandbox_flag':
1422
- case 'use_proxy':
1423
- case 'proxy_host':
1424
- case 'proxy_port':
1425
- return $pathPrefix . '/' . $fieldName;
1426
- default:
1427
- return null;
1428
- }
1429
- }
1430
-
1431
- /**
1432
- * Map PayPal common style config fields
1433
- *
1434
- * @param string $fieldName
1435
- * @return string|null
1436
- */
1437
- protected function _mapGenericStyleFieldset($fieldName)
1438
- {
1439
- switch ($fieldName) {
1440
- case 'logo':
1441
- case 'page_style':
1442
- case 'paypal_hdrimg':
1443
- case 'paypal_hdrbackcolor':
1444
- case 'paypal_hdrbordercolor':
1445
- case 'paypal_payflowcolor':
1446
- return "paypal/style/{$fieldName}";
1447
- default:
1448
- return null;
1449
- }
1450
- }
1451
-
1452
- /**
1453
- * Map PayPal General Settings
1454
- *
1455
- * @param string $fieldName
1456
- * @return string|null
1457
- */
1458
- protected function _mapGeneralFieldset($fieldName)
1459
- {
1460
- switch ($fieldName)
1461
- {
1462
- case 'business_account':
1463
- case 'merchant_country':
1464
- return "paypal/general/{$fieldName}";
1465
- default:
1466
- return null;
1467
- }
1468
- }
1469
-
1470
- /**
1471
- * Map PayPal General Settings
1472
- *
1473
- * @param string $fieldName
1474
- * @return string|null
1475
- */
1476
- protected function _mapMethodFieldset($fieldName)
1477
- {
1478
- if (!$this->_methodCode) {
1479
- return null;
1480
- }
1481
- switch ($fieldName)
1482
- {
1483
- case 'active':
1484
- case 'title':
1485
- case 'payment_action':
1486
- case 'allowspecific':
1487
- case 'specificcountry':
1488
- case 'line_items_enabled':
1489
- case 'cctypes':
1490
- case 'sort_order':
1491
- case 'debug':
1492
- case 'verify_peer':
1493
- case 'mobile_optimized':
1494
- return "payment/{$this->_methodCode}/{$fieldName}";
1495
- default:
1496
- return null;
1497
- }
1498
- }
1499
-
1500
- /**
1501
- * Payment API authentication methods source getter
1502
- *
1503
- * @return array
1504
- */
1505
- public function getApiAuthenticationMethods()
1506
- {
1507
- return array(
1508
- '0' => Mage::helper('paypal')->__('API Signature'),
1509
- '1' => Mage::helper('paypal')->__('API Certificate')
1510
- );
1511
- }
1512
-
1513
- /**
1514
- * Api certificate getter
1515
- *
1516
- * @return string
1517
- */
1518
- public function getApiCertificate()
1519
- {
1520
- $websiteId = Mage::app()->getStore($this->_storeId)->getWebsiteId();
1521
- return Mage::getModel('paypal/cert')->loadByWebsite($websiteId, false)->getCertPath();
1522
- }
1523
-
1524
-
1525
- /**
1526
- * Get PublisherId from stored config
1527
- *
1528
- * @return mixed
1529
- */
1530
- public function getBmlPublisherId()
1531
- {
1532
- return Mage::getStoreConfig('payment/paypal_express_bml/publisher_id', $this->_storeId);
1533
- }
1534
-
1535
- /**
1536
- * Get Display option from stored config
1537
- * @param $section
1538
- *
1539
- * @return mixed
1540
- */
1541
- public function getBmlDisplay($section)
1542
- {
1543
- // $display = Mage::getStoreConfig('payment/paypal_express_bml/'.$section.'_display', $this->_storeId);
1544
- $ecActive = Mage::getStoreConfig('payment/hps_paypal/active', $this->_storeId);
1545
- $bmlActive = Mage::getStoreConfig('payment/hps_paypal_credit/active', $this->_storeId);
1546
- return ($bmlActive && $ecActive); // ? $display : 0;
1547
- }
1548
-
1549
- /**
1550
- * Get Position option from stored config
1551
- * @param $section
1552
- *
1553
- * @return mixed
1554
- */
1555
- public function getBmlPosition($section)
1556
- {
1557
- return Mage::getStoreConfig('payment/paypal_express_bml/'.$section.'_position', $this->_storeId);
1558
- }
1559
-
1560
- /**
1561
- * Get Size option from stored config
1562
- * @param $section
1563
- *
1564
- * @return mixed
1565
- */
1566
- public function getBmlSize($section)
1567
- {
1568
- return Mage::getStoreConfig('payment/paypal_express_bml/'.$section.'_size', $this->_storeId);
1569
- }
1570
- }
1571
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Hps/Securesubmit/Model/Masterpass.php ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once Mage::getBaseDir('lib').DS.'SecureSubmit'.DS.'Hps.php';
4
+ /**
5
+ * @category Hps
6
+ * @package Hps_Securesubmit
7
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
8
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
9
+ */
10
+
11
+ class Hps_Securesubmit_Model_Masterpass extends Mage_Payment_Model_Method_Abstract
12
+ {
13
+ protected $_code = 'hps_masterpass';
14
+ protected $_isGateway = true;
15
+ protected $_canCapture = true;
16
+ protected $_canCapturePartial = true;
17
+ protected $_canRefund = true;
18
+ protected $_canRefundInvoicePartial = true;
19
+ protected $_canVoid = true;
20
+ protected $_canAuthorize = true;
21
+
22
+ protected $_supportedCurrencyCodes = array('USD');
23
+ protected $_minOrderTotal = 0.5;
24
+
25
+ protected $_formBlockType = 'hps_securesubmit/masterpass_form';
26
+ protected $_infoBlockType = 'hps_securesubmit/masterpass_info';
27
+
28
+ public function validate()
29
+ {
30
+ $info = $this->getInfoInstance();
31
+ $additionalData = new Varien_Object($info->getAdditionalData() ? unserialize($info->getAdditionalData()) : null);
32
+
33
+ // Only validate when not using token
34
+ if ($additionalData->getUseCreditCard()) {
35
+ parent::validate();
36
+ }
37
+
38
+ return $this;
39
+ }
40
+
41
+ /**
42
+ * Capture payment
43
+ *
44
+ * @param Varien_Object $payment
45
+ * @param float $amount
46
+ * @return $this
47
+ */
48
+ public function capture(Varien_Object $payment, $amount)
49
+ {
50
+ $this->_authorize($payment, $amount, true);
51
+ }
52
+
53
+ /**
54
+ * Authorize payment
55
+ *
56
+ * @param Varien_Object $payment
57
+ * @param float $amount
58
+ * @return $this
59
+ */
60
+ public function authorize(Varien_Object $payment, $amount)
61
+ {
62
+ $this->_authorize($payment, $amount, false);
63
+ }
64
+
65
+ /**
66
+ * Authorize or Capture payment
67
+ *
68
+ * @param Varien_Object $payment
69
+ * @param float $amount
70
+ * @param bool $capture
71
+ * @return $this
72
+ */
73
+ private function _authorize(Varien_Object $payment, $amount, $capture)
74
+ {
75
+ $order = $payment->getOrder(); /* @var $order Mage_Sales_Model_Order */
76
+ $billing = $order->getBillingAddress();
77
+ $shipping = $order->getShippingAddress();
78
+ $authenticate = Mage::getSingleton('hps_securesubmit/session')->getMasterPassAuthenticate();
79
+ $currency = $order->getBaseCurrencyCode();
80
+
81
+ // Billing
82
+ $buyer = new HpsBuyerData();
83
+ $buyer->name = $billing->getData('firstname') . ' ' . $billing->getData('lastname');
84
+
85
+ $regionModel = Mage::getModel('directory/region')->load($billing->getRegionId());
86
+
87
+ $address = new HpsAddress();
88
+ $address->address = $billing->getStreet(1);
89
+ $address->city = $billing->getCity();
90
+ $address->state = $regionModel->getCode();
91
+ $address->zip = preg_replace('/[^0-9]/', '', $billing->getPostcode());
92
+ $address->country = $billing->getCountryId();
93
+ $buyer->address = $address;
94
+
95
+ // Shipping
96
+ $shippingInfo = new HpsShippingInfo();
97
+ $shippingInfo->name = $billing->getData('firstname') . ' ' . $billing->getData('lastname');
98
+
99
+ $regionModel = Mage::getModel('directory/region')->load($shipping->getRegionId());
100
+
101
+ $address = new HpsAddress();
102
+ $address->address = $shipping->getStreet(1);
103
+ $address->city = $shipping->getCity();
104
+ $address->state = $regionModel->getCode();
105
+ $address->zip = preg_replace('/[^0-9]/', '', $shipping->getPostcode());
106
+ $address->country = $shipping->getCountryId();
107
+ $shippingInfo->address = $address;
108
+
109
+ //$details = new HpsTransactionDetails();
110
+ //$details->invoiceNumber = $order->getIncrementId();
111
+
112
+ try
113
+ {
114
+ if (!$authenticate && !$payment->getCcTransId()) {
115
+ throw new Exception(
116
+ __('Error:', 'wc_securesubmit')
117
+ . ' Invalid MasterPass session'
118
+ );
119
+ }
120
+
121
+ // Create an authorization
122
+ $response = null;
123
+ $orderId = null;
124
+ if ($capture) {
125
+ if ($payment->getCcTransId()) {
126
+ $orderId = $this->getMasterPassOrderId($payment);
127
+ $orderData = new HpsOrderData();
128
+ $orderData->currencyCode = $currency;
129
+
130
+ $response = $this->getService()->capture(
131
+ $orderId,
132
+ $amount,
133
+ $orderData
134
+ );
135
+ } else {
136
+ $response = $this->getService()->sale(
137
+ $authenticate->orderId,
138
+ $amount,
139
+ $currency,
140
+ $buyer,
141
+ new HpsPaymentData(),
142
+ $shippingInfo
143
+ );
144
+ $orderId = $authenticate->orderId;
145
+ }
146
+ } else {
147
+ $response = $this->getService()->authorize(
148
+ $authenticate->orderId,
149
+ $amount,
150
+ $currency,
151
+ $buyer,
152
+ new HpsPaymentData(),
153
+ $shippingInfo
154
+ );
155
+ $orderId = $authenticate->orderId;
156
+ }
157
+
158
+ $transactionId = null;
159
+ if (property_exists($response, 'capture')) {
160
+ $transactionId = $response->capture->transactionId;
161
+ } else {
162
+ $transactionId = $response->transactionId;
163
+ }
164
+
165
+ // No exception thrown so action was a success
166
+ $this->_debugChargeService($this->getService());
167
+ $payment->setStatus(self::STATUS_APPROVED);
168
+ $payment->setAmount($amount);
169
+ $payment->setLastTransId($orderId);
170
+ $payment->setCcTransId($orderId);
171
+ $payment->setTransactionId($transactionId);
172
+ $payment->setIsTransactionClosed(0);
173
+ } catch (HpsException $e) {
174
+ $this->_debugChargeService($this->getService(), $e);
175
+ $payment->setStatus(self::STATUS_DECLINED);
176
+ $this->throwUserError($e->getMessage(), null, true);
177
+ } catch (Exception $e) {
178
+ $this->_debugChargeService($this->getService(), $e);
179
+ Mage::logException($e);
180
+ $payment->setStatus(self::STATUS_ERROR);
181
+ $this->throwUserError($e->getMessage());
182
+ }
183
+
184
+ return $this;
185
+ }
186
+
187
+ public function refund(Varien_Object $payment, $amount)
188
+ {
189
+ $order = $payment->getOrder();
190
+ $orderId = $this->getMasterPassOrderId($payment);
191
+ $currency = $order->getBaseCurrencyCode();
192
+ $transactionId = $payment->getTransactionId();
193
+
194
+ $orderData = new HpsOrderData();
195
+ $orderData->currencyCode = $currency;
196
+
197
+ try {
198
+ $refundResponse = $this->getService()->refund(
199
+ $orderId,
200
+ $order->getGrandTotal() === $amount,
201
+ $amount,
202
+ $orderData
203
+ );
204
+
205
+ $this->_debugChargeService($this->getService());
206
+ $payment
207
+ ->setTransactionId($refundResponse->transactionId)
208
+ ->setParentTransactionId($transactionId)
209
+ ->setIsTransactionClosed(1)
210
+ ->setShouldCloseParentTransaction(1);
211
+
212
+ }
213
+ catch (HpsException $e)
214
+ {
215
+ $this->_debugChargeService($this->getService(), $e);
216
+ $this->throwUserError($e->getMessage());
217
+ }
218
+ catch (Exception $e) {
219
+ $this->_debugChargeService($this->getService(), $e);
220
+ Mage::logException($e);
221
+ $this->throwUserError($e->getMessage());
222
+ }
223
+
224
+ return $this;
225
+ }
226
+
227
+ /**
228
+ * Void payment abstract method
229
+ *
230
+ * @param Varien_Object $payment
231
+ *
232
+ * @return Hps_Securesubmit_Model_Payment
233
+ */
234
+ public function void(Varien_Object $payment)
235
+ {
236
+ $orderId = $this->getMasterPassOrderId($payment);
237
+ $transactionId = $payment->getTransactionId();
238
+
239
+ try {
240
+ $voidResponse = $this->getService()->void($orderId);
241
+
242
+ $this->_debugChargeService($this->getService());
243
+ $payment
244
+ ->setTransactionId($voidResponse->transactionId)
245
+ ->setParentTransactionId($transactionId)
246
+ ->setIsTransactionClosed(1)
247
+ ->setShouldCloseParentTransaction(1);
248
+ } catch (HpsException $e) {
249
+ $this->_debugChargeService($this->getService(), $e);
250
+ Mage::throwException($e->getMessage());
251
+ } catch (Exception $e) {
252
+ $this->_debugChargeService($this->getService(), $e);
253
+ Mage::logException($e);
254
+ Mage::throwException(Mage::helper('hps_securesubmit')->__('An unexpected error occurred. Please try again or contact a system administrator.'));
255
+ }
256
+
257
+ return $this;
258
+ }
259
+
260
+ protected function getMasterPassOrderId($payment)
261
+ {
262
+ $orderId = $payment->getCcTransId();
263
+ Mage::log($orderId);
264
+ if ($orderId == null) {
265
+ $orderId = $payment->getLastTransId();
266
+ }
267
+ Mage::log($orderId);
268
+ return $orderId;
269
+ }
270
+
271
+ public function isAvailable($quote = null)
272
+ {
273
+ if ($quote && $quote->getBaseGrandTotal() < $this->_minOrderTotal) {
274
+ return false;
275
+ }
276
+
277
+ $storeId = $quote ? $quote->getStoreId() : null;
278
+ return $this->getConfigData('processor_id', $storeId)
279
+ && $this->getConfigData('merchant_id', $storeId)
280
+ && $this->getConfigData('transaction_pwd', $storeId)
281
+ && $this->getConfigData('merchant_checkout_id', $storeId)
282
+ && parent::isAvailable($quote);
283
+ }
284
+
285
+ public function canUseForCurrency($currencyCode)
286
+ {
287
+ if (!in_array($currencyCode, $this->_supportedCurrencyCodes)) {
288
+ return false;
289
+ }
290
+
291
+ return true;
292
+ }
293
+
294
+ /**
295
+ * @param string $error
296
+ * @param string $detailedError
297
+ * @param bool $goToPaymentSection
298
+ * @throws Mage_Core_Exception
299
+ */
300
+ public function throwUserError($error, $detailedError = NULL, $goToPaymentSection = FALSE)
301
+ {
302
+ // Register detailed error for error reporting elsewhere
303
+ $detailedError = $detailedError ? $error.' ['.$detailedError.']' : $error;
304
+ Mage::unregister('payment_detailed_error');
305
+ Mage::register('payment_detailed_error', $detailedError);
306
+
307
+ // Replace gateway error with custom error message for customers
308
+ $error = Mage::helper('hps_securesubmit')->__($error);
309
+ if ($customMessage = $this->getConfigData('custom_message')) {
310
+ $error = sprintf($customMessage, $error);
311
+ }
312
+
313
+ // Send checkout session back to payment section to avoid double-attempt to charge single-use token
314
+ if ($goToPaymentSection && Mage::app()->getRequest()->getOriginalPathInfo() == '/checkout/onepage/saveOrder') {
315
+ Mage::getSingleton('checkout/session')->setGotoSection('payment');
316
+ }
317
+ throw new Mage_Core_Exception($error);
318
+ }
319
+
320
+ /**
321
+ * @param HpsMasterPassService $service
322
+ * @param Exception|null $exception
323
+ */
324
+ public function _debugChargeService(HpsMasterPassService $service, $exception = NULL)
325
+ {
326
+ if ($this->getDebugFlag()) {
327
+ $this->_debug(array(
328
+ 'store' => Mage::app()->getStore($this->getStore())->getFrontendName(),
329
+ 'exception_message' => $exception ? get_class($exception).': '.$exception->getMessage() : '',
330
+ // 'last_request' => $service->lastRequest,
331
+ // 'last_response' => $service->lastResponse,
332
+ ));
333
+ }
334
+ }
335
+
336
+ protected function getService()
337
+ {
338
+ $config = new HpsCentinelConfig();
339
+ if (!Mage::getStoreConfig('payment/hps_masterpass/use_sandbox')) {
340
+ $config->serviceUri = "https://api-uat.heartlandportico.com/paymentserver.v1/PosGatewayService.asmx";
341
+ }
342
+ $config->processorId = Mage::getStoreConfig('payment/hps_masterpass/processor_id');
343
+ $config->merchantId = Mage::getStoreConfig('payment/hps_masterpass/merchant_id');
344
+ $config->transactionPwd = Mage::getStoreConfig('payment/hps_masterpass/transaction_pwd');
345
+ return new HpsMasterPassService($config);
346
+ }
347
+ }
app/code/community/Hps/Securesubmit/Model/Payment.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
2
 
3
  require_once Mage::getBaseDir('lib').DS.'SecureSubmit'.DS.'Hps.php';
 
 
 
 
 
 
4
 
5
  class Hps_Securesubmit_Model_Payment extends Mage_Payment_Model_Method_Cc
6
  {
@@ -13,11 +19,17 @@ class Hps_Securesubmit_Model_Payment extends Mage_Payment_Model_Method_Cc
13
  protected $_canVoid = true;
14
  protected $_canAuthorize = true;
15
 
16
- protected $_supportedCurrencyCodes = array('USD');
17
- protected $_minOrderTotal = 0.5;
18
 
19
- protected $_formBlockType = 'hps_securesubmit/form';
20
- protected $_infoBlockType = 'hps_securesubmit/info';
 
 
 
 
 
 
21
 
22
  /**
23
  * Fields that should be replaced in debug with '***'
@@ -30,10 +42,12 @@ class Hps_Securesubmit_Model_Payment extends Mage_Payment_Model_Method_Cc
30
  {
31
  $info = $this->getInfoInstance();
32
  $additionalData = new Varien_Object($info->getAdditionalData() ? unserialize($info->getAdditionalData()) : null);
 
33
 
34
- // Only validate when not using token
35
- if ($additionalData->getUseCreditCard()) {
36
- parent::validate();
 
37
  }
38
 
39
  return $this;
@@ -66,7 +80,7 @@ class Hps_Securesubmit_Model_Payment extends Mage_Payment_Model_Method_Cc
66
  /**
67
  * Authorize or Capture payment
68
  *
69
- * @param Varien_Object $payment
70
  * @param float $amount
71
  * @param bool $capture
72
  * @return $this
@@ -74,16 +88,69 @@ class Hps_Securesubmit_Model_Payment extends Mage_Payment_Model_Method_Cc
74
  private function _authorize(Varien_Object $payment, $amount, $capture)
75
  {
76
  $order = $payment->getOrder(); /* @var $order Mage_Sales_Model_Order */
77
- $billing = $order->getBillingAddress();
78
  $multiToken = false;
79
  $cardData = null;
80
- $cardType = null;
81
  $additionalData = new Varien_Object($payment->getAdditionalData() ? unserialize($payment->getAdditionalData()) : null);
82
  $secureToken = $additionalData->getSecuresubmitToken() ? $additionalData->getSecuresubmitToken() : null;
83
  $saveCreditCard = !! (bool)$additionalData->getCcSaveFuture();
84
- $useCreditCard = !! (bool)$additionalData->getUseCreditCard();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
- if ($saveCreditCard && ! $useCreditCard) {
87
  $multiToken = true;
88
  $cardData = new HpsCreditCard();
89
  $cardData->number = $payment->getCcLast4();
@@ -91,128 +158,166 @@ class Hps_Securesubmit_Model_Payment extends Mage_Payment_Model_Method_Cc
91
  $cardData->expMonth = $payment->getCcExpMonth();
92
  }
93
 
94
- $config = new HpsConfiguration();
95
- // Use HTTP proxy
96
- if (Mage::getStoreConfig('payment/hps_securesubmit/use_http_proxy')) {
97
- $config->useProxy = true;
98
- $config->proxyOptions = array(
99
- 'proxy_host' => Mage::getStoreConfig('payment/hps_securesubmit/http_proxy_host'),
100
- 'proxy_port' => Mage::getStoreConfig('payment/hps_securesubmit/http_proxy_port'),
101
- );
102
- }
103
-
104
- $config->secretApiKey = $this->getConfigData('secretapikey');
105
- $config->versionNumber = '1573';
106
- $config->developerId = '002914';
107
-
108
- $chargeService = new HpsChargeService($config);
109
-
110
- $address = new HpsAddress();
111
- $address->address = $billing->getStreet(1);
112
- $address->city = $billing->getCity();
113
- $address->state = $billing->getRegion();
114
- $address->zip = preg_replace('/[^0-9]/', '', $billing->getPostcode());
115
- $address->country = $billing->getCountry();
116
-
117
- $cardHolder = new HpsCardHolder();
118
- $cardHolder->firstName = $billing->getData('firstname');
119
- $cardHolder->lastName = $billing->getData('lastname');
120
- $cardHolder->phone = preg_replace('/[^0-9]/', '', $billing->getTelephone());
121
- $cardHolder->emailAddress = $billing->getData('email');
122
- $cardHolder->address = $address;
123
 
124
- if ($useCreditCard) {
125
- $cardOrToken = new HpsCreditCard();
126
- $cardOrToken->number = $payment->getCcNumber();
127
- $cardOrToken->expYear = $payment->getCcExpYear();
128
- $cardOrToken->expMonth = $payment->getCcExpMonth();
129
- $cardOrToken->cvv = $payment->getCcCid();
130
- } else {
131
- $cardOrToken = new HpsTokenData();
132
- $cardOrToken->tokenValue = $secureToken;
133
- }
134
-
135
- $details = new HpsTransactionDetails();
136
- $details->invoiceNumber = $order->getIncrementId();
137
 
138
- try
139
- {
140
- if ($capture)
141
- {
142
- if ($payment->getCcTransId())
143
- {
144
  $response = $chargeService->capture(
145
- $payment->getCcTransId(),
146
- $amount);
147
- }
148
- else
149
- {
150
  $response = $chargeService->charge(
151
  $amount,
152
  strtolower($order->getBaseCurrencyCode()),
153
  $cardOrToken,
154
  $cardHolder,
155
  $multiToken,
156
- $details);
 
157
  }
158
- }
159
- else
160
- {
161
  $response = $chargeService->authorize(
162
  $amount,
163
  strtolower($order->getBaseCurrencyCode()),
164
  $cardOrToken,
165
  $cardHolder,
166
  $multiToken,
167
- $details);
 
168
  }
169
- }
170
- catch (CardException $e) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  $this->_debugChargeService($chargeService, $e);
172
- $payment->setStatus(self::STATUS_DECLINED);
173
- $this->throwUserError($e->getMessage(), $e->ResultText, TRUE);
174
- }
175
- catch (Exception $e)
176
- {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  $this->_debugChargeService($chargeService, $e);
178
  Mage::logException($e);
179
  $payment->setStatus(self::STATUS_ERROR);
180
  $this->throwUserError($e->getMessage());
181
  }
182
 
183
- // No exception thrown so action was a success
184
- $this->_debugChargeService($chargeService);
185
- $payment->setStatus(self::STATUS_APPROVED);
186
- $payment->setAmount($amount);
187
- $payment->setLastTransId($response->transactionId);
188
- $payment->setCcTransId($response->transactionId);
189
- $payment->setTransactionId($response->transactionId);
190
- $payment->setIsTransactionClosed(0);
191
- if($multiToken){
192
- if ($response->tokenData->responseCode == '0') {
193
- Mage::helper('hps_securesubmit')->saveMultiToken($response->tokenData->tokenValue,$cardData,$response->cardType);
194
- } else {
195
- Mage::log(Mage::helper('hps_securesubmit')->__('Requested multi token has not been generated for the transaction # %s.', $response->transactionId), Zend_Log::WARN);
196
- }
197
- }
198
  return $this;
199
  }
200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  public function refund(Varien_Object $payment, $amount)
202
  {
203
- if ($this->canVoid($payment)) {
204
- // First try to void the payment and if the batch is already closed - try to refund the payment.
205
- try {
206
- $this->void($payment);
207
- } catch (Mage_Core_Exception $e) {
208
- $this->_refund($payment, $amount);
209
- }
210
  } else {
211
  $this->_refund($payment, $amount);
212
  }
213
  return $this;
214
  }
215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  /**
217
  * Void payment abstract method
218
  *
@@ -222,87 +327,87 @@ class Hps_Securesubmit_Model_Payment extends Mage_Payment_Model_Method_Cc
222
  */
223
  public function void(Varien_Object $payment)
224
  {
225
- $transactionId = $payment->getCcTransId();
226
-
227
- $config = new HpsConfiguration();
228
- $config->secretApiKey = $this->getConfigData('secretapikey');
229
- $config->versionNumber = '1509';
230
- $config->developerId = '002914';
231
 
232
- $chargeService = new HpsChargeService($config);
233
  try {
234
  $voidResponse = $chargeService->void($transactionId);
235
- }
236
- catch (HpsException $e)
237
- {
 
 
 
238
  $this->_debugChargeService($chargeService, $e);
239
- Mage::throwException($e->getMessage());
240
- }
241
- catch (Exception $e) {
242
  $this->_debugChargeService($chargeService, $e);
243
  Mage::logException($e);
244
- Mage::throwException(Mage::helper('hps_securesubmit')->__('An unexpected error occurred. Please try again or contact a system administrator.'));
245
  }
246
- $this->_debugChargeService($chargeService);
247
-
248
- $payment
249
- ->setTransactionId($voidResponse->TransactionId)
250
- ->setParentTransactionId($transactionId)
251
- ->setIsTransactionClosed(1)
252
- ->setShouldCloseParentTransaction(1);
253
 
254
  return $this;
255
  }
256
 
257
- protected function _refund(Varien_Object $payment, $amount)
 
 
 
 
 
258
  {
259
  $transactionId = $payment->getCcTransId();
260
- $order = $payment->getOrder();
261
 
262
- $config = new HpsConfiguration();
263
- $config->secretApiKey = $this->getConfigData('secretapikey');
264
- $config->versionNumber = '1573';
265
- $config->developerId = '002914';
266
 
267
- $chargeService = new HpsChargeService($config);
268
  try {
269
- $refundResponse = $chargeService->refundTransaction(
270
  $amount,
271
  strtolower($order->getBaseCurrencyCode()),
272
- $transactionId);
 
 
 
273
 
274
- }
275
- catch (HpsException $e)
276
- {
 
 
 
277
  $this->_debugChargeService($chargeService, $e);
278
  $this->throwUserError($e->getMessage());
279
- }
280
- catch (Exception $e) {
281
  $this->_debugChargeService($chargeService, $e);
282
  Mage::logException($e);
283
  $this->throwUserError($e->getMessage());
284
  }
285
- $this->_debugChargeService($chargeService);
286
-
287
- $payment
288
- ->setTransactionId($refundResponse->transactionId)
289
- ->setParentTransactionId($transactionId)
290
- ->setIsTransactionClosed(1)
291
- ->setShouldCloseParentTransaction(1);
292
 
293
  return $this;
294
- }
295
-
 
 
 
 
296
  public function isAvailable($quote = null)
297
  {
298
- if($quote && $quote->getBaseGrandTotal()<$this->_minOrderTotal) {
299
  return false;
300
  }
301
 
302
  return $this->getConfigData('secretapikey', ($quote ? $quote->getStoreId() : null))
303
  && parent::isAvailable($quote);
304
  }
305
-
306
  public function canUseForCurrency($currencyCode)
307
  {
308
  if (!in_array($currencyCode, $this->_supportedCurrencyCodes)) {
@@ -316,12 +421,12 @@ class Hps_Securesubmit_Model_Payment extends Mage_Payment_Model_Method_Cc
316
  {
317
  parent::assignData($data);
318
 
319
- if ( ! ($data instanceof Varien_Object)) {
320
  $data = new Varien_Object($data);
321
  }
322
  $info = $this->getInfoInstance();
323
 
324
- if ( ! $info->getCcLast4() && $data->getCcLastFour()) {
325
  $info->setCcLast4($data->getCcLastFour());
326
  }
327
 
@@ -332,10 +437,16 @@ class Hps_Securesubmit_Model_Payment extends Mage_Payment_Model_Method_Cc
332
  if ($data->getData('securesubmit_token')) {
333
  $details['securesubmit_token'] = $data->getData('securesubmit_token');
334
  }
 
 
 
335
  if ($data->getData('use_credit_card')) {
336
  $details['use_credit_card'] = 1;
337
  }
338
- if ( ! empty($details)) {
 
 
 
339
  $this->getInfoInstance()->setAdditionalData(serialize($details));
340
  }
341
 
@@ -348,10 +459,10 @@ class Hps_Securesubmit_Model_Payment extends Mage_Payment_Model_Method_Cc
348
  * @param bool $goToPaymentSection
349
  * @throws Mage_Core_Exception
350
  */
351
- public function throwUserError($error, $detailedError = NULL, $goToPaymentSection = FALSE)
352
  {
353
  // Register detailed error for error reporting elsewhere
354
- $detailedError = $detailedError ? $error.' ['.$detailedError.']' : $error;
355
  Mage::unregister('payment_detailed_error');
356
  Mage::register('payment_detailed_error', $detailedError);
357
 
@@ -365,23 +476,146 @@ class Hps_Securesubmit_Model_Payment extends Mage_Payment_Model_Method_Cc
365
  if ($goToPaymentSection && Mage::app()->getRequest()->getOriginalPathInfo() == '/checkout/onepage/saveOrder') {
366
  Mage::getSingleton('checkout/session')->setGotoSection('payment');
367
  }
 
368
  throw new Mage_Core_Exception($error);
369
  }
370
 
371
  /**
372
- * @param HpsChargeService $chargeService
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
373
  * @param Exception|null $exception
374
  */
375
- public function _debugChargeService(HpsChargeService $chargeService, $exception = NULL)
376
  {
377
  if ($this->getDebugFlag()) {
378
- $this->_debug(array(
379
  'store' => Mage::app()->getStore($this->getStore())->getFrontendName(),
380
  'exception_message' => $exception ? get_class($exception).': '.$exception->getMessage() : '',
381
  // 'last_request' => $chargeService->lastRequest,
382
  // 'last_response' => $chargeService->lastResponse,
383
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  }
 
 
385
  }
386
 
 
 
 
 
 
 
 
 
 
387
  }
1
  <?php
2
 
3
  require_once Mage::getBaseDir('lib').DS.'SecureSubmit'.DS.'Hps.php';
4
+ /**
5
+ * @category Hps
6
+ * @package Hps_Securesubmit
7
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
8
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
9
+ */
10
 
11
  class Hps_Securesubmit_Model_Payment extends Mage_Payment_Model_Method_Cc
12
  {
19
  protected $_canVoid = true;
20
  protected $_canAuthorize = true;
21
 
22
+ protected $_supportedCurrencyCodes = array('USD');
23
+ protected $_minOrderTotal = 0.5;
24
 
25
+ protected $_formBlockType = 'hps_securesubmit/form';
26
+ protected $_formBlockTypeAdmin = 'hps_securesubmit/adminhtml_form';
27
+ protected $_infoBlockType = 'hps_securesubmit/info';
28
+
29
+ protected $_allow_fraud = null;
30
+ protected $_email_fraud = null;
31
+ protected $_fraud_address = null;
32
+ protected $_fraud_text = null;
33
 
34
  /**
35
  * Fields that should be replaced in debug with '***'
42
  {
43
  $info = $this->getInfoInstance();
44
  $additionalData = new Varien_Object($info->getAdditionalData() ? unserialize($info->getAdditionalData()) : null);
45
+ $secureToken = $additionalData->getSecuresubmitToken() ? $additionalData->getSecuresubmitToken() : null;
46
 
47
+ // Gracefully handle javascript errors.
48
+ if (!$secureToken) {
49
+ Mage::log('Payment information submitted without token.', Zend_Log::ERR);
50
+ $this->throwUserError(Mage::helper('hps_securesubmit')->__('An unexpected error occurred. Please try resubmitting your payment information.'), null, true);
51
  }
52
 
53
  return $this;
80
  /**
81
  * Authorize or Capture payment
82
  *
83
+ * @param Varien_Object|Mage_Sales_Model_Order_Payment $payment
84
  * @param float $amount
85
  * @param bool $capture
86
  * @return $this
88
  private function _authorize(Varien_Object $payment, $amount, $capture)
89
  {
90
  $order = $payment->getOrder(); /* @var $order Mage_Sales_Model_Order */
 
91
  $multiToken = false;
92
  $cardData = null;
 
93
  $additionalData = new Varien_Object($payment->getAdditionalData() ? unserialize($payment->getAdditionalData()) : null);
94
  $secureToken = $additionalData->getSecuresubmitToken() ? $additionalData->getSecuresubmitToken() : null;
95
  $saveCreditCard = !! (bool)$additionalData->getCcSaveFuture();
96
+ $customerId = $additionalData->getCustomerId();
97
+
98
+ $giftService = $this->_getGiftService();
99
+ $giftCardNumber = $additionalData->getGiftcardNumber();
100
+
101
+ if ($giftCardNumber) {
102
+ // 1. check balance
103
+ $giftcard = new HpsGiftCard();
104
+ $giftcard->number = $giftCardNumber;
105
+
106
+ $giftResponse = $giftService->balance($giftcard);
107
+
108
+ // 2. is balance > amount?
109
+ if ($giftResponse->balanceAmount > $amount) {
110
+ // 2.yes. process full to gift
111
+ try {
112
+ if (strpos($this->getConfigData('secretapikey'), '_cert_') !== false) {
113
+ $giftresp = $giftService->sale($giftcard, 10.00);
114
+ } else {
115
+ $giftresp = $giftService->sale($giftcard, $amount);
116
+ }
117
+
118
+ $order->addStatusHistoryComment('Used Heartland Gift Card ' . $giftCardNumber . ' for amount $' . $amount . '. [full payment]');
119
+ $payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
120
+ array(
121
+ 'gift_card_number' => $giftCardNumber,
122
+ 'gift_card_transaction' => $giftresp->transactionId,
123
+ 'gift_card_amount_charged' => $amount));
124
+ $payment->setStatus(self::STATUS_APPROVED);
125
+ $payment->setAmount($amount);
126
+ $payment->setLastTransId($response->transactionId);
127
+ $payment->setTransactionId($response->transactionId);
128
+ $payment->setIsTransactionClosed(0);
129
+
130
+ return $this;
131
+ } catch (Exception $e) {
132
+ Mage::logException($e);
133
+ $payment->setStatus(self::STATUS_ERROR);
134
+ $this->throwUserError($e->getMessage(), null, true);
135
+ }
136
+ } else {
137
+ // 2.no. process full gift card amt and card process remainder
138
+ $giftresp = $giftService->sale($giftcard, $giftResponse->balanceAmount);
139
+ $order->addStatusHistoryComment('Used Heartland Gift Card ' . $giftCardNumber . ' for amount $' . $giftResponse->balanceAmount . '. [partial payment]')->save();
140
+ $payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
141
+ array(
142
+ 'gift_card_number' => $giftCardNumber,
143
+ 'gift_card_transaction' => $giftresp->transactionId,
144
+ 'gift_card_amount_charged' => $giftResponse->balanceAmount));
145
+
146
+ $payment->setAmount($giftResponse->balanceAmount)->save();
147
+ $amount = $amount - $giftResponse->balanceAmount; // remainder
148
+
149
+ // 3. TODO: if the card payment fails later, refund the gift transaction
150
+ }
151
+ }
152
 
153
+ if ($saveCreditCard) {
154
  $multiToken = true;
155
  $cardData = new HpsCreditCard();
156
  $cardData->number = $payment->getCcLast4();
158
  $cardData->expMonth = $payment->getCcExpMonth();
159
  }
160
 
161
+ $chargeService = $this->_getChargeService();
162
+ $cardHolder = $this->_getCardHolderData($order);
163
+ $details = $this->_getTxnDetailsData($order);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
+ $cardOrToken = new HpsTokenData();
166
+ $cardOrToken->tokenValue = $secureToken;
 
 
 
 
 
 
 
 
 
 
 
167
 
168
+ try {
169
+ if ($capture) {
170
+ if ($payment->getCcTransId()) {
 
 
 
171
  $response = $chargeService->capture(
172
+ $payment->getCcTransId(),
173
+ $amount
174
+ );
175
+ } else {
 
176
  $response = $chargeService->charge(
177
  $amount,
178
  strtolower($order->getBaseCurrencyCode()),
179
  $cardOrToken,
180
  $cardHolder,
181
  $multiToken,
182
+ $details
183
+ );
184
  }
185
+ } else {
 
 
186
  $response = $chargeService->authorize(
187
  $amount,
188
  strtolower($order->getBaseCurrencyCode()),
189
  $cardOrToken,
190
  $cardHolder,
191
  $multiToken,
192
+ $details
193
+ );
194
  }
195
+
196
+ $this->_debugChargeService($chargeService);
197
+ $payment->setStatus(self::STATUS_APPROVED);
198
+ $payment->setAmount($amount);
199
+ $payment->setLastTransId($response->transactionId);
200
+ $payment->setCcTransId($response->transactionId);
201
+ $payment->setTransactionId($response->transactionId);
202
+ $payment->setIsTransactionClosed(0);
203
+ if ($giftCardNumber) {
204
+ $order->addStatusHistoryComment('Remaining amount to be charged to credit card ' .$this->_formatAmount((string)$amount) . '. [partial payment]')->save();
205
+ }
206
+
207
+ if ($multiToken) {
208
+ $tokenData = $response->tokenData; /* @var $tokenData HpsTokenData */
209
+ if ($tokenData->responseCode == '0') {
210
+ if ($customerId > 0) {
211
+ Mage::helper('hps_securesubmit')->saveMultiToken($response->tokenData->tokenValue, $cardData, $response->cardType, $customerId);
212
+ } else {
213
+ Mage::helper('hps_securesubmit')->saveMultiToken($response->tokenData->tokenValue, $cardData, $response->cardType);
214
+ }
215
+ } else {
216
+ Mage::log('Requested multi token has not been generated for the transaction # ' . $response->transactionId, Zend_Log::WARN);
217
+ }
218
+ }
219
+ } catch (HpsCreditException $e) {
220
+ Mage::logException($e);
221
+ $this->getFraudSettings();
222
  $this->_debugChargeService($chargeService, $e);
223
+
224
+ // refund gift (if used)
225
+ if ($giftCardNumber) {
226
+ $order->addStatusHistoryComment('Reversed Heartland Gift Card ' . $giftCardNumber . ' for amount $' . $giftResponse->balanceAmount . '. [full reversal]')->save();
227
+ $giftResponse = $giftService->reverse($giftcard, $giftResponse->balanceAmount);
228
+ }
229
+
230
+ if ($this->_allow_fraud && $e->getCode() == HpsExceptionCodes::POSSIBLE_FRAUD_DETECTED) {
231
+ // we can skip the card saving if it fails for possible fraud there will be no token.
232
+
233
+ if ($this->_email_fraud && $this->_fraud_address != '') {
234
+ // EMAIL THE PEOPLE
235
+ $this->sendEmail(
236
+ $this->_fraud_address,
237
+ $this->_fraud_address,
238
+ 'Suspicious order (' . $order->getIncrementId() . ') allowed',
239
+ 'Hello,<br><br>Heartland has determined that you should review order ' . $order->getRealOrderId() . ' for the amount of ' . $amount . '.'
240
+ );
241
+ }
242
+
243
+ $payment->setStatus(self::STATUS_APPROVED);
244
+ $payment->setAmount($amount);
245
+ $payment->setIsTransactionClosed(0);
246
+ } else {
247
+ $payment->setStatus(self::STATUS_ERROR);
248
+ if ($e->getCode() == HpsExceptionCodes::POSSIBLE_FRAUD_DETECTED) {
249
+ $this->throwUserError($this->_fraud_text, null, true);
250
+ } else {
251
+ $this->throwUserError($e->getMessage(), null, true);
252
+ }
253
+ }
254
+ } catch (HpsException $e) {
255
+ $this->_debugChargeService($chargeService, $e);
256
+ $payment->setStatus(self::STATUS_ERROR);
257
+ $this->throwUserError($e->getMessage(), null, true);
258
+ } catch (Exception $e) {
259
  $this->_debugChargeService($chargeService, $e);
260
  Mage::logException($e);
261
  $payment->setStatus(self::STATUS_ERROR);
262
  $this->throwUserError($e->getMessage());
263
  }
264
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  return $this;
266
  }
267
 
268
+ protected function _formatAmount($amount) {
269
+ return Mage::helper('core')->currency($amount, true, false);
270
+ }
271
+
272
+ protected function getFraudSettings()
273
+ {
274
+ $this->_allow_fraud = Mage::getStoreConfig('payment/hps_securesubmit/allow_fraud') == 1;
275
+ $this->_email_fraud = Mage::getStoreConfig('payment/hps_securesubmit/email_fraud') == 1;
276
+ $this->_fraud_address = Mage::getStoreConfig('payment/hps_securesubmit/fraud_address');
277
+ $this->_fraud_text = Mage::getStoreConfig('payment/hps_securesubmit/fraud_text');
278
+ }
279
+
280
+ /**
281
+ * @param Varien_Object|Mage_Sales_Model_Order_Payment $payment
282
+ * @param float $amount
283
+ * @return Hps_Securesubmit_Model_Payment
284
+ */
285
  public function refund(Varien_Object $payment, $amount)
286
  {
287
+ if ($this->canVoid($payment) && $this->transactionActiveOnGateway($payment)) {
288
+ $this->void($payment);
 
 
 
 
 
289
  } else {
290
  $this->_refund($payment, $amount);
291
  }
292
  return $this;
293
  }
294
 
295
+ public function getParentTransactionId(Varien_Object $payment)
296
+ {
297
+ $transaction = Mage::getModel('sales/order_payment_transaction')->getCollection()
298
+ ->addAttributeToFilter('order_id', array('eq' => $payment->getOrder()->getEntityId()))
299
+ ->addAttributeToFilter('txn_type', array('eq' => 'capture'))
300
+ ->toArray();
301
+ if ($transaction['totalRecords'] == 1) {
302
+ return $transaction['items'][0]['parent_txn_id'];
303
+ } else {
304
+ return false;
305
+ }
306
+ }
307
+
308
+ public function transactionActiveOnGateway(Varien_Object $payment)
309
+ {
310
+ $transactionId = null;
311
+ if (false !== ($parentId = $this->getParentTransactionId($payment))) {
312
+ $transactionId = $parentId;
313
+ } else {
314
+ $transactionId = $payment->getCcTransId();
315
+ }
316
+ $service = $this->_getChargeService();
317
+ $transaction = $service->get($transactionId);
318
+ return $transaction->transactionStatus == 'A';
319
+ }
320
+
321
  /**
322
  * Void payment abstract method
323
  *
327
  */
328
  public function void(Varien_Object $payment)
329
  {
330
+ $transactionId = null;
331
+ if (false !== ($parentId = $this->getParentTransactionId($payment))) {
332
+ $transactionId = $parentId;
333
+ } else {
334
+ $transactionId = $payment->getCcTransId();
335
+ }
336
 
337
+ $chargeService = $this->_getChargeService();
338
  try {
339
  $voidResponse = $chargeService->void($transactionId);
340
+ $payment
341
+ ->setTransactionId($voidResponse->transactionId)
342
+ ->setParentTransactionId($transactionId)
343
+ ->setIsTransactionClosed(1)
344
+ ->setShouldCloseParentTransaction(1);
345
+ } catch (HpsException $e) {
346
  $this->_debugChargeService($chargeService, $e);
347
+ $this->throwUserError($e->getMessage());
348
+ } catch (Exception $e) {
 
349
  $this->_debugChargeService($chargeService, $e);
350
  Mage::logException($e);
351
+ $this->throwUserError(Mage::helper('hps_securesubmit')->__('An unexpected error occurred. Please try again or contact a system administrator.'));
352
  }
 
 
 
 
 
 
 
353
 
354
  return $this;
355
  }
356
 
357
+ /**
358
+ * @param Varien_Object|Mage_Sales_Model_Order_Payment $payment
359
+ * @param $amount
360
+ * @return Hps_Securesubmit_Model_Payment
361
+ */
362
+ public function _refund(Varien_Object $payment, $amount)
363
  {
364
  $transactionId = $payment->getCcTransId();
365
+ $order = $payment->getOrder(); /* @var $order Mage_Sales_Model_Order */
366
 
367
+ $chargeService = $this->_getChargeService();
368
+ $cardHolder = $this->_getCardHolderData($order);
369
+ $details = $this->_getTxnDetailsData($order);
 
370
 
 
371
  try {
372
+ $refundResponse = $chargeService->refund(
373
  $amount,
374
  strtolower($order->getBaseCurrencyCode()),
375
+ $transactionId,
376
+ $cardHolder,
377
+ $details
378
+ );
379
 
380
+ $payment
381
+ ->setTransactionId($refundResponse->transactionId)
382
+ ->setParentTransactionId($transactionId)
383
+ ->setIsTransactionClosed(1)
384
+ ->setShouldCloseParentTransaction(1);
385
+ } catch (HpsException $e) {
386
  $this->_debugChargeService($chargeService, $e);
387
  $this->throwUserError($e->getMessage());
388
+ } catch (Exception $e) {
 
389
  $this->_debugChargeService($chargeService, $e);
390
  Mage::logException($e);
391
  $this->throwUserError($e->getMessage());
392
  }
 
 
 
 
 
 
 
393
 
394
  return $this;
395
+ }
396
+
397
+ /**
398
+ * @param null|Mage_Sales_Model_Quote $quote
399
+ * @return bool
400
+ */
401
  public function isAvailable($quote = null)
402
  {
403
+ if ($quote && $quote->getBaseGrandTotal() < $this->_minOrderTotal) {
404
  return false;
405
  }
406
 
407
  return $this->getConfigData('secretapikey', ($quote ? $quote->getStoreId() : null))
408
  && parent::isAvailable($quote);
409
  }
410
+
411
  public function canUseForCurrency($currencyCode)
412
  {
413
  if (!in_array($currencyCode, $this->_supportedCurrencyCodes)) {
421
  {
422
  parent::assignData($data);
423
 
424
+ if (!($data instanceof Varien_Object)) {
425
  $data = new Varien_Object($data);
426
  }
427
  $info = $this->getInfoInstance();
428
 
429
+ if (!$info->getCcLast4() && $data->getCcLastFour()) {
430
  $info->setCcLast4($data->getCcLastFour());
431
  }
432
 
437
  if ($data->getData('securesubmit_token')) {
438
  $details['securesubmit_token'] = $data->getData('securesubmit_token');
439
  }
440
+ if ($data->getData('giftcard_number')) {
441
+ $details['giftcard_number'] = $data->getData('giftcard_number');
442
+ }
443
  if ($data->getData('use_credit_card')) {
444
  $details['use_credit_card'] = 1;
445
  }
446
+ if ($data->getData('customer_id')) {
447
+ $details['customer_id'] = $data->getData('customer_id');
448
+ }
449
+ if (!empty($details)) {
450
  $this->getInfoInstance()->setAdditionalData(serialize($details));
451
  }
452
 
459
  * @param bool $goToPaymentSection
460
  * @throws Mage_Core_Exception
461
  */
462
+ public function throwUserError($error, $detailedError = null, $goToPaymentSection = false)
463
  {
464
  // Register detailed error for error reporting elsewhere
465
+ $detailedError = $detailedError != null ? $error.' ['.$detailedError.']' : $error;
466
  Mage::unregister('payment_detailed_error');
467
  Mage::register('payment_detailed_error', $detailedError);
468
 
476
  if ($goToPaymentSection && Mage::app()->getRequest()->getOriginalPathInfo() == '/checkout/onepage/saveOrder') {
477
  Mage::getSingleton('checkout/session')->setGotoSection('payment');
478
  }
479
+ Mage::log('throwing user error with Mage_Core_Exception');
480
  throw new Mage_Core_Exception($error);
481
  }
482
 
483
  /**
484
+ * @return HpsCreditService
485
+ */
486
+ protected function _getChargeService()
487
+ {
488
+ $config = new HpsServicesConfig();
489
+
490
+ // Support HTTP proxy
491
+ if (Mage::getStoreConfig('payment/hps_securesubmit/use_http_proxy')) {
492
+ $config->useProxy = true;
493
+ $config->proxyOptions = array(
494
+ 'proxy_host' => Mage::getStoreConfig('payment/hps_securesubmit/http_proxy_host'),
495
+ 'proxy_port' => Mage::getStoreConfig('payment/hps_securesubmit/http_proxy_port'),
496
+ );
497
+ }
498
+
499
+ $config->secretApiKey = $this->getConfigData('secretapikey');
500
+ $config->versionNumber = '1573';
501
+ $config->developerId = '002914';
502
+
503
+ return new HpsCreditService($config);
504
+ }
505
+
506
+ protected function _getGiftService()
507
+ {
508
+ $config = new HpsServicesConfig();
509
+
510
+ // Support HTTP proxy
511
+ if (Mage::getStoreConfig('payment/hps_securesubmit/use_http_proxy')) {
512
+ $config->useProxy = true;
513
+ $config->proxyOptions = array(
514
+ 'proxy_host' => Mage::getStoreConfig('payment/hps_securesubmit/http_proxy_host'),
515
+ 'proxy_port' => Mage::getStoreConfig('payment/hps_securesubmit/http_proxy_port'),
516
+ );
517
+ }
518
+
519
+ $config->secretApiKey = $this->getConfigData('secretapikey');
520
+ $config->versionNumber = '1573';
521
+ $config->developerId = '002914';
522
+
523
+ return new HpsGiftCardService($config);
524
+ }
525
+
526
+ /**
527
+ * @param Mage_Sales_Model_Order $order
528
+ * @return HpsCardHolder
529
+ */
530
+ protected function _getCardHolderData($order)
531
+ {
532
+ $billing = $order->getBillingAddress();
533
+
534
+ $address = new HpsAddress();
535
+ $address->address = substr($billing->getStreet(1), 0, 40); // Actual limit unknown..
536
+ $address->city = substr($billing->getCity(), 0, 20);
537
+ $address->state = substr($billing->getRegion(), 0, 20);
538
+ $address->zip = substr(preg_replace('/[^A-Z0-9]/', '', strtoupper($billing->getPostcode())), 0, 9);
539
+ $address->country = $billing->getCountry();
540
+
541
+ $cardHolder = new HpsCardHolder();
542
+ $cardHolder->firstName = substr($billing->getData('firstname'), 0, 26);
543
+ $cardHolder->lastName = substr($billing->getData('lastname'), 0, 26);
544
+ $cardHolder->phone = substr(preg_replace('/[^0-9]/', '', $billing->getTelephone()), 0, 10);
545
+ $cardHolder->emailAddress = substr($billing->getData('email'), 0, 40);
546
+ $cardHolder->address = $address;
547
+
548
+ return $cardHolder;
549
+ }
550
+
551
+ /**
552
+ * @param Mage_Sales_Model_Order $order
553
+ * @return HpsTransactionDetails
554
+ */
555
+ protected function _getTxnDetailsData($order)
556
+ {
557
+ $memo = array();
558
+ $ip = '';
559
+ if (isset($_SERVER['REMOTE_ADDR'])) {
560
+ $ip = $_SERVER['REMOTE_ADDR'];
561
+ }
562
+ if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
563
+ $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
564
+ }
565
+ if ($ip) {
566
+ $memo[] = 'Customer IP Address: '.$ip;
567
+ }
568
+ if (isset($_SERVER['HTTP_USER_AGENT'])) {
569
+ $memo[] = 'User Agent: '.$_SERVER['HTTP_USER_AGENT'];
570
+ }
571
+ $memo = implode(', ', $memo);
572
+
573
+ $details = new HpsTransactionDetails();
574
+ $details->memo = substr($memo, 0, 200); // Actual limit unknown..
575
+ $details->invoiceNumber = $order->getIncrementId();
576
+ $details->customerId = substr($order->getCustomerEmail(), 0, 25); // Actual limit unknown..
577
+
578
+ return $details;
579
+ }
580
+
581
+ /**
582
+ * @param HpsCreditService $chargeService
583
  * @param Exception|null $exception
584
  */
585
+ protected function _debugChargeService(HpsCreditService $chargeService, $exception = null)
586
  {
587
  if ($this->getDebugFlag()) {
588
+ $debugData = array(
589
  'store' => Mage::app()->getStore($this->getStore())->getFrontendName(),
590
  'exception_message' => $exception ? get_class($exception).': '.$exception->getMessage() : '',
591
  // 'last_request' => $chargeService->lastRequest,
592
  // 'last_response' => $chargeService->lastResponse,
593
+ );
594
+ $this->_debug($debugData);
595
+ }
596
+ }
597
+
598
+ public function sendEmail($to, $from, $subject, $body, $headers = array(), $isHtml = true)
599
+ {
600
+ $headers[] = sprintf('From: %s', $from);
601
+ $headers[] = sprintf('Reply-To: %s', $from);
602
+ $message = $body;
603
+ if ($isHtml) {
604
+ $message = sprintf('<html><body>%s</body></html>', $body);
605
+ $headers[] = 'MIME-Version: 1.0';
606
+ $headers[] = 'Content-Type: text/html; charset=ISO-8859-1';
607
  }
608
+ $message = wordwrap($message, 70, "\r\n");
609
+ mail($to, $subject, $message, implode("\r\n", $headers));
610
  }
611
 
612
+ /**
613
+ * Retrieve block type for method form generation
614
+ *
615
+ * @return string
616
+ */
617
+ public function getFormBlockType()
618
+ {
619
+ return Mage::app()->getStore()->isAdmin() ? $this->_formBlockTypeAdmin : $this->_formBlockType;
620
+ }
621
  }
app/code/community/Hps/Securesubmit/Model/Paypal.php CHANGED
@@ -105,8 +105,8 @@ class Hps_Securesubmit_Model_Paypal extends Mage_Payment_Model_Method_Cc
105
  if (Mage::getStoreConfig('payment/hps_paypal/use_http_proxy')) {
106
  $config->useProxy = true;
107
  $config->proxyOptions = array(
108
- 'proxy_host' => Mage::getStoreConfig('payment/hps_paypal/http_proxy_host'),
109
  'proxy_port' => Mage::getStoreConfig('payment/hps_paypal/http_proxy_port'),
 
110
  );
111
  }
112
 
@@ -132,9 +132,9 @@ class Hps_Securesubmit_Model_Paypal extends Mage_Payment_Model_Method_Cc
132
  $buyer->emailAddress = $shipping->getData('email');
133
 
134
  $paymentData = new HpsPaymentData();
135
- $paymentData->subtotal = $subtotal;
136
- $paymentData->shippingAmount = $shippingAmount;
137
- $paymentData->taxAmount = $taxAmount;
138
 
139
  $shippingInfo = new HpsShippingInfo();
140
  $shippingInfo->name = $billing->getData('firstname') . ' ' . $billing->getData('lastname');
@@ -201,6 +201,15 @@ class Hps_Securesubmit_Model_Paypal extends Mage_Payment_Model_Method_Cc
201
  $payment->setCcTransId($response->transactionId);
202
  $payment->setTransactionId($response->transactionId);
203
  $payment->setIsTransactionClosed(0);
 
 
 
 
 
 
 
 
 
204
  }
205
  catch (HpsProcessorException $e) {
206
  $this->_debugChargeService($payPalService, $e);
@@ -404,9 +413,7 @@ class Hps_Securesubmit_Model_Paypal extends Mage_Payment_Model_Method_Cc
404
  $config->deviceId = Mage::getStoreConfig('payment/hps_paypal/device_id');
405
  $config->licenseId = Mage::getStoreConfig('payment/hps_paypal/license_id');
406
  $config->siteId = Mage::getStoreConfig('payment/hps_paypal/site_id');
407
- $config->soapServiceUri = "https://posgateway.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx";
408
- //$config->soapServiceUri = "https://api-uat.heartlandportico.com/paymentserver.v1/PosGatewayService.asmx";
409
- //$config->soapServiceUri = "https://api-uat.heartlandportico.com/paymentserver.HotFix/POSGatewayService.asmx";
410
  } else {
411
  $config->secretApiKey = Mage::getStoreConfig('payment/hps_paypal/secretapikey');
412
  }
105
  if (Mage::getStoreConfig('payment/hps_paypal/use_http_proxy')) {
106
  $config->useProxy = true;
107
  $config->proxyOptions = array(
 
108
  'proxy_port' => Mage::getStoreConfig('payment/hps_paypal/http_proxy_port'),
109
+ 'proxy_host' => Mage::getStoreConfig('payment/hps_paypal/http_proxy_host'),
110
  );
111
  }
112
 
132
  $buyer->emailAddress = $shipping->getData('email');
133
 
134
  $paymentData = new HpsPaymentData();
135
+ $paymentData->subtotal = sprintf("%0.2f", round($subtotal, 3));
136
+ $paymentData->shippingAmount = sprintf("%0.2f", round($shippingAmount, 3));
137
+ $paymentData->taxAmount = sprintf("%0.2f", round($taxAmount, 3));
138
 
139
  $shippingInfo = new HpsShippingInfo();
140
  $shippingInfo->name = $billing->getData('firstname') . ' ' . $billing->getData('lastname');
201
  $payment->setCcTransId($response->transactionId);
202
  $payment->setTransactionId($response->transactionId);
203
  $payment->setIsTransactionClosed(0);
204
+
205
+
206
+ // $info = new Varien_Object(
207
+ // $this->getInfoInstance()->getAdditionalData() ?
208
+ // unserialize($this->getInfoInstance()->getAdditionalData()) :
209
+ // null
210
+ // );
211
+ // $info->setBuyerEmailAddress($shipping->getData('email'));
212
+ // $this->getInfoInstance()->setAdditionalData(serialize($info));
213
  }
214
  catch (HpsProcessorException $e) {
215
  $this->_debugChargeService($payPalService, $e);
413
  $config->deviceId = Mage::getStoreConfig('payment/hps_paypal/device_id');
414
  $config->licenseId = Mage::getStoreConfig('payment/hps_paypal/license_id');
415
  $config->siteId = Mage::getStoreConfig('payment/hps_paypal/site_id');
416
+ $config->soapServiceUri = "https://api-uat.heartlandportico.com/paymentserver.v1/PosGatewayService.asmx";
 
 
417
  } else {
418
  $config->secretApiKey = Mage::getStoreConfig('payment/hps_paypal/secretapikey');
419
  }
app/code/community/Hps/Securesubmit/Model/Paypal/Checkout.php DELETED
@@ -1,1036 +0,0 @@
1
- <?php
2
- /**
3
- * @category Hps
4
- * @package Hps_Securesubmit
5
- * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
- * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
- */
8
-
9
- /**
10
- * Wrapper that performs Paypal Express and Checkout communication
11
- * Use current Paypal Express method instance
12
- */
13
- class Hps_Securesubmit_Model_Paypal_Checkout
14
- {
15
- /**
16
- * Cache ID prefix for "pal" lookup
17
- * @var string
18
- */
19
- const PAL_CACHE_ID = 'paypal_express_checkout_pal';
20
-
21
- /**
22
- * Keys for passthrough variables in sales/quote_payment and sales/order_payment
23
- * Uses additional_information as storage
24
- * @var string
25
- */
26
- const PAYMENT_INFO_TRANSPORT_TOKEN = 'paypal_express_checkout_token';
27
- const PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN = 'paypal_express_checkout_shipping_overriden';
28
- const PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD = 'paypal_express_checkout_shipping_method';
29
- const PAYMENT_INFO_TRANSPORT_PAYER_ID = 'paypal_express_checkout_payer_id';
30
- const PAYMENT_INFO_TRANSPORT_REDIRECT = 'paypal_express_checkout_redirect_required';
31
- const PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT = 'paypal_ec_create_ba';
32
-
33
- /**
34
- * Flag which says that was used PayPal Express Checkout button for checkout
35
- * Uses additional_information as storage
36
- * @var string
37
- */
38
- const PAYMENT_INFO_BUTTON = 'button';
39
-
40
- /**
41
- * Flag which says that was used PayPal Credit Checkout button for checkout
42
- * Uses additional_information as storage
43
- * @var string
44
- */
45
- const PAYMENT_INFO_CREDIT = 'credit';
46
-
47
- /**
48
- * @var Mage_Sales_Model_Quote
49
- */
50
- protected $_quote = null;
51
-
52
- /**
53
- * Config instance
54
- * @var Hps_Securesubmit_Model_Config
55
- */
56
- protected $_config = null;
57
-
58
- /**
59
- * API instance
60
- * @var Hps_Securesubmit_Model_Api_Nvp
61
- */
62
- protected $_api = null;
63
-
64
- /**
65
- * Api Model Type
66
- *
67
- * @var string
68
- */
69
- protected $_apiType = 'hps_securesubmit/api_paypal';
70
-
71
- /**
72
- * Payment method type
73
- *
74
- * @var unknown_type
75
- */
76
- protected $_methodType = 'hps_paypal';
77
-
78
- /**
79
- * State helper variables
80
- * @var string
81
- */
82
- protected $_redirectUrl = '';
83
- protected $_pendingPaymentMessage = '';
84
- protected $_checkoutRedirectUrl = '';
85
-
86
- /**
87
- * @var Mage_Customer_Model_Session
88
- */
89
- protected $_customerSession;
90
-
91
- /**
92
- * Redirect urls supposed to be set to support giropay
93
- *
94
- * @var array
95
- */
96
- protected $_giropayUrls = array();
97
-
98
- /**
99
- * Create Billing Agreement flag
100
- *
101
- * @var bool
102
- */
103
- protected $_isBARequested = false;
104
-
105
- /**
106
- * Flag for Bill Me Later mode
107
- *
108
- * @var bool
109
- */
110
- protected $_isBml = false;
111
-
112
- /**
113
- * Customer ID
114
- *
115
- * @var int
116
- */
117
- protected $_customerId = null;
118
-
119
- /**
120
- * Recurring payment profiles
121
- *
122
- * @var array
123
- */
124
- protected $_recurringPaymentProfiles = array();
125
-
126
- /**
127
- * Billing agreement that might be created during order placing
128
- *
129
- * @var Mage_Sales_Model_Billing_Agreement
130
- */
131
- protected $_billingAgreement = null;
132
-
133
- /**
134
- * Order
135
- *
136
- * @var Mage_Sales_Model_QuoteMage_Sales_Model_Quote
137
- */
138
- protected $_order = null;
139
-
140
- /**
141
- * Set quote and config instances
142
- * @param array $params
143
- */
144
- public function __construct($params = array())
145
- {
146
- if (isset($params['quote']) && $params['quote'] instanceof Mage_Sales_Model_Quote) {
147
- $this->_quote = $params['quote'];
148
- } else {
149
- throw new Exception('Quote instance is required.');
150
- }
151
- if (isset($params['config']) && $params['config'] instanceof Hps_Securesubmit_Model_Config) {
152
- $this->_config = $params['config'];
153
- } else {
154
- throw new Exception('Config instance is required.');
155
- }
156
- $this->_customerSession = isset($params['session']) && $params['session'] instanceof Mage_Customer_Model_Session
157
- ? $params['session'] : Mage::getSingleton('customer/session');
158
- }
159
-
160
- /**
161
- * Checkout with PayPal image URL getter
162
- * Spares API calls of getting "pal" variable, by putting it into cache per store view
163
- * @return string
164
- */
165
- public function getCheckoutShortcutImageUrl()
166
- {
167
- // get "pal" thing from cache or lookup it via API
168
- $pal = null;
169
- if ($this->_config->areButtonsDynamic()) {
170
- $cacheId = self::PAL_CACHE_ID . Mage::app()->getStore()->getId();
171
- $pal = Mage::app()->loadCache($cacheId);
172
- if (-1 == $pal) {
173
- $pal = null;
174
- } elseif (!$pal) {
175
- $pal = null;
176
- $this->_getApi();
177
- try {
178
- $this->_api->callGetPalDetails();
179
- $pal = $this->_api->getPal();
180
- Mage::app()->saveCache($pal, $cacheId, array(Mage_Core_Model_Config::CACHE_TAG));
181
- } catch (Exception $e) {
182
- Mage::app()->saveCache(-1, $cacheId, array(Mage_Core_Model_Config::CACHE_TAG));
183
- Mage::logException($e);
184
- }
185
- }
186
- }
187
-
188
- return $this->_config->getExpressCheckoutShortcutImageUrl(
189
- Mage::app()->getLocale()->getLocaleCode(),
190
- $this->_quote->getBaseGrandTotal(),
191
- $pal
192
- );
193
- }
194
-
195
- /**
196
- * Setter that enables giropay redirects flow
197
- *
198
- * @param string $successUrl - payment success result
199
- * @param string $cancelUrl - payment cancellation result
200
- * @param string $pendingUrl - pending payment result
201
- * @return Hps_Securesubmit_Model_Paypal_Checkout
202
- */
203
- public function prepareGiropayUrls($successUrl, $cancelUrl, $pendingUrl)
204
- {
205
- $this->_giropayUrls = array($successUrl, $cancelUrl, $pendingUrl);
206
- return $this;
207
- }
208
-
209
- /**
210
- * Set create billing agreement flag
211
- *
212
- * @param bool $flag
213
- * @return Hps_Securesubmit_Model_Paypal_Checkout
214
- */
215
- public function setIsBillingAgreementRequested($flag)
216
- {
217
- $this->_isBARequested = $flag;
218
- return $this;
219
- }
220
-
221
- /**
222
- * Setter for customer Id
223
- *
224
- * @param int $id
225
- * @return Hps_Securesubmit_Model_Paypal_Checkout
226
- * @deprecated please use self::setCustomer
227
- */
228
- public function setCustomerId($id)
229
- {
230
- $this->_customerId = $id;
231
- return $this;
232
- }
233
-
234
- /**
235
- * Set flag that forces to use BillMeLater
236
- *
237
- * @param bool $isBml
238
- */
239
- public function setIsBml($isBml)
240
- {
241
- $this->_isBml = $isBml;
242
- }
243
-
244
- /**
245
- * Setter for customer
246
- *
247
- * @param Mage_Customer_Model_Customer $customer
248
- * @return Hps_Securesubmit_Model_Paypal_Checkout
249
- */
250
- public function setCustomer($customer)
251
- {
252
- $this->_quote->assignCustomer($customer);
253
- $this->_customerId = $customer->getId();
254
- return $this;
255
- }
256
-
257
- /**
258
- * Setter for customer with billing and shipping address changing ability
259
- *
260
- * @param Mage_Customer_Model_Customer $customer
261
- * @param Mage_Sales_Model_Quote_Address $billingAddress
262
- * @param Mage_Sales_Model_Quote_Address $shippingAddress
263
- * @return Hps_Securesubmit_Model_Paypal_Checkout
264
- */
265
- public function setCustomerWithAddressChange($customer, $billingAddress = null, $shippingAddress = null)
266
- {
267
- $this->_quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress);
268
- $this->_customerId = $customer->getId();
269
- return $this;
270
- }
271
-
272
- /**
273
- * Reserve order ID for specified quote and start checkout on PayPal
274
- *
275
- * @param string $returnUrl
276
- * @param string $cancelUrl
277
- * @param array|null $params
278
- * @return mixed
279
- */
280
- public function start($returnUrl, $cancelUrl, $params = null)
281
- {
282
- $button = null;
283
- $credit = null;
284
- if (!empty($params)) {
285
- if (isset($params['button'])) $button = $params['button'];
286
- if (isset($params['credit'])) $credit = $params['credit'];
287
- }
288
- $this->_quote->collectTotals();
289
-
290
- if (!$this->_quote->getGrandTotal() && !$this->_quote->hasNominalItems()) {
291
- Mage::throwException(Mage::helper('paypal')->__('PayPal does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process.'));
292
- }
293
-
294
- $this->_quote->reserveOrderId()->save();
295
- // prepare API
296
- $this->_getApi();
297
- $solutionType = $this->_config->getMerchantCountry() == 'DE'
298
- ? Hps_Securesubmit_Model_Config::EC_SOLUTION_TYPE_MARK : $this->_config->solutionType;
299
- $this->_api->setAmount($this->_quote->getBaseGrandTotal())
300
- ->setCurrencyCode($this->_quote->getBaseCurrencyCode())
301
- ->setInvNum($this->_quote->getReservedOrderId())
302
- ->setReturnUrl($returnUrl)
303
- ->setCancelUrl($cancelUrl)
304
- ->setSolutionType($solutionType)
305
- ->setPaymentAction($this->_config->paymentAction);
306
-
307
- // supress or export shipping address
308
- if ($this->_quote->getIsVirtual()) {
309
- if ($this->_config->requireBillingAddress == Hps_Securesubmit_Model_Config::REQUIRE_BILLING_ADDRESS_VIRTUAL) {
310
- $this->_api->setRequireBillingAddress(1);
311
- }
312
- $this->_api->setSuppressShipping(true);
313
- } else {
314
- $address = $this->_quote->getShippingAddress();
315
- $isOverriden = 0;
316
- if (true === $address->validate()) {
317
- $isOverriden = 1;
318
- $this->_api->setAddress($address);
319
- }
320
- $this->_quote->getPayment()->setAdditionalInformation(
321
- self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN, $isOverriden
322
- );
323
- $this->_quote->getPayment()->save();
324
- }
325
-
326
- // // add line items
327
- $paypalCart = Mage::getModel('hps_securesubmit/paypal_cart', array($this->_quote));
328
- $this->_api->setPaypalCart($paypalCart)
329
- ->setIsLineItemsEnabled($this->_config->lineItemsEnabled)
330
- ;
331
-
332
- // // add shipping options if needed and line items are available
333
- // if ($this->_config->lineItemsEnabled && $this->_config->transferShippingOptions && $paypalCart->getItems()) {
334
- if (!$this->_quote->getIsVirtual() && !$this->_quote->hasNominalItems()) {
335
- if ($options = $this->_prepareShippingOptions($address, true)) {
336
- $this->_api->setShippingOptionsCallbackUrl(
337
- Mage::getUrl('*/*/shippingOptionsCallback', array('quote_id' => $this->_quote->getId()))
338
- )->setShippingOptions($options);
339
- }
340
- }
341
- // }
342
-
343
- // // add recurring payment profiles information
344
- // if ($profiles = $this->_quote->prepareRecurringPaymentProfiles()) {
345
- // foreach ($profiles as $profile) {
346
- // $profile->setMethodCode(Hps_Securesubmit_Model_Config::METHOD_WPP_EXPRESS);
347
- // if (!$profile->isValid()) {
348
- // Mage::throwException($profile->getValidationErrors(true, true));
349
- // }
350
- // }
351
- // $this->_api->addRecurringPaymentProfiles($profiles);
352
- // }
353
-
354
- // $this->_config->exportExpressCheckoutStyleSettings($this->_api);
355
-
356
- // call API and redirect with token
357
- // print "setting checkout session";
358
- $response = $this->_api->callSetExpressCheckout($credit);
359
- // print_r($response);
360
- $token = $response->sessionId;
361
- $this->_redirectUrl = $response->redirectUrl;
362
-
363
- $this->_quote->getPayment()->unsAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
364
-
365
- // Set flag that we came from Express Checkout button
366
- if (!empty($button)) {
367
- $this->_quote->getPayment()->setAdditionalInformation(self::PAYMENT_INFO_BUTTON, 1);
368
- } elseif ($this->_quote->getPayment()->hasAdditionalInformation(self::PAYMENT_INFO_BUTTON)) {
369
- $this->_quote->getPayment()->unsAdditionalInformation(self::PAYMENT_INFO_BUTTON);
370
- }
371
-
372
- // Set flag that we came from Credit Checkout button
373
- if (!empty($credit)) {
374
- $this->_quote->getPayment()->setAdditionalInformation(self::PAYMENT_INFO_CREDIT, 1);
375
- } elseif ($this->_quote->getPayment()->hasAdditionalInformation(self::PAYMENT_INFO_CREDIT)) {
376
- $this->_quote->getPayment()->unsAdditionalInformation(self::PAYMENT_INFO_CREDIT);
377
- }
378
-
379
- $this->_quote->getPayment()->save();
380
- return $token;
381
- }
382
-
383
- /**
384
- * Check whether system can skip order review page before placing order
385
- *
386
- * @return bool
387
- */
388
- public function canSkipOrderReviewStep()
389
- {
390
- $isOnepageCheckout = !$this->_quote->getPayment()
391
- ->getAdditionalInformation(Hps_Securesubmit_Model_Paypal_Checkout::PAYMENT_INFO_BUTTON);
392
- return $this->_config->isOrderReviewStepDisabled() && $isOnepageCheckout;
393
- }
394
-
395
- /**
396
- * Update quote when returned from PayPal
397
- * rewrite billing address by paypal
398
- * save old billing address for new customer
399
- * export shipping address in case address absence
400
- *
401
- * @param string $token
402
- */
403
- public function returnFromPaypal($token, $payerId)
404
- {
405
- $this->_getApi();
406
- $response = $this->_api->setToken($token)
407
- ->callGetExpressCheckoutDetails();
408
- $quote = $this->_quote;
409
-
410
- $this->_ignoreAddressValidation();
411
- $shippingAddress = null;
412
- $billingAddress = null;
413
-
414
- // import shipping address
415
- $exportedShippingAddress = $response->shipping;
416
- if (!$quote->getIsVirtual()) {
417
- $shippingAddress = $quote->getShippingAddress();
418
- if ($shippingAddress) {
419
- if ($exportedShippingAddress
420
- && $quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_BUTTON) == 1
421
- ) {
422
- $this->_setExportedAddressData($shippingAddress, $exportedShippingAddress);
423
- // PayPal doesn't provide detailed shipping info: prefix, middlename, lastname, suffix
424
- $shippingAddress->setPrefix(null);
425
- $shippingAddress->setFirstname($response->buyer->firstName);
426
- $shippingAddress->setMiddlename(null);
427
- $shippingAddress->setLastname($response->buyer->lastName);
428
- $shippingAddress->setEmail($response->buyer->emailAddress);
429
- $shippingAddress->setSuffix(null);
430
- $shippingAddress->setCollectShippingRates(true);
431
- $shippingAddress->setSameAsBilling(0);
432
- }
433
-
434
- // import shipping method
435
- $code = '';
436
- if ($this->_api->getShippingRateCode()) {
437
- if ($code = $this->_matchShippingMethodCode($shippingAddress, $this->_api->getShippingRateCode())) {
438
- // possible bug of double collecting rates :-/
439
- $shippingAddress->setShippingMethod($code)->setCollectShippingRates(true);
440
- }
441
- }
442
- $quote->getPayment()->setAdditionalInformation(
443
- self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD,
444
- $code
445
- );
446
- }
447
- }
448
-
449
- // import billing address
450
- $portBillingFromShipping = $quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_BUTTON) == 1
451
- // && $this->_config->requireBillingAddress != Hps_Securesubmit_Model_Config::REQUIRE_BILLING_ADDRESS_ALL
452
- && !$quote->isVirtual();
453
- if ($portBillingFromShipping) {
454
- $billingAddress = clone $shippingAddress;
455
- $billingAddress->unsAddressId()
456
- ->unsAddressType();
457
- $data = $billingAddress->getData();
458
- $data['save_in_address_book'] = 0;
459
- $quote->getBillingAddress()->addData($data);
460
- $quote->getShippingAddress()->setSameAsBilling(1);
461
- } else {
462
- $billingAddress = $quote->getBillingAddress();
463
- }
464
- // $exportedBillingAddress = $this->_api->getExportedBillingAddress();
465
- // $this->_setExportedAddressData($billingAddress, $exportedBillingAddress);
466
- // $billingAddress->setCustomerNotes($exportedBillingAddress->getData('note'));
467
- $quote->setBillingAddress($billingAddress);
468
- $quote->save();
469
-
470
- // import payment info
471
- $payment = $quote->getPayment();
472
- $payment->setMethod($this->_methodType);
473
- //Mage::getSingleton('paypal/info')->importToPayment($this->_api, $payment);
474
- $payment->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID, $payerId)
475
- ->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_TOKEN, $token)
476
- ;
477
- $quote->collectTotals()->save();
478
- }
479
-
480
- /**
481
- * Check whether order review has enough data to initialize
482
- *
483
- * @param $token
484
- * @throws Mage_Core_Exception
485
- */
486
- public function prepareOrderReview($token = null)
487
- {
488
- $payment = $this->_quote->getPayment();
489
- if (!$payment || !$payment->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID)) {
490
- Mage::throwException(Mage::helper('paypal')->__('Payer is not identified.'));
491
- }
492
- $this->_quote->setMayEditShippingAddress(
493
- 1 != $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN)
494
- );
495
- $this->_quote->setMayEditShippingMethod(
496
- '' == $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD)
497
- );
498
- $this->_ignoreAddressValidation();
499
- $this->_quote->collectTotals()->save();
500
- }
501
-
502
- /**
503
- * Return callback response with shipping options
504
- *
505
- * @param array $request
506
- * @return string
507
- */
508
- public function getShippingOptionsCallbackResponse(array $request)
509
- {
510
- // prepare debug data
511
- $logger = Mage::getModel('core/log_adapter', 'payment_' . $this->_methodType . '.log');
512
- $debugData = array('request' => $request, 'response' => array());
513
-
514
- try {
515
- // obtain addresses
516
- $this->_getApi();
517
- $address = $this->_api->prepareShippingOptionsCallbackAddress($request);
518
- $quoteAddress = $this->_quote->getShippingAddress();
519
-
520
- // compare addresses, calculate shipping rates and prepare response
521
- $options = array();
522
- if ($address && $quoteAddress && !$this->_quote->getIsVirtual()) {
523
- foreach ($address->getExportedKeys() as $key) {
524
- $quoteAddress->setDataUsingMethod($key, $address->getData($key));
525
- }
526
- $quoteAddress->setCollectShippingRates(true)->collectTotals();
527
- $options = $this->_prepareShippingOptions($quoteAddress, false, true);
528
- }
529
- $response = $this->_api->setShippingOptions($options)->formatShippingOptionsCallback();
530
-
531
- // log request and response
532
- $debugData['response'] = $response;
533
- $logger->log($debugData);
534
- return $response;
535
- } catch (Exception $e) {
536
- $logger->log($debugData);
537
- throw $e;
538
- }
539
- }
540
-
541
- /**
542
- * Set shipping method to quote, if needed
543
- * @param string $methodCode
544
- */
545
- public function updateShippingMethod($methodCode)
546
- {
547
- if (!$this->_quote->getIsVirtual() && $shippingAddress = $this->_quote->getShippingAddress()) {
548
- if ($methodCode != $shippingAddress->getShippingMethod()) {
549
- $this->_ignoreAddressValidation();
550
- $shippingAddress->setShippingMethod($methodCode)->setCollectShippingRates(true);
551
- $this->_quote->collectTotals()->save();
552
- }
553
- }
554
- }
555
-
556
- /**
557
- * Place the order and recurring payment profiles when customer returned from paypal
558
- * Until this moment all quote data must be valid
559
- *
560
- * @param string $token
561
- * @param string $shippingMethodCode
562
- */
563
- public function place($token, $shippingMethodCode = null)
564
- {
565
- if ($shippingMethodCode) {
566
- $this->updateShippingMethod($shippingMethodCode);
567
- }
568
-
569
- $isNewCustomer = false;
570
- switch ($this->getCheckoutMethod()) {
571
- case Mage_Checkout_Model_Type_Onepage::METHOD_GUEST:
572
- $this->_prepareGuestQuote();
573
- break;
574
- case Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER:
575
- $this->_prepareNewCustomerQuote();
576
- $isNewCustomer = true;
577
- break;
578
- default:
579
- $this->_prepareCustomerQuote();
580
- break;
581
- }
582
-
583
- $this->_ignoreAddressValidation();
584
- $this->_quote->collectTotals();
585
- $service = Mage::getModel('sales/service_quote', $this->_quote);
586
- $service->submitAll();
587
- $this->_quote->save();
588
-
589
- if ($isNewCustomer) {
590
- try {
591
- $this->_involveNewCustomer();
592
- } catch (Exception $e) {
593
- Mage::logException($e);
594
- }
595
- }
596
-
597
- $this->_recurringPaymentProfiles = $service->getRecurringPaymentProfiles();
598
- // TODO: send recurring profile emails
599
-
600
- /** @var $order Mage_Sales_Model_Order */
601
- $order = $service->getOrder();
602
- if (!$order) {
603
- return;
604
- }
605
- $this->_billingAgreement = $order->getPayment()->getBillingAgreement();
606
-
607
- // commence redirecting to finish payment, if paypal requires it
608
- if ($order->getPayment()->getAdditionalInformation(
609
- Hps_Securesubmit_Model_Paypal_Checkout::PAYMENT_INFO_TRANSPORT_REDIRECT
610
- )) {
611
- $this->_redirectUrl = $this->_config->getExpressCheckoutCompleteUrl($token);
612
- }
613
-
614
- switch ($order->getState()) {
615
- // even after placement paypal can disallow to authorize/capture, but will wait until bank transfers money
616
- case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
617
- // TODO
618
- break;
619
- // regular placement, when everything is ok
620
- case Mage_Sales_Model_Order::STATE_PROCESSING:
621
- case Mage_Sales_Model_Order::STATE_COMPLETE:
622
- case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
623
- $order->sendNewOrderEmail();
624
- break;
625
- }
626
- $this->_order = $order;
627
- }
628
-
629
- /**
630
- * Make sure addresses will be saved without validation errors
631
- */
632
- private function _ignoreAddressValidation()
633
- {
634
- $this->_quote->getBillingAddress()->setShouldIgnoreValidation(true);
635
- if (!$this->_quote->getIsVirtual()) {
636
- $this->_quote->getShippingAddress()->setShouldIgnoreValidation(true);
637
- if (!$this->_config->requireBillingAddress && !$this->_quote->getBillingAddress()->getEmail()) {
638
- $this->_quote->getBillingAddress()->setSameAsBilling(1);
639
- }
640
- }
641
- }
642
-
643
- /**
644
- * Determine whether redirect somewhere specifically is required
645
- *
646
- * @return string
647
- */
648
- public function getRedirectUrl()
649
- {
650
- return $this->_redirectUrl;
651
- }
652
-
653
- /**
654
- * Return recurring payment profiles
655
- *
656
- * @return array
657
- */
658
- public function getRecurringPaymentProfiles()
659
- {
660
- return $this->_recurringPaymentProfiles;
661
- }
662
-
663
- /**
664
- * Get created billing agreement
665
- *
666
- * @return Mage_Sales_Model_Billing_Agreement|null
667
- */
668
- public function getBillingAgreement()
669
- {
670
- return $this->_billingAgreement;
671
- }
672
-
673
- /**
674
- * Return order
675
- *
676
- * @return Mage_Sales_Model_Order
677
- */
678
- public function getOrder()
679
- {
680
- return $this->_order;
681
- }
682
-
683
- /**
684
- * Get checkout method
685
- *
686
- * @return string
687
- */
688
- public function getCheckoutMethod()
689
- {
690
- if ($this->getCustomerSession()->isLoggedIn()) {
691
- return Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER;
692
- }
693
- if (!$this->_quote->getCheckoutMethod()) {
694
- if (Mage::helper('checkout')->isAllowedGuestCheckout($this->_quote)) {
695
- $this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST);
696
- } else {
697
- $this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER);
698
- }
699
- }
700
- return $this->_quote->getCheckoutMethod();
701
- }
702
-
703
- /**
704
- * Sets address data from exported address
705
- *
706
- * @param Mage_Sales_Model_Quote_Address $address
707
- * @param HpsShippingInfo $exportedAddress
708
- */
709
- protected function _setExportedAddressData($address, $exportedAddress)
710
- {
711
- // Exported data is more priority if we came from Express Checkout button
712
- $isButton = (bool)$this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_BUTTON);
713
- if ($isButton) {
714
- $regionModel = Mage::getModel('directory/region')->loadByCode($exportedAddress->address->state, $exportedAddress->address->country);
715
- $address->setData('street', $exportedAddress->address->address);
716
- $address->setCity($exportedAddress->address->city);
717
- $address->setRegionId($regionModel->getId());
718
- $address->setPostcode($exportedAddress->address->zip);
719
- $address->setCountryId($exportedAddress->address->country);
720
- }
721
- }
722
-
723
- /**
724
- * Set create billing agreement flag to api call
725
- *
726
- * @return Hps_Securesubmit_Model_Paypal_Checkout
727
- */
728
- protected function _setBillingAgreementRequest()
729
- {
730
- if (!$this->_customerId || $this->_quote->hasNominalItems()) {
731
- return $this;
732
- }
733
-
734
- $isRequested = $this->_isBARequested || $this->_quote->getPayment()
735
- ->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
736
-
737
- if (!($this->_config->allow_ba_signup == Hps_Securesubmit_Model_Config::EC_BA_SIGNUP_AUTO
738
- || $isRequested && $this->_config->shouldAskToCreateBillingAgreement())) {
739
- return $this;
740
- }
741
-
742
- if (!Mage::getModel('sales/billing_agreement')->needToCreateForCustomer($this->_customerId)) {
743
- return $this;
744
- }
745
- $this->_api->setBillingType($this->_api->getBillingAgreementType());
746
- return $this;
747
- }
748
-
749
- /**
750
- * @return Hps_Securesubmit_Model_Api_Nvp
751
- */
752
- protected function _getApi()
753
- {
754
- if (null === $this->_api) {
755
- $this->_api = Mage::getModel($this->_apiType)->setConfigObject($this->_config);
756
- }
757
- return $this->_api;
758
- }
759
-
760
- /**
761
- * Attempt to collect address shipping rates and return them for further usage in instant update API
762
- * Returns empty array if it was impossible to obtain any shipping rate
763
- * If there are shipping rates obtained, the method must return one of them as default.
764
- *
765
- * @param Mage_Sales_Model_Quote_Address $address
766
- * @param bool $mayReturnEmpty
767
- * @return array|false
768
- */
769
- protected function _prepareShippingOptions(
770
- Mage_Sales_Model_Quote_Address $address,
771
- $mayReturnEmpty = false, $calculateTax = false
772
- ) {
773
- $options = array(); $i = 0; $iMin = false; $min = false;
774
- $userSelectedOption = null;
775
-
776
- foreach ($address->getGroupedAllShippingRates() as $group) {
777
- foreach ($group as $rate) {
778
- $amount = (float)$rate->getPrice();
779
- if ($rate->getErrorMessage()) {
780
- continue;
781
- }
782
- $isDefault = $address->getShippingMethod() === $rate->getCode();
783
- $amountExclTax = Mage::helper('tax')->getShippingPrice($amount, false, $address);
784
- $amountInclTax = Mage::helper('tax')->getShippingPrice($amount, true, $address);
785
-
786
- $options[$i] = new Varien_Object(array(
787
- 'is_default' => $isDefault,
788
- 'name' => trim("{$rate->getCarrier()} - {$rate->getMethodTitle()}", ' -'),
789
- 'code' => $rate->getCode(),
790
- 'amount' => $amountExclTax,
791
- ));
792
- if ($calculateTax) {
793
- $options[$i]->setTaxAmount(
794
- $amountInclTax - $amountExclTax
795
- + $address->getTaxAmount() - $address->getShippingTaxAmount()
796
- );
797
- }
798
- if ($isDefault) {
799
- $userSelectedOption = $options[$i];
800
- }
801
- if (false === $min || $amountInclTax < $min) {
802
- $min = $amountInclTax;
803
- $iMin = $i;
804
- }
805
- $i++;
806
- }
807
- }
808
-
809
- if ($mayReturnEmpty && is_null($userSelectedOption)) {
810
- $options[] = new Varien_Object(array(
811
- 'is_default' => true,
812
- 'name' => Mage::helper('paypal')->__('N/A'),
813
- 'code' => 'no_rate',
814
- 'amount' => 0.00,
815
- ));
816
- if ($calculateTax) {
817
- $options[$i]->setTaxAmount($address->getTaxAmount());
818
- }
819
- } elseif (is_null($userSelectedOption) && isset($options[$iMin])) {
820
- $options[$iMin]->setIsDefault(true);
821
- }
822
-
823
- // Magento will transfer only first 10 cheapest shipping options if there are more than 10 available.
824
- if (count($options) > 10) {
825
- usort($options, array(get_class($this),'cmpShippingOptions'));
826
- array_splice($options, 10);
827
- // User selected option will be always included in options list
828
- if (!is_null($userSelectedOption) && !in_array($userSelectedOption, $options)) {
829
- $options[9] = $userSelectedOption;
830
- }
831
- }
832
-
833
- return $options;
834
- }
835
-
836
- /**
837
- * Compare two shipping options based on their amounts
838
- *
839
- * This function is used as a callback comparison function in shipping options sorting process
840
- * @see self::_prepareShippingOptions()
841
- *
842
- * @param Varien_Object $option1
843
- * @param Varien_Object $option2
844
- * @return integer
845
- */
846
- protected static function cmpShippingOptions(Varien_Object $option1, Varien_Object $option2)
847
- {
848
- if ($option1->getAmount() == $option2->getAmount()) {
849
- return 0;
850
- }
851
- return ($option1->getAmount() < $option2->getAmount()) ? -1 : 1;
852
- }
853
-
854
- /**
855
- * Try to find whether the code provided by PayPal corresponds to any of possible shipping rates
856
- * This method was created only because PayPal has issues with returning the selected code.
857
- * If in future the issue is fixed, we don't need to attempt to match it. It would be enough to set the method code
858
- * before collecting shipping rates
859
- *
860
- * @param Mage_Sales_Model_Quote_Address $address
861
- * @param string $selectedCode
862
- * @return string
863
- */
864
- protected function _matchShippingMethodCode(Mage_Sales_Model_Quote_Address $address, $selectedCode)
865
- {
866
- $options = $this->_prepareShippingOptions($address, false);
867
- foreach ($options as $option) {
868
- if ($selectedCode === $option['code'] // the proper case as outlined in documentation
869
- || $selectedCode === $option['name'] // workaround: PayPal may return name instead of the code
870
- // workaround: PayPal may concatenate code and name, and return it instead of the code:
871
- || $selectedCode === "{$option['code']} {$option['name']}"
872
- ) {
873
- return $option['code'];
874
- }
875
- }
876
- return '';
877
- }
878
-
879
- /**
880
- * Prepare quote for guest checkout order submit
881
- *
882
- * @return Hps_Securesubmit_Model_Paypal_Checkout
883
- */
884
- protected function _prepareGuestQuote()
885
- {
886
- $quote = $this->_quote;
887
- $quote->setCustomerId(null)
888
- ->setCustomerEmail($quote->getBillingAddress()->getEmail())
889
- ->setCustomerIsGuest(true)
890
- ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
891
- return $this;
892
- }
893
-
894
- /**
895
- * Checks if customer with email coming from Express checkout exists
896
- *
897
- * @return int
898
- */
899
- protected function _lookupCustomerId()
900
- {
901
- return Mage::getModel('customer/customer')
902
- ->setWebsiteId(Mage::app()->getWebsite()->getId())
903
- ->loadByEmail($this->_quote->getCustomerEmail())
904
- ->getId();
905
- }
906
-
907
- /**
908
- * Prepare quote for customer registration and customer order submit
909
- * and restore magento customer data from quote
910
- *
911
- * @return Hps_Securesubmit_Model_Paypal_Checkout
912
- */
913
- protected function _prepareNewCustomerQuote()
914
- {
915
- $quote = $this->_quote;
916
- $billing = $quote->getBillingAddress();
917
- $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
918
-
919
- $customerId = $this->_lookupCustomerId();
920
- if ($customerId) {
921
- $this->getCustomerSession()->loginById($customerId);
922
- return $this->_prepareCustomerQuote();
923
- }
924
-
925
- $customer = $quote->getCustomer();
926
- /** @var $customer Mage_Customer_Model_Customer */
927
- $customerBilling = $billing->exportCustomerAddress();
928
- $customer->addAddress($customerBilling);
929
- $billing->setCustomerAddress($customerBilling);
930
- $customerBilling->setIsDefaultBilling(true);
931
- if ($shipping && !$shipping->getSameAsBilling()) {
932
- $customerShipping = $shipping->exportCustomerAddress();
933
- $customer->addAddress($customerShipping);
934
- $shipping->setCustomerAddress($customerShipping);
935
- $customerShipping->setIsDefaultShipping(true);
936
- } elseif ($shipping) {
937
- $customerBilling->setIsDefaultShipping(true);
938
- }
939
- /**
940
- * @todo integration with dynamica attributes customer_dob, customer_taxvat, customer_gender
941
- */
942
- if ($quote->getCustomerDob() && !$billing->getCustomerDob()) {
943
- $billing->setCustomerDob($quote->getCustomerDob());
944
- }
945
-
946
- if ($quote->getCustomerTaxvat() && !$billing->getCustomerTaxvat()) {
947
- $billing->setCustomerTaxvat($quote->getCustomerTaxvat());
948
- }
949
-
950
- if ($quote->getCustomerGender() && !$billing->getCustomerGender()) {
951
- $billing->setCustomerGender($quote->getCustomerGender());
952
- }
953
-
954
- Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer);
955
- $customer->setEmail($quote->getCustomerEmail());
956
- $customer->setPrefix($quote->getCustomerPrefix());
957
- $customer->setFirstname($quote->getCustomerFirstname());
958
- $customer->setMiddlename($quote->getCustomerMiddlename());
959
- $customer->setLastname($quote->getCustomerLastname());
960
- $customer->setSuffix($quote->getCustomerSuffix());
961
- $customer->setPassword($customer->decryptPassword($quote->getPasswordHash()));
962
- $customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
963
- $customer->save();
964
- $quote->setCustomer($customer);
965
-
966
- return $this;
967
- }
968
-
969
- /**
970
- * Prepare quote for customer order submit
971
- *
972
- * @return Hps_Securesubmit_Model_Paypal_Checkout
973
- */
974
- protected function _prepareCustomerQuote()
975
- {
976
- $quote = $this->_quote;
977
- $billing = $quote->getBillingAddress();
978
- $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
979
-
980
- $customer = $this->getCustomerSession()->getCustomer();
981
- if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
982
- $customerBilling = $billing->exportCustomerAddress();
983
- $customer->addAddress($customerBilling);
984
- $billing->setCustomerAddress($customerBilling);
985
- }
986
- if ($shipping && ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling())
987
- || (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook()))) {
988
- $customerShipping = $shipping->exportCustomerAddress();
989
- $customer->addAddress($customerShipping);
990
- $shipping->setCustomerAddress($customerShipping);
991
- }
992
-
993
- if (isset($customerBilling) && !$customer->getDefaultBilling()) {
994
- $customerBilling->setIsDefaultBilling(true);
995
- }
996
- if ($shipping && isset($customerBilling) && !$customer->getDefaultShipping() && $shipping->getSameAsBilling()) {
997
- $customerBilling->setIsDefaultShipping(true);
998
- } elseif ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
999
- $customerShipping->setIsDefaultShipping(true);
1000
- }
1001
- $quote->setCustomer($customer);
1002
-
1003
- return $this;
1004
- }
1005
-
1006
- /**
1007
- * Involve new customer to system
1008
- *
1009
- * @return Hps_Securesubmit_Model_Paypal_Checkout
1010
- */
1011
- protected function _involveNewCustomer()
1012
- {
1013
- $customer = $this->_quote->getCustomer();
1014
- if ($customer->isConfirmationRequired()) {
1015
- $customer->sendNewAccountEmail('confirmation');
1016
- $url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
1017
- $this->getCustomerSession()->addSuccess(
1018
- Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.', $url)
1019
- );
1020
- } else {
1021
- $customer->sendNewAccountEmail();
1022
- $this->getCustomerSession()->loginById($customer->getId());
1023
- }
1024
- return $this;
1025
- }
1026
-
1027
- /**
1028
- * Get customer session object
1029
- *
1030
- * @return Mage_Customer_Model_Session
1031
- */
1032
- public function getCustomerSession()
1033
- {
1034
- return $this->_customerSession;
1035
- }
1036
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Hps/Securesubmit/Model/Paypal/Credit.php CHANGED
@@ -9,7 +9,7 @@
9
  /**
10
  * PayPal Credit method
11
  */
12
- class Hps_Sescuresubmit_Model_Paypal_Credit extends Hps_Securesubmit_Model_Paypal
13
  {
14
  /**
15
  * Payment method code
@@ -34,4 +34,10 @@ class Hps_Sescuresubmit_Model_Paypal_Credit extends Hps_Securesubmit_Model_Paypa
34
  {
35
  return Mage::getUrl('securesubmit/paypal/credit');
36
  }
 
 
 
 
 
 
37
  }
9
  /**
10
  * PayPal Credit method
11
  */
12
+ class Hps_Securesubmit_Model_Paypal_Credit extends Hps_Securesubmit_Model_Paypal
13
  {
14
  /**
15
  * Payment method code
34
  {
35
  return Mage::getUrl('securesubmit/paypal/credit');
36
  }
37
+
38
+ public function isAvailable($quote = null)
39
+ {
40
+ return Mage::getStoreConfig('payment/hps_paypal_credit/active')
41
+ && parent::isAvailable($quote);
42
+ }
43
  }
app/code/community/Hps/Securesubmit/Model/Resource/Setup.php CHANGED
@@ -1,5 +1,11 @@
1
  <?php
 
 
 
 
 
 
2
 
3
  class Hps_Securesubmit_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup{
4
 
5
- }
1
  <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
 
9
  class Hps_Securesubmit_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup{
10
 
11
+ }
app/code/community/Hps/Securesubmit/Model/Resource/Storedcard.php CHANGED
@@ -1,4 +1,10 @@
1
  <?php
 
 
 
 
 
 
2
 
3
  class Hps_Securesubmit_Model_Resource_Storedcard extends Mage_Core_Model_Resource_Db_Abstract{
4
  protected function _construct()
@@ -13,4 +19,4 @@ class Hps_Securesubmit_Model_Resource_Storedcard extends Mage_Core_Model_Resourc
13
  'token_value = ?' => $storedcard->getTokenValue()
14
  ));
15
  }
16
- }
1
  <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
 
9
  class Hps_Securesubmit_Model_Resource_Storedcard extends Mage_Core_Model_Resource_Db_Abstract{
10
  protected function _construct()
19
  'token_value = ?' => $storedcard->getTokenValue()
20
  ));
21
  }
22
+ }
app/code/community/Hps/Securesubmit/Model/Resource/Storedcard/Collection.php CHANGED
@@ -1,8 +1,14 @@
1
  <?php
 
 
 
 
 
 
2
 
3
  class Hps_Securesubmit_Model_Resource_Storedcard_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
4
  protected function _construct()
5
  {
6
  $this->_init('hps_securesubmit/storedcard');
7
  }
8
- }
1
  <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
 
9
  class Hps_Securesubmit_Model_Resource_Storedcard_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
10
  protected function _construct()
11
  {
12
  $this->_init('hps_securesubmit/storedcard');
13
  }
14
+ }
app/code/community/Hps/Securesubmit/Model/Source/Cctype.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
  class Hps_Securesubmit_Model_Source_Cctype extends Mage_Payment_Model_Source_Cctype
3
  {
4
  protected $_allowedTypes = array('AE','VI','MC','DI','JCB','OT');
1
  <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
  class Hps_Securesubmit_Model_Source_Cctype extends Mage_Payment_Model_Source_Cctype
10
  {
11
  protected $_allowedTypes = array('AE','VI','MC','DI','JCB','OT');
app/code/community/Hps/Securesubmit/Model/Source/PaymentAction.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
  class Hps_Securesubmit_Model_Source_PaymentAction
3
  {
4
  public function toOptionArray()
@@ -14,4 +21,4 @@ class Hps_Securesubmit_Model_Source_PaymentAction
14
  ),
15
  );
16
  }
17
- }
1
  <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
  class Hps_Securesubmit_Model_Source_PaymentAction
10
  {
11
  public function toOptionArray()
21
  ),
22
  );
23
  }
24
+ }
app/code/community/Hps/Securesubmit/Model/Storedcard.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
  /**
3
  * @method Hps_Securesubmit_Model_Resource_Storedcard getResource()
4
  * @method string getDt()
1
  <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
  /**
10
  * @method Hps_Securesubmit_Model_Resource_Storedcard getResource()
11
  * @method string getDt()
app/code/community/Hps/Securesubmit/Model/System/Config/Backend/Proxy.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
  class Hps_Securesubmit_Model_System_Config_Backend_Proxy extends Mage_Core_Model_Config_Data
3
  {
4
  protected function _beforeSave()
1
  <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
  class Hps_Securesubmit_Model_System_Config_Backend_Proxy extends Mage_Core_Model_Config_Data
10
  {
11
  protected function _beforeSave()
app/code/community/Hps/Securesubmit/controllers/Adminhtml/Hps/._.DS_Store DELETED
Binary file
app/code/community/Hps/Securesubmit/controllers/Adminhtml/Hps/Paypal/ReportsController.php CHANGED
@@ -1,18 +1,107 @@
1
  <?php
2
 
 
 
3
  class Hps_Securesubmit_Adminhtml_Hps_Paypal_ReportsController extends Mage_Adminhtml_Controller_Action
4
  {
5
  protected function _initAction()
6
  {
7
- $this->loadLayout();
8
- // ->_setActiveMenu('hps_securesubmit/items');
9
- // ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
 
 
 
10
  return $this;
11
- }
12
-
13
- public function indexAction() {
14
- $this->_initAction();
 
15
  $this->_addContent($this->getLayout()->createBlock('hps_securesubmit/adminhtml_paypal_settlement_report'));
16
  $this->renderLayout();
17
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
1
  <?php
2
 
3
+ require_once Mage::getBaseDir('lib').DS.'SecureSubmit'.DS.'Hps.php';
4
+
5
  class Hps_Securesubmit_Adminhtml_Hps_Paypal_ReportsController extends Mage_Adminhtml_Controller_Action
6
  {
7
  protected function _initAction()
8
  {
9
+ $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('PayPal Settlement Reports'));
10
+ $this->loadLayout()
11
+ ->_setActiveMenu('report/sales')
12
+ ->_addBreadcrumb(Mage::helper('hps_securesubmit')->__('Reports'), Mage::helper('hps_securesubmit')->__('Reports'))
13
+ ->_addBreadcrumb(Mage::helper('hps_securesubmit')->__('Sales'), Mage::helper('hps_securesubmit')->__('Sales'))
14
+ ->_addBreadcrumb(Mage::helper('hps_securesubmit')->__('HPS PayPal Settlement Report'), Mage::helper('hps_securesubmit')->__('HPS PayPal Settlement Report'));
15
  return $this;
16
+ }
17
+
18
+ public function indexAction()
19
+ {
20
+ $this->_initAction();
21
  $this->_addContent($this->getLayout()->createBlock('hps_securesubmit/adminhtml_paypal_settlement_report'));
22
  $this->renderLayout();
23
  }
24
+
25
+ public function viewAction()
26
+ {
27
+ $rowId = $this->getRequest()->getParam('id');
28
+ $row = Mage::getModel('hps_securesubmit/report')->load($rowId);
29
+ if (!$row->getId()) {
30
+ $this->_redirect('*/*/');
31
+ return;
32
+ }
33
+ Mage::register('current_transaction', $row);
34
+ $this->_initAction()
35
+ ->_title($this->__('View Transaction'))
36
+ ->_addContent($this->getLayout()->createBlock('hps_securesubmit/adminhtml_paypal_settlement_report_form', 'settlementView'))
37
+ ->renderLayout();
38
+ }
39
+
40
+ public function fetchAction()
41
+ {
42
+ $rows = Mage::getModel('hps_securesubmit/report')
43
+ ->getCollection()
44
+ ->addFieldToSelect(array(
45
+ 'row_id',
46
+ 'transaction_id',
47
+ 'last_known_status',
48
+ ), 'inner')
49
+ ->addFieldToFilter('last_known_status', array(
50
+ 'neq' => 'Completed (None)',
51
+ ));
52
+
53
+ $id = $this->getRequest()->getParam('id');
54
+ if ($id) {
55
+ $rows = $rows->addFieldToFilter('row_id', array(
56
+ 'eq' => $id,
57
+ ));
58
+ }
59
+
60
+ Mage::getSingleton('core/resource_iterator')->walk($rows->getSelect(), array(
61
+ array($this, 'updateRow'),
62
+ ));
63
+
64
+ if ($id) {
65
+ $this->_redirect('*/*/view', array(
66
+ 'id' => $id,
67
+ ));
68
+ } else {
69
+ $this->_redirect('*/*/index');
70
+ }
71
+ }
72
+
73
+ public function updateRow($args)
74
+ {
75
+ try {
76
+ $report = Mage::getModel('hps_securesubmit/report');
77
+ $report->setData($args['row']);
78
+
79
+ $service = $this->getService();
80
+ $status = $service->status($report->getData('transaction_id'));
81
+
82
+ $report
83
+ ->setLastKnownStatus($status->altPayment->Status . ' (' . $status->altPayment->StatusMessage . ')')
84
+ ->setUpdateTime(date('Y-m-d H:i:s'))
85
+ ->save();
86
+ } catch (HpsException $e) {
87
+ // Mage::log(print_r($e, true));
88
+ }
89
+ }
90
+
91
+ protected function getService()
92
+ {
93
+ $config = new HpsServicesConfig();
94
+ if (Mage::getStoreConfig('payment/hps_paypal/use_sandbox')) {
95
+ $config->username = Mage::getStoreConfig('payment/hps_paypal/username');
96
+ $config->password = Mage::getStoreConfig('payment/hps_paypal/password');
97
+ $config->deviceId = Mage::getStoreConfig('payment/hps_paypal/device_id');
98
+ $config->licenseId = Mage::getStoreConfig('payment/hps_paypal/license_id');
99
+ $config->siteId = Mage::getStoreConfig('payment/hps_paypal/site_id');
100
+ $config->soapServiceUri = "https://api-uat.heartlandportico.com/paymentserver.v1/PosGatewayService.asmx";
101
+ } else {
102
+ $config->secretApiKey = Mage::getStoreConfig('payment/hps_paypal/secretapikey');
103
+ }
104
+
105
+ return new HpsPayPalService($config);
106
+ }
107
  }
app/code/community/Hps/Securesubmit/controllers/Adminhtml/StoredcardController.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Hps_Securesubmit_Adminhtml_StoredcardController extends Mage_Adminhtml_Controller_Action{
4
+
5
+ /*
6
+ * Get token data during checkout
7
+ */
8
+ public function getTokenDataAction()
9
+ {
10
+ try {
11
+ $storedCard = Mage::getModel('hps_securesubmit/storedcard');
12
+ $storedCard->load($this->getRequest()->getParam('storedcard_id'));
13
+ $customerId = $this->getRequest()->getParam('customer_id');
14
+ if ( ! $storedCard->getId() || $storedCard->getCustomerId() != $customerId) {
15
+ throw new Mage_Core_Exception($this->__('Stored card no longer exists.'));
16
+ }
17
+ $result = array(
18
+ 'error' => FALSE,
19
+ 'token' => array(
20
+ 'token_value' => $storedCard->getTokenValue(),
21
+ 'cc_last4' => $storedCard->getCcLast4(),
22
+ 'cc_exp_month' => $storedCard->getCcExpMonth(),
23
+ 'cc_exp_year' => $storedCard->getCcExpYear(),
24
+ 'cc_type' => $storedCard->getCcType(),
25
+ )
26
+ );
27
+ }
28
+ catch (Mage_Core_Exception $e) {
29
+ $result = array('error' => TRUE, 'message' => $e->getMessage());
30
+ }
31
+ catch (Exception $e) {
32
+ Mage::logException($e);
33
+ $result = array('error' => TRUE, 'message' => $this->__('An unexpected error occurred retrieving your stored card. We apologize for the inconvenience, please contact us for further support.'));
34
+ }
35
+ $this->getResponse()->setHeader('Content-Type', 'application/json', TRUE);
36
+ $this->getResponse()->setBody(json_encode($result));
37
+ }
38
+ }
app/code/community/Hps/Securesubmit/controllers/GiftcardController.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once Mage::getBaseDir('lib') . DS . 'SecureSubmit' . DS . 'Hps.php';
3
+
4
+ class Hps_Securesubmit_GiftcardController extends Mage_core_Controller_Front_Action {
5
+
6
+ public function getBalanceAction() {
7
+ try {
8
+ $giftCardNumber = $this->getRequest()->getParam('giftcard_number');
9
+
10
+ if (!$giftCardNumber) {
11
+ throw new Mage_Core_Exception($this->__('No number received.'));
12
+ }
13
+
14
+ $config = new HpsServicesConfig();
15
+
16
+ $config->secretApiKey = Mage::getModel('hps_securesubmit/payment')->getConfigData('secretapikey');
17
+ $config->versionNumber = '1573';
18
+ $config->developerId = '002914';
19
+
20
+ $giftService = new HpsGiftCardService($config);
21
+
22
+ try {
23
+ $card = new HpsGiftCard();
24
+ $card->number = $_GET["giftcard_number"];
25
+
26
+ $response = $giftService->balance($card);
27
+
28
+ $result = array(
29
+ 'error' => FALSE,
30
+ 'balance' => $response->balanceAmount
31
+ );
32
+ } catch (HpsException $e) {
33
+ $result = array('error' => TRUE, 'message' => $e->getMessage());
34
+ }
35
+ } catch (Mage_Core_Exception $e) {
36
+ $result = array('error' => TRUE, 'message' => $e->getMessage());
37
+ } catch (Exception $e) {
38
+ Mage::logException($e);
39
+ $result = array('error' => TRUE, 'message' => $this->__('An unexpected error occurred retrieving your stored card. We apologize for the inconvenience, please contact us for further support.'));
40
+ }
41
+
42
+ $this->getResponse()->setHeader('Content-Type', 'application/json', TRUE);
43
+ $this->getResponse()->setBody(json_encode($result));
44
+ }
45
+
46
+ }
47
+
48
+ ?>
app/code/community/Hps/Securesubmit/controllers/MasterpassController.php ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+ require_once Mage::getBaseDir('lib').DS.'SecureSubmit'.DS.'Hps.php';
9
+
10
+ class Hps_Securesubmit_MasterpassController extends Mage_Core_Controller_Front_Action
11
+ {
12
+ private $_quote = null;
13
+
14
+ protected function _construct()
15
+ {
16
+ parent::_construct();
17
+ }
18
+
19
+ public function startAction()
20
+ {
21
+ $result = array();
22
+
23
+ try {
24
+ $helper = Mage::helper('hps_securesubmit/masterpass');
25
+
26
+ if ($this->getQuote()->getIsMultiShipping()) {
27
+ $this->getQuote()->setIsMultiShipping(false);
28
+ $this->getQuote()->removeAllAddresses();
29
+ }
30
+
31
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
32
+ $quoteCheckoutMethod = $this->getQuote()->getCheckoutMethod();
33
+ if ($customer && $customer->getId()) {
34
+ $this->getQuote()->assignCustomerWithAddressChange(
35
+ $customer,
36
+ $this->getQuote()->getBillingAddress(),
37
+ $this->getQuote()->getShippingAddress()
38
+ );
39
+ } elseif ((!$quoteCheckoutMethod
40
+ || $quoteCheckoutMethod != Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER)
41
+ && !Mage::helper('checkout')->isAllowedGuestCheckout(
42
+ $this->getQuote(),
43
+ $this->getQuote()->getStoreId()
44
+ )
45
+ ) {
46
+ Mage::getSingleton('core/session')->addNotice(
47
+ Mage::helper('hps_securesubmit')->__('To proceed to Checkout, please log in using your email address.')
48
+ );
49
+ Mage::getSingleton('customer/session')
50
+ ->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_current' => true)));
51
+ $result = array(
52
+ 'result' => 'error',
53
+ 'redirect' => Mage::getUrl('customer/account/login'),
54
+ );
55
+ $this->getResponse()->setBody(json_encode($result));
56
+ return;
57
+ }
58
+
59
+ $pair = $this->getRequest()->getParam('pair');
60
+ $returnUrl = Mage::getUrl('*/*/return');
61
+ if ($pair) {
62
+ $returnUrl = Mage::getUrl('*/*/connect');
63
+ }
64
+ $cancelUrl = Mage::getUrl('*/*/cancel');
65
+ $response = $helper->start(
66
+ $this->getQuote(),
67
+ $returnUrl,
68
+ $cancelUrl,
69
+ $pair
70
+ );
71
+
72
+ $this->getSession()->setMasterPassPayload($response->payload);
73
+ $this->getSession()->setMasterPassOrderId($response->orderId);
74
+
75
+ $result = array(
76
+ 'result' => 'success',
77
+ 'data' => array(
78
+ 'processorTransactionId' => $response->processorTransactionId,
79
+ 'returnUrl' => $returnUrl,
80
+ 'merchantCheckoutId' => Mage::getStoreConfig('payment/hps_masterpass/merchant_checkout_id'),
81
+ ),
82
+ );
83
+
84
+ if (null !== $response->processorTransactionIdPairing) {
85
+ $result['data']['processorTransactionIdPairing'] = $response->processorTransactionIdPairing;
86
+ }
87
+
88
+ $walletName = $this->getSession()->getMasterPassWalletName();
89
+ $walletId = $this->getSession()->getMasterPassWalletId();
90
+ $preCheckoutTransactionId = $this->getSession()->getMasterPassPreCheckoutTransactionId();
91
+ if (false !== $preCheckoutTransactionId) {
92
+ $result['data']['preCheckoutTransactionId'] = $preCheckoutTransactionId;
93
+ }
94
+ if (false !== $walletName) {
95
+ $result['data']['walletName'] = $walletName;
96
+ }
97
+ if (false !== $walletId) {
98
+ $result['data']['walletId'] = $walletId;
99
+ }
100
+ } catch (Mage_Core_Exception $e) {
101
+ $this->getCheckoutSession()->addError($e->getMessage());
102
+ Mage::log(Mage::helper('hps_securesubmit')->__("Error creating MasterPass session: %s", $e->getMessage()), Zend_Log::WARN);
103
+ $result = array(
104
+ 'result' => 'error',
105
+ 'message' => $e->getMessage(),
106
+ 'redirect' => Mage::getUrl('checkout/cart'),
107
+ );
108
+ } catch (Exception $e) {
109
+ $this->getCheckoutSession()->addError($this->__('Unable to start MasterPass lightbox.'));
110
+ Mage::logException($e);
111
+ Mage::log(Mage::helper('hps_securesubmit')->__("Error creating MasterPass session: %s", $e->getMessage()), Zend_Log::WARN);
112
+ $result = array(
113
+ 'result' => 'error',
114
+ 'message' => $e->getMessage(),
115
+ 'redirect' => Mage::getUrl('checkout/cart'),
116
+ );
117
+ }
118
+ $this->getResponse()
119
+ ->setHeader('Content-Type', 'application/json; charset=utf-8')
120
+ ->setBody(json_encode($result));
121
+ return;
122
+ }
123
+
124
+ public function returnAction()
125
+ {
126
+ $status = $this->getRequest()->getParam('mpstatus');
127
+ if ($status != 'success') {
128
+ $this->_redirect('checkout/cart');
129
+ return;
130
+ }
131
+ try {
132
+ $checkoutResourceUrl = $this->getRequest()->getParam('checkout_resource_url');
133
+ $oauthToken = $this->getRequest()->getParam('oauth_token');
134
+ $oauthVerifier = $this->getRequest()->getParam('oauth_verifier');
135
+ $pairingToken = $this->getRequest()->getParam('pairing_token');
136
+ $pairingVerifier = $this->getRequest()->getParam('pairing_verifier');
137
+
138
+ $helper = Mage::helper('hps_securesubmit/masterpass');
139
+
140
+ $payload = $this->getSession()->getMasterPassPayload();
141
+ $orderId = $this->getSession()->getMasterPassOrderId();
142
+
143
+ $data = $helper->returnFromMasterPass(
144
+ $status,
145
+ $orderId,
146
+ $oauthToken,
147
+ $oauthVerifier,
148
+ $payload,
149
+ $checkoutResourceUrl,
150
+ $pairingToken,
151
+ $pairingVerifier
152
+ );
153
+
154
+ $this->getSession()->setMasterPassAuthenticate($data);
155
+ $this->_redirect('*/*/review');
156
+ return;
157
+ } catch (Mage_Core_Exception $e) {
158
+ $this->getCheckoutSession()->addError($e->getMessage());
159
+ } catch (Exception $e) {
160
+ $this->getCheckoutSession()->addError($this->__('Unable to process PayPal Checkout approval.'));
161
+ Mage::logException($e);
162
+ }
163
+ $this->_redirect('checkout/cart');
164
+ }
165
+
166
+ public function reviewAction()
167
+ {
168
+ try {
169
+ $helper = Mage::helper('hps_securesubmit/masterpass');
170
+ $helper->prepareOrderReview($this->getQuote());
171
+ $this->loadLayout();
172
+ $reviewBlock = $this->getLayout()->getBlock('hps.securesubmit.masterpass.review');
173
+ $reviewBlock->setQuote($this->getQuote());
174
+ $reviewBlock->getChild('details')->setQuote($this->getQuote());
175
+ if ($reviewBlock->getChild('shipping_method')) {
176
+ $reviewBlock->getChild('shipping_method')->setQuote($this->getQuote());
177
+ }
178
+ $this->renderLayout();
179
+ return;
180
+ } catch (Mage_Core_Exception $e) {
181
+ $this->getCheckoutSession()->addError($e->getMessage());
182
+ } catch (Exception $e) {
183
+ $this->getCheckoutSession()->addError(
184
+ $this->__('Unable to initialize MasterPass order review.')
185
+ );
186
+ Mage::logException($e);
187
+ }
188
+ $this->_redirect('checkout/cart');
189
+ }
190
+
191
+ public function saveShippingMethodAction()
192
+ {
193
+ try {
194
+ $isAjax = $this->getRequest()->getParam('isAjax');
195
+
196
+ if (!$this->getQuote()->getIsVirtual() && $shippingAddress = $this->getQuote()->getShippingAddress()) {
197
+ if ($this->getRequest()->getParam('shipping_method') != $shippingAddress->getShippingMethod()) {
198
+ Mage::helper('hps_securesubmit/masterpass')->ignoreAddressValidation($this->getQuote());
199
+ $shippingAddress->setShippingMethod($this->getRequest()->getParam('shipping_method'))->setCollectShippingRates(true);
200
+ $this->getQuote()->collectTotals()->save();
201
+ }
202
+ }
203
+
204
+ if ($isAjax) {
205
+ $this->loadLayout('hps_securesubmit_masterpass_review_details');
206
+ $this->getResponse()->setBody($this->getLayout()->getBlock('root')
207
+ ->setQuote($this->getQuote())
208
+ ->toHtml());
209
+ return;
210
+ }
211
+ } catch (Mage_Core_Exception $e) {
212
+ $this->getCheckoutSession()->addError($e->getMessage());
213
+ } catch (Exception $e) {
214
+ $this->getCheckoutSession()->addError($this->__('Unable to update shipping method.'));
215
+ Mage::logException($e);
216
+ }
217
+ if ($isAjax) {
218
+ $this->getResponse()->setBody('<script type="text/javascript">window.location.href = '
219
+ . Mage::getUrl('*/*/review') . ';</script>');
220
+ } else {
221
+ $this->_redirect('*/*/review');
222
+ }
223
+ }
224
+
225
+ public function placeOrderAction()
226
+ {
227
+ try {
228
+ $helper = Mage::helper('hps_securesubmit/masterpass');
229
+ $order = $helper->place(
230
+ $this->getQuote(),
231
+ $this->getSession()->getMasterPassAuthenticate()
232
+ );
233
+
234
+ // prepare session to success or cancellation page
235
+ $session = $this->getCheckoutSession();
236
+ $session->clearHelperData();
237
+
238
+ // "last successful quote"
239
+ $quoteId = $this->getQuote()->getId();
240
+ $session->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId);
241
+
242
+ // an order may be created
243
+ if ($order) {
244
+ $session->setLastOrderId($order->getId())
245
+ ->setLastRealOrderId($order->getIncrementId());
246
+ }
247
+
248
+ $this->_redirect('checkout/onepage/success');
249
+ return;
250
+ } catch (Mage_Core_Exception $e) {
251
+ Mage::log($e->getMessage());
252
+ Mage::helper('checkout')->sendPaymentFailedEmail($this->getQuote(), $e->getMessage());
253
+ $this->getCheckoutSession()->addError($e->getMessage());
254
+ $this->_redirect('*/*/review');
255
+ } catch (Exception $e) {
256
+ Mage::log($e->getMessage());
257
+ Mage::helper('checkout')->sendPaymentFailedEmail(
258
+ $this->getQuote(),
259
+ $this->__('Unable to place the order.')
260
+ );
261
+ $this->getCheckoutSession()->addError($this->__('Unable to place the order.'));
262
+ Mage::logException($e);
263
+ $this->_redirect('*/*/review');
264
+ }
265
+ }
266
+
267
+ public function connectAction()
268
+ {
269
+ $forget = $this->getRequest()->getParam('forget_masterpass');
270
+ if ($forget && $forget == 'true') {
271
+ $customer = Mage::getModel('customer/customer')
272
+ ->load(Mage::getSingleton('customer/session')->getCustomerId());
273
+ $customer->unsMasterpassLongAccessToken();
274
+ $customer->setMasterpassLongAccessToken('');
275
+ $customer->save();
276
+ $this->_redirect('*/*/*');
277
+ return;
278
+ }
279
+
280
+ $status = $this->getRequest()->getParam('mpstatus');
281
+ if ($status && $status == 'success') {
282
+ $pairingToken = $this->getRequest()->getParam('pairing_token');
283
+ $pairingVerifier = $this->getRequest()->getParam('pairing_verifier');
284
+
285
+ $payload = $this->getSession()->getMasterPassPayload();
286
+ $orderId = $this->getSession()->getMasterPassOrderId();
287
+
288
+ try {
289
+ $orderData = new HpsOrderData();
290
+ $orderData->transactionStatus = $status;
291
+ $orderData->checkoutType = HpsCentinelCheckoutType::PAIRING;
292
+ $orderData->pairingToken = $pairingToken;
293
+ $orderData->pairingVerifier = $pairingVerifier;
294
+
295
+ // Authenticate the request with the information we've gathered
296
+ $response = Mage::helper('hps_securesubmit/masterpass')->authenticate(
297
+ $orderId,
298
+ null,
299
+ null,
300
+ $payload,
301
+ null,
302
+ $orderData
303
+ );
304
+
305
+ $customer = Mage::getModel('customer/customer')
306
+ ->load(Mage::getSingleton('customer/session')->getCustomerId());
307
+ $customer->unsMasterpassLongAccessToken();
308
+ $customer->setMasterpassLongAccessToken($response->longAccessToken);
309
+ $customer->save();
310
+ } catch (Exception $e) { Mage::logException($e->getMessage()); }
311
+
312
+ $this->_redirect('*/*/*');
313
+ return;
314
+ }
315
+
316
+ $this->loadLayout();
317
+ $this->getLayout()
318
+ ->getBlock('head')
319
+ ->setTitle(Mage::helper('hps_securesubmit')->__('MasterPass'));
320
+ $this->renderLayout();
321
+ return;
322
+ }
323
+
324
+ protected function getCheckoutSession()
325
+ {
326
+ return Mage::getSingleton('checkout/session');
327
+ }
328
+
329
+ protected function getSession()
330
+ {
331
+ return Mage::getSingleton('hps_securesubmit/session');
332
+ }
333
+
334
+ protected function getQuote()
335
+ {
336
+ if (!$this->_quote) {
337
+ $this->_quote = $this->getCheckoutSession()->getQuote();
338
+ }
339
+ return $this->_quote;
340
+ }
341
+ }
app/code/community/Hps/Securesubmit/controllers/PaypalController.php CHANGED
@@ -9,37 +9,406 @@
9
  /**
10
  * Paypal Checkout Controller
11
  */
12
- class Hps_Securesubmit_PaypalController extends Hps_Securesubmit_Controller_Paypal_Abstract
13
  {
 
 
 
 
 
 
 
 
14
  /**
15
- * Config mode type
16
- *
17
- * @var string
18
  */
19
- protected $_configType = 'hps_securesubmit/config';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  /**
22
- * Config method type
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  *
24
- * @var string
 
25
  */
26
- protected $_configMethod = Hps_Securesubmit_Model_Config::METHOD_WPP_EXPRESS;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  /**
29
- * Checkout mode type
 
30
  *
31
- * @var string
 
32
  */
33
- protected $_checkoutType = 'hps_securesubmit/paypal_checkout';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  /**
36
- * Action for Bill Me Later checkout button (product view and shopping cart pages)
 
 
 
 
37
  */
38
- public function creditAction()
39
  {
40
- $this->_forward('start', 'paypal', 'securesubmit', array(
41
- 'credit' => 1,
42
- 'button' => $this->getRequest()->getParam('button')
43
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
45
  }
9
  /**
10
  * Paypal Checkout Controller
11
  */
12
+ class Hps_Securesubmit_PaypalController extends Mage_Core_Controller_Front_Action
13
  {
14
+ protected $_checkoutType = 'hps_securesubmit/paypal_checkout';
15
+ protected $_quote = null;
16
+
17
+ protected function _construct()
18
+ {
19
+ parent::_construct();
20
+ }
21
+
22
  /**
23
+ * Action for Bill Me Later checkout button (product view and shopping cart pages)
 
 
24
  */
25
+ public function creditAction()
26
+ {
27
+ $this->_forward('start', 'paypal', 'securesubmit', array(
28
+ 'credit' => 1,
29
+ 'button' => $this->getRequest()->getParam('button')
30
+ ));
31
+ }
32
+
33
+ public function incontextAction()
34
+ {
35
+ $this->_forward('start', 'paypal', 'securesubmit', array(
36
+ 'incontext' => 1,
37
+ 'credit' => $this->getRequest()->getParam('credit'),
38
+ 'button' => $this->getRequest()->getParam('button'),
39
+ ));
40
+ }
41
+
42
+ public function incontextCreditAction()
43
+ {
44
+ $this->_forward('incontext', 'paypal', 'securesubmit', array(
45
+ 'credit' => 1,
46
+ 'button' => $this->getRequest()->getParam('button'),
47
+ ));
48
+ }
49
+
50
+ /**
51
+ * Start PayPal Checkout by requesting initial token and dispatching customer to PayPal
52
+ */
53
+ public function startAction()
54
+ {
55
+ try {
56
+ $helper = Mage::helper('hps_securesubmit/paypal');
57
+
58
+ if ($this->_getQuote()->getIsMultiShipping()) {
59
+ $this->_getQuote()->setIsMultiShipping(false);
60
+ $this->_getQuote()->removeAllAddresses();
61
+ }
62
+
63
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
64
+ $quoteCheckoutMethod = $this->_getQuote()->getCheckoutMethod();
65
+ if ($customer && $customer->getId()) {
66
+ $this->_getQuote()->assignCustomerWithAddressChange(
67
+ $customer,
68
+ $this->_getQuote()->getBillingAddress(),
69
+ $this->_getQuote()->getShippingAddress()
70
+ );
71
+ } elseif ((!$quoteCheckoutMethod
72
+ || $quoteCheckoutMethod != Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER)
73
+ && !Mage::helper('checkout')->isAllowedGuestCheckout(
74
+ $this->_getQuote(),
75
+ $this->_getQuote()->getStoreId()
76
+ )
77
+ ) {
78
+ Mage::getSingleton('core/session')->addNotice(
79
+ Mage::helper('hps_securesubmit')->__('To proceed to Checkout, please log in using your email address.')
80
+ );
81
+ $this->redirectLogin();
82
+ Mage::getSingleton('customer/session')
83
+ ->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_current' => true)));
84
+ return;
85
+ }
86
+
87
+ $button = (bool)$this->getRequest()->getParam('button');
88
+ $credit = (bool)$this->getRequest()->getParam('credit');
89
+ $incontext = (bool)$this->getRequest()->getParam('incontext');
90
+ $token = $helper->start(
91
+ $this->_getQuote(),
92
+ Mage::getUrl('*/*/return'),
93
+ Mage::getUrl('*/*/cancel'),
94
+ array(
95
+ 'button' => $button,
96
+ 'credit' => $credit,
97
+ )
98
+ );
99
+
100
+ $this->_initRedirectUrl($url = $helper->getRedirectUrl());
101
+
102
+ if ($token && $incontext && $url) {
103
+ $this->_initToken($token);
104
+ $this->getResponse()->setBody($url);
105
+ return;
106
+ }
107
+ if ($token && $url) {
108
+ $this->_initToken($token);
109
+ $this->getResponse()->setRedirect($url);
110
+ return;
111
+ }
112
+ } catch (Mage_Core_Exception $e) {
113
+ $this->_getCheckoutSession()->addError($e->getMessage());
114
+ Mage::log(Mage::helper('hps_securesubmit')->__("Error creating PayPal session: %s", $e->getMessage()), Zend_Log::WARN);
115
+ } catch (Exception $e) {
116
+ $this->_getCheckoutSession()->addError($this->__('Unable to start PayPal Checkout.'));
117
+ Mage::logException($e);
118
+ Mage::log(Mage::helper('hps_securesubmit')->__("Error creating PayPal session: %s", $e->getMessage()), Zend_Log::WARN);
119
+ }
120
+ $this->_redirect('checkout/cart');
121
+ }
122
 
123
  /**
124
+ * Cancel PayPal Checkout
125
+ */
126
+ public function cancelAction()
127
+ {
128
+ try {
129
+ $this->_initToken(false);
130
+ // TODO verify if this logic of order cancelation is deprecated
131
+ // if there is an order - cancel it
132
+ $orderId = $this->_getCheckoutSession()->getLastOrderId();
133
+ $order = ($orderId) ? Mage::getModel('sales/order')->load($orderId) : false;
134
+ if ($order && $order->getId() && $order->getQuoteId() == $this->_getCheckoutSession()->getQuoteId()) {
135
+ $order->cancel()->save();
136
+ $this->_getCheckoutSession()
137
+ ->unsLastQuoteId()
138
+ ->unsLastSuccessQuoteId()
139
+ ->unsLastOrderId()
140
+ ->unsLastRealOrderId()
141
+ ->addSuccess($this->__('PayPal Checkout and Order have been canceled.'))
142
+ ;
143
+ } else {
144
+ $this->_getCheckoutSession()->addSuccess($this->__('PayPal Checkout has been canceled.'));
145
+ }
146
+ } catch (Mage_Core_Exception $e) {
147
+ $this->_getCheckoutSession()->addError($e->getMessage());
148
+ } catch (Exception $e) {
149
+ $this->_getCheckoutSession()->addError($this->__('Unable to cancel PayPal Checkout.'));
150
+ Mage::logException($e);
151
+ }
152
+
153
+ $this->_redirect('checkout/cart');
154
+ }
155
+
156
+ /**
157
+ * Return from PayPal and dispatch customer to order review page
158
+ */
159
+ public function returnAction()
160
+ {
161
+ if ($this->getRequest()->getParam('retry_authorization') == 'true'
162
+ && is_array($this->_getCheckoutSession()->getPaypalTransactionData())
163
+ ) {
164
+ $this->_forward('placeOrder');
165
+ return;
166
+ }
167
+ try {
168
+ $token = $this->getRequest()->getParam('token');
169
+ $payerId = $this->getRequest()->getParam('PayerID');
170
+ $this->_getCheckoutSession()->unsPaypalTransactionData();
171
+ $helper = Mage::helper('hps_securesubmit/paypal');
172
+ $token = $this->_initToken();
173
+ $helper->returnFromPaypal($this->_getQuote(), $token, $payerId);
174
+ $this->_getSession()->setPayPalPayerId($payerId);
175
+
176
+ $this->_redirect('*/*/review');
177
+ return;
178
+ } catch (Mage_Core_Exception $e) {
179
+ $this->_getCheckoutSession()->addError($e->getMessage());
180
+ } catch (Exception $e) {
181
+ $this->_getCheckoutSession()->addError($this->__('Unable to process PayPal Checkout approval.'));
182
+ Mage::logException($e);
183
+ }
184
+ $this->_redirect('checkout/cart');
185
+ }
186
+
187
+ /**
188
+ * Review order after returning from PayPal
189
+ */
190
+ public function reviewAction()
191
+ {
192
+ try {
193
+ $helper = Mage::helper('hps_securesubmit/paypal');
194
+ $token = $this->_initToken();
195
+ $helper->prepareOrderReview($this->_getQuote(), $token);
196
+ $this->loadLayout();
197
+ $this->_initLayoutMessages('paypal/session');
198
+ $reviewBlock = $this->getLayout()->getBlock('hps.securesubmit.paypal.review');
199
+ $reviewBlock->setQuote($this->_getQuote());
200
+ $reviewBlock->getChild('details')->setQuote($this->_getQuote());
201
+ if ($reviewBlock->getChild('shipping_method')) {
202
+ $reviewBlock->getChild('shipping_method')->setQuote($this->_getQuote());
203
+ }
204
+ $this->renderLayout();
205
+ return;
206
+ } catch (Mage_Core_Exception $e) {
207
+ $this->_getCheckoutSession()->addError($e->getMessage());
208
+ } catch (Exception $e) {
209
+ $this->_getCheckoutSession()->addError(
210
+ $this->__('Unable to initialize PayPal Checkout review.')
211
+ );
212
+ Mage::logException($e);
213
+ }
214
+ $this->_redirect('checkout/cart');
215
+ }
216
+
217
+ /**
218
+ * Update shipping method (combined action for ajax and regular request)
219
+ */
220
+ public function saveShippingMethodAction()
221
+ {
222
+ try {
223
+ $isAjax = $this->getRequest()->getParam('isAjax');
224
+
225
+ if (!$this->_getQuote()->getIsVirtual() && $shippingAddress = $this->_getQuote()->getShippingAddress()) {
226
+ if ($this->getRequest()->getParam('shipping_method') != $shippingAddress->getShippingMethod()) {
227
+ Mage::helper('hps_securesubmit/paypal')->ignoreAddressValidation($this->_getQuote());
228
+ $shippingAddress->setShippingMethod($this->getRequest()->getParam('shipping_method'))->setCollectShippingRates(true);
229
+ $this->_getQuote()->collectTotals()->save();
230
+ }
231
+ }
232
+
233
+ if ($isAjax) {
234
+ $this->loadLayout('hps_securesubmit_paypal_review_details');
235
+ $this->getResponse()->setBody($this->getLayout()->getBlock('root')
236
+ ->setQuote($this->_getQuote())
237
+ ->toHtml());
238
+ return;
239
+ }
240
+ } catch (Mage_Core_Exception $e) {
241
+ $this->_getSession()->addError($e->getMessage());
242
+ } catch (Exception $e) {
243
+ $this->_getSession()->addError($this->__('Unable to update shipping method.'));
244
+ Mage::logException($e);
245
+ }
246
+ if ($isAjax) {
247
+ $this->getResponse()->setBody('<script type="text/javascript">window.location.href = '
248
+ . Mage::getUrl('*/*/review') . ';</script>');
249
+ } else {
250
+ $this->_redirect('*/*/review');
251
+ }
252
+ }
253
+
254
+ /**
255
+ * Submit the order
256
+ */
257
+ public function placeOrderAction()
258
+ {
259
+ try {
260
+ $requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();
261
+ if ($requiredAgreements) {
262
+ $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
263
+ if (array_diff($requiredAgreements, $postedAgreements)) {
264
+ Mage::throwException(Mage::helper('paypal')->__('Please agree to all the terms and conditions before placing the order.'));
265
+ }
266
+ }
267
+ $helper = Mage::helper('hps_securesubmit/paypal');
268
+ $order = $helper->place($this->_getQuote(), $this->_initToken());
269
+
270
+ // prepare session to success or cancellation page
271
+ $session = $this->_getCheckoutSession();
272
+ $session->clearHelperData();
273
+
274
+ // "last successful quote"
275
+ $quoteId = $this->_getQuote()->getId();
276
+ $session->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId);
277
+
278
+ // an order may be created
279
+ if ($order) {
280
+ $session->setLastOrderId($order->getId())
281
+ ->setLastRealOrderId($order->getIncrementId());
282
+ }
283
+
284
+ $this->_initToken(false); // no need in token anymore
285
+ $this->_redirect('checkout/onepage/success');
286
+ return;
287
+ } catch (HpsProcessorException $e) {
288
+ $this->_processPaypalApiError($e);
289
+ } catch (Mage_Core_Exception $e) {
290
+ Mage::helper('checkout')->sendPaymentFailedEmail($this->_getQuote(), $e->getMessage());
291
+ $this->_getSession()->addError($e->getMessage());
292
+ $this->_redirect('*/*/review');
293
+ } catch (Exception $e) {
294
+ Mage::helper('checkout')->sendPaymentFailedEmail(
295
+ $this->_getQuote(),
296
+ $this->__('Unable to place the order.')
297
+ );
298
+ $this->_getSession()->addError($this->__('Unable to place the order.'));
299
+ Mage::logException($e);
300
+ $this->_redirect('*/*/review');
301
+ }
302
+ }
303
+
304
+ /**
305
+ * Process PayPal API's processable errors
306
  *
307
+ * @param HpsProcessorException $exception
308
+ * @throws HpsProcessorException
309
  */
310
+ protected function _processPaypalApiError($exception)
311
+ {
312
+ switch ($exception->getCode()) {
313
+ case 10486:
314
+ case 10422:
315
+ $token = $this->_initToken();
316
+ $this->getResponse()->setRedirect(
317
+ $this->_config->getPayPalCheckoutStartUrl($token)
318
+ );
319
+ break;
320
+ case 10416:
321
+ case 10411:
322
+ $this->getResponse()->setRedirect(
323
+ $this->_getQuote()->getPayment()->getCheckoutRedirectUrl()
324
+ );
325
+ break;
326
+ default:
327
+ $cart = Mage::getSingleton('checkout/cart');
328
+ $cart->getCheckoutSession()->addError($exception->getUserMessage());
329
+ $this->_redirect('checkout/cart');
330
+ break;
331
+ }
332
+
333
+ }
334
 
335
  /**
336
+ * Search for proper checkout token in request or session or (un)set specified one
337
+ * Combined getter/setter
338
  *
339
+ * @param string $setToken
340
+ * @return Hps_Securesubmit_PaypalController|string
341
  */
342
+ protected function _initToken($setToken = null)
343
+ {
344
+ if (null !== $setToken) {
345
+ if (false === $setToken) {
346
+ // security measure for avoid unsetting token twice
347
+ if (!$this->_getSession()->getPayPalCheckoutToken()) {
348
+ Mage::throwException($this->__('PayPal Checkout Token does not exist.'));
349
+ }
350
+ $this->_getSession()->unsPayPalCheckoutToken();
351
+ } else {
352
+ $this->_getSession()->setPayPalCheckoutToken($setToken);
353
+ }
354
+ return $this;
355
+ }
356
+ if ($setToken = $this->getRequest()->getParam('token')) {
357
+ if ($setToken !== $this->_getSession()->getPayPalCheckoutToken()) {
358
+ Mage::throwException($this->__('Wrong PayPal Checkout Token specified.'));
359
+ }
360
+ } else {
361
+ $setToken = $this->_getSession()->getPayPalCheckoutToken();
362
+ }
363
+ return $setToken;
364
+ }
365
 
366
  /**
367
+ * Search for proper checkout token in request or session or (un)set specified one
368
+ * Combined getter/setter
369
+ *
370
+ * @param string $setRedirectUrl
371
+ * @return Hps_Securesubmit_PaypalController|string
372
  */
373
+ protected function _initRedirectUrl($setRedirectUrl = null)
374
  {
375
+ if (null !== $setRedirectUrl) {
376
+ if (false === $setRedirectUrl) {
377
+ // security measure for avoid unsetting token twice
378
+ if (!$this->_getSession()->getPayPalCheckoutRedirectUrl()) {
379
+ Mage::throwException($this->__('PayPal Checkout RedirectUrl does not exist.'));
380
+ }
381
+ $this->_getSession()->unsPayPalCheckoutRedirectUrl();
382
+ } else {
383
+ $this->_getSession()->setPayPalCheckoutRedirectUrl($setRedirectUrl);
384
+ }
385
+ return $this;
386
+ }
387
+ if ($setRedirectUrl = $this->getRequest()->getParam('token')) {
388
+ if ($setRedirectUrl !== $this->_getSession()->getPayPalCheckoutRedirectUrl()) {
389
+ Mage::throwException($this->__('Wrong PayPal Checkout RedirectUrl specified.'));
390
+ }
391
+ } else {
392
+ $setRedirectUrl = $this->_getSession()->getPayPalCheckoutRedirectUrl();
393
+ }
394
+ return $setRedirectUrl;
395
+ }
396
+
397
+ protected function _getCheckoutSession()
398
+ {
399
+ return Mage::getSingleton('checkout/session');
400
+ }
401
+
402
+ protected function _getSession()
403
+ {
404
+ return Mage::getSingleton('hps_securesubmit/session');
405
+ }
406
+
407
+ protected function _getQuote()
408
+ {
409
+ if (!$this->_quote) {
410
+ $this->_quote = $this->_getCheckoutSession()->getQuote();
411
+ }
412
+ return $this->_quote;
413
  }
414
  }
app/code/community/Hps/Securesubmit/controllers/StoredcardController.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
 
3
  class Hps_Securesubmit_StoredcardController extends Mage_core_Controller_Front_Action
4
  {
@@ -31,7 +38,7 @@ class Hps_Securesubmit_StoredcardController extends Mage_core_Controller_Front_A
31
  try{
32
  $storedCard = Mage::getModel('hps_securesubmit/storedcard');
33
  $storedCard->load($this->getRequest()->getParam('storedcard_id'));
34
- if ( ! $storedCard->getId() || $storedCard->getCustomerId() != Mage::getSingleton('customer/session')->getCustomerId()) {
35
  throw new Mage_Core_Exception($this->__('Stored card no longer exists.'));
36
  }
37
  $storedCard->delete();
@@ -55,7 +62,7 @@ class Hps_Securesubmit_StoredcardController extends Mage_core_Controller_Front_A
55
  try {
56
  $storedCard = Mage::getModel('hps_securesubmit/storedcard');
57
  $storedCard->load($this->getRequest()->getParam('storedcard_id'));
58
- if ( ! $storedCard->getId() || $storedCard->getCustomerId() != Mage::getSingleton('customer/session')->getCustomerId()) {
59
  throw new Mage_Core_Exception($this->__('Stored card no longer exists.'));
60
  }
61
  $result = array(
@@ -80,4 +87,47 @@ class Hps_Securesubmit_StoredcardController extends Mage_core_Controller_Front_A
80
  $this->getResponse()->setBody(json_encode($result));
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
1
  <?php
2
+ require_once Mage::getBaseDir('lib').DS.'SecureSubmit'.DS.'Hps.php';
3
+ /**
4
+ * @category Hps
5
+ * @package Hps_Securesubmit
6
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
7
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
8
+ */
9
 
10
  class Hps_Securesubmit_StoredcardController extends Mage_core_Controller_Front_Action
11
  {
38
  try{
39
  $storedCard = Mage::getModel('hps_securesubmit/storedcard');
40
  $storedCard->load($this->getRequest()->getParam('storedcard_id'));
41
+ if ( ! $storedCard->getId()) {
42
  throw new Mage_Core_Exception($this->__('Stored card no longer exists.'));
43
  }
44
  $storedCard->delete();
62
  try {
63
  $storedCard = Mage::getModel('hps_securesubmit/storedcard');
64
  $storedCard->load($this->getRequest()->getParam('storedcard_id'));
65
+ if (!$storedCard->getId() || $storedCard->getCustomerId() != Mage::getSingleton('customer/session')->getCustomerId()) {
66
  throw new Mage_Core_Exception($this->__('Stored card no longer exists.'));
67
  }
68
  $result = array(
87
  $this->getResponse()->setBody(json_encode($result));
88
  }
89
 
90
+ public function getBalanceAction()
91
+ {
92
+ try {
93
+ $giftCardNumber = $this->getRequest()->getParam('giftcard_number');
94
+
95
+ if (!$giftCardNumber) {
96
+ throw new Mage_Core_Exception($this->__('No number received.'));
97
+ }
98
+
99
+ $config = new HpsServicesConfig();
100
+
101
+ $config->secretApiKey = Mage::getModel('hps_securesubmit/payment')->getConfigData('secretapikey');
102
+ $config->versionNumber = '1573';
103
+ $config->developerId = '002914';
104
+
105
+ $giftService = new HpsGiftCardService($config);
106
+
107
+ try {
108
+ $card = new HpsGiftCard();
109
+ $card->number = $_GET["giftcard_number"];
110
+
111
+ $response = $giftService->balance($card);
112
+
113
+ $result = array(
114
+ 'error' => FALSE,
115
+ 'balance' => $response->balanceAmount
116
+ );
117
+ } catch (HpsException $e) {
118
+ $result = array('error' => TRUE, 'message' => $e->getMessage());
119
+ }
120
+ }
121
+ catch (Mage_Core_Exception $e) {
122
+ $result = array('error' => TRUE, 'message' => $e->getMessage());
123
+ }
124
+ catch (Exception $e) {
125
+ Mage::logException($e);
126
+ $result = array('error' => TRUE, 'message' => $this->__('An unexpected error occurred retrieving your stored card. We apologize for the inconvenience, please contact us for further support.'));
127
+ }
128
+
129
+ $this->getResponse()->setHeader('Content-Type', 'application/json', TRUE);
130
+ $this->getResponse()->setBody(json_encode($result));
131
+ }
132
+
133
  }
app/code/community/Hps/Securesubmit/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Hps_Securesubmit>
5
- <version>1.0.0</version>
6
  </Hps_Securesubmit>
7
  </modules>
8
  <global>
@@ -13,6 +13,16 @@
13
  <class>Hps_Securesubmit_Model_Resource_Setup</class>
14
  </setup>
15
  </hps_securesubmit_setup>
 
 
 
 
 
 
 
 
 
 
16
  </resources>
17
  <models>
18
  <hps_securesubmit>
@@ -25,6 +35,9 @@
25
  <storedcard>
26
  <table>storedcard</table>
27
  </storedcard>
 
 
 
28
  </entities>
29
  </hps_securesubmit_resource>
30
  </models>
@@ -38,6 +51,18 @@
38
  <class>Hps_Securesubmit_Block</class>
39
  </hps_securesubmit>
40
  </blocks>
 
 
 
 
 
 
 
 
 
 
 
 
41
  </global>
42
  <default>
43
  <payment>
@@ -47,12 +72,45 @@
47
  <title>Credit Card (SecureSubmit)</title>
48
  <cctypes>AE,VI,MC,DI,JCB</cctypes>
49
  <useccv>1</useccv>
50
- <min_order_total>0.50</min_order_total>
51
  <secretapikey backend_model="adminhtml/system_config_backend_encrypted" />
52
  <publicapikey backend_model="adminhtml/system_config_backend_encrypted" />
53
  <use_http_proxy>0</use_http_proxy>
54
  <debug>0</debug>
55
  </hps_securesubmit>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  </payment>
57
  </default>
58
  <frontend>
@@ -82,7 +140,7 @@
82
  </secure_url>
83
  <layout>
84
  <updates>
85
- <hps_securesubmit module="Hps_Securesubmit">
86
  <file>securesubmit.xml</file>
87
  </hps_securesubmit>
88
  </updates>
@@ -97,4 +155,15 @@
97
  </hps_securesubmit>
98
  </routers>
99
  </adminhtml>
 
 
 
 
 
 
 
 
 
 
 
100
  </config>
2
  <config>
3
  <modules>
4
  <Hps_Securesubmit>
5
+ <version>1.2.0</version>
6
  </Hps_Securesubmit>
7
  </modules>
8
  <global>
13
  <class>Hps_Securesubmit_Model_Resource_Setup</class>
14
  </setup>
15
  </hps_securesubmit_setup>
16
+ <hps_securesubmit_write>
17
+ <connection>
18
+ <use>core_write</use>
19
+ </connection>
20
+ </hps_securesubmit_write>
21
+ <hps_securesubmit_read>
22
+ <connection>
23
+ <use>core_read</use>
24
+ </connection>
25
+ </hps_securesubmit_read>
26
  </resources>
27
  <models>
28
  <hps_securesubmit>
35
  <storedcard>
36
  <table>storedcard</table>
37
  </storedcard>
38
+ <report>
39
+ <table>report_settlement</table>
40
+ </report>
41
  </entities>
42
  </hps_securesubmit_resource>
43
  </models>
51
  <class>Hps_Securesubmit_Block</class>
52
  </hps_securesubmit>
53
  </blocks>
54
+ <fieldsets>
55
+ <sales_convert_quote_payment>
56
+ <securesubmit_use_stored_card>
57
+ <to_order_payment>*</to_order_payment>
58
+ </securesubmit_use_stored_card>
59
+ </sales_convert_quote_payment>
60
+ </fieldsets>
61
+ <payment>
62
+ <groups>
63
+ <hps_paypal>HPS PayPal</hps_paypal>
64
+ </groups>
65
+ </payment>
66
  </global>
67
  <default>
68
  <payment>
72
  <title>Credit Card (SecureSubmit)</title>
73
  <cctypes>AE,VI,MC,DI,JCB</cctypes>
74
  <useccv>1</useccv>
75
+ <min_order_total/>
76
  <secretapikey backend_model="adminhtml/system_config_backend_encrypted" />
77
  <publicapikey backend_model="adminhtml/system_config_backend_encrypted" />
78
  <use_http_proxy>0</use_http_proxy>
79
  <debug>0</debug>
80
  </hps_securesubmit>
81
+ <hps_paypal>
82
+ <model>hps_securesubmit/paypal</model>
83
+ <payment_action>authorize_capture</payment_action>
84
+ <title>PayPal</title>
85
+ <secretapikey backend_model="adminhtml/system_config_backend_encrypted" />
86
+ <publicapikey backend_model="adminhtml/system_config_backend_encrypted" />
87
+ <use_sandbox>0</use_sandbox>
88
+ <username backend_model="adminhtml/system_config_backend_encrypted" />
89
+ <password backend_model="adminhtml/system_config_backend_encrypted" />
90
+ <device_id backend_model="adminhtml/system_config_backend_encrypted" />
91
+ <license_id backend_model="adminhtml/system_config_backend_encrypted" />
92
+ <site_id backend_model="adminhtml/system_config_backend_encrypted" />
93
+ <use_http_proxy>0</use_http_proxy>
94
+ <debug>0</debug>
95
+ <paypal_credit>1</paypal_credit>
96
+ <group>hps_paypal</group>
97
+ </hps_paypal>
98
+ <hps_paypal_credit>
99
+ <model>hps_securesubmit/paypal_credit</model>
100
+ <title>PayPal Credit</title>
101
+ <group>hps_paypal</group>
102
+ </hps_paypal_credit>
103
+ <hps_masterpass>
104
+ <model>hps_securesubmit/masterpass</model>
105
+ <payment_action>authorize_capture</payment_action>
106
+ <title>MasterPass</title>
107
+ <processor_id backend_model="adminhtml/system_config_backend_encrypted" />
108
+ <merchant_id backend_model="adminhtml/system_config_backend_encrypted" />
109
+ <transaction_pwd backend_model="adminhtml/system_config_backend_encrypted" />
110
+ <merchant_checkout_id backend_model="adminhtml/system_config_backend_encrypted" />
111
+ <use_sandbox>0</use_sandbox>
112
+ <debug>0</debug>
113
+ </hps_masterpass>
114
  </payment>
115
  </default>
116
  <frontend>
140
  </secure_url>
141
  <layout>
142
  <updates>
143
+ <hps_securesubmit>
144
  <file>securesubmit.xml</file>
145
  </hps_securesubmit>
146
  </updates>
155
  </hps_securesubmit>
156
  </routers>
157
  </adminhtml>
158
+ <admin>
159
+ <routers>
160
+ <adminhtml>
161
+ <args>
162
+ <modules>
163
+ <Hps_Securesubmit before="Mage_Adminhtml">Hps_Securesubmit_Adminhtml</Hps_Securesubmit>
164
+ </modules>
165
+ </args>
166
+ </adminhtml>
167
+ </routers>
168
+ </admin>
169
  </config>
app/code/community/Hps/Securesubmit/etc/system.xml CHANGED
@@ -22,13 +22,13 @@
22
  <show_in_store>0</show_in_store>
23
  </active>
24
  <order_status translate="label">
25
- <label>New order status</label>
26
- <frontend_type>select</frontend_type>
27
- <source_model>adminhtml/system_config_source_order_status_processing</source_model>
28
- <sort_order>4</sort_order>
29
- <show_in_default>1</show_in_default>
30
- <show_in_website>1</show_in_website>
31
- <show_in_store>0</show_in_store>
32
  </order_status>
33
  <title translate="label">
34
  <label>Title</label>
@@ -85,10 +85,59 @@
85
  Heartland Account must be configured for multi-use tokenization.]]>
86
  </comment>
87
  </allow_card_saving>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  <custom_message>
89
  <label>Custom Error Message</label>
90
  <frontend_type>textarea</frontend_type>
91
- <sort_order>65</sort_order>
92
  <show_in_default>1</show_in_default>
93
  <show_in_website>1</show_in_website>
94
  <show_in_store>1</show_in_store>
@@ -146,6 +195,345 @@
146
  </debug>
147
  </fields>
148
  </hps_securesubmit>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  </groups>
150
  </payment>
151
  </sections>
22
  <show_in_store>0</show_in_store>
23
  </active>
24
  <order_status translate="label">
25
+ <label>New order status</label>
26
+ <frontend_type>select</frontend_type>
27
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
28
+ <sort_order>4</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>0</show_in_store>
32
  </order_status>
33
  <title translate="label">
34
  <label>Title</label>
85
  Heartland Account must be configured for multi-use tokenization.]]>
86
  </comment>
87
  </allow_card_saving>
88
+ <allow_heartland_gift translate="label">
89
+ <label>Allow Heartland Gift Cards</label>
90
+ <frontend_type>select</frontend_type>
91
+ <source_model>adminhtml/system_config_source_yesno</source_model>
92
+ <sort_order>61</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ <comment><![CDATA[
97
+ Heartland Account must already be signed up to accept Gift Cards.]]>
98
+ </comment>
99
+ </allow_heartland_gift>
100
+ <allow_fraud translate="label">
101
+ <label>Allow Suspicious</label>
102
+ <frontend_type>select</frontend_type>
103
+ <source_model>adminhtml/system_config_source_yesno</source_model>
104
+ <sort_order>62</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>1</show_in_store>
108
+ <comment><![CDATA[Note: You will have 72 hours from the original authorization date to manually review suspicious orders in the virtual terminal and make a final decision (either to accept the gateway fraud decision or to manually override).]]></comment>
109
+ </allow_fraud>
110
+ <email_fraud translate="label">
111
+ <label>Email Store Owner on Suspicious Orders</label>
112
+ <frontend_type>select</frontend_type>
113
+ <source_model>adminhtml/system_config_source_yesno</source_model>
114
+ <sort_order>63</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
+ </email_fraud>
119
+ <fraud_address translate="label">
120
+ <label>Notification Email Address</label>
121
+ <frontend_type>text</frontend_type>
122
+ <sort_order>64</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>1</show_in_store>
126
+ <comment><![CDATA[This email address will be notified of suspicious orders.]]></comment>
127
+ </fraud_address>
128
+ <fraud_text>
129
+ <label>Fraud Text</label>
130
+ <frontend_type>textarea</frontend_type>
131
+ <sort_order>65</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>1</show_in_website>
134
+ <show_in_store>1</show_in_store>
135
+ <comment><![CDATA[This is the text that will display to the customer when fraud is detected and the transaction fails.]]></comment>
136
+ </fraud_text>
137
  <custom_message>
138
  <label>Custom Error Message</label>
139
  <frontend_type>textarea</frontend_type>
140
+ <sort_order>66</sort_order>
141
  <show_in_default>1</show_in_default>
142
  <show_in_website>1</show_in_website>
143
  <show_in_store>1</show_in_store>
195
  </debug>
196
  </fields>
197
  </hps_securesubmit>
198
+ <hps_paypal translate="label" module="hps_securesubmit">
199
+ <label>HPS PayPal</label>
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
+ <comment><![CDATA[<a href="http://developer.heartlandpaymentsystems.com/SecureSubmit" target="_blank">Click here to sign up for SecureSubmit account</a>]]></comment>
206
+ <fields>
207
+ <active translate="label">
208
+ <label>Enabled</label>
209
+ <frontend_type>select</frontend_type>
210
+ <source_model>adminhtml/system_config_source_yesno</source_model>
211
+ <sort_order>10</sort_order>
212
+ <show_in_default>1</show_in_default>
213
+ <show_in_website>1</show_in_website>
214
+ <show_in_store>0</show_in_store>
215
+ </active>
216
+ <order_status translate="label">
217
+ <label>New order status</label>
218
+ <frontend_type>select</frontend_type>
219
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
220
+ <sort_order>4</sort_order>
221
+ <show_in_default>1</show_in_default>
222
+ <show_in_website>1</show_in_website>
223
+ <show_in_store>0</show_in_store>
224
+ </order_status>
225
+ <title translate="label">
226
+ <label>Title</label>
227
+ <frontend_type>text</frontend_type>
228
+ <sort_order>20</sort_order>
229
+ <show_in_default>1</show_in_default>
230
+ <show_in_website>1</show_in_website>
231
+ <show_in_store>1</show_in_store>
232
+ </title>
233
+ <use_sandbox translate="label">
234
+ <label>Use Sandbox</label>
235
+ <frontend_type>select</frontend_type>
236
+ <source_model>adminhtml/system_config_source_yesno</source_model>
237
+ <sort_order>25</sort_order>
238
+ <show_in_default>1</show_in_default>
239
+ <show_in_website>1</show_in_website>
240
+ <show_in_store>1</show_in_store>
241
+ </use_sandbox>
242
+ <username translate="label">
243
+ <label>Username</label>
244
+ <frontend_type>text</frontend_type>
245
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
246
+ <sort_order>30</sort_order>
247
+ <show_in_default>1</show_in_default>
248
+ <show_in_website>1</show_in_website>
249
+ <show_in_store>1</show_in_store>
250
+ <depends><use_sandbox>1</use_sandbox></depends>
251
+ </username>
252
+ <password translate="label">
253
+ <label>Password</label>
254
+ <frontend_type>text</frontend_type>
255
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
256
+ <sort_order>31</sort_order>
257
+ <show_in_default>1</show_in_default>
258
+ <show_in_website>1</show_in_website>
259
+ <show_in_store>1</show_in_store>
260
+ <depends><use_sandbox>1</use_sandbox></depends>
261
+ </password>
262
+ <device_id translate="label">
263
+ <label>Device ID</label>
264
+ <frontend_type>text</frontend_type>
265
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
266
+ <sort_order>32</sort_order>
267
+ <show_in_default>1</show_in_default>
268
+ <show_in_website>1</show_in_website>
269
+ <show_in_store>1</show_in_store>
270
+ <depends><use_sandbox>1</use_sandbox></depends>
271
+ </device_id>
272
+ <license_id translate="label">
273
+ <label>License ID</label>
274
+ <frontend_type>text</frontend_type>
275
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
276
+ <sort_order>33</sort_order>
277
+ <show_in_default>1</show_in_default>
278
+ <show_in_website>1</show_in_website>
279
+ <show_in_store>1</show_in_store>
280
+ <depends><use_sandbox>1</use_sandbox></depends>
281
+ </license_id>
282
+ <site_id translate="label">
283
+ <label>Site ID</label>
284
+ <frontend_type>text</frontend_type>
285
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
286
+ <sort_order>34</sort_order>
287
+ <show_in_default>1</show_in_default>
288
+ <show_in_website>1</show_in_website>
289
+ <show_in_store>1</show_in_store>
290
+ <depends><use_sandbox>1</use_sandbox></depends>
291
+ </site_id>
292
+ <publicapikey translate="label">
293
+ <label>Public Api Key</label>
294
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
295
+ <sort_order>30</sort_order>
296
+ <show_in_default>1</show_in_default>
297
+ <show_in_website>1</show_in_website>
298
+ <show_in_store>1</show_in_store>
299
+ <depends><use_sandbox>0</use_sandbox></depends>
300
+ </publicapikey>
301
+ <secretapikey translate="label">
302
+ <label>Secret Api Key</label>
303
+ <frontend_type>obscure</frontend_type>
304
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
305
+ <sort_order>40</sort_order>
306
+ <show_in_default>1</show_in_default>
307
+ <show_in_website>1</show_in_website>
308
+ <show_in_store>1</show_in_store>
309
+ <depends><use_sandbox>0</use_sandbox></depends>
310
+ </secretapikey>
311
+ <!-- <buyer_id translate="label">
312
+ <label>Buyer ID</label>
313
+ <frontend_type>text</frontend_type>
314
+ <sort_order>45</sort_order>
315
+ <show_in_default>1</show_in_default>
316
+ <show_in_website>1</show_in_website>
317
+ <show_in_store>1</show_in_store>
318
+ <comment><![CDATA[
319
+ How to obtain buyer id.]]>
320
+ </comment>
321
+ </buyer_id> -->
322
+ <cctypes translate="label">
323
+ <label>Credit Card Types</label>
324
+ <frontend_type>multiselect</frontend_type>
325
+ <source_model>hps_securesubmit/source_cctype</source_model>
326
+ <sort_order>50</sort_order>
327
+ <show_in_default>1</show_in_default>
328
+ <show_in_website>1</show_in_website>
329
+ <show_in_store>0</show_in_store>
330
+ </cctypes>
331
+ <payment_action translate="label">
332
+ <label>Payment Action</label>
333
+ <frontend_type>select</frontend_type>
334
+ <source_model>hps_securesubmit/source_paymentAction</source_model>
335
+ <sort_order>60</sort_order>
336
+ <show_in_default>1</show_in_default>
337
+ <show_in_website>1</show_in_website>
338
+ <show_in_store>0</show_in_store>
339
+ </payment_action>
340
+ <paypal_credit translate="label comment">
341
+ <label>Enable Paypal Credit</label>
342
+ <comment><![CDATA[
343
+ PayPal Express Checkout lets you give customers access to financing
344
+ through Paypal Credit&#174; - at no additional cost to you.
345
+ You get paid up front, even though customers have more time to pay.
346
+ A pre-integrated payment button lets customers pay quickly with Paypal
347
+ Credit&#174;.
348
+ <a href="https://www.paypal.com/webapps/mpp/promotional-financing" target="_blank">Learn More</a>]]>
349
+ </comment>
350
+ <config_path>payment/hps_paypal_credit/active</config_path>
351
+ <frontend_type>select</frontend_type>
352
+ <source_model>adminhtml/system_config_source_yesno</source_model>
353
+ <sort_order>61</sort_order>
354
+ <show_in_default>1</show_in_default>
355
+ <show_in_website>1</show_in_website>
356
+ <requires>hps_paypal_active</requires>
357
+ <!-- <frontend_class>paypal-bml</frontend_class> -->
358
+ </paypal_credit>
359
+ <custom_message>
360
+ <label>Custom Error Message</label>
361
+ <frontend_type>textarea</frontend_type>
362
+ <sort_order>65</sort_order>
363
+ <show_in_default>1</show_in_default>
364
+ <show_in_website>1</show_in_website>
365
+ <show_in_store>1</show_in_store>
366
+ <comment><![CDATA[
367
+ To use the default Secure Submit error message use %s in the custom message text, ex.
368
+ My message. %s -> will be displayed as: My message. Original Secure Submit message.]]>
369
+ </comment>
370
+ </custom_message>
371
+ <sort_order translate="label">
372
+ <label>Sort Order</label>
373
+ <frontend_type>text</frontend_type>
374
+ <sort_order>70</sort_order>
375
+ <show_in_default>1</show_in_default>
376
+ <show_in_website>1</show_in_website>
377
+ <show_in_store>0</show_in_store>
378
+ </sort_order>
379
+ <use_http_proxy translate="label">
380
+ <label>Use HTTP Proxy</label>
381
+ <frontend_type>select</frontend_type>
382
+ <source_model>adminhtml/system_config_source_yesno</source_model>
383
+ <backend_model>hps_securesubmit/system_config_backend_proxy</backend_model>
384
+ <sort_order>80</sort_order>
385
+ <show_in_default>1</show_in_default>
386
+ <show_in_website>1</show_in_website>
387
+ <show_in_store>0</show_in_store>
388
+ </use_http_proxy>
389
+ <http_proxy_host translate="label">
390
+ <label>HTTP Proxy Host</label>
391
+ <frontend_type>text</frontend_type>
392
+ <sort_order>90</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
+ <depends><use_http_proxy>1</use_http_proxy></depends>
397
+ <comment>Example: example.com</comment>
398
+ </http_proxy_host>
399
+ <http_proxy_port translate="label">
400
+ <label>HTTP Proxy Port</label>
401
+ <frontend_type>text</frontend_type>
402
+ <sort_order>100</sort_order>
403
+ <show_in_default>1</show_in_default>
404
+ <show_in_website>1</show_in_website>
405
+ <show_in_store>0</show_in_store>
406
+ <comment>Example: 8888</comment>
407
+ <depends><use_http_proxy>1</use_http_proxy></depends>
408
+ </http_proxy_port>
409
+ <debug translate="label">
410
+ <label>Debug</label>
411
+ <frontend_type>select</frontend_type>
412
+ <source_model>adminhtml/system_config_source_yesno</source_model>
413
+ <sort_order>110</sort_order>
414
+ <show_in_default>1</show_in_default>
415
+ <show_in_website>1</show_in_website>
416
+ <show_in_store>0</show_in_store>
417
+ </debug>
418
+ </fields>
419
+ </hps_paypal>
420
+ <hps_masterpass translate="label" module="hps_securesubmit">
421
+ <label>HPS MasterPass</label>
422
+ <frontend_type>text</frontend_type>
423
+ <sort_order>20</sort_order>
424
+ <show_in_default>1</show_in_default>
425
+ <show_in_website>1</show_in_website>
426
+ <show_in_store>1</show_in_store>
427
+ <comment><![CDATA[<a href="http://developer.heartlandpaymentsystems.com/SecureSubmit" target="_blank">Click here to sign up for SecureSubmit account</a>]]></comment>
428
+ <fields>
429
+ <active translate="label">
430
+ <label>Enabled</label>
431
+ <frontend_type>select</frontend_type>
432
+ <source_model>adminhtml/system_config_source_yesno</source_model>
433
+ <sort_order>10</sort_order>
434
+ <show_in_default>1</show_in_default>
435
+ <show_in_website>1</show_in_website>
436
+ <show_in_store>0</show_in_store>
437
+ </active>
438
+ <order_status translate="label">
439
+ <label>New order status</label>
440
+ <frontend_type>select</frontend_type>
441
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
442
+ <sort_order>4</sort_order>
443
+ <show_in_default>1</show_in_default>
444
+ <show_in_website>1</show_in_website>
445
+ <show_in_store>0</show_in_store>
446
+ </order_status>
447
+ <title translate="label">
448
+ <label>Title</label>
449
+ <frontend_type>text</frontend_type>
450
+ <sort_order>20</sort_order>
451
+ <show_in_default>1</show_in_default>
452
+ <show_in_website>1</show_in_website>
453
+ <show_in_store>1</show_in_store>
454
+ </title>
455
+ <processor_id translate="label">
456
+ <label>Processor ID</label>
457
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
458
+ <sort_order>30</sort_order>
459
+ <show_in_default>1</show_in_default>
460
+ <show_in_website>1</show_in_website>
461
+ <show_in_store>1</show_in_store>
462
+ </processor_id>
463
+ <merchant_id translate="label">
464
+ <label>Merchant ID</label>
465
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
466
+ <sort_order>31</sort_order>
467
+ <show_in_default>1</show_in_default>
468
+ <show_in_website>1</show_in_website>
469
+ <show_in_store>1</show_in_store>
470
+ </merchant_id>
471
+ <transaction_pwd translate="label">
472
+ <label>Transaction Password</label>
473
+ <frontend_type>obscure</frontend_type>
474
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
475
+ <sort_order>32</sort_order>
476
+ <show_in_default>1</show_in_default>
477
+ <show_in_website>1</show_in_website>
478
+ <show_in_store>1</show_in_store>
479
+ </transaction_pwd>
480
+ <merchant_checkout_id translate="label">
481
+ <label>Merchant Checkout ID</label>
482
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
483
+ <sort_order>33</sort_order>
484
+ <show_in_default>1</show_in_default>
485
+ <show_in_website>1</show_in_website>
486
+ <show_in_store>1</show_in_store>
487
+ </merchant_checkout_id>
488
+ <use_sandbox translate="label">
489
+ <label>Use Sandbox</label>
490
+ <frontend_type>select</frontend_type>
491
+ <source_model>adminhtml/system_config_source_yesno</source_model>
492
+ <sort_order>25</sort_order>
493
+ <show_in_default>1</show_in_default>
494
+ <show_in_website>1</show_in_website>
495
+ <show_in_store>1</show_in_store>
496
+ </use_sandbox>
497
+ <payment_action translate="label">
498
+ <label>Payment Action</label>
499
+ <frontend_type>select</frontend_type>
500
+ <source_model>hps_securesubmit/source_paymentAction</source_model>
501
+ <sort_order>60</sort_order>
502
+ <show_in_default>1</show_in_default>
503
+ <show_in_website>1</show_in_website>
504
+ <show_in_store>0</show_in_store>
505
+ </payment_action>
506
+ <custom_message>
507
+ <label>Custom Error Message</label>
508
+ <frontend_type>textarea</frontend_type>
509
+ <sort_order>65</sort_order>
510
+ <show_in_default>1</show_in_default>
511
+ <show_in_website>1</show_in_website>
512
+ <show_in_store>1</show_in_store>
513
+ <comment><![CDATA[
514
+ To use the default Secure Submit error message use %s in the custom message text, ex.
515
+ My message. %s -> will be displayed as: My message. Original Secure Submit message.]]>
516
+ </comment>
517
+ </custom_message>
518
+ <sort_order translate="label">
519
+ <label>Sort Order</label>
520
+ <frontend_type>text</frontend_type>
521
+ <sort_order>70</sort_order>
522
+ <show_in_default>1</show_in_default>
523
+ <show_in_website>1</show_in_website>
524
+ <show_in_store>0</show_in_store>
525
+ </sort_order>
526
+ <debug translate="label">
527
+ <label>Debug</label>
528
+ <frontend_type>select</frontend_type>
529
+ <source_model>adminhtml/system_config_source_yesno</source_model>
530
+ <sort_order>110</sort_order>
531
+ <show_in_default>1</show_in_default>
532
+ <show_in_website>1</show_in_website>
533
+ <show_in_store>0</show_in_store>
534
+ </debug>
535
+ </fields>
536
+ </hps_masterpass>
537
  </groups>
538
  </payment>
539
  </sections>
app/code/community/Hps/Securesubmit/sql/hps_securesubmit_setup/install-1.0.0.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
  $installer = $this;
3
  $installer->startSetup();
4
 
1
  <?php
2
+ /**
3
+ * @category Hps
4
+ * @package Hps_Securesubmit
5
+ * @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com)
6
+ * @license https://github.com/SecureSubmit/heartland-magento-extension/blob/master/LICENSE Custom License
7
+ */
8
+
9
  $installer = $this;
10
  $installer->startSetup();
11
 
app/code/community/Hps/Securesubmit/sql/hps_securesubmit_setup/mysql4-upgrade-1.0.1-1.1.0.php CHANGED
@@ -21,4 +21,4 @@ CREATE TABLE {$this->getTable('hps_securesubmit/report')} (
21
 
22
  ");
23
 
24
- $installer->endSetup();
21
 
22
  ");
23
 
24
+ $installer->endSetup();
app/code/community/Hps/Securesubmit/sql/hps_securesubmit_setup/mysql4-upgrade-1.1.0-1.2.0.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = Mage::getResourceModel('customer/setup', 'customer_setup');
3
+
4
+ $installer->startSetup();
5
+
6
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
7
+
8
+ $entityTypeId = $setup->getEntityTypeId('customer');
9
+ $attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
10
+ $attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
11
+
12
+ $installer->addAttribute('customer', 'masterpass_long_access_token', array(
13
+ 'type' => 'varchar',
14
+ 'backend' => '',
15
+ 'label' => 'MasterPass Long Access Token',
16
+ 'input' => 'text',
17
+ 'source' => '',
18
+ 'visible' => false,
19
+ 'required' => false,
20
+ 'default' => '',
21
+ 'frontend' => '',
22
+ 'unique' => true,
23
+ 'note' => 'MasterPass Long Access Token'
24
+ ));
25
+
26
+ $attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'masterpass_long_access_token');
27
+
28
+
29
+ $setup->addAttributeToGroup(
30
+ $entityTypeId,
31
+ $attributeSetId,
32
+ $attributeGroupId,
33
+ 'masterpass_long_access_token',
34
+ '999' //sort_order
35
+ );
36
+
37
+ $installer->endSetup();
app/design/adminhtml/default/default/template/securesubmit/form.phtml CHANGED
@@ -1,30 +1,55 @@
1
- <?php
2
- $_code=$this->getMethodCode();
 
 
3
  $public_key = Mage::getModel('hps_securesubmit/payment')->getConfigData('publicapikey');
 
 
 
4
  ?>
 
5
  <input id="<?php echo $_code ?>_payment_method" type="hidden" name="payment[method]" value="<?php echo $_code ?>" />
6
  <ul id="payment_form_<?php echo $_code ?>" class="form-list" style="display:none;">
7
- <li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  <label for="<?php echo $_code ?>_cc_type" ><?php echo Mage::helper('payment')->__('Credit Card Type') ?><span class="required">*</span></label>
9
  <div class="input-box">
10
  <select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
11
- <option value=""><?php echo Mage::helper('payment')->__('--Please Select--')?></option>
12
  <?php $_ccType = $this->getInfoData('cc_type') ?>
13
- <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
14
- <option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
15
  <?php endforeach ?>
16
  </select>
17
  </div>
18
  </li>
19
- <li>
20
  <label for="<?php echo $_code ?>_cc_number"><?php echo Mage::helper('payment')->__('Credit Card Number') ?><span class="required">*</span></label>
21
  <div class="input-box">
22
- <input type="text" id="<?php echo $_code ?>_cc_number" data-encrypted-name="payment[cc_number]" title="<?php echo Mage::helper('payment')->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value=""/>
 
23
  <input type="hidden" id="<?php echo $_code ?>_token" name="payment[securesubmit_token]" value="">
24
  <input type="hidden" id="<?php echo $_code ?>_cc_last_four" name="payment[cc_last_four]" value="">
25
  </div>
26
  </li>
27
- <li>
28
  <div class="input-box">
29
  <label for="<?php echo $_code ?>_expiration"><?php echo Mage::helper('payment')->__('Expiration Date') ?> <span class="required">*</span></label><br/>
30
  <select id="<?php echo $_code ?>_expiration" style="width:140px;" name="payment[cc_exp_month]" class="validate-cc-exp required-entry">
@@ -42,18 +67,58 @@ $public_key = Mage::getModel('hps_securesubmit/payment')->getConfigData('publica
42
  </div>
43
  </li>
44
  <?php if($this->hasVerification()): ?>
45
- <li>
46
  <div class="input-box">
47
  <label for="<?php echo $_code ?>_cc_cid"><?php echo Mage::helper('payment')->__('Card Verification Number') ?> <span class="required">*</span></label><br/>
48
  <input type="text" title="<?php echo Mage::helper('payment')->__('Card Verification Number') ?>" class="required-entry input-text validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" style="width:3em;" value=""/>
49
  </div>
50
  </li>
51
  <?php endif; ?>
52
- </ul>
53
 
 
 
 
 
 
 
 
 
 
 
54
  <script type="text/javascript">
55
  //<![CDATA[
56
- order.secureSubmitPublicKey = '<?php echo $public_key ?>';
57
- order.secureSubmitGetTokenDataUrl = '<?php echo Mage::getUrl('securesubmit/storedcard/getTokenData', array('_secure' => TRUE)) ?>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  //]]>
59
  </script>
1
+ <?php /** @var $this Hps_Securesubmit_Block_Adminhtml_Form */
2
+ $_code = $this->getMethodCode();
3
+ $customerStoredCards = $this->getCustomerStoredCards();
4
+ $useStoredCard = !! $this->getInfoData('securesubmit_use_stored_card');
5
  $public_key = Mage::getModel('hps_securesubmit/payment')->getConfigData('publicapikey');
6
+ $customerId = Mage::getSingleton('adminhtml/session_quote')->getCustomerId();
7
+ // $customerStoredCards = Mage::helper('hps_securesubmit')->getStoredCards( $customerId );
8
+ $allow_card_saving = Mage::getModel('hps_securesubmit/payment')->getConfigData('allow_card_saving');
9
  ?>
10
+
11
  <input id="<?php echo $_code ?>_payment_method" type="hidden" name="payment[method]" value="<?php echo $_code ?>" />
12
  <ul id="payment_form_<?php echo $_code ?>" class="form-list" style="display:none;">
13
+ <?php if($allow_card_saving && count($customerStoredCards)): ?>
14
+ <li>
15
+ <label for="<?php echo $_code ?>_stored_card_checkbox"><?php echo $this->__('Use a stored card') ?></label>
16
+ <div class="input-box">
17
+ <input type="checkbox" id="<?php echo $_code ?>_stored_card_checkbox" name="payment[securesubmit_use_stored_card]" <?php if ($useStoredCard) : ?> checked="checked" <?php endif ?> value="1" />
18
+ </div>
19
+ </li>
20
+ <li id="<?php echo $_code ?>_stored_cards" style="display: none">
21
+ <label for="<?php echo $_code ?>_stored_card_select"><?php echo $this->__('Stored Card') ?></label>
22
+ <div class="input-box">
23
+ <select id="<?php echo $_code ?>_stored_card_select" autocomplete="off">
24
+ <?php foreach ($customerStoredCards as $key => $card): ?>
25
+ <option value="<?php echo $card->getId() ?>"><?php echo $card->getCcType().' ************'.$card->getCcLast4().' ('.$card->getCcExpMonth().'/'.$card->getCcExpYear().')' ?></option>
26
+ <?php endforeach ?>
27
+ </select>
28
+ </div>
29
+ </li>
30
+ <?php endif ?>
31
+ <li class="stored_cards_selected">
32
  <label for="<?php echo $_code ?>_cc_type" ><?php echo Mage::helper('payment')->__('Credit Card Type') ?><span class="required">*</span></label>
33
  <div class="input-box">
34
  <select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
35
+ <option value=""><?php echo $this->__('--Please Select--') ?></option>
36
  <?php $_ccType = $this->getInfoData('cc_type') ?>
37
+ <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName) : ?>
38
+ <option value="<?php echo $_typeCode ?>"<?php if($_typeCode == $_ccType) : ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
39
  <?php endforeach ?>
40
  </select>
41
  </div>
42
  </li>
43
+ <li class="stored_cards_selected">
44
  <label for="<?php echo $_code ?>_cc_number"><?php echo Mage::helper('payment')->__('Credit Card Number') ?><span class="required">*</span></label>
45
  <div class="input-box">
46
+ <input type="text" id="<?php echo $_code ?>_cc_number" data-encrypted-name="payment[cc_number]" title="<?php echo Mage::helper('payment')->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type required-entry" value=""/>
47
+ <input type="hidden" id="<?php echo $_code ?>_use_credit_card" name="payment[use_credit_card]" value="1" />
48
  <input type="hidden" id="<?php echo $_code ?>_token" name="payment[securesubmit_token]" value="">
49
  <input type="hidden" id="<?php echo $_code ?>_cc_last_four" name="payment[cc_last_four]" value="">
50
  </div>
51
  </li>
52
+ <li class="stored_cards_selected">
53
  <div class="input-box">
54
  <label for="<?php echo $_code ?>_expiration"><?php echo Mage::helper('payment')->__('Expiration Date') ?> <span class="required">*</span></label><br/>
55
  <select id="<?php echo $_code ?>_expiration" style="width:140px;" name="payment[cc_exp_month]" class="validate-cc-exp required-entry">
67
  </div>
68
  </li>
69
  <?php if($this->hasVerification()): ?>
70
+ <li class="stored_cards_selected">
71
  <div class="input-box">
72
  <label for="<?php echo $_code ?>_cc_cid"><?php echo Mage::helper('payment')->__('Card Verification Number') ?> <span class="required">*</span></label><br/>
73
  <input type="text" title="<?php echo Mage::helper('payment')->__('Card Verification Number') ?>" class="required-entry input-text validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" style="width:3em;" value=""/>
74
  </div>
75
  </li>
76
  <?php endif; ?>
 
77
 
78
+ <?php if ($allow_card_saving && $public_key): ?>
79
+ <li class="stored_cards_selected">
80
+ <label for="<?php echo $_code ?>_cc_save_future"><?php echo $this->__('Save this card for future use?') ?></label>
81
+ <div class="input-box">
82
+ <input type="checkbox" id="<?php echo $_code ?>_cc_save_future" name="payment[cc_save_future]" value="Y" autocomplete="off" />
83
+ <input type="hidden" id="<?php echo $_code ?>_customer_id" name="payment[customer_id]" value="<?php echo $customerId; ?>" />
84
+ </div>
85
+ </li>
86
+ <?php endif ?>
87
+ </ul>
88
  <script type="text/javascript">
89
  //<![CDATA[
90
+ (function () {
91
+ order.secureSubmitPublicKey = '<?php echo $public_key ?>';
92
+ order.secureSubmitGetTokenDataUrl = '<?php echo Mage::getUrl('securesubmit/storedcard/getTokenData', array('_secure' => TRUE)) ?>';
93
+
94
+ <?php if (count($customerStoredCards)) : ?>
95
+ order.customerStoredCards = <?php echo json_encode($this->getJsConfig()) ?>;
96
+ $('<?php echo $_code ?>_stored_card_checkbox').stopObserving('click').observe('click', toggleStoredCards);
97
+ function toggleStoredCards() {
98
+ // Toggle between the saved credit cards and a new card form
99
+ $$('.stored_cards_selected').invoke('toggle');
100
+ $('<?php echo $_code ?>_stored_cards').toggle();
101
+ $('<?php echo $_code ?>_cc_type')
102
+ .toggleClassName('validate-cc-type-select')
103
+ .toggleClassName('required-entry');
104
+ $('<?php echo $_code ?>_cc_number')
105
+ .toggleClassName('validate-cc-number')
106
+ .toggleClassName('validate-cc-type')
107
+ .toggleClassName('required-entry');
108
+ $('<?php echo $_code ?>_expiration')
109
+ .toggleClassName('validate-cc-exp')
110
+ .toggleClassName('required-entry');
111
+ $('<?php echo $_code ?>_expiration_yr')
112
+ .toggleClassName('required-entry');
113
+ $('<?php echo $_code ?>_cc_cid')
114
+ .toggleClassName('validate-cc-cvn')
115
+ .toggleClassName('required-entry');
116
+ $('<?php echo $_code ?>_use_credit_card').value = $('<?php echo $_code ?>_stored_card_checkbox').checked ? '0' : '1';
117
+ }
118
+ <?php if ($useStoredCard) : ?>
119
+ toggleStoredCards();
120
+ <?php endif ?>
121
+ <?php endif ?>
122
+ })();
123
  //]]>
124
  </script>
app/design/frontend/base/default/layout/securesubmit.xml CHANGED
@@ -4,18 +4,43 @@
4
  <onestepcheckout_index_index>
5
  <reference name="head">
6
  <action method="addJs"><file>securesubmit/secure.submit-1.0.1.js</file></action>
 
 
 
 
 
7
  </reference>
8
  </onestepcheckout_index_index>
9
  <checkout_onepage_index>
10
  <reference name="head">
11
  <action method="addJs"><file>securesubmit/secure.submit-1.0.1.js</file></action>
 
 
 
 
 
12
  </reference>
13
  </checkout_onepage_index>
14
  <onepagecheckout_index_index>
15
  <reference name="head">
16
  <action method="addJs"><file>securesubmit/secure.submit-1.0.1.js</file></action>
 
 
 
 
 
17
  </reference>
18
  </onepagecheckout_index_index>
 
 
 
 
 
 
 
 
 
 
19
  <customer_account>
20
  <reference name="customer_account_navigation">
21
  <action method="addLink" >
@@ -23,6 +48,11 @@
23
  <path>securesubmit/storedcard/index</path>
24
  <label>Manage Cards</label>
25
  </action>
 
 
 
 
 
26
  </reference>
27
  </customer_account>
28
 
@@ -32,4 +62,117 @@
32
  <block type="core/template" name="hps_securesubmit_content" template="securesubmit/storedcards.phtml"/>
33
  </reference>
34
  </hps_securesubmit_storedcard_index>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  </layout>
4
  <onestepcheckout_index_index>
5
  <reference name="head">
6
  <action method="addJs"><file>securesubmit/secure.submit-1.0.1.js</file></action>
7
+ <action method="addJs"><file>securesubmit/checkout-form.js</file></action>
8
+ <action method="addJs"><file>securesubmit/masterpass/lightbox.js</file></action>
9
+ </reference>
10
+ <reference name="before_body_end">
11
+ <block type="hps_securesubmit/masterpass_client_js" name="hps_securesubmit_masterpass_js" />
12
  </reference>
13
  </onestepcheckout_index_index>
14
  <checkout_onepage_index>
15
  <reference name="head">
16
  <action method="addJs"><file>securesubmit/secure.submit-1.0.1.js</file></action>
17
+ <action method="addJs"><file>securesubmit/checkout-form.js</file></action>
18
+ <action method="addJs"><file>securesubmit/masterpass/lightbox.js</file></action>
19
+ </reference>
20
+ <reference name="before_body_end">
21
+ <block type="hps_securesubmit/masterpass_client_js" name="hps_securesubmit_masterpass_js" />
22
  </reference>
23
  </checkout_onepage_index>
24
  <onepagecheckout_index_index>
25
  <reference name="head">
26
  <action method="addJs"><file>securesubmit/secure.submit-1.0.1.js</file></action>
27
+ <action method="addJs"><file>securesubmit/checkout-form.js</file></action>
28
+ <action method="addJs"><file>securesubmit/masterpass/lightbox.js</file></action>
29
+ </reference>
30
+ <reference name="before_body_end">
31
+ <block type="hps_securesubmit/masterpass_client_js" name="hps_securesubmit_masterpass_js" />
32
  </reference>
33
  </onepagecheckout_index_index>
34
+ <checkout_multishipping_billing>
35
+ <reference name="head">
36
+ <action method="addJs"><file>securesubmit/secure.submit-1.0.1.js</file></action>
37
+ <action method="addJs"><file>securesubmit/checkout-form.js</file></action>
38
+ <action method="addJs"><file>securesubmit/masterpass/lightbox.js</file></action>
39
+ </reference>
40
+ <reference name="before_body_end">
41
+ <block type="hps_securesubmit/masterpass_client_js" name="hps_securesubmit_masterpass_js" />
42
+ </reference>
43
+ </checkout_multishipping_billing>
44
  <customer_account>
45
  <reference name="customer_account_navigation">
46
  <action method="addLink" >
48
  <path>securesubmit/storedcard/index</path>
49
  <label>Manage Cards</label>
50
  </action>
51
+ <action method="addLink">
52
+ <name>masterpass_connect</name>
53
+ <path>securesubmit/masterpass/connect</path>
54
+ <label>MasterPass</label>
55
+ </action>
56
  </reference>
57
  </customer_account>
58
 
62
  <block type="core/template" name="hps_securesubmit_content" template="securesubmit/storedcards.phtml"/>
63
  </reference>
64
  </hps_securesubmit_storedcard_index>
65
+
66
+ <hps_securesubmit_masterpass_connect>
67
+ <update handle="customer_account" />
68
+ <reference name="my.account.wrapper">
69
+ <block type="hps_securesubmit/masterpass_connect" name="hps_securesubmit_masterpass_connect" template="securesubmit/masterpass/connect.phtml" />
70
+ </reference>
71
+ <reference name="head">
72
+ <action method="addJs"><file>securesubmit/masterpass/lightbox.js</file></action>
73
+ </reference>
74
+ <reference name="before_body_end">
75
+ <block type="hps_securesubmit/masterpass_client_js" name="hps_securesubmit_masterpass_js" />
76
+ </reference>
77
+ </hps_securesubmit_masterpass_connect>
78
+
79
+ <checkout_cart_index>
80
+ <reference name="checkout.cart.top_methods">
81
+ <block type="hps_securesubmit/paypal_shortcut" name="checkout.cart.methods.hps_paypal.top" before="-" template="securesubmit/paypal/shortcut.phtml">
82
+ <action method="setIsQuoteAllowed"><value>1</value></action>
83
+ </block>
84
+ </reference>
85
+
86
+ <reference name="checkout.cart.methods">
87
+ <block type="hps_securesubmit/paypal_shortcut" name="checkout.cart.methods.hps_paypal.bottom" before="-" template="securesubmit/paypal/shortcut.phtml">
88
+ <action method="setIsQuoteAllowed"><value>1</value></action>
89
+ </block>
90
+ </reference>
91
+
92
+ <update handle="SHORTCUT_popup" />
93
+ </checkout_cart_index>
94
+
95
+ <hps_securesubmit_paypal_review translate="label">
96
+ <label>PayPal Express Order Review Form</label>
97
+ <remove name="right"/>
98
+ <remove name="left"/>
99
+
100
+ <reference name="root">
101
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
102
+ </reference>
103
+ <reference name="content">
104
+ <block type="hps_securesubmit/paypal_review" name="hps.securesubmit.paypal.review" template="securesubmit/paypal/review.phtml">
105
+ <block type="hps_securesubmit/paypal_review" name="hps.securesubmit.review.shipping.method" as="shipping_method" template="securesubmit/paypal/review/shipping/method.phtml"/>
106
+ <block type="hps_securesubmit/paypal_review_details" name="hps.securesubmit.paypal.review.details" as="details" template="securesubmit/paypal/review/details.phtml">
107
+ <action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
108
+ <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
109
+ <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
110
+ <block type="checkout/cart_totals" name="hps.securesubmit.paypal.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
111
+ </block>
112
+ <block type="checkout/agreements" name="hps.securesubmit.paypal.review.details.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
113
+ </block>
114
+ </reference>
115
+ <reference name="head">
116
+ <action method="addItem"><type>skin_js</type><name>js/checkout/review.js</name></action>
117
+ </reference>
118
+ <block type="core/text_list" name="additional.product.info" />
119
+ </hps_securesubmit_paypal_review>
120
+
121
+ <hps_securesubmit_paypal_review_details>
122
+ <block type="hps_securesubmit/paypal_review_details" name="root" output="toHtml" template="securesubmit/paypal/review/details.phtml">
123
+ <action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
124
+ <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
125
+ <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
126
+ <block type="checkout/cart_totals" name="hps.securesubmit.paypal.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
127
+ </block>
128
+ </hps_securesubmit_paypal_review_details>
129
+
130
+ <default>
131
+ <reference name="head">
132
+ <action method="addJs"><file>securesubmit/paypal/incontext.js</file></action>
133
+ </reference>
134
+ <reference name="before_body_end">
135
+ <block type="hps_securesubmit/paypal_incontext_js" name="hps_securesubmit_paypal_js" />
136
+ </reference>
137
+ </default>
138
+ <checkout_onepage_index>
139
+ <reference name="checkout.onepage.payment">
140
+ <action method="setTemplate"><template>securesubmit/paypal/incontext/payment.phtml</template></action>
141
+ </reference>
142
+ </checkout_onepage_index>
143
+
144
+ <hps_securesubmit_masterpass_review translate="label">
145
+ <label>MasterPass Order Review Form</label>
146
+ <remove name="right"/>
147
+ <remove name="left"/>
148
+
149
+ <reference name="root">
150
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
151
+ </reference>
152
+ <reference name="content">
153
+ <block type="hps_securesubmit/masterpass_review" name="hps.securesubmit.masterpass.review" template="securesubmit/masterpass/review.phtml">
154
+ <block type="hps_securesubmit/masterpass_review" name="hps.securesubmit.review.shipping.method" as="shipping_method" template="securesubmit/masterpass/review/shipping/method.phtml"/>
155
+ <block type="hps_securesubmit/masterpass_review_details" name="hps.securesubmit.masterpass.review.details" as="details" template="securesubmit/masterpass/review/details.phtml">
156
+ <action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
157
+ <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
158
+ <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
159
+ <block type="checkout/cart_totals" name="hps.securesubmit.masterpass.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
160
+ </block>
161
+ <block type="checkout/agreements" name="hps.securesubmit.masterpass.review.details.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
162
+ </block>
163
+ </reference>
164
+ <reference name="head">
165
+ <action method="addItem"><type>skin_js</type><name>js/checkout/review.js</name></action>
166
+ </reference>
167
+ <block type="core/text_list" name="additional.product.info" />
168
+ </hps_securesubmit_masterpass_review>
169
+
170
+ <hps_securesubmit_masterpass_review_details>
171
+ <block type="hps_securesubmit/masterpass_review_details" name="root" output="toHtml" template="securesubmit/masterpass/review/details.phtml">
172
+ <action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
173
+ <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
174
+ <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
175
+ <block type="checkout/cart_totals" name="hps.securesubmit.masterpass.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
176
+ </block>
177
+ </hps_securesubmit_masterpass_review_details>
178
  </layout>
app/design/frontend/base/default/template/securesubmit/form.phtml CHANGED
@@ -1,13 +1,25 @@
1
  <?php /* @var $this Hps_Securesubmit_Block_Form */
2
  $_code = $this->getMethodCode();
3
  $public_key = Mage::getModel('hps_securesubmit/payment')->getConfigData('publicapikey');
4
- $allow_card_saving = (bool)Mage::getModel('hps_securesubmit/payment')->getConfigData('allow_card_saving');
 
5
  $_loggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
 
6
  if ($_loggedIn && $allow_card_saving) {
7
  $customerStoredCards = Mage::helper('hps_securesubmit')->getStoredCards( Mage::getSingleton('customer/session')->getCustomerId());
8
  }
9
  ?>
10
- <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none">
 
 
 
 
 
 
 
 
 
 
11
  <?php if($_loggedIn && $allow_card_saving && count($customerStoredCards)): ?>
12
  <li>
13
  <label for="<?php echo $_code ?>_stored_card_checkbox"><?php echo $this->__('Use a stored card') ?></label>
@@ -27,7 +39,7 @@ if ($_loggedIn && $allow_card_saving) {
27
  </li>
28
  <?php endif ?>
29
  <li class="stored_cards_selected">
30
- <label for="<?php echo $_code ?>_cc_number"><?php echo $this->__('Credit Card Number') ?> <span class="required">*</span></label>
31
  <div class="input-box">
32
  <input type="text" id="<?php echo $_code ?>_cc_number" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value="" autocomplete="off" />
33
  <input type="hidden" id="<?php echo $_code ?>_token" name="payment[securesubmit_token]" value="">
@@ -35,7 +47,7 @@ if ($_loggedIn && $allow_card_saving) {
35
  </div>
36
  </li>
37
  <li class="stored_cards_selected">
38
- <label for="<?php echo $_code ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label>
39
  <div class="input-box">
40
  <div class="v-fix">
41
  <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month required-entry validate-cc-exp" autocomplete="off">
@@ -55,7 +67,7 @@ if ($_loggedIn && $allow_card_saving) {
55
  </div>
56
  </li>
57
  <li class="stored_cards_selected">
58
- <label for="<?php echo $_code ?>_cc_cid"><?php echo $this->__('Card Verification Number') ?> <span class="required">*</span></label>
59
  <div class="input-box">
60
  <div class="v-fix">
61
  <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="cvv required-entry input-text validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" value="" autocomplete="off" />
@@ -65,13 +77,14 @@ if ($_loggedIn && $allow_card_saving) {
65
  </li>
66
  <?php if ($_loggedIn && $allow_card_saving && $public_key): ?>
67
  <li class="stored_cards_selected">
68
- <label for="<?php echo $_code ?>_cc_save_future"><?php echo $this->__('Save this card for future use?') ?></label>
69
  <div class="input-box">
70
  <input type="checkbox" id="<?php echo $_code ?>_cc_save_future" name="payment[cc_save_future]" value="Y" autocomplete="off" />
71
  </div>
72
  </li>
73
  <?php endif ?>
74
  </ul>
 
75
  <script type="text/javascript">
76
  //<![CDATA[
77
  <?php if($_loggedIn && $allow_card_saving && count($customerStoredCards)): ?>
@@ -82,160 +95,53 @@ if ($_loggedIn && $allow_card_saving) {
82
  });
83
  <?php endif ?>
84
 
85
-
86
- if (typeof Payment != "undefined") {
87
- if (typeof Payment.prototype._secureSubmitOldSave === 'undefined') {
88
- var oldPayment = Object.clone(Payment.prototype);
89
- Payment.prototype._secureSubmitOldSave = oldPayment.save;
90
- }
91
- Object.extend(Payment.prototype, {
92
- save: function() {
93
- if (this.currentMethod != 'hps_securesubmit') {
94
- this._secureSubmitOldSave();
95
- return;
96
- }
97
-
98
- if (checkout.loadWaiting != false) return;
99
-
100
- // Use stored card checked, get existing token data
101
- if (this.secureSubmitUseStoredCard()) {
102
- var storedcardId = $('hps_securesubmit_stored_card_select').value;
103
- checkout.setLoadWaiting('payment');
104
- new Ajax.Request(this.secureSubmitGetTokenDataUrl, {
105
- method: 'post',
106
- parameters: {storedcard_id: storedcardId},
107
- onSuccess: function(response) {
108
- var data = response.responseJSON;
109
- if (data && data.token) {
110
- $('hps_securesubmit_expiration').value = parseInt(data.token.cc_exp_month);
111
- $('hps_securesubmit_expiration_yr').value = data.token.cc_exp_year;
112
- }
113
- this.secureSubmitResponseHandler({
114
- token_value: data.token.token_value,
115
- token_type: null, // 'supt'?
116
- token_expire: new Date().toISOString(),
117
- card: {
118
- number: data.token.cc_last4
119
- }
120
- });
121
- }.bind(this),
122
- onFailure: function() {
123
- alert('Unknown error. Please try again.');
124
- checkout.setLoadWaiting(false);
125
- }
126
- });
127
- }
128
- // Use stored card not checked, get new token
129
- else {
130
- var validator = new Validation(this.form);
131
- if (this.validate() && validator.validate()) {
132
- checkout.setLoadWaiting('payment');
133
-
134
- hps.tokenize({
135
- data: {
136
- public_key: this.secureSubmitPublicKey,
137
- number: $('hps_securesubmit_cc_number').value,
138
- cvc: $('hps_securesubmit_cc_cid').value,
139
- exp_month: $('hps_securesubmit_expiration').value,
140
- exp_year: $('hps_securesubmit_expiration_yr').value
141
- },
142
- success: this.secureSubmitResponseHandler.bind(this),
143
- error: this.secureSubmitResponseHandler.bind(this)
144
- });
145
  }
146
  }
147
- },
148
- secureSubmitUseStoredCard: function () {
149
- var storedCheckbox = $('hps_securesubmit_stored_card_checkbox');
150
- return storedCheckbox && storedCheckbox.checked;
151
- },
152
- secureSubmitResponseHandler: function (response) {
153
- var tokenField = $('hps_securesubmit_token'),
154
- lastFourField = $('hps_securesubmit_cc_last_four');
155
- tokenField.value = lastFourField.value = null;
156
-
157
- if (response && response.error) {
158
- if (response.message) {
159
- alert(response.message);
160
- }
161
- checkout.setLoadWaiting(false);
162
- } else if (response && response.token_value) {
163
- tokenField.value = response.token_value;
164
- lastFourField.value = response.card.number.substr(-4);
165
 
166
- // Continue Magento checkout steps
167
- new Ajax.Request(this.saveUrl, {
168
- method:'post',
169
- onComplete: this.onComplete,
170
- onSuccess: this.onSave,
171
- onFailure: checkout.ajaxFailure.bind(checkout),
172
- parameters: Form.serialize(this.form)
173
- });
174
- } else {
175
- alert('Unexpected error.')
176
- }
177
- }
178
  });
 
179
 
 
180
  payment.secureSubmitPublicKey = '<?php echo $public_key ?>';
181
  payment.secureSubmitGetTokenDataUrl = '<?php echo Mage::getUrl('securesubmit/storedcard/getTokenData', array('_secure' => TRUE)) ?>';
182
- }
183
-
184
- if (typeof OPC != "undefined") {
185
- if (typeof OPC.prototype._secureSubmitOldSubmit === 'undefined') {
186
- var oldOPC = Object.clone(OPC.prototype);
187
- OPC.prototype._secureSubmitOldSubmit = oldOPC.submit;
188
- }
189
- Object.extend(OPC.prototype, {
190
- save: function() {
191
- if (this.sectionsToValidate[0].currentMethod != 'hps_securesubmit') {
192
- this._secureSubmitOldSubmit();
193
- return;
194
- }
195
- hps.tokenize({
196
- data: {
197
- public_key: this.secureSubmitPublicKey,
198
- number: $('hps_securesubmit_cc_number').value,
199
- cvc: $('hps_securesubmit_cc_cid').value,
200
- exp_month: $('hps_securesubmit_expiration').value,
201
- exp_year: $('hps_securesubmit_expiration_yr').value
202
- },
203
- success: this.secureSubmitResponseHandler.bind(this),
204
- error: this.secureSubmitResponseHandler.bind(this)
205
- });
206
- },
207
- secureSubmitResponseHandler: function (response) {
208
- var tokenField = $('hps_securesubmit_token'),
209
- lastFourField = $('hps_securesubmit_cc_last_four');
210
- tokenField.value = lastFourField.value = null;
211
 
212
- if (response && response.error) {
213
- if (response.message) {
214
- alert(response.message);
215
- }
216
- checkout.setLoadWaiting(false);
217
- } else if (response && response.token_value) {
218
- tokenField.value = response.token_value;
219
- lastFourField.value = response.card.number.substr(-4);
220
-
221
- this.setLoadWaiting(true);
222
- var params = Form.serialize(this.form);
223
- var request = new Ajax.Request(this.saveUrl, {
224
- method: 'post',
225
- parameters: params,
226
- onSuccess: this.setResponse.bind(this),
227
- onFailure: this.ajaxFailure.bind(this)
228
- });;
229
- } else {
230
- alert('Unexpected error.')
231
- }
232
- }
233
  });
 
234
 
 
235
  OPC.prototype.secureSubmitPublicKey = '<?php echo $public_key ?>';
236
  OPC.prototype.secureSubmitGetTokenDataUrl = '<?php echo Mage::getUrl('securesubmit/storedcard/getTokenData', array('_secure' => TRUE)) ?>';
237
  }
238
-
239
-
240
  //]]>
241
  </script>
1
  <?php /* @var $this Hps_Securesubmit_Block_Form */
2
  $_code = $this->getMethodCode();
3
  $public_key = Mage::getModel('hps_securesubmit/payment')->getConfigData('publicapikey');
4
+ $allow_card_saving = Mage::getModel('hps_securesubmit/payment')->getConfigData('allow_card_saving');
5
+ $allow_heartland_gift = Mage::getModel('hps_securesubmit/payment')->getConfigData('allow_heartland_gift');
6
  $_loggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
7
+
8
  if ($_loggedIn && $allow_card_saving) {
9
  $customerStoredCards = Mage::helper('hps_securesubmit')->getStoredCards( Mage::getSingleton('customer/session')->getCustomerId());
10
  }
11
  ?>
12
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
13
+ <?php if ($allow_heartland_gift): ?>
14
+ <li id="<?php echo $_code; ?>_gift_card">
15
+ <label for="<?php echo $_code ?>_giftcard_number"><?php echo $this->__('Optional Gift Card Number') ?></label><br />
16
+ <input type="text" id="<?php echo $_code; ?>_giftcard_number" title="<?php echo $this->__('Gift Card Number') ?>" class="input-text validate-gift-number" value ="" autocomplete="off" name="payment[giftcard_number]" />
17
+ <label id="gift-card-number-label" style="display: none;"></label>
18
+ <a id="remove-gift-card" class="button" style="display: none;"><?php echo $this->__('Remove Gift Card') ?></a>
19
+ <a id="apply-gift-card" class="button"><?php echo $this->__('Apply Gift Card') ?></a>
20
+ </li>
21
+ <?php endif ?>
22
+
23
  <?php if($_loggedIn && $allow_card_saving && count($customerStoredCards)): ?>
24
  <li>
25
  <label for="<?php echo $_code ?>_stored_card_checkbox"><?php echo $this->__('Use a stored card') ?></label>
39
  </li>
40
  <?php endif ?>
41
  <li class="stored_cards_selected">
42
+ <label for="<?php echo $_code ?>_cc_number"><?php echo $this->__('Credit Card Number') ?> <span class="required">&nbsp;</span></label>
43
  <div class="input-box">
44
  <input type="text" id="<?php echo $_code ?>_cc_number" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value="" autocomplete="off" />
45
  <input type="hidden" id="<?php echo $_code ?>_token" name="payment[securesubmit_token]" value="">
47
  </div>
48
  </li>
49
  <li class="stored_cards_selected">
50
+ <label for="<?php echo $_code ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">&nbsp;</span></label>
51
  <div class="input-box">
52
  <div class="v-fix">
53
  <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month required-entry validate-cc-exp" autocomplete="off">
67
  </div>
68
  </li>
69
  <li class="stored_cards_selected">
70
+ <label for="<?php echo $_code ?>_cc_cid"><?php echo $this->__('Card Verification Number') ?> <span class="required">&nbsp;</span></label>
71
  <div class="input-box">
72
  <div class="v-fix">
73
  <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="cvv required-entry input-text validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" value="" autocomplete="off" />
77
  </li>
78
  <?php if ($_loggedIn && $allow_card_saving && $public_key): ?>
79
  <li class="stored_cards_selected">
80
+ <label style="display: inline-block;" for="<?php echo $_code ?>_cc_save_future"><?php echo $this->__('Save this card for future use?') ?></label>
81
  <div class="input-box">
82
  <input type="checkbox" id="<?php echo $_code ?>_cc_save_future" name="payment[cc_save_future]" value="Y" autocomplete="off" />
83
  </div>
84
  </li>
85
  <?php endif ?>
86
  </ul>
87
+
88
  <script type="text/javascript">
89
  //<![CDATA[
90
  <?php if($_loggedIn && $allow_card_saving && count($customerStoredCards)): ?>
95
  });
96
  <?php endif ?>
97
 
98
+ <?php if ($allow_heartland_gift): ?>
99
+ Event.observe('apply-gift-card', 'click', function(event) {
100
+ $j.ajax({
101
+ url: "<?php echo Mage::getUrl('securesubmit/giftcard/getBalance', array('_secure' => TRUE)) ?>",
102
+ type: "GET",
103
+ data: "giftcard_number=" + $j("#<?php echo $_code; ?>_giftcard_number").val(),
104
+ success: function(data) {
105
+ if (data.error) {
106
+ alert('Error adding gift card: ' + data.message);
107
+ } else {
108
+ //successful gift, show things
109
+ $j('#apply-gift-card').hide();
110
+ $j("#<?php echo $_code; ?>_giftcard_number").hide();
111
+ $j('#gift-card-number-label').text($j("#<?php echo $_code; ?>_giftcard_number").val() + " - $" + data.balance);
112
+ $j('#gift-card-number-label').show();
113
+ $j('#remove-gift-card').show();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  }
115
  }
116
+ });
117
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
+ Event.observe('remove-gift-card', 'click', function(event) {
120
+ $j('#apply-gift-card').show();
121
+ $j("#<?php echo $_code; ?>_giftcard_number").val('');
122
+ $j("#<?php echo $_code; ?>_giftcard_number").show();
123
+ $j('#gift-card-number-label').text('');
124
+ $j('#gift-card-number-label').hide();
125
+ $j('#remove-gift-card').hide();
 
 
 
 
 
126
  });
127
+ <?php endif; ?>
128
 
129
+ if (typeof Payment !== 'undefined') {
130
  payment.secureSubmitPublicKey = '<?php echo $public_key ?>';
131
  payment.secureSubmitGetTokenDataUrl = '<?php echo Mage::getUrl('securesubmit/storedcard/getTokenData', array('_secure' => TRUE)) ?>';
132
+ } else if( !document.getElementById('multishipping-billing-form').empty() ){
133
+ secureSubmit = securesubmitMultishipping(document.getElementById('multishipping-billing-form'));
134
+ secureSubmit.secureSubmitPublicKey = '<?php echo $public_key ?>';
135
+ secureSubmit.secureSubmitGetTokenDataUrl = '<?php echo Mage::getUrl('securesubmit/storedcard/getTokenData', array('_secure' => TRUE)) ?>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
+ document.observe('dom:loaded', function() {
138
+ Event.observe('payment-continue', 'click', function(e){ Event.stop(e); secureSubmit.save(); });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  });
140
+ }
141
 
142
+ if (typeof OPC !== 'undefined') {
143
  OPC.prototype.secureSubmitPublicKey = '<?php echo $public_key ?>';
144
  OPC.prototype.secureSubmitGetTokenDataUrl = '<?php echo Mage::getUrl('securesubmit/storedcard/getTokenData', array('_secure' => TRUE)) ?>';
145
  }
 
 
146
  //]]>
147
  </script>
app/design/frontend/base/default/template/securesubmit/masterpass/connect.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h1><?php echo $this->__('MasterPass') ?></h1>
2
+ <div class="box-account">
3
+ <div class="box-head">
4
+ <h2><?php echo $this->__('Connect with MasterPass') ?></h2>
5
+ </div>
6
+ <div class="securesubmit-connect-with-masterpass">
7
+ <?php $longAccessToken = $this->getLongAccessToken(); ?>
8
+ <?php if ($longAccessToken): ?>
9
+ <form method="POST">
10
+ <input type="hidden" name="forget_masterpass" value="true">
11
+ <input type="submit" value="Disconnect">
12
+ </form>
13
+ <?php else: ?>
14
+ <button type="button"
15
+ class="button"
16
+ onclick="jQuery(this).attr('disabled', 'disabled').val('Processing'); jQuery(this).parents('form').submit(); return false;"
17
+ id="securesubmit-connect-with-masterpass">
18
+ <img src="https://www.mastercard.com/mc_us/wallet/img/en/US/mp_connect_with_button_034px.png"
19
+ alt="Connect with MasterPass" />
20
+ </button>
21
+ <?php endif; ?>
22
+ </div>
23
+ </div>
app/design/frontend/base/default/template/securesubmit/masterpass/form.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <ul class="form-list" id="payment_form_<?= $this->getMethodCode(); ?>" style="display:none;">
2
+ <li>
3
+ <?php echo Mage::helper('hps_securesubmit')->__('You will be redirected to the MasterPass site.'); ?>
4
+ </li>
5
+ <li>
6
+ <?php $cards = $this->getCards(); ?>
7
+ <?php if ($cards && !empty($cards)): ?>
8
+ <input type="hidden" id="<?= $this->getMethodCode(); ?>_connected" value="true" />
9
+ <h6>Credit Cards</h6>
10
+ <?php foreach ($cards as $card): ?>
11
+ <label>
12
+ <input type="radio"
13
+ name="masterpass_card_id"
14
+ value="<?= $card->CardId; ?>"
15
+ <?php if ($card->SelectedAsDefault == 'true'): ?> checked="checked"<?php endif;?> />
16
+ <?= $card->BrandName; ?>
17
+ ending in <?= $card->LastFour; ?>
18
+ expiring <?= $card->ExpiryMonth; ?>/<?= $card->ExpiryYear; ?>
19
+ <?php if ($card->SelectedAsDefault == 'true'): ?>(default)<?php endif; ?>
20
+ </label><br />
21
+ <?php endforeach; ?>
22
+ <?php endif; ?>
23
+ </li>
24
+ </ul>
app/design/frontend/base/default/template/securesubmit/masterpass/js.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php if ($this->isSandbox()): ?>
2
+ <script type="text/javascript" src="https://sandbox.masterpass.com/lightbox/Switch/integration/MasterPass.client.js" async></script>
3
+ <?php else: ?>
4
+ <script type="text/javascript" src="https://www.masterpass.com/lightbox/Switch/integration/MasterPass.client.js" async></script>
5
+ <?php endif; ?>
app/design/frontend/base/default/template/securesubmit/masterpass/mark.phtml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <img src="<?php echo $this->escapeHtml($this->getMarkSrc())?>" alt="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('hps_securesubmit')->__('Acceptance Mark')) ?>" class="v-middle" />&nbsp;
2
+ <a href="<?php echo $this->getMarkHref()?>" onclick="javascript:window.open('<?php echo $this->getMarkHref()?>','masterpasslearnmore','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=0, top=0, width=624, height=350'); return false;">
3
+ <?php echo Mage::helper('hps_securesubmit')->__('Learn more'); ?>
4
+ </a>
app/design/frontend/base/default/template/securesubmit/masterpass/review.phtml ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ /** @var $this Mage_Paypal_Block_Express_Review */
27
+ ?>
28
+ <div class="page-title">
29
+ <h1><?php echo $this->__('Review Order') ?></h1>
30
+ </div>
31
+ <?php echo $this->getMessagesBlock()->toHtml() ?>
32
+ <?php if ($this->getShippingAddress()): ?>
33
+ <div class="info-set col2-set">
34
+ <h2 class="legend"><?php echo $this->__('Shipping Information') ?></h2>
35
+ <div class="col-1">
36
+ <div class="box">
37
+ <div class="box-title">
38
+ <h3><?php echo $this->__('Shipping Address') ?><span class="separator"><?php if ($this->getCanEditShippingAddress()):?> | </span><a href="<?php echo $this->getEditUrl() ?>"><?php echo $this->__('Edit') ?></a><?php endif;?></h3>
39
+ </div>
40
+ <div class="box-content">
41
+ <address><?php echo $this->renderAddress($this->getShippingAddress())?></address>
42
+ </div>
43
+ </div>
44
+ </div>
45
+ <div class="col-2">
46
+ <div class="box">
47
+ <div class="box-title">
48
+ <h3><?php echo $this->__('Shipping Method') ?></h3>
49
+ </div>
50
+ <div class="box-content">
51
+ <form method="post" id="shipping_method_form" action="<?php echo $this->escapeHtml($this->getShippingMethodSubmitUrl()) ?>">
52
+ <?php if ($this->getCanEditShippingMethod() || !$this->getCurrentShippingRate()):?>
53
+ <?php if ($groups = $this->getShippingRateGroups()):?>
54
+ <?php $currentRate = $this->getCurrentShippingRate(); ?>
55
+ <fieldset>
56
+ <select name="shipping_method" id="shipping_method" style="width:250px;" class="required-entry">
57
+ <?php if (!$currentRate):?>
58
+ <option value=""><?php echo $this->__('Please select a shipping method...') ?></option>
59
+ <?php endif;?>
60
+ <?php foreach ($groups as $code => $rates):?>
61
+ <optgroup label="<?php echo $this->escapeHtml($this->getCarrierName($code)) ?>" style="font-style:normal;">
62
+ <?php foreach ($rates as $rate):?>
63
+ <option value="<?php echo $this->renderShippingRateValue($rate)?>"<?php echo ($currentRate === $rate) ? ' selected="selected"' : '' ;?>>
64
+ <?php echo $this->renderShippingRateOption($rate)?>
65
+ </option>
66
+ <?php endforeach;?>
67
+ </optgroup>
68
+ <?php endforeach;?>
69
+ </select>
70
+ </fieldset>
71
+ <p class="actions">
72
+ <button id="update_shipping_method_submit" type="submit" class="button"><span><span><?php echo $this->__('Update Shipping Method') ?></span></span></button>
73
+ </p>
74
+ <?php else: ?>
75
+ <p><strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong></p>
76
+ <?php endif;?>
77
+ <?php else: ?>
78
+ <p><strong><?php echo $this->renderShippingRateOption($this->getCurrentShippingRate())?></strong></p>
79
+ <?php endif; ?>
80
+ </form>
81
+ </div>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ <?php endif; ?>
86
+
87
+ <div class="info-set col2-set">
88
+ <h2 class="legend"><?php echo $this->__('Billing Information') ?></h2>
89
+ <div class="col-1">
90
+ <div class="box">
91
+ <div class="box-title">
92
+ <h3><?php echo $this->__('Payment Method') ?> <span class="separator">|</span>
93
+ <?php if($this->getEditUrl()):?><a href="<?php echo $this->getEditUrl() ?>"><?php echo $this->__('Edit Payment Information') ?></a> <?php endif ?>
94
+ </h3>
95
+ </div>
96
+ <div class="box-content">
97
+ <?php echo $this->escapeHtml($this->getPaymentMethodTitle()) ?>
98
+ </div>
99
+ </div>
100
+ </div>
101
+ </div>
102
+
103
+ <div class="info-set">
104
+ <h2 class="legend"><?php echo $this->__('Items in Your Shopping Cart') ?><span class="separator"> | </span><a href="<?php echo $this->getUrl('checkout/cart') ?>"><?php echo $this->__('Edit Shopping Cart') ?></a></h2>
105
+ <div id="details-reload">
106
+ <?php echo $this->getChildHtml('details') ?>
107
+ </div>
108
+ </div>
109
+ <form method="post" id="order_review_form" action="<?php echo $this->getPlaceOrderUrl() ?>">
110
+ <?php echo $this->getChildHtml('agreements'); ?>
111
+ <div class="buttons-set buttons-set-order" id="review-buttons-container">
112
+ <button type="button" id="review_button" value="<?php echo $this->__('Place Order') ?>" class="button btn-checkout"><span><span><?php echo $this->__('Place Order') ?></span></span></button>
113
+ <button type="button" id="review_submit" value="<?php echo $this->__('Place Order') ?>" class="button btn-checkout"><span><span><?php echo $this->__('Place Order') ?></span></span></button>
114
+ <span class="please-wait" id="review-please-wait" style="display:none;">
115
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Submitting order information...') ?>" title="<?php echo $this->__('Submitting order information...') ?>" class="v-middle" /> <?php echo $this->__('Submitting order information...') ?>
116
+ </span>
117
+ </div>
118
+ </form>
119
+ <script type="text/javascript">
120
+ //<![CDATA[
121
+ // submit buttons are not needed when submitting with ajax
122
+ $('review_submit').hide();
123
+ if ($('update_shipping_method_submit')) {
124
+ $('update_shipping_method_submit').hide();
125
+ }
126
+
127
+ <?php if ($this->getUseAjax()):?>
128
+ OrderReviewController.prototype._submitOrder = function() {
129
+ if (this._canSubmitOrder) {
130
+ if (this._pleaseWait) {
131
+ this._pleaseWait.show();
132
+ }
133
+ new Ajax.Request(this.form.action, {
134
+ parameters: {isAjax: 1, method: 'POST'},
135
+ onSuccess: function(transport) {
136
+ try{
137
+ response = eval('(' + transport.responseText + ')');
138
+ } catch (e) {
139
+ response = {};
140
+ }
141
+ if (response.redirect) {
142
+ setLocation(response.redirect);
143
+ return;
144
+ }
145
+ if (response.success) {
146
+ setLocation('<?php echo $this->getSuccessUrl()?>');
147
+ return;
148
+ } else {
149
+ var msg = response.error_messages;
150
+ if (typeof(msg)=='object') {
151
+ msg = msg.join("\n");
152
+ }
153
+ if (msg) {
154
+ $('review-please-wait').hide();
155
+ alert(msg);
156
+ return;
157
+ }
158
+ }
159
+ $('review-please-wait').hide();
160
+ alert('<?php echo $this->jsQuoteEscape($this->__('Unknown Error. Please try again later.')); ?>');
161
+ return;
162
+ },
163
+ onFailure: function(){
164
+ alert('<?php echo $this->jsQuoteEscape($this->__('Server Error. Please try again.')) ?>');
165
+ $('review-please-wait').hide();
166
+ }
167
+ });
168
+ }
169
+ }
170
+ <?php endif ?>
171
+
172
+ PayPalExpressAjax = new OrderReviewController($('order_review_form'), $('review_button'),
173
+ $('shipping_method'), $('shipping_method_form'), 'details-reload'
174
+ );
175
+ PayPalExpressAjax.addPleaseWait($('review-please-wait'));
176
+ //]]>
177
+ </script>
app/design/frontend/base/default/template/securesubmit/masterpass/review/details.phtml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+
27
+ /**
28
+ * @see Mage_Paypal_Block_Express_Review_Details
29
+ */
30
+ ?>
31
+ <table id="details-table" class="data-table">
32
+ <?php if ($this->helper('tax')->displayCartBothPrices()): $colspan = $rowspan = 2; else: $colspan = $rowspan = 1; endif; ?>
33
+ <col />
34
+ <col width="1" />
35
+ <col width="1" />
36
+ <col width="1" />
37
+ <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
38
+ <col width="1" />
39
+ <col width="1" />
40
+ <?php endif; ?>
41
+ <thead>
42
+ <tr>
43
+ <th rowspan="<?php echo $rowspan ?>"><?php echo $this->__('Product Name') ?></th>
44
+ <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Price') ?></th>
45
+ <th rowspan="<?php echo $rowspan ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
46
+ <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Subtotal') ?></th>
47
+ </tr>
48
+ <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
49
+ <tr>
50
+ <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
51
+ <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
52
+ <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
53
+ <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
54
+ </tr>
55
+ <?php endif; ?>
56
+ </thead>
57
+ <?php echo $this->getChildHtml('totals'); ?>
58
+ <tbody>
59
+ <?php foreach($this->getItems() as $_item): ?>
60
+ <?php echo $this->getItemHtml($_item) ?>
61
+ <?php endforeach ?>
62
+ </tbody>
63
+ </table>
64
+ <script type="text/javascript">decorateTable('details-table');</script>
app/design/frontend/base/default/template/securesubmit/masterpass/review/shipping/method.phtml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ /** @var $this Mage_Paypal_Block_Express_Review */
27
+ ?>
28
+ <fieldset id="shipping-method-container">
29
+ <?php if ($this->getCanEditShippingMethod() || !$this->getCurrentShippingRate()):?>
30
+ <?php if ($groups = $this->getShippingRateGroups()):?>
31
+ <?php $currentRate = $this->getCurrentShippingRate(); ?>
32
+ <select name="shipping_method" id="shipping_method" style="width:250px;" class="required-entry">
33
+ <?php if (!$currentRate):?>
34
+ <option value=""><?php echo $this->__('Please select a shipping method...') ?></option>
35
+ <?php endif;?>
36
+ <?php foreach ($groups as $code => $rates):?>
37
+ <optgroup label="<?php echo $this->escapeHtml($this->getCarrierName($code)) ?>" style="font-style:normal;">
38
+ <?php foreach ($rates as $rate):?>
39
+ <option value="<?php echo $this->renderShippingRateValue($rate)?>"<?php echo ($currentRate === $rate) ? ' selected="selected"' : '' ;?>>
40
+ <?php echo $this->renderShippingRateOption($rate)?>
41
+ </option>
42
+ <?php endforeach;?>
43
+ </optgroup>
44
+ <?php endforeach;?>
45
+ </select>
46
+ <?php else: ?>
47
+ <p><strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong></p>
48
+ <?php endif;?>
49
+ <?php else: ?>
50
+ <p><strong><?php echo $this->renderShippingRateOption($this->getCurrentShippingRate())?></strong></p>
51
+ <?php endif; ?>
52
+ </fieldset>
53
+ <div style="display:none" id="shipping_method_update"><p><?php echo $this->__('Please update order data to get shipping methods and rates') ?></p></div>
app/design/frontend/base/default/template/securesubmit/paypal/incontext/js.phtml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ var hps = hps || {};
3
+ hps.paypal = hps.paypal || {};
4
+ hps.paypal.incontext = <?php echo $this->getConfig(); ?>
5
+ </script>
6
+ <script type="text/javascript" src="//www.paypalobjects.com/api/checkout.js" async></script>
app/design/frontend/base/default/template/securesubmit/paypal/incontext/payment.phtml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ //<![CDATA[
3
+ var quoteBaseGrandTotal = <?php echo (float)$this->getQuoteBaseGrandTotal(); ?>;
4
+ var checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
5
+ var payment = new Payment('co-payment-form', '<?php echo $this->getUrl('checkout/onepage/savePayment') ?>');
6
+ var lastPrice;
7
+ //]]>
8
+ </script>
9
+ <form action="" id="co-payment-form">
10
+ <fieldset>
11
+ <?php echo $this->getChildHtml('methods') ?>
12
+ </fieldset>
13
+ </form>
14
+ <div class="tool-tip" id="payment-tool-tip" style="display:none;">
15
+ <div class="btn-close"><a href="#" id="payment-tool-tip-close" title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
16
+ <div class="tool-tip-content"><img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>" alt="<?php echo $this->__('Card Verification Number Visual Reference') ?>" title="<?php echo $this->__('Card Verification Number Visual Reference') ?>" /></div>
17
+ </div>
18
+ <div class="buttons-set" id="payment-buttons-container">
19
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
20
+ <p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
21
+ <button type="button" class="button" id="hps-paypal-save-button" onclick="payment.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
22
+ <span class="please-wait" id="payment-please-wait" style="display:none;">
23
+ <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...') ?>
24
+ </span>
25
+ </div>
26
+ <script type="text/javascript">
27
+ //<![CDATA[
28
+ function toggleToolTip(event){
29
+ if($('payment-tool-tip')){
30
+ $('payment-tool-tip').setStyle({
31
+ top: (Event.pointerY(event)-560)+'px'
32
+ })
33
+ $('payment-tool-tip').toggle();
34
+ }
35
+ Event.stop(event);
36
+ }
37
+ if($('payment-tool-tip-close')){
38
+ Event.observe($('payment-tool-tip-close'), 'click', toggleToolTip);
39
+ }
40
+ //]]>
41
+ </script>
42
+ <script type="text/javascript">
43
+ //<![CDATA[
44
+ payment.currentMethod = "<?php echo $this->getChild('methods')->getSelectedMethodCode() ?>";
45
+ //]]>
46
+ </script>
47
+ <script type="text/javascript">
48
+ //<![CDATA[
49
+ window.secureSubmitPayPalIncontext = window.secureSubmitPayPalIncontext || function () {};
50
+ window.secureSubmitPayPalIncontext();
51
+ //]]>
52
+ </script>
app/design/frontend/base/default/template/securesubmit/storedcards.phtml CHANGED
@@ -27,7 +27,7 @@ $_storedCards = Mage::helper('hps_securesubmit')->getStoredCards(Mage::getSingle
27
  <td class="a-center"><span class="nobr"><?php echo $card['cc_type'] ?></span></td>
28
  <td class="a-center"><span class="nobr"><?php echo "************".$card['cc_last4'] ?></span></td>
29
  <td class="a-center"><span class="nobr"><?php echo $card['cc_exp_month'] ."-".$card['cc_exp_year'] ?></span></td>
30
- <td><a href="<?php echo Mage::getUrl('securesubmit/storedcard/delete', array('storedcard_id' => $card['storedcard_id'], '_secure' => TRUE)) ?>">Delete</a></td>
31
  </tr>
32
  <?php endforeach; ?>
33
  </tbody>
27
  <td class="a-center"><span class="nobr"><?php echo $card['cc_type'] ?></span></td>
28
  <td class="a-center"><span class="nobr"><?php echo "************".$card['cc_last4'] ?></span></td>
29
  <td class="a-center"><span class="nobr"><?php echo $card['cc_exp_month'] ."-".$card['cc_exp_year'] ?></span></td>
30
+ <td><a href="<?php echo Mage::getUrl('securesubmit/storedcard/delete', array('storedcard_id' => $card['storedcard_id'], '_secure' => TRUE)) ?>"><?php echo $this->__('Delete') ?></a></td>
31
  </tr>
32
  <?php endforeach; ?>
33
  </tbody>
js/securesubmit/admin-checkout.js CHANGED
@@ -1,21 +1,53 @@
1
- AdminOrder.prototype.__secureSubmitOldSubmit = AdminOrder.prototype.submit;
 
 
 
2
  Object.extend(AdminOrder.prototype, {
3
  submit: function() {
4
  if (this.paymentMethod != 'hps_securesubmit') {
5
  this._secureSubmitOldSubmit();
6
  return;
7
  }
8
- hps.tokenize({
9
- data: {
10
- public_key: this.secureSubmitPublicKey,
11
- number: $('hps_securesubmit_cc_number').value,
12
- cvc: $('hps_securesubmit_cc_cid').value,
13
- exp_month: $('hps_securesubmit_expiration').value,
14
- exp_year: $('hps_securesubmit_expiration_yr').value
15
- },
16
- success: this.secureSubmitResponseHandler.bind(this),
17
- error: this.secureSubmitResponseHandler.bind(this)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  });
 
 
 
 
 
19
  },
20
  secureSubmitResponseHandler: function (response) {
21
  var tokenField = $('hps_securesubmit_token'),
@@ -26,7 +58,7 @@ Object.extend(AdminOrder.prototype, {
26
  if (response.message) {
27
  alert(response.message);
28
  }
29
- checkout.setLoadWaiting(false);
30
  } else if (response && response.token_value) {
31
  tokenField.value = response.token_value;
32
  lastFourField.value = response.card.number.substr(-4);
@@ -40,12 +72,18 @@ Object.extend(AdminOrder.prototype, {
40
  this.itemsUpdate();
41
  }
42
  } else {
43
- if (editForm.submit()) {
44
- disableElements('save');
 
 
 
 
 
 
45
  }
46
  }
47
  } else {
48
  alert('Unexpected error.')
49
  }
50
  }
51
- });
1
+ if (typeof AdminOrder.prototype._secureSubmitOldSubmit === 'undefined') {
2
+ var oldAdminOrder = Object.clone(AdminOrder.prototype);
3
+ AdminOrder.prototype._secureSubmitOldSubmit = oldAdminOrder.submit;
4
+ }
5
  Object.extend(AdminOrder.prototype, {
6
  submit: function() {
7
  if (this.paymentMethod != 'hps_securesubmit') {
8
  this._secureSubmitOldSubmit();
9
  return;
10
  }
11
+ // Use stored card checked, get existing token data
12
+ if (this.secureSubmitUseStoredCard()) {
13
+ var storedcardId = $('hps_securesubmit_stored_card_select').value;
14
+ var customerId = $('hps_securesubmit_customer_id').value;
15
+ // Set credit card information
16
+ var creditCardId = $('hps_securesubmit_stored_card_select').value;
17
+ if (order.customerStoredCards[creditCardId]) {
18
+ var creditCardData = order.customerStoredCards[creditCardId];
19
+ $('hps_securesubmit_expiration').value = parseInt(creditCardData.cc_exp_month);
20
+ $('hps_securesubmit_expiration_yr').value = creditCardData.cc_exp_year;
21
+ $('hps_securesubmit_token').value = creditCardData.token_value;
22
+ $('hps_securesubmit_cc_last_four').value = creditCardData.cc_last_four;
23
+ this.secureSubmitResponseHandler({
24
+ token_value: creditCardData.token_value,
25
+ token_type: null, // 'supt'?
26
+ token_expire: new Date().toISOString(),
27
+ card: {
28
+ number: creditCardData.cc_last_four
29
+ }
30
+ });
31
+ }
32
+ }
33
+ // Use stored card not checked, get new token
34
+ else{
35
+ hps.tokenize({
36
+ data: {
37
+ public_key: this.secureSubmitPublicKey,
38
+ number: $('hps_securesubmit_cc_number').value,
39
+ cvc: $('hps_securesubmit_cc_cid').value,
40
+ exp_month: $('hps_securesubmit_expiration').value,
41
+ exp_year: $('hps_securesubmit_expiration_yr').value
42
+ },
43
+ success: this.secureSubmitResponseHandler.bind(this),
44
+ error: this.secureSubmitResponseHandler.bind(this)
45
  });
46
+ }
47
+ },
48
+ secureSubmitUseStoredCard: function () {
49
+ var storedCheckbox = $('hps_securesubmit_stored_card_checkbox');
50
+ return storedCheckbox && storedCheckbox.checked;
51
  },
52
  secureSubmitResponseHandler: function (response) {
53
  var tokenField = $('hps_securesubmit_token'),
58
  if (response.message) {
59
  alert(response.message);
60
  }
61
+ //checkout.setLoadWaiting(false);
62
  } else if (response && response.token_value) {
63
  tokenField.value = response.token_value;
64
  lastFourField.value = response.card.number.substr(-4);
72
  this.itemsUpdate();
73
  }
74
  } else {
75
+ if(this.secureSubmitUseStoredCard()){
76
+ if (editForm._submit()) {
77
+ disableElements('save');
78
+ }
79
+ }else{
80
+ if (editForm.submit()) {
81
+ disableElements('save');
82
+ }
83
  }
84
  }
85
  } else {
86
  alert('Unexpected error.')
87
  }
88
  }
89
+ });
js/securesubmit/checkout-form.js CHANGED
@@ -1,3 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  document.observe('dom:loaded', function () {
2
  // Override default Payment save handler
3
  if (typeof Payment != "undefined") {
@@ -95,90 +179,6 @@ document.observe('dom:loaded', function () {
95
  });
96
  }
97
 
98
- function multishipping(multiForm){
99
- var secureSubmit = {
100
- save: function() {
101
- if (payment.currentMethod != 'hps_securesubmit') {
102
- multiForm.submit();
103
- return;
104
- }
105
-
106
- document.getElementById('payment-continue').disable();
107
-
108
- // Use stored card checked, get existing token data
109
- if (this.secureSubmitUseStoredCard()) {
110
- var storedcardId = $('hps_securesubmit_stored_card_select').value;
111
-
112
- new Ajax.Request(this.secureSubmitGetTokenDataUrl, {
113
- method: 'post',
114
- parameters: {storedcard_id: storedcardId},
115
- onSuccess: function(response) {
116
- var data = response.responseJSON;
117
- if (data && data.token) {
118
- $('hps_securesubmit_expiration').value = parseInt(data.token.cc_exp_month);
119
- $('hps_securesubmit_expiration_yr').value = data.token.cc_exp_year;
120
- }
121
- this.secureSubmitResponseHandler({
122
- token_value: data.token.token_value,
123
- token_type: null, // 'supt'?
124
- token_expire: new Date().toISOString(),
125
- card: {
126
- number: data.token.cc_last4
127
- }
128
- });
129
- }.bind(this),
130
- onFailure: function() {
131
- alert('Unknown error. Please try again.');
132
- }
133
- });
134
- }
135
- // Use stored card not checked, get new token
136
- else {
137
- var validator = new Validation(multiForm);
138
- if (validator.validate()) {
139
-
140
- hps.tokenize({
141
- data: {
142
- public_key: this.secureSubmitPublicKey,
143
- number: $('hps_securesubmit_cc_number').value,
144
- cvc: $('hps_securesubmit_cc_cid').value,
145
- exp_month: $('hps_securesubmit_expiration').value,
146
- exp_year: $('hps_securesubmit_expiration_yr').value
147
- },
148
- success: this.secureSubmitResponseHandler.bind(this),
149
- error: this.secureSubmitResponseHandler.bind(this),
150
- });
151
- }
152
- }
153
- },
154
- secureSubmitUseStoredCard: function () {
155
- var storedCheckbox = $('hps_securesubmit_stored_card_checkbox');
156
- return storedCheckbox && storedCheckbox.checked;
157
- },
158
- secureSubmitResponseHandler: function (response) {
159
- var tokenField = $('hps_securesubmit_token'),
160
- lastFourField = $('hps_securesubmit_cc_last_four');
161
- tokenField.value = lastFourField.value = null;
162
-
163
- if (response && response.error) {
164
- if (response.message) {
165
- alert(response.message);
166
- }
167
- } else if (response && response.token_value) {
168
- tokenField.value = response.token_value;
169
- lastFourField.value = response.card.number.substr(-4);
170
-
171
- // Continue Magento checkout steps
172
- document.getElementById('payment-continue').enable();
173
- multiForm.submit();
174
- } else {
175
- alert('Unexpected error.')
176
- }
177
- }
178
- };
179
- return secureSubmit;
180
- }
181
-
182
  if (typeof OPC != "undefined") {
183
  if (typeof OPC.prototype._secureSubmitOldSubmit === 'undefined') {
184
  var oldOPC = Object.clone(OPC.prototype);
@@ -230,4 +230,4 @@ document.observe('dom:loaded', function () {
230
  }
231
  });
232
  }
233
- });
1
+ function securesubmitMultishipping(multiForm){
2
+ var secureSubmit = {
3
+ save: function() {
4
+ if (payment.currentMethod != 'hps_securesubmit') {
5
+ multiForm.submit();
6
+ return;
7
+ }
8
+
9
+ document.getElementById('payment-continue').disable();
10
+
11
+ // Use stored card checked, get existing token data
12
+ if (this.secureSubmitUseStoredCard()) {
13
+ var storedcardId = $('hps_securesubmit_stored_card_select').value;
14
+
15
+ new Ajax.Request(this.secureSubmitGetTokenDataUrl, {
16
+ method: 'post',
17
+ parameters: {storedcard_id: storedcardId},
18
+ onSuccess: function(response) {
19
+ var data = response.responseJSON;
20
+ if (data && data.token) {
21
+ $('hps_securesubmit_expiration').value = parseInt(data.token.cc_exp_month);
22
+ $('hps_securesubmit_expiration_yr').value = data.token.cc_exp_year;
23
+ }
24
+ this.secureSubmitResponseHandler({
25
+ token_value: data.token.token_value,
26
+ token_type: null, // 'supt'?
27
+ token_expire: new Date().toISOString(),
28
+ card: {
29
+ number: data.token.cc_last4
30
+ }
31
+ });
32
+ }.bind(this),
33
+ onFailure: function() {
34
+ alert('Unknown error. Please try again.');
35
+ }
36
+ });
37
+ }
38
+ // Use stored card not checked, get new token
39
+ else {
40
+ var validator = new Validation(multiForm);
41
+ if (validator.validate()) {
42
+
43
+ hps.tokenize({
44
+ data: {
45
+ public_key: this.secureSubmitPublicKey,
46
+ number: $('hps_securesubmit_cc_number').value,
47
+ cvc: $('hps_securesubmit_cc_cid').value,
48
+ exp_month: $('hps_securesubmit_expiration').value,
49
+ exp_year: $('hps_securesubmit_expiration_yr').value
50
+ },
51
+ success: this.secureSubmitResponseHandler.bind(this),
52
+ error: this.secureSubmitResponseHandler.bind(this),
53
+ });
54
+ }
55
+ }
56
+ },
57
+ secureSubmitUseStoredCard: function () {
58
+ var storedCheckbox = $('hps_securesubmit_stored_card_checkbox');
59
+ return storedCheckbox && storedCheckbox.checked;
60
+ },
61
+ secureSubmitResponseHandler: function (response) {
62
+ var tokenField = $('hps_securesubmit_token'),
63
+ lastFourField = $('hps_securesubmit_cc_last_four');
64
+ tokenField.value = lastFourField.value = null;
65
+
66
+ if (response && response.error) {
67
+ if (response.message) {
68
+ alert(response.message);
69
+ }
70
+ } else if (response && response.token_value) {
71
+ tokenField.value = response.token_value;
72
+ lastFourField.value = response.card.number.substr(-4);
73
+
74
+ // Continue Magento checkout steps
75
+ document.getElementById('payment-continue').enable();
76
+ multiForm.submit();
77
+ } else {
78
+ alert('Unexpected error.')
79
+ }
80
+ }
81
+ };
82
+ return secureSubmit;
83
+ }
84
+
85
  document.observe('dom:loaded', function () {
86
  // Override default Payment save handler
87
  if (typeof Payment != "undefined") {
179
  });
180
  }
181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  if (typeof OPC != "undefined") {
183
  if (typeof OPC.prototype._secureSubmitOldSubmit === 'undefined') {
184
  var oldOPC = Object.clone(OPC.prototype);
230
  }
231
  });
232
  }
233
+ });
js/securesubmit/masterpass/lightbox.js ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (window, document) {
2
+ var lookupUrl = '/securesubmit/masterpass/start';
3
+
4
+ // Checkout success handler
5
+ function startMasterPassCheckout(payload) {
6
+ var data = {
7
+ requestToken: payload.processorTransactionId,
8
+ callbackUrl: payload.returnUrl,
9
+ merchantCheckoutId: payload.merchantCheckoutId,
10
+ allowedCardTypes: ['master','amex','diners','discover','visa'],
11
+ version: 'v6'
12
+ };
13
+ var cardIds = $$('[name="masterpass_card_id"]:checked');
14
+
15
+ if (cardIds.length === 1) {
16
+ data.cardId = cardIds[0].value;
17
+ }
18
+ if (payload.preCheckoutTransactionId) {
19
+ data.precheckoutTransactionId = payload.preCheckoutTransactionId;
20
+ }
21
+ if (payload.walletName) {
22
+ data.walletName = payload.walletName;
23
+ }
24
+ if (payload.walletId) {
25
+ data.consumerwalletId = payload.walletId;
26
+ }
27
+
28
+ MasterPass.client.checkout(data);
29
+ }
30
+
31
+ // Connect success handler
32
+ function startMasterPassConnect(payload) {
33
+ MasterPass.client.connect({
34
+ pairingRequestToken: payload.processorTransactionIdPairing,
35
+ callbackUrl: payload.returnUrl,
36
+ merchantCheckoutId: payload.merchantCheckoutId,
37
+ requestedDataTypes: '[CARD]',
38
+ requestPairing: true,
39
+ version: 'v6'
40
+ });
41
+ }
42
+
43
+ function clickHandler(data, callback) {
44
+ var checkout = checkout || {};
45
+ checkout.ajaxFailure = checkout.ajaxFailure || function () { };
46
+ return function (e) {
47
+ e.preventDefault();
48
+ if (payment.currentMethod.indexOf('hps_masterpass') === 0) {
49
+ var request = new Ajax.Request(lookupUrl, {
50
+ method: 'post',
51
+ onComplete: function () {},
52
+ onSuccess: function (response) {
53
+ var resp = JSON.parse(response.responseText);
54
+ if (resp.result === 'error' && resp.redirect) {
55
+ window.location.href = resp.redirect;
56
+ }
57
+ if (resp.result === 'error') {
58
+ checkout.ajaxFailure.bind(checkout);
59
+ }
60
+ callback(resp.data);
61
+ },
62
+ onFailure: checkout.ajaxFailure.bind(checkout),
63
+ parameters: data
64
+ });
65
+ }
66
+ };
67
+ }
68
+
69
+ function setSubmitHandler() {
70
+ var button = $$('#payment-buttons-container button');
71
+ var data = {};
72
+ if (button.length !== 1) {
73
+ return;
74
+ }
75
+ button = button[0];
76
+ if ($('hps_masterpass_connected')) {
77
+ data.pair = true;
78
+ }
79
+ button.observe('click', clickHandler(data, startMasterPassCheckout));
80
+ }
81
+
82
+ function setConnectHandler() {
83
+ var button = $('securesubmit-connect-with-masterpass');
84
+ if (!button) {
85
+ return;
86
+ }
87
+ button.observe('click', clickHandler({pair: true}, startMasterPassConnect));
88
+ }
89
+
90
+ function setPaymentCallbacks() {
91
+ if (typeof Payment === 'undefined') {
92
+ return;
93
+ }
94
+
95
+ Payment.prototype.save = Payment.prototype.save.wrap(function (save) {
96
+ var validator = new Validation(this.form);
97
+ if (this.validate() && validator.validate()) {
98
+
99
+ if (payment.currentMethod.indexOf('hps_masterpass') === 0) {
100
+ var request = new Ajax.Request(this.saveUrl, {
101
+ method: 'post',
102
+ onComplete: function () {},
103
+ onSuccess: function () {},
104
+ onFailure: checkout.ajaxFailure.bind(checkout),
105
+ parameters: Form.serialize(this.form)
106
+ });
107
+ } else {
108
+ save(); //return default method
109
+ }
110
+ }
111
+ });
112
+ }
113
+
114
+ document.observe('dom:loaded', function () {
115
+ setPaymentCallbacks();
116
+ setSubmitHandler();
117
+ setConnectHandler();
118
+ });
119
+ }(window, document));
js/securesubmit/paypal/incontext.js ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*global window,document,alert,$$,Ajax,Validation,Form,Payment,checkout,payment,hps,paypal*/
2
+ (function (document, window) {
3
+ var PAYMENT_CONTINUE_BUTTON_ID = 'hps-paypal-save-button';
4
+
5
+ function getAnchor(el) {
6
+ if (el.href) {
7
+ return el;
8
+ }
9
+
10
+ return getAnchor(el.parentNode);
11
+ }
12
+
13
+ function getUrl(e, buttons, config) {
14
+ var url = '';
15
+
16
+ if (buttons.length === 1 && buttons[0] === PAYMENT_CONTINUE_BUTTON_ID) {
17
+ if (payment.currentMethod === 'hps_paypal_credit') {
18
+ url = config.bmlUrl;
19
+ } else {
20
+ url = config.stdUrl;
21
+ }
22
+ } else {
23
+ if (getAnchor(e.target).href.indexOf('credit') !== -1) {
24
+ url = config.bmlUrl;
25
+ } else {
26
+ url = config.stdUrl;
27
+ }
28
+ }
29
+
30
+ return url;
31
+ }
32
+
33
+ function setPaymentCallbacks() {
34
+ if (typeof Payment === 'undefined') {
35
+ return;
36
+ }
37
+
38
+ Payment.prototype.save = Payment.prototype.save.wrap(function (save) {
39
+ var validator = new Validation(this.form);
40
+ if (this.validate() && validator.validate()) {
41
+
42
+ if (payment.currentMethod.indexOf('hps_paypal') === 0) {
43
+ var request = new Ajax.Request(this.saveUrl, {
44
+ method: 'post',
45
+ onComplete: function () {},
46
+ onSuccess: function () {},
47
+ onFailure: checkout.ajaxFailure.bind(checkout),
48
+ parameters: Form.serialize(this.form)
49
+ });
50
+ } else {
51
+ save(); //return default method
52
+ }
53
+ }
54
+ });
55
+ }
56
+
57
+ function checkoutReady() {
58
+ var config = hps.paypal.incontext;
59
+ var buttons = [];
60
+ var request;
61
+ var url;
62
+
63
+ $$('[id^="hps_shortcut_"]').each(function (el) { buttons.push(el); });
64
+
65
+ if (buttons && buttons.length === 0) {
66
+ if ($(PAYMENT_CONTINUE_BUTTON_ID) !== null) {
67
+ buttons.push(PAYMENT_CONTINUE_BUTTON_ID);
68
+ } else {
69
+ paypal.checkout.closeFlow();
70
+ return;
71
+ }
72
+ }
73
+
74
+ paypal.checkout.setup('undefined', {
75
+ environment: config.env,
76
+ button: buttons,
77
+ click: function (e) {
78
+ if (typeof payment !== 'undefined' && payment.currentMethod.indexOf('hps_paypal') === -1) {
79
+ return;
80
+ }
81
+ e.preventDefault();
82
+ paypal.checkout.initXO();
83
+
84
+ url = getUrl(e, buttons, config);
85
+ request = new Ajax.Request(url, {
86
+ onSuccess: function (response) {
87
+ paypal.checkout.startFlow(response.responseText);
88
+ },
89
+ onFailure: function (response) {
90
+ alert(response.responseText);
91
+ paypal.checkout.closeFlow();
92
+ }
93
+ });
94
+ }
95
+ });
96
+ }
97
+
98
+ window.secureSubmitPayPalIncontext = function () {
99
+ window.paypalCheckoutReady = checkoutReady;
100
+ setPaymentCallbacks();
101
+ };
102
+
103
+ document.observe('dom:loaded', window.secureSubmitPayPalIncontext);
104
+ }(document, window));
js/securesubmit/secure.submit-1.0.1.js CHANGED
@@ -7,8 +7,8 @@ var hps = (function () {
7
  Tag: "SecureSubmit",
8
 
9
  Urls: {
10
- CERT: "https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway.Hpf.v1/api/token",
11
- PROD: "https://api.heartlandportico.com/SecureSubmit.v1/api/token"
12
  },
13
 
14
  tokenize: function (options) {
7
  Tag: "SecureSubmit",
8
 
9
  Urls: {
10
+ CERT: "https://cert.api2.heartlandportico.com/Hps.Exchange.PosGateway.Hpf.v1/api/token",
11
+ PROD: "https://api2.heartlandportico.com/SecureSubmit.v1/api/token"
12
  },
13
 
14
  tokenize: function (options) {
lib/SecureSubmit/.DS_Store DELETED
Binary file
lib/SecureSubmit/Hps.php CHANGED
@@ -1,42 +1,202 @@
1
  <?php
2
- if ( ! defined('DS')) define('DS', DIRECTORY_SEPARATOR);
3
- if ( ! defined('PS')) define('PS', PATH_SEPARATOR);
4
 
5
- // Infrastructure
6
- require_once(dirname(__FILE__).DS.'infrastructure/HpsConfiguration.php');
7
- require_once(dirname(__FILE__).DS.'infrastructure/HpsException.php');
8
- require_once(dirname(__FILE__).DS.'infrastructure/ApiConnectionException.php');
9
- require_once(dirname(__FILE__).DS.'infrastructure/AuthenticationException.php');
10
- require_once(dirname(__FILE__).DS.'infrastructure/AVSResponseCodeHandler.php');
11
- require_once(dirname(__FILE__).DS.'infrastructure/CardException.php');
12
- require_once(dirname(__FILE__).DS.'infrastructure/HpsExceptionMapper.php');
13
- require_once(dirname(__FILE__).DS.'infrastructure/HpsSdkCodes.php');
14
- require_once(dirname(__FILE__).DS.'infrastructure/InvalidRequestException.php');
15
 
16
- // Entities
17
- require_once(dirname(__FILE__).DS.'entities/HpsTransaction.php');
18
- require_once(dirname(__FILE__).DS.'entities/HpsAuthorization.php');
19
- require_once(dirname(__FILE__).DS.'entities/HpsAccountVerify.php');
20
- require_once(dirname(__FILE__).DS.'entities/HpsAddress.php');
21
- require_once(dirname(__FILE__).DS.'entities/HpsTransactionType.php');
22
- require_once(dirname(__FILE__).DS.'entities/HpsBatch.php');
23
- require_once(dirname(__FILE__).DS.'entities/HpsCardHolder.php');
24
- require_once(dirname(__FILE__).DS.'entities/HpsCharge.php');
25
- require_once(dirname(__FILE__).DS.'entities/HpsChargeExceptions.php');
26
- require_once(dirname(__FILE__).DS.'entities/HpsCreditCard.php');
27
- require_once(dirname(__FILE__).DS.'entities/HpsItemChoiceTypePosResponseVer10Transaction.php');
28
- require_once(dirname(__FILE__).DS.'entities/HpsRefund.php');
29
- require_once(dirname(__FILE__).DS.'entities/HpsReportTransactionDetails.php');
30
- require_once(dirname(__FILE__).DS.'entities/HpsReportTransactionSummary.php');
31
- require_once(dirname(__FILE__).DS.'entities/HpsReversal.php');
32
- require_once(dirname(__FILE__).DS.'entities/HpsTokenData.php');
33
- require_once(dirname(__FILE__).DS.'entities/HpsTransactionDetails.php');
34
- require_once(dirname(__FILE__).DS.'entities/HpsTransactionHeader.php');
35
- require_once(dirname(__FILE__).DS.'entities/HpsVoid.php');
36
 
 
 
 
 
 
 
 
 
37
 
38
- // Services
39
- require_once(dirname(__FILE__).DS.'services/HpsTokenService.php');
40
- require_once(dirname(__FILE__).DS.'services/HpsService.php');
41
- require_once(dirname(__FILE__).DS.'services/HpsChargeService.php');
42
- require_once(dirname(__FILE__).DS.'services/HpsBatchService.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
 
 
2
 
3
+ if (!defined('DS')) {
4
+ define('DS', DIRECTORY_SEPARATOR);
5
+ }
6
+ if (!defined('PS')) {
7
+ define('PS', PATH_SEPARATOR);
8
+ }
 
 
 
 
9
 
10
+ if (!defined('HPS_SDK_LOADED')) {
11
+ // Setup
12
+ define('HPS_SDK_LOADED', true);
13
+ $baseDir = dirname(__FILE__).DS.'src/';
14
+ $originalPath = get_include_path();
15
+ ini_set('include_path', $originalPath . PATH_SEPARATOR . $baseDir);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
+ // Abstractions
18
+ require_once 'Abstractions/HpsAltPaymentServiceInterface.php';
19
+ require_once 'Abstractions/HpsBuilderAbstract.php';
20
+ require_once 'Abstractions/HpsConfigInterface.php';
21
+ require_once 'Abstractions/HpsGatewayServiceAbstract.php';
22
+ require_once 'Abstractions/HpsGatewayServiceInterface.php';
23
+ require_once 'Abstractions/HpsPayPlanResourceInterface.php';
24
+ require_once 'Abstractions/HpsPayPlanResourceAbstract.php';
25
 
26
+ // Infrastructure
27
+ require_once 'Infrastructure/HpsConfiguration.php';
28
+ require_once 'Infrastructure/HpsException.php';
29
+ require_once 'Infrastructure/HpsArgumentException.php';
30
+ require_once 'Infrastructure/HpsAuthenticationException.php';
31
+ require_once 'Infrastructure/HpsInvalidRequestException.php';
32
+ require_once 'Infrastructure/HpsCheckException.php';
33
+ require_once 'Infrastructure/HpsCreditException.php';
34
+ require_once 'Infrastructure/HpsCreditExceptionDetails.php';
35
+ require_once 'Infrastructure/HpsGatewayException.php';
36
+ require_once 'Infrastructure/HpsGatewayExceptionDetails.php';
37
+ require_once 'Infrastructure/HpsProcessorError.php';
38
+ require_once 'Infrastructure/HpsProcessorException.php';
39
+ require_once 'Infrastructure/HpsProcessorExceptionDetails.php';
40
+ require_once 'Infrastructure/Enums/HpsAccountType.php';
41
+ require_once 'Infrastructure/Enums/HpsCheckType.php';
42
+ require_once 'Infrastructure/Enums/HpsDataEntryMode.php';
43
+ require_once 'Infrastructure/Enums/HpsExceptionCodes.php';
44
+ require_once 'Infrastructure/Enums/HpsGiftCardAliasAction.php';
45
+ require_once 'Infrastructure/Enums/HpsItemChoiceTypePosResponseVer10Transaction.php';
46
+ require_once 'Infrastructure/Enums/HpsSECCode.php';
47
+ require_once 'Infrastructure/Enums/HpsTaxType.php';
48
+ require_once 'Infrastructure/Enums/HpsTrackDataMethod.php';
49
+ require_once 'Infrastructure/Enums/HpsTransactionType.php';
50
+ require_once 'Infrastructure/Enums/HpsACHType.php';
51
+ require_once 'Infrastructure/Enums/HpsCardBrand.php';
52
+ require_once 'Infrastructure/Enums/HpsPayPlanCustomerStatus.php';
53
+ require_once 'Infrastructure/Enums/HpsPayPlanAccountType.php';
54
+ require_once 'Infrastructure/Enums/HpsPayPlanPaymentMethodStatus.php';
55
+ require_once 'Infrastructure/Enums/HpsPayPlanPaymentMethodType.php';
56
+ require_once 'Infrastructure/Enums/HpsPayPlanScheduleDuration.php';
57
+ require_once 'Infrastructure/Enums/HpsPayPlanScheduleFrequency.php';
58
+ require_once 'Infrastructure/Enums/HpsPayPlanScheduleStatus.php';
59
+ require_once 'Infrastructure/Enums/HpsCentinelCheckoutType.php';
60
+ require_once 'Infrastructure/Validation/HpsGatewayResponseValidation.php';
61
+ require_once 'Infrastructure/Validation/HpsInputValidation.php';
62
+ require_once 'Infrastructure/Validation/HpsIssuerResponseValidation.php';
63
+ require_once 'Infrastructure/Validation/HpsProcessorResponseValidation.php';
64
+
65
+ // Entities
66
+ require_once 'Entities/HpsAddress.php';
67
+ require_once 'Entities/HpsConsumer.php';
68
+ require_once 'Entities/HpsDirectMarketData.php';
69
+ require_once 'Entities/HpsEncryptionData.php';
70
+ require_once 'Entities/HpsTokenData.php';
71
+ require_once 'Entities/HpsTrackData.php';
72
+ require_once 'Entities/HpsTransaction.php';
73
+ require_once 'Entities/HpsTransactionDetails.php';
74
+ require_once 'Entities/HpsTransactionHeader.php';
75
+ require_once 'Entities/HpsTransactionStatus.php';
76
+ require_once 'Entities/Batch/HpsBatch.php';
77
+ require_once 'Entities/Check/HpsCheck.php';
78
+ require_once 'Entities/Check/HpsCheckHolder.php';
79
+ require_once 'Entities/Check/HpsCheckResponse.php';
80
+ require_once 'Entities/Check/HpsCheckResponseDetails.php';
81
+ require_once 'Entities/Credit/HpsAuthorization.php';
82
+ require_once 'Entities/Credit/HpsAccountVerify.php';
83
+ require_once 'Entities/Credit/HpsCardHolder.php';
84
+ require_once 'Entities/Credit/HpsCharge.php';
85
+ require_once 'Entities/Credit/HpsChargeExceptions.php';
86
+ require_once 'Entities/Credit/HpsCreditCard.php';
87
+ require_once 'Entities/Credit/HpsOfflineAuthorization.php';
88
+ require_once 'Entities/Credit/HpsRecurringBilling.php';
89
+ require_once 'Entities/Credit/HpsRefund.php';
90
+ require_once 'Entities/Credit/HpsReportTransactionDetails.php';
91
+ require_once 'Entities/Credit/HpsReportTransactionSummary.php';
92
+ require_once 'Entities/Credit/HpsReversal.php';
93
+ require_once 'Entities/Credit/HpsCPCData.php';
94
+ require_once 'Entities/Credit/HpsCPCEdit.php';
95
+ require_once 'Entities/Credit/HpsVoid.php';
96
+ require_once 'Entities/Debit/HpsDebitAddValue.php';
97
+ require_once 'Entities/Debit/HpsDebitReturn.php';
98
+ require_once 'Entities/Debit/HpsDebitReversal.php';
99
+ require_once 'Entities/Debit/HpsDebitSale.php';
100
+ require_once 'Entities/Fluent/HpsBuilderAction.php';
101
+ require_once 'Entities/Fluent/HpsUnknownPropertyException.php';
102
+ require_once 'Entities/Gift/HpsGiftCard.php';
103
+ require_once 'Entities/Gift/HpsGiftCardActivate.php';
104
+ require_once 'Entities/Gift/HpsGiftCardAddValue.php';
105
+ require_once 'Entities/Gift/HpsGiftCardAlias.php';
106
+ require_once 'Entities/Gift/HpsGiftCardBalance.php';
107
+ require_once 'Entities/Gift/HpsGiftCardDeactivate.php';
108
+ require_once 'Entities/Gift/HpsGiftCardReplace.php';
109
+ require_once 'Entities/Gift/HpsGiftCardReversal.php';
110
+ require_once 'Entities/Gift/HpsGiftCardReward.php';
111
+ require_once 'Entities/Gift/HpsGiftCardSale.php';
112
+ require_once 'Entities/Gift/HpsGiftCardVoid.php';
113
+ require_once 'Entities/PayPlan/HpsPayPlanCustomer.php';
114
+ require_once 'Entities/PayPlan/HpsPayPlanPaymentMethod.php';
115
+ require_once 'Entities/PayPlan/HpsPayPlanSchedule.php';
116
+ require_once 'Entities/PayPlan/HpsPayPlanAmount.php';
117
+ require_once 'Entities/AltPayment/HpsAltPaymentResponse.php';
118
+ require_once 'Entities/AltPayment/HpsAltPaymentCreateSession.php';
119
+ require_once 'Entities/AltPayment/HpsAltPaymentSessionInfo.php';
120
+ require_once 'Entities/AltPayment/HpsAltPaymentSale.php';
121
+ require_once 'Entities/AltPayment/HpsAltPaymentAuth.php';
122
+ require_once 'Entities/AltPayment/HpsAltPaymentReturn.php';
123
+ require_once 'Entities/AltPayment/HpsAltPaymentVoid.php';
124
+ require_once 'Entities/AltPayment/HpsAltPaymentCapture.php';
125
+ require_once 'Entities/AltPayment/HpsBuyerData.php';
126
+ require_once 'Entities/AltPayment/HpsCardinalMPIResponse.php';
127
+ require_once 'Entities/AltPayment/HpsCardinalMPIAddOrderNumberResponse.php';
128
+ require_once 'Entities/AltPayment/HpsCardinalMPIAuthenticateResponse.php';
129
+ require_once 'Entities/AltPayment/HpsCardinalMPIAuthorizeResponse.php';
130
+ require_once 'Entities/AltPayment/HpsCardinalMPIAuthresponseResponse.php';
131
+ require_once 'Entities/AltPayment/HpsCardinalMPICaptureResponse.php';
132
+ require_once 'Entities/AltPayment/HpsCardinalMPILookupResponse.php';
133
+ require_once 'Entities/AltPayment/HpsCardinalMPIPreapprovalResponse.php';
134
+ require_once 'Entities/AltPayment/HpsCardinalMPIRefundResponse.php';
135
+ require_once 'Entities/AltPayment/HpsCardinalMPIVoidResponse.php';
136
+ require_once 'Entities/AltPayment/HpsLineItem.php';
137
+ require_once 'Entities/AltPayment/HpsOrderData.php';
138
+ require_once 'Entities/AltPayment/HpsPaymentData.php';
139
+ require_once 'Entities/AltPayment/HpsShippingInfo.php';
140
+
141
+ // Services
142
+ require_once 'Services/HpsCentinelConfig.php';
143
+ require_once 'Services/HpsServicesConfig.php';
144
+ require_once 'Services/Gateway/HpsCentinelGatewayService.php';
145
+ require_once 'Services/Gateway/HpsRestGatewayService.php';
146
+ require_once 'Services/Gateway/HpsSoapGatewayService.php';
147
+ require_once 'Services/Gateway/HpsBatchService.php';
148
+ require_once 'Services/Gateway/HpsCheckService.php';
149
+ require_once 'Services/Gateway/HpsCreditService.php';
150
+ require_once 'Services/Gateway/HpsDebitService.php';
151
+ require_once 'Services/Gateway/HpsGiftCardService.php';
152
+ require_once 'Services/Gateway/HpsPayPlanService.php';
153
+ require_once 'Services/Gateway/HpsTokenService.php';
154
+ require_once 'Services/Gateway/AltPayment/HpsAltPaymentService.php';
155
+ require_once 'Services/Gateway/AltPayment/HpsPayPalService.php';
156
+ require_once 'Services/Gateway/AltPayment/HpsMasterPassService.php';
157
+ require_once 'Services/Gateway/PayPlan/HpsPayPlanCustomerService.php';
158
+ require_once 'Services/Gateway/PayPlan/HpsPayPlanPaymentMethodService.php';
159
+ require_once 'Services/Gateway/PayPlan/HpsPayPlanScheduleService.php';
160
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceAuthorizeBuilder.php';
161
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceCaptureBuilder.php';
162
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceChargeBuilder.php';
163
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceCpcEditBuilder.php';
164
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceEditBuilder.php';
165
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceGetBuilder.php';
166
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceListTransactionsBuilder.php';
167
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceOfflineAuthBuilder.php';
168
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceOfflineChargeBuilder.php';
169
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServicePrepaidAddValueBuilder.php';
170
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServicePrepaidBalanceInquiryBuilder.php';
171
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceRecurringBuilder.php';
172
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceRefundBuilder.php';
173
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceReverseBuilder.php';
174
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceVerifyBuilder.php';
175
+ require_once 'Services/Fluent/Gateway/Credit/HpsCreditServiceVoidBuilder.php';
176
+ require_once 'Services/Fluent/Gateway/Check/HpsCheckServiceOverrideBuilder.php';
177
+ require_once 'Services/Fluent/Gateway/Check/HpsCheckServiceRecurringBuilder.php';
178
+ require_once 'Services/Fluent/Gateway/Check/HpsCheckServiceReturnBuilder.php';
179
+ require_once 'Services/Fluent/Gateway/Check/HpsCheckServiceSaleBuilder.php';
180
+ require_once 'Services/Fluent/Gateway/Check/HpsCheckServiceVoidBuilder.php';
181
+ require_once 'Services/Fluent/Gateway/Debit/HpsDebitServiceAddValueBuilder.php';
182
+ require_once 'Services/Fluent/Gateway/Debit/HpsDebitServiceChargeBuilder.php';
183
+ require_once 'Services/Fluent/Gateway/Debit/HpsDebitServiceReturnBuilder.php';
184
+ require_once 'Services/Fluent/Gateway/Debit/HpsDebitServiceReverseBuilder.php';
185
+ require_once 'Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceActivateBuilder.php';
186
+ require_once 'Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceAddValueBuilder.php';
187
+ require_once 'Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceAliasBuilder.php';
188
+ require_once 'Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceBalanceBuilder.php';
189
+ require_once 'Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceDeactivateBuilder.php';
190
+ require_once 'Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceReplaceBuilder.php';
191
+ require_once 'Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceReverseBuilder.php';
192
+ require_once 'Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceRewardBuilder.php';
193
+ require_once 'Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceSaleBuilder.php';
194
+ require_once 'Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceVoidBuilder.php';
195
+ require_once 'Services/Fluent/Gateway/HpsFluentCheckService.php';
196
+ require_once 'Services/Fluent/Gateway/HpsFluentCreditService.php';
197
+ require_once 'Services/Fluent/Gateway/HpsFluentDebitService.php';
198
+ require_once 'Services/Fluent/Gateway/HpsFluentGiftCardService.php';
199
+
200
+ // Cleanup
201
+ ini_set('include_path', $originalPath);
202
+ }
lib/SecureSubmit/README.md CHANGED
@@ -17,7 +17,7 @@ Using Composer? Require this library in your `composer.json`:
17
  ```json
18
  {
19
  "require": {
20
- "securesubmit/heartland-php": "*"
21
  }
22
  }
23
  ```
17
  ```json
18
  {
19
  "require": {
20
+ "hps/heartland-php": "*"
21
  }
22
  }
23
  ```
lib/SecureSubmit/entities/HpsAccountVerify.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- class HpsAccountVerify extends HpsAuthorization{
4
- public function __construct($header){
5
- parent::__construct($header);
6
- }
7
- }
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsAddress.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- class HpsAddress {
4
- public $address = null,
5
- $city = null,
6
- $state = null,
7
- $zip = null,
8
- $country = null;
9
- }
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsAuthorization.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
3
-
4
- class HpsAuthorization extends HpsTransaction {
5
- public $avsResultCode = null,
6
- $avsResultText = null,
7
- $cvvResultCode = null,
8
- $cvvResultText = null,
9
- $cpcIndicator = null,
10
- $authorizationCode = null,
11
- $authorizedAmount = null,
12
- $cardType = null,
13
- $tokenData = null;
14
-
15
- public function __construct($header){
16
- parent::__construct($header);
17
- }
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsBatch.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
-
3
- class HpsBatch {
4
- public $id = null,
5
- $transactionCount = null,
6
- $totalAmount = null,
7
- $sequenceNumber = null;
8
- }
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsCardHolder.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- class HpsCardHolder {
4
- public $firstName = null,
5
- $lastName = null,
6
- $phone = null,
7
- $emailAddress = null,
8
- $address = null;
9
- }
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsCharge.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- class HpsCharge extends HpsAuthorization{
4
- public function __construct($header){
5
- parent::__construct($header);
6
- }
7
- }
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsChargeExceptions.php DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
-
3
- class HpsChargeExceptions {
4
- public $cardException = null,
5
- $hpsException = null;
6
- }
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsCreditCard.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
-
4
- class HpsCreditCard {
5
- public $number = null,
6
- $cvv = null,
7
- $expMonth = null,
8
- $expYear = null;
9
-
10
- function cardType(){
11
- $regexMap = array(
12
- 'Amex' => '/^3[47][0-9]{13}$/',
13
- 'MasterCard' => '/^5[1-5][0-9]{14}$/',
14
- 'Visa' => '/^4[0-9]{12}(?:[0-9]{3})?$/',
15
- 'DinersClub' => '/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/',
16
- 'EnRoute' => '/^(2014|2149)/',
17
- 'Discover' => '/^6(?:011|5[0-9]{2})[0-9]{12}$/',
18
- 'Jcb' => '/^(?:2131|1800|35\d{3})\d{11}$/',
19
- );
20
- foreach($regexMap as $card=>$rx){
21
- if(preg_match($rx, $this->number)){
22
- return $card;
23
- }
24
- }
25
- return "Unknown";
26
- }
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsItemChoiceTypePosResponseVer10Transaction.php DELETED
@@ -1,63 +0,0 @@
1
- <?php
2
-
3
- class HpsItemChoiceTypePosResponseVer10Transaction{
4
- static public $AddAttachment = "AddAttachment";
5
- static public $Authenticate = "Authenticate";
6
- static public $BatchClose = "BatchClose";
7
- static public $CancelImpersonation = "CancelImpersonation";
8
- static public $CheckSale = "CheckSale";
9
- static public $CheckVoid = "CheckVoid";
10
- static public $CreditAccountVerify = "CreditAccountVerify";
11
- static public $CreditAddToBatch = "CreditAddToBatch";
12
- static public $CreditAuth = "CreditAuth";
13
- static public $CreditCPCEdit = "CreditCPCEdit";
14
- static public $CreditIncrementalAuth = "CreditIncrementalAuth";
15
- static public $CreditOfflineAuth = "CreditOfflineAuth";
16
- static public $CreditOfflineSale = "CreditOfflineSale";
17
- static public $CreditReturn = "CreditReturn";
18
- static public $CreditReversal = "CreditReversal";
19
- static public $CreditSale = "CreditSale";
20
- static public $CreditTxnEdit = "CreditTxnEdit";
21
- static public $CreditVoid = "CreditVoid";
22
- static public $DebitAddValue = "DebitAddValue";
23
- static public $DebitReturn = "DebitReturn";
24
- static public $DebitReversal = "DebitReversal";
25
- static public $DebitSale = "DebitSale";
26
- static public $EBTBalanceInquiry = "EBTBalanceInquiry";
27
- static public $EBTCashBackPurchase = "EBTCashBackPurchase";
28
- static public $EBTCashBenefitWithdrawal = "EBTCashBenefitWithdrawal";
29
- static public $EBTFSPurchase = "EBTFSPurchase";
30
- static public $EBTFSReturn = "EBTFSReturn";
31
- static public $EBTVoucherPurchase = "EBTVoucherPurchase";
32
- static public $EndToEndTest = "EndToEndTest";
33
- static public $FindTransactions = "FindTransactions";
34
- static public $GetAttachments = "GetAttachments";
35
- static public $GetUserDeviceSettings = "GetUserDeviceSettings";
36
- static public $GetUserSettings = "GetUserSettings";
37
- static public $GiftCardActivate = "GiftCardActivate";
38
- static public $GiftCardAddValue = "GiftCardAddValue";
39
- static public $GiftCardBalance = "GiftCardBalance";
40
- static public $GiftCardCurrentDayTotals = "GiftCardCurrentDayTotals";
41
- static public $GiftCardDeactivate = "GiftCardDeactivate";
42
- static public $GiftCardPreviousDayTotals = "GiftCardPreviousDayTotals";
43
- static public $GiftCardReplace = "GiftCardReplace";
44
- static public $GiftCardReversal = "GiftCardReversal";
45
- static public $GiftCardSale = "GiftCardSale";
46
- static public $GiftCardVoid = "GiftCardVoid";
47
- static public $Impersonate = "Impersonate";
48
- static public $InvalidateAuthentication = "InvalidateAuthentication";
49
- static public $ManageSettings = "ManageSettings";
50
- static public $ManageUsers = "ManageUsers";
51
- static public $PrePaidAddValue = "PrePaidAddValue";
52
- static public $PrePaidBalanceInquiry = "PrePaidBalanceInquiry";
53
- static public $RecurringBilling = "RecurringBilling";
54
- static public $ReportActivity = "ReportActivity";
55
- static public $ReportBatchDetail = "ReportBatchDetail";
56
- static public $ReportBatchHistory = "ReportBatchHistory";
57
- static public $ReportBatchSummary = "ReportBatchSummary";
58
- static public $ReportOpenAuths = "ReportOpenAuths";
59
- static public $ReportSearch = "ReportSearch";
60
- static public $ReportTxnDetail = "ReportTxnDetail";
61
- static public $SendReceipt = "SendReceipt";
62
- static public $TestCredentials = "TestCredentials";
63
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsRefund.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- class HpsRefund extends HpsTransaction{
4
- public function __construct($header){
5
- parent::__construct($header);
6
- }
7
- }
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsReportTransactionDetails.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
-
3
-
4
- class HpsReportTransactionDetails extends HpsAuthorization {
5
- public $originalTransactionId = null,
6
- $maskedCardNumber = null,
7
- $transactionType = null,
8
- $transactionDate = null,
9
- $exceptions = null;
10
-
11
- public function __construct($header){
12
- parent::__construct($header);
13
- }
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsReportTransactionSummary.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
- class HpsReportTransactionSummary extends HpsTransaction{
4
- public $amount = null,
5
- $originalTransactionId = null,
6
- $maskedCardNumber = null,
7
- $transactionType = null,
8
- $transactionDate = null,
9
- $exceptions = null;
10
- }
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsReversal.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- class HpsReversal extends HpsTransaction{
4
- public $avsResultCode = null,
5
- $avsResultText = null,
6
- $cvvResultCode = null,
7
- $cvvResultText = null,
8
- $cpcIndicator = null;
9
-
10
- public function __construct($header){
11
- parent::__construct($header);
12
- }
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsTokenData.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
-
3
- class HpsTokenData {
4
- public $tokenValue = null,
5
- $responseCode = null,
6
- $responseMessage = null;
7
-
8
- public function __construct($responseMessage = null){
9
- $this->responseMessage = $responseMessage;
10
- }
11
- }
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsTransaction.php DELETED
@@ -1,111 +0,0 @@
1
- <?php
2
-
3
- class HpsTransaction {
4
- public $transactionHeader = null,
5
- $transactionId = null,
6
- $responseCode = null,
7
- $responseText = null,
8
- $referenceNumber = null;
9
-
10
- public function __construct($transactionHeader=null){
11
- $this->transactionHeader = $transactionHeader;
12
- }
13
-
14
- static public function transactionTypeToServiceName($transactionType){
15
- switch ($transactionType){
16
- case HpsTransactionType::$AUTHORIZE :
17
- return HpsItemChoiceTypePosResponseVer10Transaction::$CreditAuth;
18
- break;
19
-
20
- case HpsTransactionType::$CAPTURE:
21
- return HpsItemChoiceTypePosResponseVer10Transaction::$CreditAddToBatch;
22
- break;
23
-
24
- case HpsTransactionType::$CHARGE:
25
- return HpsItemChoiceTypePosResponseVer10Transaction::$CreditSale;
26
- break;
27
-
28
- case HpsTransactionType::$REFUND:
29
- return HpsItemChoiceTypePosResponseVer10Transaction::$CreditReturn;
30
- break;
31
-
32
- case HpsTransactionType::$REVERSE:
33
- return HpsItemChoiceTypePosResponseVer10Transaction::$CreditReversal;
34
- break;
35
-
36
- case HpsTransactionType::$VERIFY:
37
- return HpsItemChoiceTypePosResponseVer10Transaction::$CreditAccountVerify;
38
- break;
39
-
40
- case HpsTransactionType::$LIST:
41
- return HpsItemChoiceTypePosResponseVer10Transaction::$ReportActivity;
42
- break;
43
-
44
- case HpsTransactionType::$GET:
45
- return HpsItemChoiceTypePosResponseVer10Transaction::$ReportTxnDetail;
46
- break;
47
-
48
- case HpsTransactionType::$VOID:
49
- return HpsItemChoiceTypePosResponseVer10Transaction::$CreditVoid;
50
- break;
51
-
52
- case HpsTransactionType::$BATCH_CLOSE:
53
- return HpsItemChoiceTypePosResponseVer10Transaction::$BatchClose;
54
- break;
55
-
56
- case HpsTransactionType::$SECURITY_ERROR:
57
- return "SecurityError";
58
- break;
59
-
60
- default:
61
- return "";
62
- }
63
- }
64
-
65
- static public function serviceNameToTransactionType($serviceName){
66
- switch ($serviceName){
67
- case HpsItemChoiceTypePosResponseVer10Transaction::$CreditAuth:
68
- return HpsTransactionType::$CAPTURE;
69
- break;
70
-
71
- case HpsItemChoiceTypePosResponseVer10Transaction::$CreditAddToBatch:
72
- return HpsTransactionType::$CAPTURE;
73
- break;
74
-
75
- case HpsItemChoiceTypePosResponseVer10Transaction::$CreditSale:
76
- return HpsTransactionType::$CHARGE;
77
- break;
78
-
79
- case HpsItemChoiceTypePosResponseVer10Transaction::$CreditReturn:
80
- return HpsTransactionType::$REFUND;
81
- break;
82
-
83
- case HpsItemChoiceTypePosResponseVer10Transaction::$CreditReversal:
84
- return HpsTransactionType::$REVERSE;
85
- break;
86
-
87
- case HpsItemChoiceTypePosResponseVer10Transaction::$CreditAccountVerify:
88
- return HpsTransactionType::$VERIFY;
89
- break;
90
-
91
- case HpsItemChoiceTypePosResponseVer10Transaction::$ReportActivity:
92
- return HpsTransactionType::$LIST;
93
- break;
94
-
95
- case HpsItemChoiceTypePosResponseVer10Transaction::$ReportTxnDetail:
96
- return HpsTransactionType::$GET;
97
- break;
98
-
99
- case HpsItemChoiceTypePosResponseVer10Transaction::$CreditVoid:
100
- return HpsTransactionType::$VOID;
101
- break;
102
-
103
- case HpsItemChoiceTypePosResponseVer10Transaction::$BatchClose:
104
- return HpsTransactionType::$BATCH_CLOSE;
105
- break;
106
-
107
- default:
108
- return null;
109
- }
110
- }
111
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsTransactionDetails.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
-
3
- class HpsTransactionDetails {
4
- public $memo = null,
5
- $invoiceNumber = null,
6
- $customerId = null,
7
- $clientTransactionId = null;
8
- }
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsTransactionHeader.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
-
4
- class HpsTransactionHeader {
5
- public $gatewayResponseCode = null,
6
- $gatewayResponseMessage = null,
7
- $responseDt = null,
8
- $clientTxnId = null;
9
- }
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsTransactionType.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class HpsTransactionType {
4
- static public $AUTHORIZE = 0;
5
- static public $CAPTURE = 1;
6
- static public $CHARGE = 2;
7
- static public $REFUND = 3;
8
- static public $REVERSE = 4;
9
- static public $VERIFY = 5;
10
- static public $LIST = 6;
11
- static public $GET = 7;
12
- static public $VOID = 8;
13
- static public $SECURITY_ERROR = 9;
14
- static public $BATCH_CLOSE = 10;
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/entities/HpsVoid.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- class HpsVoid extends HpsTransaction{
4
- public function __construct($header){
5
- parent::__construct($header);
6
- }
7
- }
 
 
 
 
 
 
 
lib/SecureSubmit/infrastructure/AVSResponseCodeHandler.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
-
3
-
4
- class AVSResponseCodeHandler {
5
- private $avsResultCode;
6
- private $config;
7
- private $response;
8
- private $transaction;
9
- private $transactionId;
10
- private $ver;
11
-
12
- function __construct($response, $hpsChargeService=null, $config=null)
13
- {
14
- $this->config = $config;
15
- if(count($this->config->avsResponseErrors) == 0){
16
- return;
17
- }
18
-
19
- $this->transaction = $response->Transaction;
20
- $this->transactionId = $response->Header->GatewayTxnId;
21
-
22
- if(isset($this->transaction->CreditSale) && is_object($this->transaction->CreditSale)){
23
- $this->avsResultCode = $this->transaction->CreditSale->AVSRsltCode;
24
- $this->evaluate($hpsChargeService,'sale');
25
- }else if(isset($this->transaction->CreditAuth) && is_object($this->transaction->CreditAuth)){
26
- $this->avsResultCode = $this->transaction->CreditAuth->AVSRsltCode;
27
- $this->evaluate($hpsChargeService,'auth');
28
- }
29
- }
30
-
31
- function evaluate($hpsChargeService,$type){
32
- $exceptionFound = false;
33
- $code = "";
34
- $message = "";
35
-
36
- foreach ($this->config->avsResponseErrors as $c=>$m) {
37
- if($this->avsResultCode == $c){
38
- $code = $c;
39
- $message = $m;
40
- $exceptionFound = true;
41
- }
42
- }
43
-
44
- if($exceptionFound){
45
- $hpsChargeService->void($this->transactionId);
46
- throw new HpsException($message,$code);
47
- }
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/infrastructure/ApiConnectionException.php DELETED
@@ -1,4 +0,0 @@
1
- <?php
2
- class ApiConnectionException extends HpsException{
3
-
4
- }
 
 
 
 
lib/SecureSubmit/infrastructure/AuthenticationException.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- class AuthenticationException extends HpsException{
4
-
5
- public function __construct($message){
6
- parent::__construct($message, null);
7
- }
8
-
9
- }
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/infrastructure/CardException.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- class CardException extends HpsException{
4
- public $TransactionId = null;
5
- public $ResultText = null;
6
-
7
- public function __construct($transactionId, $code, $message, $resultText = null) {
8
- $this->TransactionId = $transactionId;
9
- $this->ResultText = $resultText;
10
- parent::__construct($message, $code);
11
- }
12
-
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/infrastructure/Exceptions.json DELETED
@@ -1,469 +0,0 @@
1
- {
2
- "version": "1.0.0",
3
-
4
- "exception_mappings":[
5
- {
6
- "object":"exception_mapping",
7
- "category":"issuer",
8
- "exception_codes":[
9
- "02",
10
- "03",
11
- "04",
12
- "05",
13
- "41",
14
- "43",
15
- "44",
16
- "51",
17
- "56",
18
- "61",
19
- "62",
20
- "63",
21
- "65",
22
- "78"
23
- ],
24
- "mapping_type":"CardException",
25
- "mapping_code":"card_declined",
26
- "mapping_message":"Exception_Message_CardDeclined"
27
- },
28
- {
29
- "object":"exception_mapping",
30
- "category":"issuer",
31
- "exception_codes":[
32
- "06",
33
- "07",
34
- "12",
35
- "15",
36
- "19",
37
- "12",
38
- "52",
39
- "53",
40
- "57",
41
- "58",
42
- "76",
43
- "77",
44
- "91",
45
- "96",
46
- "EC"
47
- ],
48
- "mapping_type":"CardException",
49
- "mapping_code":"processing_error",
50
- "mapping_message":"Exception_Message_ProcessingError"
51
- },
52
- {
53
- "object":"exception_mapping",
54
- "category":"issuer",
55
- "exception_codes":[
56
- "13"
57
- ],
58
- "mapping_type":"CardException",
59
- "mapping_code":"invalid_amount",
60
- "mapping_message":"Exception_Message_ChargeAmount"
61
- },
62
- {
63
- "object":"exception_mapping",
64
- "category":"issuer",
65
- "exception_codes":[
66
- "14"
67
- ],
68
- "mapping_type":"CardException",
69
- "mapping_code":"incorrect_number",
70
- "mapping_message":"Exception_Message_IncorrectNumber"
71
- },
72
- {
73
- "object":"exception_mapping",
74
- "category":"issuer",
75
- "exception_codes":[
76
- "54"
77
- ],
78
- "mapping_type":"CardException",
79
- "mapping_code":"expired_card",
80
- "mapping_message":"Exception_Message_CardExpired"
81
- },
82
- {
83
- "object":"exception_mapping",
84
- "category":"issuer",
85
- "exception_codes":[
86
- "55"
87
- ],
88
- "mapping_type":"CardException",
89
- "mapping_code":"invalid_pin",
90
- "mapping_message":"Exception_Message_InvalidPin"
91
- },
92
- {
93
- "object":"exception_mapping",
94
- "category":"issuer",
95
- "exception_codes":[
96
- "75"
97
- ],
98
- "mapping_type":"CardException",
99
- "mapping_code":"pin_retries_exceeded",
100
- "mapping_message":"Exception_Message_PinExceeded"
101
- },
102
- {
103
- "object":"exception_mapping",
104
- "category":"issuer",
105
- "exception_codes":[
106
- "80"
107
- ],
108
- "mapping_type":"CardException",
109
- "mapping_code":"invalid_expiry",
110
- "mapping_message":"Exception_Message_InvalidExpiry"
111
- },
112
- {
113
- "object":"exception_mapping",
114
- "category":"issuer",
115
- "exception_codes":[
116
- "80"
117
- ],
118
- "mapping_type":"CardException",
119
- "mapping_code":"invalid_expiry",
120
- "mapping_message":"Exception_Message_InvalidExpiry"
121
- },
122
- {
123
- "object":"exception_mapping",
124
- "category":"issuer",
125
- "exception_codes":[
126
- "86"
127
- ],
128
- "mapping_type":"CardException",
129
- "mapping_code":"pin_verification",
130
- "mapping_message":"Exception_Message_PinVerification"
131
- },
132
- {
133
- "object":"exception_mapping",
134
- "category":"issuer",
135
- "exception_codes":[
136
- "EB",
137
- "N7"
138
- ],
139
- "mapping_type":"CardException",
140
- "mapping_code":"incorrect_cvc",
141
- "mapping_message":"Exception_Message_IncorrectCvc"
142
- },
143
- {
144
- "object":"exception_mapping",
145
- "category":"gateway",
146
- "exception_codes":[
147
- "-2"
148
- ],
149
- "mapping_type":"AuthenticationException",
150
- "mapping_message":"Exception_Message_AuthenticationError"
151
- },
152
- {
153
- "object":"exception_mapping",
154
- "category":"gateway",
155
- "exception_codes":[
156
- "1"
157
- ],
158
- "mapping_type":"HpsException"
159
- },
160
- {
161
- "object":"exception_mapping",
162
- "category":"gateway",
163
- "exception_codes":[
164
- "3"
165
- ],
166
- "mapping_type":"HpsException",
167
- "mapping_code":"invalid_original_transaction"
168
- },
169
- {
170
- "object":"exception_mapping",
171
- "category":"gateway",
172
- "exception_codes":[
173
- "5"
174
- ],
175
- "mapping_type":"HpsException",
176
- "mapping_code":"no_open_batch"
177
- },
178
- {
179
- "object":"exception_mapping",
180
- "category":"gateway",
181
- "param":"card",
182
- "exception_codes":[
183
- "12"
184
- ],
185
- "mapping_type":"InvalidRequestException",
186
- "mapping_code":"invalid_cpc_data",
187
- "mapping_message":"Exception_Message_InvalidCpcData"
188
- },
189
- {
190
- "object":"exception_mapping",
191
- "category":"gateway",
192
- "param":"card",
193
- "exception_codes":[
194
- "13"
195
- ],
196
- "mapping_type":"InvalidRequestException",
197
- "mapping_code":"invalid_card_data",
198
- "mapping_message":"Exception_Message_InvalidCardData"
199
- },
200
- {
201
- "object":"exception_mapping",
202
- "category":"gateway",
203
- "exception_codes":[
204
- "14"
205
- ],
206
- "mapping_type":"CardException",
207
- "mapping_code":"invalid_number",
208
- "mapping_message":"Exception_Message_InvalidNumber"
209
- },
210
- {
211
- "object":"exception_mapping",
212
- "category":"gateway",
213
- "exception_codes":[
214
- "30"
215
- ],
216
- "mapping_type":"HpsException",
217
- "mapping_message":"Exception_Message_GatewayTimedOut"
218
- },
219
- {
220
- "object":"exception_mapping",
221
- "category":"sdk",
222
- "param":"gatewayTransactionId",
223
- "exception_codes":[
224
- "0"
225
- ],
226
- "mapping_type":"InvalidRequestException",
227
- "mapping_code":"invalid_transaction_id",
228
- "mapping_message":"Exception_Message_TransactionIdLessThanEqualZero"
229
- },
230
- {
231
- "object":"exception_mapping",
232
- "category":"sdk",
233
- "param":"HpsServiceUri",
234
- "exception_codes":[
235
- "1"
236
- ],
237
- "mapping_type":"InvalidRequestException",
238
- "mapping_code":"sdk_exception",
239
- "mapping_message":"Exception_Message_InvalidGatewayUrl"
240
- },
241
- {
242
- "object":"exception_mapping",
243
- "category":"sdk",
244
- "exception_codes":[
245
- "2"
246
- ],
247
- "mapping_type":"ApiConnectionException",
248
- "mapping_code":"sdk_exception",
249
- "mapping_message":"Exception_Message_UnableToProcessTransaction"
250
- },
251
- {
252
- "object":"exception_mapping",
253
- "category":"sdk",
254
- "param":"start",
255
- "exception_codes":[
256
- "3"
257
- ],
258
- "mapping_type":"InvalidRequestException",
259
- "mapping_code":"invalid_date",
260
- "mapping_message":"Exception_Message_FutureDate"
261
- },
262
- {
263
- "object":"exception_mapping",
264
- "category":"sdk",
265
- "param":"end",
266
- "exception_codes":[
267
- "4"
268
- ],
269
- "mapping_type":"InvalidRequestException",
270
- "mapping_code":"invalid_date",
271
- "mapping_message":"Exception_Message_FutureDate"
272
- },
273
- {
274
- "object":"exception_mapping",
275
- "category":"sdk",
276
- "param":"currency",
277
- "exception_codes":[
278
- "5"
279
- ],
280
- "mapping_type":"InvalidRequestException",
281
- "mapping_code":"missing_currency",
282
- "mapping_message":"Exception_Message_ArgumentNull"
283
- },
284
- {
285
- "object":"exception_mapping",
286
- "category":"sdk",
287
- "param":"currency",
288
- "exception_codes":[
289
- "6"
290
- ],
291
- "mapping_type":"InvalidRequestException",
292
- "mapping_code":"invalid_currency",
293
- "mapping_message":"Exception_Message_InvalidCurrency"
294
- },
295
- {
296
- "object":"exception_mapping",
297
- "category":"sdk",
298
- "param":"amount",
299
- "exception_codes":[
300
- "7"
301
- ],
302
- "mapping_type":"InvalidRequestException",
303
- "mapping_code":"invalid_amount",
304
- "mapping_message":"Exception_Message_ChargeAmount"
305
- },
306
- {
307
- "object":"exception_mapping",
308
- "category":"sdk",
309
- "exception_codes":[
310
- "8"
311
- ],
312
- "mapping_type":"HpsException",
313
- "mapping_code":"gateway_timeout",
314
- "mapping_message":"Exception_Message_UnableToReverseTransactionAfterGatewayTimeout"
315
- },
316
- {
317
- "object":"exception_mapping",
318
- "category":"sdk",
319
- "exception_codes":[
320
- "9"
321
- ],
322
- "mapping_type":"HpsException",
323
- "mapping_code":"issuer_timeout",
324
- "mapping_message":"Exception_Message_UnableToReverseTransactionAfterIssuerTimeout"
325
- },
326
- {
327
- "object":"exception_mapping",
328
- "category":"sdk",
329
- "exception_codes":[
330
- "10"
331
- ],
332
- "mapping_type":"CardException",
333
- "mapping_code":"processing_error",
334
- "mapping_message":"Exception_Message_ProcessingError"
335
- }
336
- ],
337
- "exception_messages":[
338
- {
339
- "object":"exception_message",
340
- "code":"Exception_Message_ArgumentNull",
341
- "message":"Argument can't be null."
342
- },
343
- {
344
- "object":"exception_message",
345
- "code":"Exception_Message_AuthenticationError",
346
- "message":"Authentication error. Please double check your service configuration."
347
- },
348
- {
349
- "object":"exception_message",
350
- "code":"Exception_Message_CardDeclined",
351
- "message":"The card was declined."
352
- },
353
- {
354
- "object":"exception_message",
355
- "code":"Exception_Message_CardExpired",
356
- "message":"The card has expired."
357
- },
358
- {
359
- "object":"exception_message",
360
- "code":"Exception_Message_ChargeAmount",
361
- "message":"Must be greater than or equal 0."
362
- },
363
- {
364
- "object":"exception_message",
365
- "code":"Exception_Message_FutureDate",
366
- "message":"Date can not be in the future."
367
- },
368
- {
369
- "object":"exception_message",
370
- "code":"Exception_Message_IncorrectCvc",
371
- "message":"The card's security code is incorrect."
372
- },
373
- {
374
- "object":"exception_message",
375
- "code":"Exception_Message_IncorrectNumber",
376
- "message":"The card number is incorrect."
377
- },
378
- {
379
- "object":"exception_message",
380
- "code":"Exception_Message_InvalidConfig",
381
- "message":"The HPS SDK has not been properly configured. Please make sure to initialize the config either in a service constructor or in your App.config or Web.config file."
382
- },
383
- {
384
- "object":"exception_message",
385
- "code":"Exception_Message_InvalidCurrency",
386
- "message":"The only supported currency is \"usd\""
387
- },
388
- {
389
- "object":"exception_message",
390
- "code":"Exception_Message_InvalidExpiry",
391
- "message":"Card expiration date is invalid."
392
- },
393
- {
394
- "object":"exception_message",
395
- "code":"Exception_Message_InvalidNumber",
396
- "message":"The card number is not a valid credit card number."
397
- },
398
- {
399
- "object":"exception_message",
400
- "code":"Exception_Message_InvalidPin",
401
- "message":"The 4-digit pin is invalid."
402
- },
403
- {
404
- "object":"exception_message",
405
- "code":"Exception_Message_PinExceeded",
406
- "message":"Maximum number of pin retries exceeded."
407
- },
408
- {
409
- "object":"exception_message",
410
- "code":"Exception_Message_PinVerification",
411
- "message":"Can't verify card pin number."
412
- },
413
- {
414
- "object":"exception_message",
415
- "code":"Exception_Message_ProcessingError",
416
- "message":"An error occurred while processing the card."
417
- },
418
- {
419
- "object":"exception_message",
420
- "code":"Exception_Message_TransactionIdLessThanEqualZero",
421
- "message":"Transaction ID must be greater than zero."
422
- },
423
- {
424
- "object":"exception_message",
425
- "code":"Exception_Message_UnexpectedResponseCode",
426
- "message":"Unsuccessful response code ({0}) received from HPS Gateway."
427
- },
428
- {
429
- "object":"exception_message",
430
- "code":"Exception_Message_UnexpectedResponseType",
431
- "message":"Received unexpected response from POS Gateway. (Request and response transaction types don't match)."
432
- },
433
- {
434
- "object":"exception_message",
435
- "code":"Exception_Message_InvalidCpcData",
436
- "message":"Invalid CPC data."
437
- },
438
- {
439
- "object":"exception_message",
440
- "code":"Exception_Message_InvalidCardData",
441
- "message":"Invalid card data."
442
- },
443
- {
444
- "object":"exception_message",
445
- "code":"Exception_Message_GatewayTimedOut",
446
- "message":"Gateway timed out."
447
- },
448
- {
449
- "object":"exception_message",
450
- "code":"Exception_Message_InvalidGatewayUrl",
451
- "message":"Invalid HpsServiceUri."
452
- },
453
- {
454
- "object":"exception_message",
455
- "code":"Exception_Message_UnableToProcessTransaction",
456
- "message":"Unable to process the payment transaction."
457
- },
458
- {
459
- "object":"exception_message",
460
- "code":"Exception_Message_UnableToReverseTransactionAfterGatewayTimeout",
461
- "message":"Error occurred while reversing a charge due to HPS gateway time-out."
462
- },
463
- {
464
- "object":"exception_message",
465
- "code":"Exception_Message_UnableToReverseTransactionAfterIssuerTimeout",
466
- "message":"Error occurred while reversing a charge due to issuer time-out."
467
- }
468
- ]
469
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/infrastructure/HpsConfiguration.php DELETED
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- class HpsConfiguration {
4
- public $secretApiKey = null,
5
- $licenseId = null,
6
- $siteId = null,
7
- $deviceId = null,
8
- $versionNumber = null,
9
- $userName = null,
10
- $password = null,
11
- $developerId = null,
12
- $siteTrace = null,
13
- $useProxy = null,
14
- $proxyOptions = null,
15
- $avsResponseErrors = null,
16
- $serviceUri = "https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx";
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/infrastructure/HpsException.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- class HpsException extends Exception{
3
- public $code = null,
4
- $innerException = null,
5
- $responseCode = null,
6
- $responseText = null;
7
-
8
- public function __construct($message, $code, $innerException = null){
9
- $this->code = $code;
10
- $this->innerException = $innerException;
11
- parent::__construct($message, 0);
12
- }
13
-
14
- public function code(){
15
- if($this->code == null){
16
- return "unknown";
17
- }else{
18
- return $this->code;
19
- }
20
- }
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/infrastructure/HpsExceptionMapper.php DELETED
@@ -1,109 +0,0 @@
1
- <?php
2
-
3
- class HpsExceptionMapper{
4
- public $exceptions = null;
5
-
6
- public function __construct(){
7
- $path = realpath(dirname(__FILE__));
8
- $fileName = $path .'/Exceptions.json';
9
- $fh = fopen($fileName,'r');
10
- $jsonString = fread($fh, filesize($fileName));
11
- $this->exceptions = json_decode($jsonString);
12
- }
13
-
14
- public function version_number(){
15
- return $this->exceptions->version;
16
- }
17
-
18
- public function map_issuer_exception($transaction_id, $response_code, $response_text, $result_text = null){
19
- $mapping = $this->exception_for_category_and_code('issuer', $response_code);
20
-
21
- if(isset($mapping)){
22
- $message = $this->message_for_mapping($mapping, $response_text);
23
- $code = $mapping->mapping_code;
24
- return new CardException($transaction_id, $code, $message, $result_text);
25
- }else{
26
- return new CardException($transaction_id, 'unknown_card_exception', $response_text, $result_text);
27
- }
28
- }
29
-
30
- public function map_gateway_exception($transaction_id, $response_code, $response_text){
31
- $mapping = $this->exception_for_category_and_code('gateway',$response_code);
32
-
33
- if(isset($mapping)){
34
- $message = $this->message_for_mapping($mapping, $response_text);
35
- $code = $mapping->exception_codes[0];
36
- $exception_type = $mapping->mapping_type;
37
-
38
- if($exception_type == 'AuthenticationException'){
39
- return new AuthenticationException($message);
40
- }else if($exception_type == "CardException"){
41
- return new CardException($transaction_id, $code, $message);
42
- }else if($exception_type == "InvalidRequestException"){
43
- return new InvalidRequestException($message, $mapping->param, $code);
44
- }else if(isset($code)){
45
- return new HpsException($response_text,$code);
46
- }
47
-
48
- }
49
- return new HpsException($response_text,"unknown");
50
- }
51
-
52
- public function map_sdk_exception($error_code, $inner_exception = null){
53
- $mapping = $this->exception_for_category_and_code('sdk', $error_code);
54
- $sdk_codes = get_class_vars('HpsSdkCodes');
55
- foreach($sdk_codes as $code_name=>$code_value){
56
- if($code_value == $error_code){
57
- $sdk_code_name = $code_name;
58
- break;
59
- }
60
- }
61
-
62
- if(isset($sdk_code_name)){
63
- $response_text = $sdk_code_name;
64
- }else{
65
- $response_text = 'unknown';
66
- }
67
-
68
- if(isset($mapping)){
69
- $message = $this->message_for_mapping($mapping, $response_text);
70
- $code = $mapping->mapping_code;
71
- $exception_type = $mapping->mapping_type;
72
-
73
- if($exception_type == "InvalidRequestException"){
74
- return new InvalidRequestException($message, $mapping->param, $code, $inner_exception);
75
- }else if($exception_type == "ApiConnectionException"){
76
- return new ApiConnectionException($message, $code, $inner_exception);
77
- }else if(isset($code)){
78
- return new HpsException($message, $code, $inner_exception);
79
- }
80
- }
81
-
82
- return new HpsException('unknown', 'unknown', $inner_exception);
83
- }
84
-
85
- private function exception_for_category_and_code($category, $code){
86
- foreach($this->exceptions->exception_mappings as $key=>$mapping){
87
- if($mapping->category == $category && in_array($code,$mapping->exception_codes)){
88
- return $mapping;
89
- }
90
- }
91
- }
92
-
93
- private function message_for_mapping($mapping, $original_message){
94
- if(isset($mapping) && $mapping != null && $mapping != ""){
95
- if(isset($mapping->mapping_message)){
96
- $message = $mapping->mapping_message;
97
- if(isset($message)){
98
- foreach($this->exceptions->exception_messages as $key=>$exception_mapping){
99
- if($exception_mapping->code == $message){
100
- return $exception_mapping->message;
101
- }
102
- }
103
- }
104
- }
105
- }
106
- return $original_message;
107
- }
108
-
109
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/infrastructure/HpsSdkCodes.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
- class HpsSdkCodes {
3
- public static $invalidTransactionId = "0",
4
- $invalidGatewayUrl = "1",
5
- $unableToProcessTransaction = "2",
6
- $invalidStartDate = "3",
7
- $invalidEndDate = "4",
8
- $missingCurrency = "5",
9
- $invalidCurrency = "6",
10
- $invalidAmount = "7",
11
- $reversalErrorAfterGatewayTimeout = "8",
12
- $reversalErrorAfterIssuerTimeout = "9",
13
- $processingError = "10";
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/infrastructure/InvalidRequestException.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- class InvalidRequestException extends HpsException{
3
- public $param = null;
4
-
5
- public function __construct($message, $param = null, $code = null, $innerException = null){
6
- $this->param = $param;
7
- parent::__construct($message, $code, $innerException);
8
- }
9
-
10
- }
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/services/HpsBatchService.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
-
3
- class HpsBatchService extends HpsService{
4
- public function closeBatch(){
5
- $xml = new DOMDocument();
6
- $hpsTransaction = $xml->createElement('hps:Transaction');
7
- $hpsBatchClose = $xml->createElement('hps:BatchClose');
8
- $hpsTransaction->appendChild($hpsBatchClose);
9
-
10
- $response = $this->doTransaction($hpsTransaction);
11
- $header = $response->Header;
12
-
13
- if($header->GatewayRspCode != "0"){
14
- throw $this->exceptionMapper->map_gateway_exception($header->GatewayTxnId,$header->GatewayRspCode,$header->GatewayRspMsg);
15
- }
16
-
17
- $batchClose = $response->Transaction->BatchClose;
18
- $result = new HpsBatch();
19
- $result->id = (isset($batchClose->BatchId) ? (string)$batchClose->BatchId : null);
20
- $result->sequenceNumber = (isset($batchClose->BatchSeqNbr) ? (string)$batchClose->BatchSeqNbr : null);
21
- $result->totalAmount = (isset($batchClose->TotalAmt) ? (string)$batchClose->TotalAmt : null);
22
- $result->transactionCount = (isset($batchClose->TxnCnt) ? (string)$batchClose->TxnCnt : null);
23
-
24
- return $result;
25
- }
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/services/HpsChargeService.php DELETED
@@ -1,602 +0,0 @@
1
- <?php
2
-
3
- class HpsChargeService extends HpsService{
4
-
5
- public function authorize($amount, $currency, $cardOrToken, $cardHolder=null, $requestMultiUseToken=false, $details=null){
6
- $this->_checkAmount($amount);
7
- $this->_checkCurrency($currency);
8
- $amount = sprintf("%0.2f",round($amount,3));
9
-
10
- $xml = new DOMDocument();
11
- $hpsTransaction = $xml->createElement('hps:Transaction');
12
- $hpsCreditAuth = $xml->createElement('hps:CreditAuth');
13
- $hpsBlock1 = $xml->createElement('hps:Block1');
14
- $hpsBlock1->appendChild($xml->createElement('hps:AllowDup','Y'));
15
- $hpsBlock1->appendChild($xml->createElement('hps:Amt',$amount));
16
- if($cardHolder != null){
17
- $hpsBlock1->appendChild($this->_hydrateCardHolderData($cardHolder,$xml));
18
- }
19
-
20
- if($details != null){
21
- $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details,$xml));
22
- }
23
- $cardData = $xml->createElement('hps:CardData');
24
- if($cardOrToken instanceOf HpsCreditCard){
25
- $cardData->appendChild($this->_hydrateManualEntry($cardOrToken,$xml));
26
- }else{
27
- $tokenData = $xml->createElement('hps:TokenData');
28
- $tokenData->appendChild($xml->createElement('hps:TokenValue',$cardOrToken->tokenValue));
29
- $cardData->appendChild($tokenData);
30
- }
31
- $cardData->appendChild($xml->createElement('hps:TokenRequest',($requestMultiUseToken) ? 'Y' : 'N'));
32
- $hpsBlock1->appendChild($cardData);
33
- $hpsCreditAuth->appendChild($hpsBlock1);
34
- $hpsTransaction->appendChild($hpsCreditAuth);
35
- return $this->_submitAuthorize($hpsTransaction, $amount, $currency);
36
- }
37
-
38
- public function capture($transactionId, $amount=null, $gratuity=null){
39
- $xml = new DOMDocument();
40
- $hpsTransaction = $xml->createElement('hps:Transaction');
41
- $hpsCreditAddToBatch = $xml->createElement('hps:CreditAddToBatch');
42
- $hpsCreditAddToBatch->appendChild($xml->createElement('hps:GatewayTxnId',$transactionId));
43
- if($amount != null){
44
- $amount = sprintf("%0.2f",round($amount,3));
45
- $hpsCreditAddToBatch->appendChild($xml->createElement('hps:Amt',$amount));
46
- }
47
- if($gratuity != null){
48
- $hpsCreditAddToBatch->appendChild($xml->createElement('hps:GratuityAmtInfo',$gratuity));
49
- }
50
- $hpsTransaction->appendChild($hpsCreditAddToBatch);
51
- $response = $this->doTransaction($hpsTransaction);
52
- $header = $response->Header;
53
-
54
- if($header->GatewayRspCode != 0){
55
- throw $this->exceptionMapper->map_gateway_exception($transactionId,$header->GatewayRspCode,$header->GatewayRspMsg);
56
- }
57
-
58
- return $this->get($transactionId);
59
- }
60
-
61
- public function charge($amount, $currency, $cardOrToken, $cardHolder=null, $requestMultiUseToken=false, $details=null){
62
- $this->_checkAmount($amount);
63
- $this->_checkCurrency($currency);
64
- $amount = sprintf("%0.2f",round($amount,3));
65
-
66
- $xml = new DOMDocument();
67
- $hpsTransaction = $xml->createElement('hps:Transaction');
68
- $hpsCreditSale = $xml->createElement('hps:CreditSale');
69
- $hpsBlock1 = $xml->createElement('hps:Block1');
70
- $hpsBlock1->appendChild($xml->createElement('hps:AllowDup','Y'));
71
- $hpsBlock1->appendChild($xml->createElement('hps:Amt',$amount));
72
- if($cardHolder != null){
73
- $hpsBlock1->appendChild($this->_hydrateCardHolderData($cardHolder,$xml));
74
- }
75
-
76
- if($details != null){
77
- $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details,$xml));
78
- }
79
- $cardData = $xml->createElement('hps:CardData');
80
- if($cardOrToken instanceOf HpsCreditCard){
81
- $cardData->appendChild($this->_hydrateManualEntry($cardOrToken,$xml));
82
- }else{
83
- $tokenData = $xml->createElement('hps:TokenData');
84
- $tokenData->appendChild($xml->createElement('hps:TokenValue',$cardOrToken->tokenValue));
85
- $cardData->appendChild($tokenData);
86
- }
87
- $cardData->appendChild($xml->createElement('hps:TokenRequest',($requestMultiUseToken) ? 'Y' : 'N'));
88
- $hpsBlock1->appendChild($cardData);
89
- $hpsCreditSale->appendChild($hpsBlock1);
90
- $hpsTransaction->appendChild($hpsCreditSale);
91
-
92
- return $this->_submitCharge($hpsTransaction,$amount,$currency);
93
- }
94
-
95
- public function get($transactionId){
96
- if($transactionId <= 0){
97
- throw $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$invalidTransactionId);
98
- }
99
-
100
- $xml = new DOMDocument();
101
- $hpsTransaction = $xml->createElement('hps:Transaction');
102
- $hpsReportTxnDetail = $xml->createElement('hps:ReportTxnDetail');
103
- $hpsReportTxnDetail->appendChild($xml->createElement('hps:TxnId',$transactionId));
104
- $hpsTransaction->appendChild($hpsReportTxnDetail);
105
-
106
- $response = $this->doTransaction($hpsTransaction);
107
- $detail = $response->Transaction->ReportTxnDetail;
108
-
109
- $header = $this->hydrateTransactionHeader($response->Header);
110
- $result = new HpsReportTransactionDetails($header);
111
- $result->transactionId = (string)$detail->GatewayTxnId;
112
- $result->originalTransactionId = (isset($detail->OriginalGatewayTxnId) ? (string)$detail->OriginalGatewayTxnId : null);
113
- $result->authorizedAmount = (isset($detail->Data->AuthAmt) ? (string)$detail->Data->AuthAmt : null);
114
- $result->authorizationCode = (isset($detail->Data->AuthCode) ? (string)$detail->Data->AuthCode : null);
115
- $result->avsResultCode = (isset($detail->Data->AVSRsltCode) ? (string)$detail->Data->AVSRsltCode : null);
116
- $result->avsResultText = (isset($detail->Data->AVSRsltText) ? (string)$detail->Data->AVSRsltText : null);
117
- $result->cardType = (isset($detail->Data->CardType) ? (string)$detail->Data->CardType : null);
118
- $result->maskedCardNumber = (isset($detail->Data->MaskedCardNbr) ? (string)$detail->Data->MaskedCardNbr : null);
119
- $result->transactionType = (isset($detail->ServiceName) ? HpsTransaction::serviceNameToTransactionType((string)$detail->ServiceName) : null);
120
- $result->transactionDate = (isset($detail->RspUtcDT) ? (string)$detail->RspUtcDT : null);
121
- $result->cpcIndicator = (isset($detail->Data->CPCInd) ? (string)$detail->Data->CPCInd : null);
122
- $result->cvvResultCode = (isset($detail->Data->CVVRsltCode) ? (string)$detail->Data->CVVRsltCode : null);
123
- $result->cvvResultText = (isset($detail->Data->CVVRsltText) ? (string)$detail->Data->CVVRsltText : null);
124
- $result->referenceNumber = (isset($detail->Data->RefNbr) ? (string)$detail->Data->RefNbr : null);
125
- $result->responseCode = (isset($detail->Data->RspCode) ? (string)$detail->Data->RspCode : null);
126
- $result->responseText = (isset($detail->Data->RspText) ? (string)$detail->Data->RspText : null);
127
-
128
- $tokenizationMessage = (isset($detail->Data->TokenizationMsg) ? (string)$detail->Data->TokenizationMsg : null);
129
- if($tokenizationMessage != null){
130
- $result->tokenData = new HpsTokenData($tokenizationMessage);
131
- }
132
-
133
- $headerResponseCode = (isset($response->Header->GatewayRspCode) ? (string)$response->Header->GatewayRspCode : null);
134
- $dataResponseCode = (isset($detail->Data->RspCode) ? (string)$detail->Data->RspCode : null);
135
-
136
- if($headerResponseCode != "0" || $dataResponseCode != "00"){
137
- $exceptions = new HpsChargeExceptions();
138
-
139
- if($headerResponseCode != "0"){
140
- $message = (string)$response->Header->GatewayRspMsg;
141
- $exceptions->hpsException = $this->exceptionMapper->map_gateway_exception($result->transactionId,$headerResponseCode,$message);
142
- }
143
- if($dataResponseCode != "00"){
144
- $message = (string)$detail->Data->RspText;
145
- $exceptions->cardException = $this->exceptionMapper->map_issuer_exception($transactionId,$dataResponseCode,$message);
146
- }
147
- $result->exceptions = $exceptions;
148
- }
149
- return $result;
150
- }
151
-
152
- public function listTransactions($startDate, $endDate, $filterBy=null){
153
- date_default_timezone_set("UTC");
154
- $dateFormat = 'Y-m-d\TH:i:s.00\Z';
155
- $current = new DateTime();
156
- $currentTime = $current->format($dateFormat);
157
-
158
- if($startDate > $currentTime){
159
- throw $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$invalidStartDate);
160
- }
161
- else if($endDate > $currentTime){
162
- throw $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$invalidEndDate);
163
- }
164
-
165
- $xml = new DOMDocument();
166
- $hpsTransaction = $xml->createElement('hps:Transaction');
167
- $hpsReportActivity = $xml->createElement('hps:ReportActivity');
168
- $hpsReportActivity->appendChild($xml->createElement('hps:RptStartUtcDT',$startDate));
169
- $hpsReportActivity->appendChild($xml->createElement('hps:RptEndUtcDT',$endDate));
170
- $hpsTransaction->appendChild($hpsReportActivity);
171
-
172
- $response = $this->doTransaction($hpsTransaction);
173
-
174
- // Gateway Exception
175
- if((string)$response->Header->GatewayRspCode != '0'){
176
- $transactionId = (string)$response->Header->GatewayTxnId;
177
- $responseCode = (string)$response->Header->GatewayRspCode;
178
- $responseMessage = (string)$response->Header->GatewayRspMessage;
179
- throw $this->exceptionMapper->map_gateway_exception($transactionId,$responseCode,$responseMessage);
180
- }
181
- $result = array();
182
- if((string)$response->Transaction->ReportActivity->Header->TxnCnt == "0"){
183
- return $result;
184
- }
185
-
186
- foreach ($response->Transaction->ReportActivity->Details as $charge) {
187
- if($filterBy != null && (string)$charge->ServiceName != HpsTransaction::transactionTypeToServiceName($filterBy)){
188
- continue;
189
- }else{
190
- $summary = new HpsReportTransactionSummary();
191
- $summary->transactionId = (isset($charge->GatewayTxnId) ? (string)$charge->GatewayTxnId : null);
192
- $summary->originalTransactionId = (isset($charge->OriginalGatewayTxnId) ? (string)$charge->OriginalGatewayTxnId : null);
193
- $summary->maskedCardNumber = (isset($charge->MaskedCardNbr) ? (string)$charge->MaskedCardNbr : null);
194
- $summary->responseCode = (isset($charge->IssuerRspCode) ? (string)$charge->IssuerRspCode : null);
195
- $summary->responseText = (isset($charge->IssuerRspText) ? (string)$charge->IssuerRspText : null);
196
-
197
- if($filterBy != null ){
198
- $summary->transactionType = (isset($charge->ServiceName) ? HpsTransaction::transactionTypeToServiceName((string)$charge->ServiceName) : null);
199
- }
200
-
201
- $gwResponseCode = (isset($charge->GatewayRspCode) ? (string)$charge->GatewayRspCode : null);
202
- $issuerResponseCode = (isset($charge->IssuerRspCode) ? (string)$charge->IssuerRspCode : null);
203
-
204
- if($gwResponseCode != "0" || $issuerResponseCode != "00"){
205
- $exceptions = new HpsChargeExceptions();
206
- if($gwResponseCode != "0"){
207
- $message = (string)$charge->GatewayRspMsg;
208
- $exceptions->hpsException = $this->exceptionMapper->map_gateway_exception((string)$charge->GatewayTxnId, $gwResponseCode, $message);
209
- }
210
- if($issuerResponseCode != "00"){
211
- $message = (string)$charge->IssuerRspText;
212
- $exceptions->cardException = $this->exceptionMapper->map_issuer_exception((string)$charge->GatewayTxnId, $issuerResponseCode, $message);
213
- }
214
- $summary->exceptions = $exceptions;
215
- }
216
- }
217
- $result = $summary;
218
- }
219
- return $result;
220
- }
221
-
222
- public function refund($amount, $currency, $cardOrToken, $cardHolder=null, $details=null){
223
- $this->_checkAmount($amount);
224
- $this->_checkCurrency($currency);
225
- $amount = sprintf("%0.2f",round($amount,3));
226
-
227
- $xml = new DOMDocument();
228
- $hpsTransaction = $xml->createElement('hps:Transaction');
229
- $hpsCreditReturn = $xml->createElement('hps:CreditReturn');
230
- $hpsBlock1 = $xml->createElement('hps:Block1');
231
- $hpsBlock1->appendChild($xml->createElement('hps:AllowDup','Y'));
232
- $hpsBlock1->appendChild($xml->createElement('hps:Amt',$amount));
233
- if($cardHolder != null){
234
- $hpsBlock1->appendChild($this->_hydrateCardHolderData($cardHolder,$xml));
235
- }
236
- if($details != null){
237
- $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details,$xml));
238
- }
239
- $cardData = $xml->createElement('hps:CardData');
240
- if($cardOrToken instanceOf HpsCreditCard){
241
- $cardData->appendChild($this->_hydrateManualEntry($cardOrToken,$xml));
242
- }else{
243
- $tokenData = $xml->createElement('hps:TokenData');
244
- $tokenData->appendChild($xml->createElement('hps:TokenValue',$cardOrToken->tokenValue));
245
- $cardData->appendChild($tokenData);
246
- }
247
- $hpsBlock1->appendChild($cardData);
248
- $hpsCreditReturn->appendChild($hpsBlock1);
249
- $hpsTransaction->appendChild($hpsCreditReturn);
250
- return $this->_submitRefund($hpsTransaction);
251
- }
252
-
253
- public function refundTransaction($amount,$currency,$transactionId, $cardHolder=null, $details=null){
254
- $this->_checkAmount($amount);
255
- $this->_checkCurrency($currency);
256
- $amount = sprintf("%0.2f",round($amount,3));
257
-
258
- $xml = new DOMDocument();
259
- $hpsTransaction = $xml->createElement('hps:Transaction');
260
- $hpsCreditReturn = $xml->createElement('hps:CreditReturn');
261
- $hpsBlock1 = $xml->createElement('hps:Block1');
262
- $hpsBlock1->appendChild($xml->createElement('hps:AllowDup','Y'));
263
- $hpsBlock1->appendChild($xml->createElement('hps:Amt',$amount));
264
- $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId',$transactionId));
265
- if($cardHolder != null){
266
- $hpsBlock1->appendChild($this->_hydrateCardHolderData($cardHolder,$xml));
267
- }
268
- if($details != null){
269
- $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details,$xml));
270
- }
271
- $hpsCreditReturn->appendChild($hpsBlock1);
272
- $hpsTransaction->appendChild($hpsCreditReturn);
273
- return $this->_submitRefund($hpsTransaction);
274
- }
275
-
276
- public function reverse($cardOrToken, $amount, $currency, $details=null){
277
- $this->_checkAmount($amount);
278
- $this->_checkCurrency($currency);
279
- $amount = sprintf("%0.2f",round($amount,3));
280
-
281
- $xml = new DOMDocument();
282
- $hpsTransaction = $xml->createElement('hps:Transaction');
283
- $hpsCreditReversal = $xml->createElement('hps:CreditReversal');
284
- $hpsBlock1 = $xml->createElement('hps:Block1');
285
- $hpsBlock1->appendChild($xml->createElement('hps:Amt',$amount));
286
- if($details != null){
287
- $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details,$xml));
288
- }
289
- $cardData = $xml->createElement('hps:CardData');
290
- if($cardOrToken instanceOf HpsCreditCard){
291
- $cardData->appendChild($this->_hydrateManualEntry($cardOrToken,$xml));
292
- }else{
293
- $tokenData = $xml->createElement('hps:TokenData');
294
- $tokenData->appendChild($xml->createElement('hps:TokenValue',$cardOrToken->tokenValue));
295
- $cardData->appendChild($tokenData);
296
- }
297
- $hpsBlock1->appendChild($cardData);
298
- $hpsCreditReversal->appendChild($hpsBlock1);
299
- $hpsTransaction->appendChild($hpsCreditReversal);
300
-
301
- return $this->_submitReverse($hpsTransaction);
302
- }
303
-
304
- public function reverseTransaction($transactionId, $amount,$currency, $details=null){
305
- $this->_checkAmount($amount);
306
- $this->_checkCurrency($currency);
307
- $amount = sprintf("%0.2f",round($amount,3));
308
-
309
- $xml = new DOMDocument();
310
- $hpsTransaction = $xml->createElement('hps:Transaction');
311
- $hpsCreditReversal = $xml->createElement('hps:CreditReversal');
312
- $hpsBlock1 = $xml->createElement('hps:Block1');
313
- $hpsBlock1->appendChild($xml->createElement('hps:Amt',$amount));
314
- $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId',$transactionId));
315
- if($details != null){
316
- $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details,$xml));
317
- }
318
- $hpsCreditReversal->appendChild($hpsBlock1);
319
- $hpsTransaction->appendChild($hpsCreditReversal);
320
-
321
- return $this->_submitReverse($hpsTransaction);
322
- }
323
-
324
- public function verify($cardOrToken, $cardHolder=null, $requestMultiUseToken=false){
325
- $xml = new DOMDocument();
326
- $hpsTransaction = $xml->createElement('hps:Transaction');
327
- $hpsCreditAccountVerify = $xml->createElement('hps:CreditAccountVerify');
328
- $hpsBlock1 = $xml->createElement('hps:Block1');
329
- if($cardHolder != null){
330
- $hpsBlock1->appendChild($this->_hydrateCardHolderData($cardHolder,$xml));
331
- }
332
- $cardData = $xml->createElement('hps:CardData');
333
- if($cardOrToken instanceOf HpsCreditCard){
334
- $cardData->appendChild($this->_hydrateManualEntry($cardOrToken,$xml));
335
- }else{
336
- $tokenData = $xml->createElement('hps:TokenData');
337
- $tokenData->appendChild($xml->createElement('hps:TokenValue',$cardOrToken->tokenValue));
338
- $cardData->appendChild($tokenData);
339
- }
340
- $cardData->appendChild($xml->createElement('hps:TokenRequest',($requestMultiUseToken) ? 'Y' : 'N'));
341
- $hpsBlock1->appendChild($cardData);
342
- $hpsCreditAccountVerify->appendChild($hpsBlock1);
343
- $hpsTransaction->appendChild($hpsCreditAccountVerify);
344
-
345
- $response = $this->doTransaction($hpsTransaction);
346
- $header = $response->Header;
347
-
348
- if($header->GatewayRspCode != "0"){
349
- throw $this->exceptionMapper->map_gateway_exception($header->GatewayTxnId,$header->GatewayRspCode,$header->GatewayRspMsg);
350
- }
351
-
352
- $accountVerify = $response->Transaction->CreditAccountVerify;
353
- $result = new HpsAccountVerify($this->hydrateTransactionHeader($header));
354
- $result->transactionId = (isset($accountVerify->GatewayTxnId) ? (string)$accountVerify->GatewayTxnId : null);
355
- $result->avsResultCode = (isset($accountVerify->AVSRsltCode) ? (string)$accountVerify->AVSRsltCode : null);
356
- $result->avsResultText = (isset($accountVerify->AVSRsltText) ? (string)$accountVerify->AVSRsltText : null);
357
- $result->referenceNumber = (isset($accountVerify->RefNbr) ? (string)$accountVerify->RefNbr : null);
358
- $result->responseCode = (isset($accountVerify->RspCode) ? (string)$accountVerify->RspCode : null);
359
- $result->responseText = (isset($accountVerify->RspText) ? (string)$accountVerify->RspText : null);
360
- $result->cardType = (isset($accountVerify->CardType) ? (string)$accountVerify->CardType : null);
361
- $result->cpcIndicator = (isset($accountVerify->CPCInd) ? (string)$accountVerify->CPCInd : null);
362
- $result->cvvResultCode = (isset($accountVerify->CVVRsltCode) ? (string)$accountVerify->CVVRsltCode : null);
363
- $result->cvvResultText = (isset($accountVerify->CVVRsltText) ? (string)$accountVerify->CVVRsltText : null);
364
- $result->authorizationCode = (isset($accountVerify->AuthCode) ? (string)$accountVerify->AuthCode : null);
365
- $result->authorizedAmount = (isset($accountVerify->AuthAmt) ? (string)$accountVerify->AuthAmt : null);
366
-
367
- if($result->responseCode != "00" && $result->responseCode != "85"){
368
- throw $this->exceptionMapper->map_issuer_exception($result->transactionId, $result->responseCode, $result->responseText);
369
- }
370
-
371
- if(isset($header->TokenData) && is_object($header->TokenData)){
372
- $result->tokenData = new HpsTokenData();
373
- $result->tokenData->responseCode = (string)$header->TokenData->TokenRspCode;
374
- $result->tokenData->responseMessage = (string)$header->TokenData->TokenRspMsg;
375
- $result->tokenData->tokenValue = (string)$header->TokenData->TokenValue;
376
- }
377
-
378
- return $result;
379
- }
380
-
381
- public function void($transactionId){
382
- $xml = new DOMDocument();
383
- $hpsTransaction = $xml->createElement('hps:Transaction');
384
- $hpsCreditVoid = $xml->createElement('hps:CreditVoid');
385
- $hpsCreditVoid->appendChild($xml->createElement('hps:GatewayTxnId',$transactionId));
386
- $hpsTransaction->appendChild($hpsCreditVoid);
387
-
388
- $response = $this->doTransaction($hpsTransaction);
389
- $header = $response->Header;
390
-
391
- if($header->GatewayRspCode != "0"){
392
- throw $this->exceptionMapper->map_gateway_exception($header->GatewayTxnId,$header->GatewayRspCode,$header->GatewayRspMsg);
393
- }
394
-
395
- $creditVoid = $response->Transaction->CreditVoid;
396
- $result = new HpsVoid($this->hydrateTransactionHeader($header));
397
- $result->transactionId = (isset($creditVoid->GatewayTxnId) ? $creditVoid->GatewayTxnId : null);
398
- $result->responseCode = "00";
399
- $result->responseText = "";
400
- return $result;
401
- }
402
-
403
- private function _checkAmount($amount){
404
- if ($amount <= 0 || $amount == null){
405
- throw $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$invalidAmount);
406
- }
407
- }
408
-
409
- private function _checkCurrency($currency){
410
- if ($currency == null or $currency == ""){
411
- throw $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$missingCurrency);
412
- }
413
- if (strtolower($currency) != "usd"){
414
- throw $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$invalidCurrency);
415
- }
416
- }
417
-
418
- private function _hydrateAdditionalTxnFields($details,DOMDocument $xml){
419
- $additionalTxnFields = $xml->createElement('hps:AdditionalTxnFields');
420
- if($details->memo != null && $details->memo != ""){
421
- $additionalTxnFields->appendChild($xml->createElement('hps:Description',$details->memo));
422
- }
423
- if($details->invoiceNumber != null && $details->invoiceNumber != ""){
424
- $additionalTxnFields->appendChild($xml->createElement('hps:InvoiceNbr',$details->invoiceNumber));
425
- }
426
- if($details->customerId != null && $details->customerId != ""){
427
- $additionalTxnFields->appendChild($xml->createElement('hps:CustomerID',$details->customerId));
428
- }
429
- return $additionalTxnFields;
430
- }
431
-
432
- private function _hydrateCardHolderData(HpsCardHolder $cardHolder, DOMDocument $xml){
433
- $cardHolderData = $xml->createElement('hps:CardHolderData');
434
- $cardHolderData->appendChild($xml->createElement('hps:CardHolderFirstName',$cardHolder->firstName));
435
- $cardHolderData->appendChild($xml->createElement('hps:CardHolderLastName',$cardHolder->lastName));
436
- $cardHolderData->appendChild($xml->createElement('hps:CardHolderEmail',$cardHolder->emailAddress));
437
- $cardHolderData->appendChild($xml->createElement('hps:CardHolderPhone',$cardHolder->phone));
438
- $cardHolderData->appendChild($xml->createElement('hps:CardHolderAddr',$cardHolder->address->address));
439
- $cardHolderData->appendChild($xml->createElement('hps:CardHolderCity',$cardHolder->address->city));
440
- $cardHolderData->appendChild($xml->createElement('hps:CardHolderState',$cardHolder->address->state));
441
- $cardHolderData->appendChild($xml->createElement('hps:CardHolderZip',$cardHolder->address->zip));
442
-
443
- return $cardHolderData;
444
- }
445
-
446
- private function _hydrateManualEntry(HpsCreditCard $card,DOMDocument $xml){
447
- $manualEntry = $xml->createElement('hps:ManualEntry');
448
- $manualEntry->appendChild($xml->createElement('hps:CardNbr',$card->number));
449
- $manualEntry->appendChild($xml->createElement('hps:ExpMonth',$card->expMonth));
450
- $manualEntry->appendChild($xml->createElement('hps:ExpYear',$card->expYear));
451
- $manualEntry->appendChild($xml->createElement('hps:CVV2',$card->cvv));
452
- $manualEntry->appendChild($xml->createElement('hps:CardPresent',"N"));
453
- $manualEntry->appendChild($xml->createElement('hps:ReaderPresent',"N"));
454
-
455
- return $manualEntry;
456
- }
457
-
458
- private function _processChargeGatewayResponse($responseCode, $responseText, $transactionId, $amount, $currency){
459
- if($responseCode != 0){
460
- if($responseCode == 30){
461
- try{
462
- $this->reverseTransaction($transactionId, $amount, $currency);
463
- }catch (Exception $e){
464
- $exception = $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$reversalErrorAfterGatewayTimeout, $e);
465
- $exception->responseCode = $responseCode;
466
- $exception->responseText = $responseText;
467
- throw $exception;
468
- }
469
- }
470
- $exception = $this->exceptionMapper->map_gateway_exception($transactionId,$responseCode, $responseText);
471
- $exception->responseCode = $responseCode;
472
- $exception->responseText = $responseText;
473
- throw $exception;
474
- }
475
- }
476
-
477
- private function _processChargeIssuerResponse($responseCode, $responseText, $transactionId, $amount, $currency){
478
- if($responseCode == "91"){
479
- try{
480
- $this->reverseTransaction($transactionId, $amount, $currency);
481
- }catch (Exception $e){
482
- $exception = $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$reversalErrorAfterIssuerTimeout, $e);
483
- $exception->responseCode = $responseCode;
484
- $exception->responseText = $responseText;
485
- throw $exception;
486
- }
487
- $exception = $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$processingError);
488
- $exception->responseCode = $responseCode;
489
- $exception->responseText = $responseText;
490
- throw $exception;
491
- }else if($responseCode != "00"){
492
- $exception = $this->exceptionMapper->map_issuer_exception($transactionId, $responseCode, $responseText);
493
- $exception->responseCode = $responseCode;
494
- $exception->responseText = $responseText;
495
- throw $exception;
496
- }
497
- }
498
-
499
- private function _submitAuthorize($transaction, $amount, $currency){
500
- $response = $this->doTransaction($transaction);
501
- $avsChecking = new AVSResponseCodeHandler($response,$this,$this->config);
502
- $header = $response->Header;
503
- $this->_processChargeGatewayResponse((string)$header->GatewayRspCode,(string)$header->GatewayRspMsg,(string)$header->GatewayTxnId,$amount,$currency);
504
-
505
- $authResponse = $response->Transaction->CreditAuth;
506
- $this->_processChargeIssuerResponse((string)$authResponse->RspCode,(string)$authResponse->RspText,(string)$authResponse->GatewayTxnId,$amount,$currency);
507
-
508
- $result = new HpsAuthorization($this->hydrateTransactionHeader($header));
509
- $result->transactionId = (string)$header->GatewayTxnId;
510
- $result->authorizedAmount = (isset($authResponse->AuthAmt) ? (string)$authResponse->AuthAmt : null);
511
- $result->authorizationCode = (isset($authResponse->AuthCode) ? (string)$authResponse->AuthCode : null);
512
- $result->avsResultCode = (isset($authResponse->AVSRsltCode) ? (string)$authResponse->AVSRsltCode : null);
513
- $result->avsResultText = (isset($authResponse->AVSRsltText) ? (string)$authResponse->AVSRsltText : null);
514
- $result->cardType = (isset($authResponse->CardType) ? (string)$authResponse->CardType : null);
515
- $result->cpcIndicator = (isset($authResponse->CPCInd) ? (string)$authResponse->CPCInd : null);
516
- $result->cvvResultCode = (isset($authResponse->CVVRsltCode) ? (string)$authResponse->CVVRsltCode : null);
517
- $result->cvvResultText = (isset($authResponse->CVVRsltText) ? (string)$authResponse->CVVRsltText : null);
518
- $result->referenceNumber = (isset($authResponse->RefNbr) ? (string)$authResponse->RefNbr : null);
519
- $result->responseCode = (isset($authResponse->RspCode) ? (string)$authResponse->RspCode : null);
520
- $result->responseText = (isset($authResponse->RspText) ? (string)$authResponse->RspText : null);
521
-
522
- if(isset($header->TokenData) && is_object($header->TokenData)){
523
- $result->tokenData = new HpsTokenData();
524
- $result->tokenData->responseCode = (string)$header->TokenData->TokenRspCode;
525
- $result->tokenData->responseMessage = (string)$header->TokenData->TokenRspMsg;
526
- $result->tokenData->tokenValue = (string)$header->TokenData->TokenValue;
527
- }
528
-
529
- return $result;
530
- }
531
-
532
- private function _submitCharge($transaction, $amount, $currency){
533
- $response = $this->doTransaction($transaction);
534
- $avsChecking = new AVSResponseCodeHandler($response,$this,$this->config);
535
- $header = $response->Header;
536
- $this->_processChargeGatewayResponse((string)$header->GatewayRspCode,(string)$header->GatewayRspMsg,(string)$header->GatewayTxnId,$amount,$currency);
537
-
538
- $creditSaleRsp = $response->Transaction->CreditSale;
539
- $this->_processChargeIssuerResponse((string)$creditSaleRsp->RspCode,(string)$creditSaleRsp->RspText,(string)$creditSaleRsp->GatewayTxnId,$amount,$currency);
540
-
541
- $result = new HpsCharge($this->hydrateTransactionHeader($header));
542
- $result->transactionId = (string)$header->GatewayTxnId;
543
- $result->authorizedAmount = (isset($creditSaleRsp->AuthAmt) ? (string)$creditSaleRsp->AuthAmt : null);
544
- $result->authorizationCode = (isset($creditSaleRsp->AuthCode) ? (string)$creditSaleRsp->AuthCode : null);
545
- $result->avsResultCode = (isset($creditSaleRsp->AVSRsltCode) ? (string)$creditSaleRsp->AVSRsltCode : null);
546
- $result->avsResultText = (isset($creditSaleRsp->AVSRsltText) ? (string)$creditSaleRsp->AVSRsltText : null);
547
- $result->cardType = (isset($creditSaleRsp->CardType) ? (string)$creditSaleRsp->CardType : null);
548
- $result->cpcIndicator = (isset($creditSaleRsp->CPCInd) ? (string)$creditSaleRsp->CPCInd : null);
549
- $result->cvvResultCode = (isset($creditSaleRsp->CVVRsltCode) ? (string)$creditSaleRsp->CVVRsltCode : null);
550
- $result->cvvResultText = (isset($creditSaleRsp->CVVRsltText) ? (string)$creditSaleRsp->CVVRsltText : null);
551
- $result->referenceNumber = (isset($creditSaleRsp->RefNbr) ? (string)$creditSaleRsp->RefNbr : null);
552
- $result->responseCode = (isset($creditSaleRsp->RspCode) ? (string)$creditSaleRsp->RspCode : null);
553
- $result->responseText = (isset($creditSaleRsp->RspText) ? (string)$creditSaleRsp->RspText : null);
554
-
555
- if(isset($header->TokenData) && is_object($header->TokenData)){
556
- $result->tokenData = new HpsTokenData();
557
- $result->tokenData->responseCode = (string)$header->TokenData->TokenRspCode;
558
- $result->tokenData->responseMessage = (string)$header->TokenData->TokenRspMsg;
559
- $result->tokenData->tokenValue = (string)$header->TokenData->TokenValue;
560
- }
561
-
562
- return $result;
563
- }
564
-
565
- private function _submitRefund($transaction){
566
- $response = $this->doTransaction($transaction);
567
- $header = $response->Header;
568
-
569
- if((string)$header->GatewayRspCode != "0"){
570
- throw $this->exceptionMapper->map_gateway_exception((string)$header->GatewayTxnId,(string)$header->GatewayRspCode,(string)$header->GatewayRspMsg);
571
- }
572
-
573
- $result = new HpsRefund($this->hydrateTransactionHeader($header));
574
- $result->transactionId = (string)$header->GatewayTxnId;
575
- $result->responseCode = "00";
576
- $result->responseText = "";
577
-
578
- return $result;
579
- }
580
-
581
- private function _submitReverse($transaction){
582
- $response = $this->doTransaction($transaction);
583
- $header = $response->Header;
584
-
585
- if((string)$header->GatewayRspCode != "0"){
586
- throw $this->exceptionMapper->map_gateway_exception((string)$header->GatewayTxnId,(string)$header->GatewayRspCode,(string)$header->GatewayRspMsg);
587
- }
588
-
589
- $reversal = (isset($response->Transaction->CreditReversal) ? $response->Transaction->CreditReversal : null);
590
- $result = new HpsReversal($this->hydrateTransactionHeader($header));
591
- $result->transactionId = (isset($header->GatewayTxnId) ? (string)$header->GatewayTxnId : null);
592
- $result->avsResultCode = (isset($reversal->AVSRsltCode) ? (string)$reversal->AVSRsltCode : null);
593
- $result->avsResultText = (isset($reversal->AVSRsltText) ? (string)$reversal->AVSRsltText : null);
594
- $result->cpcIndicator = (isset($reversal->CPCInd) ? (string)$reversal->CPCInd : null);
595
- $result->cvvResultCode = (isset($reversal->CVVRsltCode) ? (string)$reversal->CVVRsltCode : null);
596
- $result->cvvResultText = (isset($reversal->CVVRsltText) ? (string)$reversal->CVVRsltText : null);
597
- $result->referenceNumber = (isset($reversal->RefNbr) ? (string)$reversal->RefNbr : null);
598
- $result->responseCode = (isset($reversal->RspCode) ? (string)$reversal->RspCode : null);
599
- $result->responseText = (isset($reversal->RspText) ? (string)$reversal->RspText : null);
600
- return $result;
601
- }
602
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/services/HpsService.php DELETED
@@ -1,129 +0,0 @@
1
- <?php
2
-
3
- class HpsService {
4
- public $exceptionMapper = null,
5
- $config = null;
6
-
7
- public function __construct(HpsConfiguration $config=null){
8
- if($config != null){
9
- $this->config = $config;
10
- }
11
- $this->exceptionMapper = new HpsExceptionMapper();
12
- }
13
-
14
- public function doTransaction($transaction){
15
- if($this->_configurationInvalid()){
16
- throw $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$invalidTransactionId);
17
- }
18
-
19
- $xml = new DOMDocument('1.0', 'utf-8');
20
- $soapEnvelope = $xml->createElement('soapenv:Envelope');
21
- $soapEnvelope->setAttribute('xmlns:soapenv', 'http://schemas.xmlsoap.org/soap/envelope/');
22
- $soapEnvelope->setAttribute('xmlns:hps', 'http://Hps.Exchange.PosGateway');
23
-
24
- $soapBody = $xml->createElement('soapenv:Body');
25
- $hpsRequest = $xml->createElement('hps:PosRequest');
26
- $hpsVersion = $xml->createElement('hps:Ver1.0');
27
- $hpsHeader = $xml->createElement('hps:Header');
28
-
29
- if ($this->config->secretApiKey != NULL && $this->config->secretApiKey != ""){
30
- $hpsHeader->appendChild($xml->createElement('hps:SecretAPIKey',$this->config->secretApiKey));
31
- }else{
32
- $hpsHeader->appendChild($xml->createElement('hps:UserName',$this->config->userName));
33
- $hpsHeader->appendChild($xml->createElement('hps:Password',$this->config->password));
34
- $hpsHeader->appendChild($xml->createElement('hps:DeviceId',$this->config->deviceId));
35
- $hpsHeader->appendChild($xml->createElement('hps:LicenseId',$this->config->licenseId));
36
- $hpsHeader->appendChild($xml->createElement('hps:SiteId',$this->config->siteId));
37
- }
38
- if ($this->config->developerId != null && $this->config->developerId != ""){
39
- $hpsHeader->appendChild($xml->createElement('hps:DeveloperID',$this->config->developerId));
40
- $hpsHeader->appendChild($xml->createElement('hps:VersionNbr',$this->config->versionNumber));
41
- $hpsHeader->appendChild($xml->createElement('hps:SiteTrace',$this->config->siteTrace));
42
- }
43
-
44
- $hpsVersion->appendChild($hpsHeader);
45
- $transaction = $xml->importNode($transaction,true);
46
- $hpsVersion->appendChild($transaction);
47
- $hpsRequest->appendChild($hpsVersion);
48
- $soapBody->appendChild($hpsRequest);
49
- $soapEnvelope->appendChild($soapBody);
50
- $xml->appendChild($soapEnvelope);
51
-
52
- //cURL
53
- try{
54
- $header = array(
55
- "Content-type: text/xml;charset=\"utf-8\"",
56
- "Accept: text/xml",
57
- "SOAPAction: \"\"",
58
- "Content-length: ".strlen($xml->saveXML()),
59
- );
60
- $soap_do = curl_init();
61
- curl_setopt($soap_do, CURLOPT_URL, $this->_gatewayUrlForKey($this->config->secretApiKey));
62
- curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
63
- curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
64
- curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
65
- curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
66
- curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
67
- curl_setopt($soap_do, CURLOPT_POST, true);
68
- curl_setopt($soap_do, CURLOPT_POSTFIELDS, $xml->saveXML());
69
- curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
70
-
71
- if($this->config->useProxy){
72
- curl_setopt($soap_do, CURLOPT_PROXY, $this->config->proxyOptions['proxy_host']);
73
- curl_setopt($soap_do, CURLOPT_PROXYPORT, $this->config->proxyOptions['proxy_port']);
74
- }
75
- $curlResponse = curl_exec($soap_do);
76
- $curlInfo = curl_getinfo($soap_do);
77
-
78
- if($curlInfo['http_code'] == '200'){
79
- $responseObject = $this->_XML2Array($curlResponse);
80
- $ver = "Ver1.0";
81
- return $responseObject->$ver;
82
- }else{
83
- throw $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$unableToProcessTransaction);
84
- }
85
- }catch (Exception $e){
86
- throw $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$unableToProcessTransaction, $e);
87
- }
88
- }
89
-
90
- private function _configurationInvalid(){
91
- if($this->config == null && (
92
- $this->config->secretApiKey == null ||
93
- $this->config->userName == null ||
94
- $this->config->password == null ||
95
- $this->config->licenseId == null ||
96
- $this->config->deviceId == null ||
97
- $this->config->siteId == null)
98
- ){
99
- return true;
100
- }
101
- return false;
102
- }
103
-
104
- private function _gatewayUrlForKey($apiKey){
105
- if ($apiKey != NULL && $apiKey != "" && strpos($apiKey, '_cert_') !== false){
106
- return "https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx";
107
- }else{
108
- return "https://posgateway.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx";
109
- }
110
- }
111
-
112
- public function hydrateTransactionHeader($header){
113
- $result = new HpsTransactionHeader();
114
- $result->gatewayResponseCode = $header['GatewayRspCode'];
115
- $result->gatewayResponseMessage = $header['GatewayRspMsg'];
116
- $result->responseDt = $header['RspDT'];
117
- $result->clientTxnId = $header['GatewayTxnId'];
118
- return $result;
119
- }
120
-
121
- private function _XML2Array($xml){
122
- $envelope = simplexml_load_string($xml, "SimpleXMLElement", 0,'http://schemas.xmlsoap.org/soap/envelope/');
123
- foreach($envelope->Body as $response) {
124
- foreach ($response->children('http://Hps.Exchange.PosGateway') as $item) {
125
- return $item;
126
- }
127
- }
128
- }
129
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/services/HpsTokenService.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
- // This should only be used for testing tokens.
3
-
4
- class HpsTokenService {
5
- private $_publicAPIKey = null;
6
- private $_url = null;
7
-
8
- function __construct($publicAPIKey){
9
- $this->_publicAPIKey = $publicAPIKey;
10
-
11
- if($publicAPIKey == null || $publicAPIKey == ""){
12
- throw new HpsException("Public Key not found","0");
13
- }
14
-
15
- $components = explode("_",$publicAPIKey);
16
- if(count($components) != 3){
17
- throw new HpsException("Public API Key must Contain three underscores","0");
18
- }
19
-
20
- if(strtolower($components[1]) == "prod"){
21
- $this->_url = "https://api.heartlandportico.com/SecureSubmit.v1/api/token";
22
- }else {
23
- $this->_url = "https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway.Hpf.v1/api/token";
24
- }
25
- }
26
-
27
- function getToken(HpsCreditCard $cardData){
28
- try{
29
- $data['api_key'] = $this->_publicAPIKey;
30
- $data['object'] = 'token';
31
- $data['token_type'] = 'supt';
32
- $data['_method'] = 'post';
33
- $data['card[number]'] = $cardData->number;
34
- $data['card[cvc]'] = $cardData->cvv;
35
- $data['card[exp_month]'] = $cardData->expMonth;
36
- $data['card[exp_year]'] = $cardData->expYear;
37
-
38
- $header = array('Content-type: application/json');
39
-
40
- $tokenFetch = curl_init();
41
- curl_setopt($tokenFetch, CURLOPT_URL, $this->_url ."?". http_build_query($data));
42
- curl_setopt($tokenFetch, CURLOPT_CONNECTTIMEOUT, 10);
43
- curl_setopt($tokenFetch, CURLOPT_TIMEOUT, 10);
44
- curl_setopt($tokenFetch, CURLOPT_RETURNTRANSFER, true );
45
- curl_setopt($tokenFetch, CURLOPT_SSL_VERIFYPEER, false);
46
- curl_setopt($tokenFetch, CURLOPT_SSL_VERIFYHOST, false);
47
- curl_setopt($tokenFetch, CURLOPT_HTTPHEADER, $header);
48
- $curlResponse = curl_exec($tokenFetch);
49
-
50
- $response = json_decode($curlResponse);
51
- if(isset($response->error) && is_object($response->error)){
52
- throw new HpsException($response->error->message,$response->error->code);
53
- }
54
- return $response;
55
- }catch (Exception $e){
56
- throw new HpsException($e->getMessage(),$e->getCode());
57
- }
58
- }
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{app/code/community/Hps/Securesubmit/controllers/Adminhtml/Hps → lib/SecureSubmit/src}/.DS_Store RENAMED
Binary file
lib/SecureSubmit/src/Abstractions/HpsAltPaymentServiceInterface.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * AltPayment Service Interface
4
+ *
5
+ * PHP Version 5.2+
6
+ *
7
+ * @category PHP
8
+ * @package HPS
9
+ * @author Heartland Payment Systems <EntApp_DevPortal@e-hps.com>
10
+ * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom
11
+ * @link https://github.com/hps/heartland-php
12
+ */
13
+
14
+ /**
15
+ * AltPayment Service Interface
16
+ *
17
+ * @category PHP
18
+ * @package HPS
19
+ * @author Heartland Payment Systems <EntApp_DevPortal@e-hps.com>
20
+ * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom
21
+ * @link https://github.com/hps/heartland-php
22
+ */
23
+ interface HpsAltPaymentServiceInterface
24
+ {
25
+ /**
26
+ * Creates an authorization
27
+ *
28
+ * @param string $orderId order id from gateway
29
+ * @param mixed $amount amount to be authorized
30
+ * @param string $currency currency code
31
+ * @param HpsBuyerData $buyer buyer information
32
+ * @param HpsPaymentData $payment payment information
33
+ * @param HpsShippingInfo $shippingAddress shipping information
34
+ * @param array<int, HpsLineItem> $lineItems line items from order
35
+ * @param HpsOrderData $orderData gateway/processor specific
36
+ * data
37
+ *
38
+ * @return object
39
+ */
40
+ public function authorize(
41
+ $orderId,
42
+ $amount,
43
+ $currency,
44
+ HpsBuyerData $buyer,
45
+ HpsPaymentData $payment,
46
+ HpsShippingInfo $shippingAddress = null,
47
+ $lineItems = null,
48
+ HpsOrderData $orderData = null
49
+ );
50
+
51
+ /**
52
+ * Captures an authorization
53
+ *
54
+ * @param string $orderId order id from gateway
55
+ * @param mixed $amount amount to be authorized
56
+ * @param HpsOrderData $orderData gateway/processor specific data
57
+ *
58
+ * @return object
59
+ */
60
+ public function capture(
61
+ $orderId,
62
+ $amount,
63
+ HpsOrderData $orderData = null
64
+ );
65
+
66
+ /**
67
+ * Creates a new AltPayment session
68
+ *
69
+ * @param mixed $amount amount to be authorized
70
+ * @param string $currency currency code
71
+ * @param HpsBuyerData $buyer buyer information
72
+ * @param HpsPaymentData $payment payment information
73
+ * @param HpsShippingInfo $shippingAddress shipping information
74
+ * @param array<int, HpsLineItem> $lineItems line items from order
75
+ * @param HpsOrderData $orderData gateway/processor specific
76
+ * data
77
+ *
78
+ * @return object
79
+ */
80
+ public function createSession(
81
+ $amount,
82
+ $currency,
83
+ HpsBuyerData $buyer,
84
+ HpsPaymentData $payment,
85
+ HpsShippingInfo $shippingAddress = null,
86
+ $lineItems = null,
87
+ HpsOrderData $orderData = null
88
+ );
89
+
90
+ /**
91
+ * Refunds a transaction
92
+ *
93
+ * @param string $orderId order id from gateway
94
+ * @param boolean $isPartial flag for partial refund
95
+ * @param string $partialAmount partial amount to be refunded
96
+ * @param HpsOrderData $orderData gateway/processor specific data
97
+ *
98
+ * @return object
99
+ */
100
+ public function refund(
101
+ $orderId,
102
+ $isPartial = false,
103
+ $partialAmount = null,
104
+ HpsOrderData $orderData = null
105
+ );
106
+
107
+ /**
108
+ * Creates an authorization
109
+ *
110
+ * @param string $orderId order id from gateway
111
+ * @param mixed $amount amount to be authorized
112
+ * @param string $currency currency code
113
+ * @param HpsBuyerData $buyer buyer information
114
+ * @param HpsPaymentData $payment payment information
115
+ * @param HpsShippingInfo $shippingAddress shipping information
116
+ * @param array<int, HpsLineItem> $lineItems line items from order
117
+ * @param HpsOrderData $orderData gateway/processor specific
118
+ * data
119
+ *
120
+ * @return object
121
+ */
122
+ public function sale(
123
+ $orderId,
124
+ $amount,
125
+ $currency,
126
+ HpsBuyerData $buyer,
127
+ HpsPaymentData $payment,
128
+ HpsShippingInfo $shippingAddress = null,
129
+ $lineItems = null,
130
+ HpsOrderData $orderData = null
131
+ );
132
+
133
+ /**
134
+ * Voids a transaction
135
+ *
136
+ * @param string $orderId order id from gateway
137
+ * @param HpsOrderData $orderData gateway/processor specific data
138
+ *
139
+ * @return object
140
+ */
141
+ public function void(
142
+ $orderId,
143
+ HpsOrderData $orderData = null
144
+ );
145
+
146
+ /**
147
+ * Gets information about a session
148
+ *
149
+ * @param string $orderId order id from gateway
150
+ * @param HpsOrderData $orderData gateway/processor specific data
151
+ *
152
+ * @return object
153
+ */
154
+ public function sessionInfo(
155
+ $orderId,
156
+ HpsOrderData $orderData = null
157
+ );
158
+ }
lib/SecureSubmit/src/Abstractions/HpsConfigInterface.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface HpsConfigInterface
4
+ {
5
+ const KEY_TYPE_SECRET = 'secret';
6
+ const KEY_TYPE_PUBLIC = 'public';
7
+ const KEY_TYPE_UNKNOWN = 'unknown';
8
+ public function serviceUri();
9
+ public function setServiceUri(string $value);
10
+ public function validate($keyType);
11
+ }
lib/SecureSubmit/src/Abstractions/HpsGatewayServiceAbstract.php CHANGED
@@ -9,7 +9,7 @@ abstract class HpsGatewayServiceAbstract
9
  protected $_currency = null;
10
  protected $_filterBy = null;
11
 
12
- public function __construct(HpsServicesConfig $config = null)
13
  {
14
  if ($config != null) {
15
  $this->_config = $config;
@@ -26,8 +26,6 @@ abstract class HpsGatewayServiceAbstract
26
  $this->_config = $value;
27
  }
28
 
29
- abstract protected function processResponse($curlResponse, $curlInfo, $curlError);
30
-
31
  protected function submitRequest($url, $headers, $data = null, $httpVerb = 'POST', $keyType = HpsServicesConfig::KEY_TYPE_SECRET, $options = null)
32
  {
33
  if ($this->_isConfigInvalid()) {
@@ -39,7 +37,7 @@ abstract class HpsGatewayServiceAbstract
39
  );
40
  }
41
 
42
- if (!$this->_config->validateApiKey($keyType)) {
43
  $type = $this->_config->getKeyType($keyType);
44
  $message = "The HPS SDK requires a valid {$keyType} API key to be used";
45
  if ($type == $keyType) {
@@ -56,8 +54,8 @@ abstract class HpsGatewayServiceAbstract
56
  try {
57
  $request = curl_init();
58
  curl_setopt($request, CURLOPT_URL, $url);
59
- curl_setopt($request, CURLOPT_CONNECTTIMEOUT, 60);
60
- curl_setopt($request, CURLOPT_TIMEOUT, 60);
61
  curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
62
  curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);
63
  curl_setopt($request, CURLOPT_SSL_VERIFYHOST, false);
9
  protected $_currency = null;
10
  protected $_filterBy = null;
11
 
12
+ public function __construct(HpsConfigInterface $config = null)
13
  {
14
  if ($config != null) {
15
  $this->_config = $config;
26
  $this->_config = $value;
27
  }
28
 
 
 
29
  protected function submitRequest($url, $headers, $data = null, $httpVerb = 'POST', $keyType = HpsServicesConfig::KEY_TYPE_SECRET, $options = null)
30
  {
31
  if ($this->_isConfigInvalid()) {
37
  );
38
  }
39
 
40
+ if (!$this->_config->validate($keyType) && ($this->_config->username == null && $this->_config->password == null)) {
41
  $type = $this->_config->getKeyType($keyType);
42
  $message = "The HPS SDK requires a valid {$keyType} API key to be used";
43
  if ($type == $keyType) {
54
  try {
55
  $request = curl_init();
56
  curl_setopt($request, CURLOPT_URL, $url);
57
+ curl_setopt($request, CURLOPT_CONNECTTIMEOUT, 100);
58
+ curl_setopt($request, CURLOPT_TIMEOUT, 100);
59
  curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
60
  curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);
61
  curl_setopt($request, CURLOPT_SSL_VERIFYHOST, false);
lib/SecureSubmit/src/Abstractions/HpsGatewayServiceInterface.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface HpsGatewayServiceInterface
4
+ {
5
+ public function doRequest($data, $options);
6
+ public function processResponse($curlResponse, $curlInfo, $curlError);
7
+ }
{app/design/frontend/base/default/template/securesubmit → lib/SecureSubmit/src/Entities}/.DS_Store RENAMED
Binary file
lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentAddToBatch.php CHANGED
@@ -2,18 +2,4 @@
2
 
3
  class HpsAltPaymentAddToBatch extends HpsAuthorization
4
  {
5
- public $status = null;
6
- public $statusMessage = null;
7
-
8
- public static function fromDict($rsp, $txnType, $returnType = 'HpsAltPaymentAddToBatch')
9
- {
10
- $addToBatch = $rsp->Transaction->$txnType;
11
-
12
- $capture = parent::fromDict($rsp, $txnType, $returnType);
13
-
14
- $capture->status = isset($addToBatch->Status) ? (string)$addToBatch->Status : null;
15
- $capture->statusMessage = isset($addToBatch->StatusMessage) ? (string)$addToBatch->StatusMessage : null;
16
-
17
- return $capture;
18
- }
19
  }
2
 
3
  class HpsAltPaymentAddToBatch extends HpsAuthorization
4
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  }
lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentAuth.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class HpsAltPaymentAuth extends HpsAuthorization
4
  {
5
  public $status = null;
6
  public $statusMessage = null;
1
  <?php
2
 
3
+ class HpsAltPaymentAuth extends HpsAltPaymentResponse
4
  {
5
  public $status = null;
6
  public $statusMessage = null;
lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentCapture.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsAltPaymentCapture extends HpsAltPaymentResponse
4
+ {
5
+ public $status = null;
6
+ public $statusMessage = null;
7
+
8
+ public static function fromDict($rsp, $txnType, $returnType = 'HpsAltPaymentCapture')
9
+ {
10
+ $addToBatch = $rsp->Transaction->$txnType;
11
+
12
+ $capture = parent::fromDict($rsp, $txnType, $returnType);
13
+
14
+ $capture->status = isset($addToBatch->Status) ? (string)$addToBatch->Status : null;
15
+ $capture->statusMessage = isset($addToBatch->StatusMessage) ? (string)$addToBatch->StatusMessage : null;
16
+
17
+ return $capture;
18
+ }
19
+ }
lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentCreateSession.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class HpsAltPaymentCreateSession extends HpsAuthorization
4
  {
5
  public $sessionId = null;
6
  public $redirectUrl = null;
@@ -19,13 +19,4 @@ class HpsAltPaymentCreateSession extends HpsAuthorization
19
 
20
  return $session;
21
  }
22
-
23
- protected static function nvpToArray($pairs)
24
- {
25
- $array = array();
26
- foreach ($pairs->NameValuePair as $pair) {
27
- $array[(string)$pair->Name] = (string)$pair->Value;
28
- }
29
- return $array;
30
- }
31
  }
1
  <?php
2
 
3
+ class HpsAltPaymentCreateSession extends HpsAltPaymentResponse
4
  {
5
  public $sessionId = null;
6
  public $redirectUrl = null;
19
 
20
  return $session;
21
  }
 
 
 
 
 
 
 
 
 
22
  }
lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentResponse.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsAltPaymentResponse extends HpsAuthorization
4
+ {
5
+ public $error = null;
6
+
7
+ public static function fromDict($rsp, $txnType, $returnType = 'HpsAltPaymentResponse')
8
+ {
9
+ $response = $rsp->Transaction->$txnType;
10
+
11
+ $altPayment = parent::fromDict($rsp, $txnType, $returnType);
12
+
13
+ if ($response->RspCode != 0) {
14
+ $error = self::nvpToArray($response->Processor->Response);
15
+ $altPayment->error = new HpsProcessorError();
16
+ $altPayment->error->code = isset($error['Code']) ? $error['Code'] : null;
17
+ $altPayment->error->message = isset($error['Message']) ? $error['Message'] : null;
18
+ $altPayment->error->type = isset($error['Type']) ? $error['Type'] : null;
19
+ }
20
+
21
+ return $altPayment;
22
+ }
23
+
24
+ public static function nvpToArray($pairs)
25
+ {
26
+ $array = array();
27
+ foreach ($pairs->NameValuePair as $pair) {
28
+ $array[(string)$pair->Name] = (string)$pair->Value;
29
+ }
30
+ return $array;
31
+ }
32
+ }
lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentReturn.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
 
3
- class HpsAltPaymentReturn extends HpsAuthorization
4
  {
5
  }
1
  <?php
2
 
3
+ class HpsAltPaymentReturn extends HpsAltPaymentResponse
4
  {
5
  }
lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentSale.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class HpsAltPaymentSale extends HpsAuthorization
4
  {
5
  public $status = null;
6
  public $statusMessage = null;
1
  <?php
2
 
3
+ class HpsAltPaymentSale extends HpsAltPaymentResponse
4
  {
5
  public $status = null;
6
  public $statusMessage = null;
lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentSessionInfo.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class HpsAltPaymentSessionInfo extends HpsAuthorization
4
  {
5
  /** @var string|null */
6
  public $status = null;
@@ -60,13 +60,4 @@ class HpsAltPaymentSessionInfo extends HpsAuthorization
60
 
61
  return $session;
62
  }
63
-
64
- protected static function nvpToArray($pairs)
65
- {
66
- $array = array();
67
- foreach ($pairs->NameValuePair as $pair) {
68
- $array[(string)$pair->Name] = (string)$pair->Value;
69
- }
70
- return $array;
71
- }
72
  }
1
  <?php
2
 
3
+ class HpsAltPaymentSessionInfo extends HpsAltPaymentResponse
4
  {
5
  /** @var string|null */
6
  public $status = null;
60
 
61
  return $session;
62
  }
 
 
 
 
 
 
 
 
 
63
  }
lib/SecureSubmit/src/Entities/AltPayment/HpsAltPaymentVoid.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
 
3
- class HpsAltPaymentVoid extends HpsAuthorization
4
  {
5
  }
1
  <?php
2
 
3
+ class HpsAltPaymentVoid extends HpsAltPaymentResponse
4
  {
5
  }
lib/SecureSubmit/src/Entities/AltPayment/HpsBuyerData.php CHANGED
@@ -23,9 +23,18 @@ class HpsBuyerData
23
  /** @var string|null */
24
  public $firstName = null;
25
 
 
 
 
26
  /** @var string|null */
27
  public $lastName = null;
28
 
29
  /** @var string|null */
30
  public $credit = null;
 
 
 
 
 
 
31
  }
23
  /** @var string|null */
24
  public $firstName = null;
25
 
26
+ /** @var string|null */
27
+ public $middleName = null;
28
+
29
  /** @var string|null */
30
  public $lastName = null;
31
 
32
  /** @var string|null */
33
  public $credit = null;
34
+
35
+ /** @var HpsAddress|null */
36
+ public $address = null;
37
+
38
+ /** @var string|null */
39
+ public $phoneNumber = null;
40
  }
lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIAddOrderNumberResponse.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsCardinalMPIAddOrderNumberResponse extends HpsCardinalMPIResponse
4
+ {
5
+ public static function fromObject($data, $returnType = 'HpsCardinalMPIAddOrderNumberResponse')
6
+ {
7
+ parent::fromObject($data, $returnType);
8
+ }
9
+ }
lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIAuthenticateResponse.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsCardinalMPIAuthenticateResponse extends HpsCardinalMPIResponse
4
+ {
5
+ public $authenticateMethod = null;
6
+ public $authorizationCode = null;
7
+ public $cardBin = null;
8
+ public $cardEnrollmentMethod = null;
9
+ public $cardExpMonth = null;
10
+ public $cardExpYear = null;
11
+ public $cardLastFour = null;
12
+ public $cardType = null;
13
+ public $cardTypeName = null;
14
+ public $longAccessToken = null;
15
+ public $mastercardAssignedId = null;
16
+ public $nameOnCard = null;
17
+ public $paResStatus = null;
18
+ public $payPassWalletIndicator = null;
19
+ public $paymentProcessorOrderNumber = null;
20
+ public $processorBillingAddress1 = null;
21
+ public $processorBillingAddress2 = null;
22
+ public $processorBillingCity = null;
23
+ public $processorBillingCountryCode = null;
24
+ public $processorBillingFirstName = null;
25
+ public $processorBillingLastName = null;
26
+ public $processorBillingMiddleName = null;
27
+ public $processorBillingPhone = null;
28
+ public $processorBillingPostalCode = null;
29
+ public $processorBillingState = null;
30
+ public $processorCavv = null;
31
+ public $processorEciFlag = null;
32
+ public $processorEmail = null;
33
+ public $processorPayresStatus = null;
34
+ public $processorShippingAddress1 = null;
35
+ public $processorShippingAddress2 = null;
36
+ public $processorShippingCity = null;
37
+ public $processorShippingCountryCode = null;
38
+ public $processorShippingFullName = null;
39
+ public $processorShippingPhone = null;
40
+ public $processorShippingPostalCode = null;
41
+ public $processorShippingState = null;
42
+ public $processorSignatureVerification = null;
43
+ public $processorTransactionIdPairing = null;
44
+ public $processorXid = null;
45
+ public $rewardExpMonth = null;
46
+ public $rewardExpYear = null;
47
+ public $rewardId = null;
48
+ public $rewardName = null;
49
+ public $rewardNumber = null;
50
+ public $scEnrollmentStatus = null;
51
+ public $signatureVerification = null;
52
+
53
+ public static function fromObject($data, $returnType = 'HpsCardinalMPIAuthenticateResponse')
54
+ {
55
+ $response = parent::fromObject($data, $returnType);
56
+ $response->authenticateMethod = self::readDataKey($data, 'AuthenticateMethod');
57
+ $response->authorizationCode = self::readDataKey($data, 'AuthorizationCode');
58
+ $response->cardBin = self::readDataKey($data, 'CardBin');
59
+ $response->cardEnrollmentMethod = self::readDataKey($data, 'CardEnrollmentMethod');
60
+ $response->cardExpMonth = self::readDataKey($data, 'CardExpMonth');
61
+ $response->cardExpYear = self::readDataKey($data, 'CardExpYear');
62
+ $response->cardLastFour = self::readDataKey($data, 'CardLastFour');
63
+ $response->cardType = self::readDataKey($data, 'CardType');
64
+ $response->cardTypeName = self::readDataKey($data, 'CardTypeName');
65
+ $response->longAccessToken = self::readDataKey($data, 'LongAccessToken');
66
+ $response->mastercardAssignedId = self::readDataKey($data, 'MasterCardAssignedId');
67
+ $response->nameOnCard = self::readDataKey($data, 'NameOnCard');
68
+ $response->paResStatus = self::readDataKey($data, 'PaResStatus');
69
+ $response->payPassWalletIndicator = self::readDataKey($data, 'PayPassWalletIndicator');
70
+ $response->paymentProcessorOrderNumber = self::readDataKey($data, 'PaymentProcessorOrderNumber');
71
+ $response->processorBillingAddress1 = self::readDataKey($data, 'ProcessorBillingAddress1');
72
+ $response->processorBillingAddress2 = self::readDataKey($data, 'ProcessorBillingAddress2');
73
+ $response->processorBillingCity = self::readDataKey($data, 'ProcessorBillingCity');
74
+ $response->processorBillingCountryCode = self::readDataKey($data, 'ProcessorBillingCountryCode');
75
+ $response->processorBillingFirstName = self::readDataKey($data, 'ProcessorBillingFirstName');
76
+ $response->processorBillingLastName = self::readDataKey($data, 'ProcessorBillingLastName');
77
+ $response->processorBillingMiddleName = self::readDataKey($data, 'ProcessorBillingMiddleName');
78
+ $response->processorBillingPhone = self::readDataKey($data, 'ProcessorBillingPhone');
79
+ $response->processorBillingPostalCode = self::readDataKey($data, 'ProcessorBillingPostalCode');
80
+ $response->processorBillingState = self::readDataKey($data, 'ProcessorBillingState');
81
+ $response->processorCavv = self::readDataKey($data, 'ProcessorCavv');
82
+ $response->processorEciFlag = self::readDataKey($data, 'ProcessorEciFlag');
83
+ $response->processorEmail = self::readDataKey($data, 'ProcessorEmail');
84
+ $response->processorPayresStatus = self::readDataKey($data, 'ProcessorPayresStatus');
85
+ $response->processorShippingAddress1 = self::readDataKey($data, 'ProcessorShippingAddress1');
86
+ $response->processorShippingAddress2 = self::readDataKey($data, 'ProcessorShippingAddress2');
87
+ $response->processorShippingCity = self::readDataKey($data, 'ProcessorShippingCity');
88
+ $response->processorShippingCountryCode = self::readDataKey($data, 'ProcessorShippingCountryCode');
89
+ $response->processorShippingFullName = self::readDataKey($data, 'ProcessorShippingFullName');
90
+ $response->processorShippingPhone = self::readDataKey($data, 'ProcessorShippingPhone');
91
+ $response->processorShippingPostalCode = self::readDataKey($data, 'ProcessorShippingPostalCode');
92
+ $response->processorShippingState = self::readDataKey($data, 'ProcessorShippingState');
93
+ $response->processorSignatureVerification = self::readDataKey($data, 'ProcessorSignatureVerification');
94
+ $response->processorXid = self::readDataKey($data, 'ProcessorXid');
95
+ $response->rewardExpMonth = self::readDataKey($data, 'RewardExpMonth');
96
+ $response->rewardExpYear = self::readDataKey($data, 'RewardExpYear');
97
+ $response->rewardId = self::readDataKey($data, 'RewardId');
98
+ $response->rewardName = self::readDataKey($data, 'RewardName');
99
+ $response->rewardNumber = self::readDataKey($data, 'RewardNumber');
100
+ $response->scEnrollmentStatus = self::readDataKey($data, 'ScEnrollmentStatus');
101
+ $response->signatureVerification = self::readDataKey($data, 'SignatureVerification');
102
+ return $response;
103
+ }
104
+ }
lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIAuthorizeResponse.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsCardinalMPIAuthorizeResponse extends HpsCardinalMPIResponse
4
+ {
5
+ public $authorizationCode = null;
6
+ public $avsResult = null;
7
+ public $cardBin = null;
8
+ public $cardCodeResult = null;
9
+ public $cardExpMonth = null;
10
+ public $cardExpYear = null;
11
+ public $cardLastFour = null;
12
+ public $cardType = null;
13
+ public $longAccessToken = null;
14
+ public $nameOnCard = null;
15
+ public $processorBillingAddress1 = null;
16
+ public $processorBillingAddress2 = null;
17
+ public $processorBillingCity = null;
18
+ public $processorBillingCountryCode = null;
19
+ public $processorBillingFirstName = null;
20
+ public $processorBillingLastName = null;
21
+ public $processorBillingMiddleName = null;
22
+ public $processorBillingPhone = null;
23
+ public $processorBillingPostalCode = null;
24
+ public $processorBillingState = null;
25
+ public $processorCavv = null;
26
+ public $processorEciFlag = null;
27
+ public $processorEmail = null;
28
+ public $processorPayresStatus = null;
29
+ public $processorShippingAddress1 = null;
30
+ public $processorShippingAddress2 = null;
31
+ public $processorShippingCity = null;
32
+ public $processorShippingCountryCode = null;
33
+ public $processorShippingFullName = null;
34
+ public $processorShippingPhone = null;
35
+ public $processorShippingPostalCode = null;
36
+ public $processorShippingState = null;
37
+
38
+ public static function fromObject($data, $returnType = 'HpsCardinalMPIAuthorizeResponse')
39
+ {
40
+ $response = parent::fromObject($data, $returnType);
41
+ $response->authorizationCode = self::readDataKey($data, 'AuthorizationCode');
42
+ $response->avsResult = self::readDataKey($data, 'AvsResult');
43
+ $response->cardBin = self::readDataKey($data, 'CardBin');
44
+ $response->cardExpMonth = self::readDataKey($data, 'CardExpMonth');
45
+ $response->cardExpYear = self::readDataKey($data, 'CardExpYear');
46
+ $response->cardLastFour = self::readDataKey($data, 'CardLastFour');
47
+ $response->cardType = self::readDataKey($data, 'CardType');
48
+ $response->longAccessToken = self::readDataKey($data, 'LongAccessToken');
49
+ $response->nameOnCard = self::readDataKey($data, 'NameOnCard');
50
+ $response->processorBillingAddress1 = self::readDataKey($data, 'ProcessorBillingAddress1');
51
+ $response->processorBillingAddress2 = self::readDataKey($data, 'ProcessorBillingAddress2');
52
+ $response->processorBillingCity = self::readDataKey($data, 'ProcessorBillingCity');
53
+ $response->processorBillingCountryCode = self::readDataKey($data, 'ProcessorBillingCountryCode');
54
+ $response->processorBillingFirstName = self::readDataKey($data, 'ProcessorBillingFirstName');
55
+ $response->processorBillingLastName = self::readDataKey($data, 'ProcessorBillingLastName');
56
+ $response->processorBillingMiddleName = self::readDataKey($data, 'ProcessorBillingMiddleName');
57
+ $response->processorBillingPhone = self::readDataKey($data, 'ProcessorBillingPhone');
58
+ $response->processorBillingPostalCode = self::readDataKey($data, 'ProcessorBillingPostalCode');
59
+ $response->processorBillingState = self::readDataKey($data, 'ProcessorBillingState');
60
+ $response->processorCavv = self::readDataKey($data, 'ProcessorCavv');
61
+ $response->processorEciFlag = self::readDataKey($data, 'ProcessorEciFlag');
62
+ $response->processorEmail = self::readDataKey($data, 'ProcessorEmail');
63
+ $response->processorPayresStatus = self::readDataKey($data, 'ProcessorPayresStatus');
64
+ $response->processorShippingAddress1 = self::readDataKey($data, 'ProcessorShippingAddress1');
65
+ $response->processorShippingAddress2 = self::readDataKey($data, 'ProcessorShippingAddress2');
66
+ $response->processorShippingCity = self::readDataKey($data, 'ProcessorShippingCity');
67
+ $response->processorShippingCountryCode = self::readDataKey($data, 'ProcessorShippingCountryCode');
68
+ $response->processorShippingFullName = self::readDataKey($data, 'ProcessorShippingFullName');
69
+ $response->processorShippingPhone = self::readDataKey($data, 'ProcessorShippingPhone');
70
+ $response->processorShippingPostalCode = self::readDataKey($data, 'ProcessorShippingPostalCode');
71
+ $response->processorShippingState = self::readDataKey($data, 'ProcessorShippingState');
72
+ return $response;
73
+ }
74
+ }
lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIAuthresponseResponse.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsCardinalMPIAuthresponseResponse extends HpsCardinalMPIResponse
4
+ {
5
+ public static function fromObject($data, $returnType = 'HpsCardinalMPIAuthresponseResponse')
6
+ {
7
+ return parent::fromObject($data, $returnType);
8
+ }
9
+ }
lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPICaptureResponse.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsCardinalMPICaptureResponse extends HpsCardinalMPIResponse
4
+ {
5
+ public static function fromObject($data, $returnType = 'HpsCardinalMPICaptureResponse')
6
+ {
7
+ return parent::fromObject($data, $returnType);
8
+ }
9
+ }
lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPILookupResponse.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsCardinalMPILookupResponse extends HpsCardinalMPIResponse
4
+ {
5
+ public $acsUrl = null;
6
+ public $enrolled = null;
7
+ public $payload = null;
8
+ public $processorTransactionIdPairing = null;
9
+
10
+ public static function fromObject($data, $returnType = 'HpsCardinalMPILookupResponse')
11
+ {
12
+ $response = parent::fromObject($data, $returnType);
13
+ $response->acsUrl = self::readDataKey($data, 'ACSUrl');
14
+ $response->enrolled = self::readDataKey($data, 'Enrolled');
15
+ $response->payload = self::readDataKey($data, 'Payload');
16
+ $response->processorTransactionIdPairing = self::readDataKey($data, 'ProcessorTransactionIdPairing');
17
+ return $response;
18
+ }
19
+ }
lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIPreapprovalResponse.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsCardinalMPIPreapprovalResponse extends HpsCardinalMPIResponse
4
+ {
5
+ public $longAccessToken = null;
6
+ public $preCheckoutData = null;
7
+ public $preCheckoutTransactionId = null;
8
+
9
+ public static function fromObject($data, $returnType = 'HpsCardinalMPIPreapprovalResponse')
10
+ {
11
+ $response = parent::fromObject($data, $returnType);
12
+ $response->longAccessToken = self::readDataKey($data, 'LongAccessToken');
13
+ $response->preCheckoutData = isset($data->PrecheckoutData) ? simplexml_load_string($data->PrecheckoutData)->PrecheckoutData : null;
14
+ $response->preCheckoutTransactionId = self::readDataKey($data, 'PrecheckoutTransactionId');
15
+ return $response;
16
+ }
17
+ }
lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIRefundResponse.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsCardinalMPIRefundResponse extends HpsCardinalMPIResponse
4
+ {
5
+ public static function fromObject($data, $returnType = 'HpsCardinalMPIRefundResponse')
6
+ {
7
+ return parent::fromObject($data, $returnType);
8
+ }
9
+ }
lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIResponse.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsCardinalMPIResponse
4
+ {
5
+ public $errorDescription = null;
6
+ public $errorNumber = null;
7
+ public $merchantData = null;
8
+ public $merchantReferenceNumber = null;
9
+ public $orderId = null;
10
+ public $orderNumber = null;
11
+ public $processorOrderNumber = null;
12
+ public $processorStatusCode = null;
13
+ public $processorTransactionId = null;
14
+ public $reasonCode = null;
15
+ public $reasonDescription = null;
16
+ public $statusCode = null;
17
+ public $transactionId = null;
18
+
19
+ public static function fromObject($data, $returnType = 'HpsCardinalMPIResponse')
20
+ {
21
+ $response = new $returnType();
22
+ $response->errorDescription = self::readDataKey($data, 'ErrorDesc');
23
+ $response->errorNumber = self::readDataKey($data, 'ErrorNo');
24
+ $response->merchantData = self::readDataKey($data, 'MerchantData');
25
+ $response->merchantReferenceNumber = self::readDataKey($data, 'MerchantReferenceNumber');
26
+ $response->orderId = self::readDataKey($data, 'OrderId');
27
+ $response->orderNumber = self::readDataKey($data, 'OrderNumber');
28
+ $response->processorOrderNumber = self::readDataKey($data, 'ProcessorOrderNumber');
29
+ $response->processorStatusCode = self::readDataKey($data, 'ProcessorStatusCode');
30
+ $response->processorTransactionId = self::readDataKey($data, 'ProcessorTransactionId');
31
+ $response->reasonCode = self::readDataKey($data, 'ReasonCode');
32
+ $response->reasonDescription = self::readDataKey($data, 'ReasonDesc');
33
+ $response->statusCode = self::readDataKey($data, 'StatusCode');
34
+ $response->transactionId = self::readDataKey($data, 'TransactionId');
35
+ return $response;
36
+ }
37
+
38
+ public static function readDataKey($data, $key)
39
+ {
40
+ return isset($data->{$key}) ? (string)$data->{$key} : null;
41
+ }
42
+ }
lib/SecureSubmit/src/Entities/AltPayment/HpsCardinalMPIVoidResponse.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsCardinalMPIVoidResponse extends HpsCardinalMPIResponse
4
+ {
5
+ public static function fromObject($data, $returnType = 'HpsCardinalMPIVoidResponse')
6
+ {
7
+ return parent::fromObject($data, $returnType);
8
+ }
9
+ }
lib/SecureSubmit/src/Entities/AltPayment/HpsOrderData.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Order Data
4
+ *
5
+ * PHP Version 5.2+
6
+ *
7
+ * @category PHP
8
+ * @package HPS
9
+ * @author Heartland Payment Systems <EntApp_DevPortal@e-hps.com>
10
+ * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom
11
+ * @link https://github.com/hps/heartland-php
12
+ */
13
+
14
+ /**
15
+ * Order Data
16
+ *
17
+ * @category PHP
18
+ * @package HPS
19
+ * @author Heartland Payment Systems <EntApp_DevPortal@e-hps.com>
20
+ * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom
21
+ * @link https://github.com/hps/heartland-php
22
+ */
23
+ class HpsOrderData
24
+ {
25
+ public $transactionStatus = null;
26
+ public $currencyCode = null;
27
+ public $orderId = null;
28
+ public $orderNumber = null;
29
+ public $transactionMode = 'S';
30
+ public $ipAddress = null;
31
+ public $browserHeader = null;
32
+ public $userAgent = null;
33
+ public $originUrl = null;
34
+ public $termUrl = null;
35
+ public $checkoutType = null;
36
+ public $pairingToken = null;
37
+ public $pairingVerifier = null;
38
+ }
lib/SecureSubmit/src/Entities/AltPayment/HpsPaymentData.php CHANGED
@@ -1,5 +1,25 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
2
 
 
 
 
 
 
 
 
 
 
3
  class HpsPaymentData
4
  {
5
  /** @var double|null */
1
  <?php
2
+ /**
3
+ * Order Data
4
+ *
5
+ * PHP Version 5.2+
6
+ *
7
+ * @category PHP
8
+ * @package HPS
9
+ * @author Heartland Payment Systems <EntApp_DevPortal@e-hps.com>
10
+ * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom
11
+ * @link https://github.com/hps/heartland-php
12
+ */
13
 
14
+ /**
15
+ * Order Data
16
+ *
17
+ * @category PHP
18
+ * @package HPS
19
+ * @author Heartland Payment Systems <EntApp_DevPortal@e-hps.com>
20
+ * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom
21
+ * @link https://github.com/hps/heartland-php
22
+ */
23
  class HpsPaymentData
24
  {
25
  /** @var double|null */
lib/SecureSubmit/src/Entities/AltPayment/HpsShippingInfo.php CHANGED
@@ -7,4 +7,19 @@ class HpsShippingInfo
7
 
8
  /** @var HpsAddress|null */
9
  public $address = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  }
7
 
8
  /** @var HpsAddress|null */
9
  public $address = null;
10
+
11
+ /** @var string|null */
12
+ public $firstName = null;
13
+
14
+ /** @var string|null */
15
+ public $middleName = null;
16
+
17
+ /** @var string|null */
18
+ public $lastName = null;
19
+
20
+ /** @var string|null */
21
+ public $countryCode = null;
22
+
23
+ /** @var string|null */
24
+ public $phoneNumber = null;
25
  }
lib/SecureSubmit/src/Entities/Credit/HpsCPCData.php CHANGED
@@ -2,7 +2,25 @@
2
 
3
  class HpsCPCData
4
  {
5
- public $CardHolderPONbr = null;
6
- public $TaxType = null;
7
- public $TaxAmt = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
2
 
3
  class HpsCPCData
4
  {
5
+ public $cardHolderPONbr = null;
6
+ public $taxType = null;
7
+ public $taxAmt = null;
8
+
9
+ public function __construct($poNbr = null, $taxType = null, $taxAmt = null)
10
+ {
11
+ if ($poNbr != null) {
12
+ if (strlen($poNbr) > 17) {
13
+ throw new HpsArgumentException('Card holder PO number must be less than 17 characters');
14
+ }
15
+ $this->cardHolderPONbr = $poNbr;
16
+ }
17
+
18
+ if ($taxType != null) {
19
+ $this->taxType = $taxType;
20
+ }
21
+
22
+ if ($taxAmt != null) {
23
+ $this->taxAmt = $taxAmt;
24
+ }
25
+ }
26
  }
lib/SecureSubmit/src/Entities/Credit/HpsCreditCard.php CHANGED
@@ -2,10 +2,11 @@
2
 
3
  class HpsCreditCard
4
  {
5
- public $number = null;
6
- public $cvv = null;
7
- public $expMonth = null;
8
- public $expYear = null;
 
9
 
10
  public function cardType()
11
  {
2
 
3
  class HpsCreditCard
4
  {
5
+ public $number = null;
6
+ public $cvv = null;
7
+ public $expMonth = null;
8
+ public $expYear = null;
9
+ public $encryptionData = null;
10
 
11
  public function cardType()
12
  {
lib/SecureSubmit/src/Entities/Credit/HpsOfflineAuthorization.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsOfflineAuthorization extends HpsTransaction
4
+ {
5
+ public static function fromDict($rsp, $txnType, $returnType = 'HpsOfflineAuthorization')
6
+ {
7
+ $offlineAuth = parent::fromDict($rsp, $txnType, $returnType);
8
+ $offlineAuth->responseCode = '00';
9
+ $offlineAuth->responseText = '';
10
+ return $offlineAuth;
11
+ }
12
+ }
lib/SecureSubmit/src/Entities/Credit/HpsReportTransactionDetails.php CHANGED
@@ -13,6 +13,7 @@ class HpsReportTransactionDetails extends HpsAuthorization
13
  public $memo = null;
14
  public $invoiceNumber = null;
15
  public $customerId = null;
 
16
 
17
  public static function fromDict($rsp, $txnType, $returnType = 'HpsReportTransactionDetails')
18
  {
@@ -35,6 +36,7 @@ class HpsReportTransactionDetails extends HpsAuthorization
35
  $details->referenceNumber = (isset($reportResponse->Data->RefNbr) ? (string)$reportResponse->Data->RefNbr : null);
36
  $details->responseCode = (isset($reportResponse->Data->RspCode) ? (string)$reportResponse->Data->RspCode : null);
37
  $details->responseText = (isset($reportResponse->Data->RspText) ? (string)$reportResponse->Data->RspText : null);
 
38
 
39
  if (isset($reportResponse->Data->TokenizationMsg)) {
40
  $details->tokenData = new HpsTokenData();
13
  public $memo = null;
14
  public $invoiceNumber = null;
15
  public $customerId = null;
16
+ public $transactionStatus = null;
17
 
18
  public static function fromDict($rsp, $txnType, $returnType = 'HpsReportTransactionDetails')
19
  {
36
  $details->referenceNumber = (isset($reportResponse->Data->RefNbr) ? (string)$reportResponse->Data->RefNbr : null);
37
  $details->responseCode = (isset($reportResponse->Data->RspCode) ? (string)$reportResponse->Data->RspCode : null);
38
  $details->responseText = (isset($reportResponse->Data->RspText) ? (string)$reportResponse->Data->RspText : null);
39
+ $details->transactionStatus = (isset($reportResponse->Data->TxnStatus) ? (string)$reportResponse->Data->TxnStatus : null);
40
 
41
  if (isset($reportResponse->Data->TokenizationMsg)) {
42
  $details->tokenData = new HpsTokenData();
lib/SecureSubmit/src/Entities/Credit/HpsReportTransactionSummary.php CHANGED
@@ -59,7 +59,7 @@ class HpsReportTransactionSummary extends HpsTransaction
59
  }
60
  if ($issuerResponseCode != "00") {
61
  $message = (string)$charge->IssuerRspText;
62
- $exceptions->cardException = HpsIssuerResponseValidation::getException((string)$charge->GatewayTxnId, $issuerResponseCode, $message);
63
  }
64
  $summary->exceptions = $exceptions;
65
  }
59
  }
60
  if ($issuerResponseCode != "00") {
61
  $message = (string)$charge->IssuerRspText;
62
+ $exceptions->cardException = HpsIssuerResponseValidation::getException((string)$charge->GatewayTxnId, $issuerResponseCode, $message, 'credit');
63
  }
64
  $summary->exceptions = $exceptions;
65
  }
lib/SecureSubmit/src/Entities/Gift/HpsGiftCard.php CHANGED
@@ -3,10 +3,11 @@
3
  class HpsGiftCard
4
  {
5
  public $number = null;
6
- public $expMonth = null;
7
- public $expYear = null;
8
- public $isTrackData = false;
9
  public $encryptionData = null;
 
10
 
11
  public function __construct($number = null)
12
  {
3
  class HpsGiftCard
4
  {
5
  public $number = null;
6
+ public $trackData = null;
7
+ public $alias = null;
8
+ public $tokenValue = null;
9
  public $encryptionData = null;
10
+ public $pin = null;
11
 
12
  public function __construct($number = null)
13
  {
lib/SecureSubmit/src/Entities/Gift/HpsGiftCardActivate.php CHANGED
@@ -36,7 +36,7 @@ class HpsGiftCardActivate extends HpsTransaction
36
  $activation->transactionId = (string)$rsp->Header->GatewayTxnId;
37
  $activation->authorizationCode = (isset($activationRsp->AuthCode) ? (string)$activationRsp->AuthCode : null);
38
  $activation->balanceAmount = (isset($activationRsp->BalanceAmt) ? (string)$activationRsp->BalanceAmt : null);
39
- $activation->pointsBalanceAmount = (isset($activationRsp->PointsBalanceAmount) ? (string)$activationRsp->PointsBalanceAmount : null);
40
  $activation->rewards = (isset($activationRsp->Rewards) ? (string)$activationRsp->Rewards : null);
41
  $activation->notes = (isset($activationRsp->Notes) ? (string)$activationRsp->Notes : null);
42
  $activation->responseCode = (isset($activationRsp->RspCode) ? (string)$activationRsp->RspCode : null);
36
  $activation->transactionId = (string)$rsp->Header->GatewayTxnId;
37
  $activation->authorizationCode = (isset($activationRsp->AuthCode) ? (string)$activationRsp->AuthCode : null);
38
  $activation->balanceAmount = (isset($activationRsp->BalanceAmt) ? (string)$activationRsp->BalanceAmt : null);
39
+ $activation->pointsBalanceAmount = (isset($activationRsp->PointsBalanceAmt) ? (string)$activationRsp->PointsBalanceAmt : null);
40
  $activation->rewards = (isset($activationRsp->Rewards) ? (string)$activationRsp->Rewards : null);
41
  $activation->notes = (isset($activationRsp->Notes) ? (string)$activationRsp->Notes : null);
42
  $activation->responseCode = (isset($activationRsp->RspCode) ? (string)$activationRsp->RspCode : null);
lib/SecureSubmit/src/Entities/HpsDirectMarketData.php CHANGED
@@ -9,7 +9,15 @@ class HpsDirectMarketData
9
  public function __construct($invoiceNumber = null, $shipMonth = null, $shipDay = null)
10
  {
11
  $this->invoiceNumber = $invoiceNumber;
 
 
 
 
12
  $this->shipMonth = $shipMonth;
 
 
 
 
13
  $this->shipDay = $shipDay;
14
  }
15
  }
9
  public function __construct($invoiceNumber = null, $shipMonth = null, $shipDay = null)
10
  {
11
  $this->invoiceNumber = $invoiceNumber;
12
+
13
+ if ($shipMonth == null) {
14
+ $shipMonth = date('m');
15
+ }
16
  $this->shipMonth = $shipMonth;
17
+
18
+ if ($shipDay == null) {
19
+ $shipDay = date('d');
20
+ }
21
  $this->shipDay = $shipDay;
22
  }
23
  }
lib/SecureSubmit/src/Entities/{Gift/HpsEncryptionData.php → HpsEncryptionData.php} RENAMED
@@ -2,29 +2,30 @@
2
 
3
  class HpsEncryptionData
4
  {
5
- public $version = null;
 
6
 
7
  /**
8
  * This is required in certain encryption versions when supplying
9
  * track data and indicates which track has been supplied.
10
  *
11
- * @var null
12
- */
13
  public $encryptedTrackNumber = null;
14
 
15
  /**
16
  * This is requied in certain encryption versions;
17
  * the Key Transmission Block (KTB) used at the point of sale.
18
  *
19
- * @var null
20
- */
21
- public $ktb = null;
22
 
23
- /**
24
  * This is required in certain encryption versions;
25
  * the Key Serial Number (KSN) used at the point of sale.
26
  *
27
- * @var null
28
- */
29
- public $ksn = null;
30
  }
2
 
3
  class HpsEncryptionData
4
  {
5
+ /** @var string|null **/
6
+ public $version = null;
7
 
8
  /**
9
  * This is required in certain encryption versions when supplying
10
  * track data and indicates which track has been supplied.
11
  *
12
+ * @var string|null
13
+ **/
14
  public $encryptedTrackNumber = null;
15
 
16
  /**
17
  * This is requied in certain encryption versions;
18
  * the Key Transmission Block (KTB) used at the point of sale.
19
  *
20
+ * @var string|null
21
+ **/
22
+ public $ktb = null;
23
 
24
+ /**
25
  * This is required in certain encryption versions;
26
  * the Key Serial Number (KSN) used at the point of sale.
27
  *
28
+ * @var string|null
29
+ **/
30
+ public $ksn = null;
31
  }
lib/SecureSubmit/src/Entities/HpsTrackData.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsTrackData
4
+ {
5
+ /** @var HpsTrackDataMethod **/
6
+ public $method = HpsTrackDataMethod::SWIPE;
7
+
8
+ /** @var string|null **/
9
+ public $value = null;
10
+
11
+ /** @var HpsEncryptionData|null **/
12
+ public $encryptionData = null;
13
+ }
lib/SecureSubmit/src/Entities/HpsTransactionStatus.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsTransactionStatus extends HpsTransaction
4
+ {
5
+ public $originalGatewayResponseCode;
6
+ public $originalGatewayResponseText;
7
+ public $originalResponseCode;
8
+ public $originalResponseText;
9
+ public $transactionStatus;
10
+ public $originalTransactionId;
11
+ public $altPayment;
12
+ public $timezoneConversion;
13
+
14
+ public static function fromDict($rsp, $txnType, $returnType = 'HpsTransactionStatus')
15
+ {
16
+ $statusResponse = $rsp->Transaction->$txnType;
17
+
18
+ $status = parent::fromDict($rsp, $txnType, $returnType);
19
+ $status->authorizationCode = (isset($statusResponse->TransactionStatus->AuthCode) ? (string)$statusResponse->TransactionStatus->AuthCode : null);
20
+ $status->originalGatewayResponseCode = (isset($statusResponse->TransactionStatus->GatewayRspCode) ? (string)$statusResponse->TransactionStatus->GatewayRspCode : null);
21
+ $status->originalGatewayResponseText = (isset($statusResponse->TransactionStatus->GatewayRspMsg) ? (string)$statusResponse->TransactionStatus->GatewayRspMsg : null);
22
+ $status->originalResponseCode = (isset($statusResponse->TransactionStatus->RspCode) ? (string)$statusResponse->TransactionStatus->RspCode : null);
23
+ $status->originalResponseText = (isset($statusResponse->TransactionStatus->RspText) ? (string)$statusResponse->TransactionStatus->RspText : null);
24
+ $status->transactionStatus = (isset($statusResponse->TransactionStatus->TxnStatus) ? (string)$statusResponse->TransactionStatus->TxnStatus : null);
25
+ $status->originalTransactionId = (isset($statusResponse->TransactionStatus->GatewayTxnId) ? (string)$statusResponse->TransactionStatus->GatewayTxnId : null);
26
+ $status->altPayment = (isset($statusResponse->TransactionStatus->AltPayment) ? $statusResponse->TransactionStatus->AltPayment : null);
27
+ $status->timezoneConversion = (isset($statusResponse->TzConversion) ? (string)$statusResponse->TzConversion : null);
28
+
29
+ return $status;
30
+ }
31
+ }
lib/SecureSubmit/src/Entities/PayPlan/HpsPayPlanAmount.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsPayPlanAmount
4
+ {
5
+ public $value = null;
6
+ public $currency = 'USD';
7
+
8
+ public function __construct($value, $currency = null)
9
+ {
10
+ $this->value = $value;
11
+ if ($currency != null) {
12
+ $this->currency = $currency;
13
+ }
14
+ }
15
+ }
lib/SecureSubmit/src/Entities/PayPlan/HpsPayPlanPaymentMethod.php CHANGED
@@ -104,6 +104,12 @@ class HpsPayPlanPaymentMethod extends HpsPayPlanResourceAbstract
104
  /** @var string|null */
105
  public $hasActiveSchedules = null;
106
 
 
 
 
 
 
 
107
  public static function getEditableFields($type = null)
108
  {
109
  $fields = array(
104
  /** @var string|null */
105
  public $hasActiveSchedules = null;
106
 
107
+ /** @var string|null */
108
+ public $accountNumber = null;
109
+
110
+ /** @var string|null */
111
+ public $paymentToken = null;
112
+
113
  public static function getEditableFields($type = null)
114
  {
115
  $fields = array(
lib/SecureSubmit/src/Entities/PayPlan/HpsPayPlanSchedule.php CHANGED
@@ -83,6 +83,11 @@ class HpsPayPlanSchedule extends HpsPayPlanResourceAbstract
83
  /** @var string|null */
84
  public $scheduleStarted = null;
85
 
 
 
 
 
 
86
  public static function getEditableFields()
87
  {
88
  return array(
83
  /** @var string|null */
84
  public $scheduleStarted = null;
85
 
86
+ public function __construct() {
87
+ $this->emailReceipt = 'Never';
88
+ $this->emailAdvanceNotice = 'No';
89
+ }
90
+
91
  public static function getEditableFields()
92
  {
93
  return array(
lib/SecureSubmit/src/Entities/index.php CHANGED
@@ -1 +1 @@
1
- <?php
1
+ <?php
lib/SecureSubmit/src/Infrastructure/Enums/HpsCentinelCheckoutType.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsCentinelCheckoutType
4
+ {
5
+ const LIGHTBOX = 'lightbox';
6
+ const CONNECT = 'connect';
7
+ const PAIRING = 'pairing';
8
+ const PAIRING_CHECKOUT = 'pairingcheckout';
9
+ }
lib/SecureSubmit/src/Infrastructure/Enums/HpsExceptionCodes.php CHANGED
@@ -11,7 +11,7 @@ abstract class HpsExceptionCodes
11
  const MISSING_CURRENCY = 3;
12
  const INVALID_CURRENCY = 4;
13
  const INVALID_DATE = 5;
14
- const MISSING_CHECK_NAME = 27;
15
 
16
  // gateway codes
17
  const UNKNOWN_GATEWAY_ERROR = 6;
@@ -37,4 +37,9 @@ abstract class HpsExceptionCodes
37
  const PROCESSING_ERROR = 24;
38
  const ISSUER_TIMEOUT_REVERSAL_ERROR = 25;
39
  const UNKNOWN_CREDIT_ERROR = 26;
 
 
 
 
 
40
  }
11
  const MISSING_CURRENCY = 3;
12
  const INVALID_CURRENCY = 4;
13
  const INVALID_DATE = 5;
14
+ const MISSING_CHECK_NAME = 28;
15
 
16
  // gateway codes
17
  const UNKNOWN_GATEWAY_ERROR = 6;
37
  const PROCESSING_ERROR = 24;
38
  const ISSUER_TIMEOUT_REVERSAL_ERROR = 25;
39
  const UNKNOWN_CREDIT_ERROR = 26;
40
+ const POSSIBLE_FRAUD_DETECTED = 27;
41
+
42
+ // gift codes
43
+ const UNKNOWN_GIFT_ERROR = 29;
44
+ const PARTIAL_APPROVAL = 30;
45
  }
lib/SecureSubmit/src/Infrastructure/Enums/HpsTrackDataMethod.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsTrackDataMethod
4
+ {
5
+ const SWIPE = 'swipe';
6
+ const PROXIMITY = 'proximity';
7
+ }
lib/SecureSubmit/src/Infrastructure/HpsConfiguration.php CHANGED
@@ -14,5 +14,5 @@ class HpsConfiguration
14
  public $useProxy = null;
15
  public $proxyOptions = null;
16
  public $avsResponseErrors = null;
17
- public $serviceUri = "https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx";
18
  }
14
  public $useProxy = null;
15
  public $proxyOptions = null;
16
  public $avsResponseErrors = null;
17
+ public $serviceUri = "https://cert.api2.heartlandportico.com/Hps.Exchange.PosGateway/PosGatewayService.asmx";
18
  }
lib/SecureSubmit/src/Infrastructure/HpsProcessorError.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsProcessorError
4
+ {
5
+ public $code;
6
+ public $message;
7
+ public $type;
8
+ }
lib/SecureSubmit/src/Infrastructure/Validation/HpsGatewayResponseValidation.php CHANGED
@@ -34,7 +34,6 @@ class HpsGatewayResponseValidation
34
  );
35
  break;
36
  case '3':
37
- print_r($response);
38
  $e = new HpsGatewayException(
39
  HpsExceptionCodes::INVALID_ORIGINAL_TRANSACTION,
40
  $responseText,
34
  );
35
  break;
36
  case '3':
 
37
  $e = new HpsGatewayException(
38
  HpsExceptionCodes::INVALID_ORIGINAL_TRANSACTION,
39
  $responseText,
lib/SecureSubmit/src/Infrastructure/Validation/HpsIssuerResponseValidation.php CHANGED
@@ -40,6 +40,23 @@ class HpsIssuerResponseValidation
40
  '91' => HpsExceptionCodes::ISSUER_TIMEOUT,
41
  'EB' => HpsExceptionCodes::INCORRECT_CVC,
42
  'N7' => HpsExceptionCodes::INCORRECT_CVC,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  );
44
 
45
  public static $_creditExceptionCodeToMessage = array(
@@ -54,28 +71,50 @@ class HpsIssuerResponseValidation
54
  HpsExceptionCodes::INCORRECT_CVC => "The card's security code is incorrect.",
55
  HpsExceptionCodes::ISSUER_TIMEOUT => "The card issuer timed-out.",
56
  HpsExceptionCodes::UNKNOWN_CREDIT_ERROR => "An unknown issuer error has occurred.",
57
- HpsExceptionCodes::INCORRECT_NUMBER => "The card number is incorrect."
 
 
 
 
58
  );
59
 
60
- public static function checkResponse($transactionId, $responseCode, $responseText)
61
  {
62
- $e = HpsIssuerResponseValidation::getException($transactionId, $responseCode, $responseText);
 
 
 
 
 
63
 
64
  if ($e != null) {
65
  throw $e;
66
  }
67
  }
68
 
69
- public static function getException($transactionId, $responseCode, $responseText)
70
  {
71
- $responseCode = (string)$responseCode;
72
- if ($responseCode == '85' || $responseCode == '00') {
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  return null;
74
  }
75
 
76
  $code = null;
77
- if (array_key_exists($responseCode, self::$_issuerCodeToCreditExceptionCode)) {
78
- $code = self::$_issuerCodeToCreditExceptionCode[$responseCode];
79
  }
80
 
81
  if ($code == null) {
40
  '91' => HpsExceptionCodes::ISSUER_TIMEOUT,
41
  'EB' => HpsExceptionCodes::INCORRECT_CVC,
42
  'N7' => HpsExceptionCodes::INCORRECT_CVC,
43
+ 'FR' => HpsExceptionCodes::POSSIBLE_FRAUD_DETECTED,
44
+ );
45
+
46
+ public static $_issuerCodeToGiftExceptionCode = array(
47
+ '1' => HpsExceptionCodes::UNKNOWN_GIFT_ERROR,
48
+ '2' => HpsExceptionCodes::UNKNOWN_GIFT_ERROR,
49
+ '11' => HpsExceptionCodes::UNKNOWN_GIFT_ERROR,
50
+ '3' => HpsExceptionCodes::INVALID_CARD_DATA,
51
+ '8' => HpsExceptionCodes::INVALID_CARD_DATA,
52
+ '4' => HpsExceptionCodes::EXPIRED_CARD,
53
+ '5' => HpsExceptionCodes::CARD_DECLINED,
54
+ '12' => HpsExceptionCodes::CARD_DECLINED,
55
+ '6' => HpsExceptionCodes::PROCESSING_ERROR,
56
+ '7' => HpsExceptionCodes::PROCESSING_ERROR,
57
+ '10' => HpsExceptionCodes::PROCESSING_ERROR,
58
+ '9' => HpsExceptionCodes::INVALID_AMOUNT,
59
+ '13' => HpsExceptionCodes::PARTIAL_APPROVAL,
60
  );
61
 
62
  public static $_creditExceptionCodeToMessage = array(
71
  HpsExceptionCodes::INCORRECT_CVC => "The card's security code is incorrect.",
72
  HpsExceptionCodes::ISSUER_TIMEOUT => "The card issuer timed-out.",
73
  HpsExceptionCodes::UNKNOWN_CREDIT_ERROR => "An unknown issuer error has occurred.",
74
+ HpsExceptionCodes::INCORRECT_NUMBER => "The card number is incorrect.",
75
+ HpsExceptionCodes::POSSIBLE_FRAUD_DETECTED => "Possible fraud detected",
76
+ HpsExceptionCodes::UNKNOWN_GIFT_ERROR => "An unknown gift error has occurred.",
77
+ HpsExceptionCodes::PARTIAL_APPROVAL => "The amount was partially approved.",
78
+ HpsExceptionCodes::INVALID_CARD_DATA => "The card data is invalid.",
79
  );
80
 
81
+ public static function checkResponse($transactionId, $responseCode, $responseText, $type = 'credit')
82
  {
83
+ $e = HpsIssuerResponseValidation::getException(
84
+ (string)$transactionId,
85
+ (string)$responseCode,
86
+ (string)$responseText,
87
+ $type
88
+ );
89
 
90
  if ($e != null) {
91
  throw $e;
92
  }
93
  }
94
 
95
+ public static function getException($transactionId, $responseCode, $responseText, $type)
96
  {
97
+ $acceptedCodes = array('00', '0');
98
+ $map = array();
99
+
100
+ switch ($type) {
101
+ case 'credit':
102
+ $acceptedCodes = array_merge($acceptedCodes, array('85', '10'));
103
+ $map = self::$_issuerCodeToCreditExceptionCode;
104
+ break;
105
+ case 'gift':
106
+ $acceptedCodes = array_merge($acceptedCodes, array('13'));
107
+ $map = self::$_issuerCodeToGiftExceptionCode;
108
+ break;
109
+ }
110
+
111
+ if (in_array($responseCode, $acceptedCodes)) {
112
  return null;
113
  }
114
 
115
  $code = null;
116
+ if (array_key_exists($responseCode, $map)) {
117
+ $code = $map[$responseCode];
118
  }
119
 
120
  if ($code == null) {
lib/SecureSubmit/src/Infrastructure/Validation/HpsProcessorResponseValidation.php CHANGED
@@ -17,7 +17,7 @@ class HpsProcessorResponseValidation
17
  $code = null;
18
  $message = null;
19
 
20
- if ($responseCode == '0') {
21
  return null;
22
  }
23
 
17
  $code = null;
18
  $message = null;
19
 
20
+ if ($responseCode == '00') {
21
  return null;
22
  }
23
 
lib/SecureSubmit/src/Infrastructure/index.php CHANGED
@@ -1 +1 @@
1
- <?php
1
+ <?php
lib/SecureSubmit/src/Services/Fluent/Gateway/Check/HpsCheckServiceOverrideBuilder.php CHANGED
@@ -37,8 +37,8 @@ class HpsCheckServiceOverrideBuilder extends HpsBuilderAbstract
37
  {
38
  parent::execute();
39
 
40
- $saleSvc = new HpsCheckService($this->service->servicesConfig());
41
- return $saleSvc->override(
42
  $this->check,
43
  $this->amount,
44
  $this->clientTransactionId
37
  {
38
  parent::execute();
39
 
40
+ return $this->service->_buildTransaction(
41
+ 'OVERRIDE',
42
  $this->check,
43
  $this->amount,
44
  $this->clientTransactionId
lib/SecureSubmit/src/Services/Fluent/Gateway/Check/HpsCheckServiceRecurringBuilder.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * A fluent interface for creating and executing a sale
5
+ * transaction through the HpsCheckService.
6
+ *
7
+ * @method HpsCheckServiceRecurringBuilder withPaymentMethodKey(string $paymentMethodKey)
8
+ * @method HpsCheckServiceRecurringBuilder withAmount(double $amount)
9
+ * @method HpsCheckServiceRecurringBuilder withSchedule(HpsPayPlanSchedule|string $schedule)
10
+ * @method HpsCheckServiceRecurringBuilder withOneTime(bool $oneTime)
11
+ */
12
+ class HpsCheckServiceRecurringBuilder extends HpsBuilderAbstract
13
+ {
14
+ /** @var string|null */
15
+ protected $paymentMethodKey = null;
16
+
17
+ /** @var double|null */
18
+ protected $amount = null;
19
+
20
+ /** @var HpsPayPlanSchedule|string|null */
21
+ protected $schedule = null;
22
+
23
+ /** @var bool */
24
+ protected $oneTime = false;
25
+
26
+ /**
27
+ * Instatiates a new HpsCheckServiceRecurringBuilder
28
+ *
29
+ * @param HpsSoapGatewayService $service
30
+ */
31
+ public function __construct(HpsSoapGatewayService $service)
32
+ {
33
+ parent::__construct($service);
34
+ $this->setUpValidations();
35
+ }
36
+
37
+ /**
38
+ * Creates a sale transaction through the HpsCheckService
39
+ */
40
+ public function execute()
41
+ {
42
+ parent::execute();
43
+
44
+ HpsInputValidation::checkAmount($this->amount);
45
+
46
+ $xml = new DOMDocument();
47
+ $hpsTransaction = $xml->createElement('hps:Transaction');
48
+ $hpsCheckSale = $xml->createElement('hps:CheckSale');
49
+ $hpsBlock1 = $xml->createElement('hps:Block1');
50
+
51
+ $hpsBlock1->appendChild($xml->createElement('hps:Amt', sprintf("%0.2f", round($this->amount, 3))));
52
+ $hpsBlock1->appendChild($xml->createElement('hps:CheckAction', 'SALE'));
53
+ $hpsBlock1->appendChild($xml->createElement('hps:PaymentMethodKey', $this->paymentMethodKey));
54
+
55
+ $recurringData = $xml->createElement('hps:RecurringData');
56
+ if ($this->schedule != null) {
57
+ $scheduleKey = $this->schedule;
58
+ if ($this->schedule instanceof HpsPayPlanSchedule) {
59
+ $scheduleKey = $this->schedule->scheduleKey;
60
+ }
61
+ $recurringData->appendChild($xml->createElement('hps:ScheduleID', $scheduleKey));
62
+ }
63
+ $recurringData->appendChild($xml->createElement('hps:OneTime', ($this->oneTime ? 'Y' : 'N')));
64
+
65
+ $hpsBlock1->appendChild($recurringData);
66
+ $hpsCheckSale->appendChild($hpsBlock1);
67
+ $hpsTransaction->appendChild($hpsCheckSale);
68
+
69
+ return $this->service->_submitTransaction($hpsTransaction, 'CheckSale');
70
+ }
71
+
72
+ /**
73
+ * Setups up validations for building sales.
74
+ *
75
+ * @return null
76
+ */
77
+ private function setUpValidations()
78
+ {
79
+ $this
80
+ ->addValidation(array($this, 'paymentMethodKeyNotNull'), 'HpsArgumentException', 'Sale needs a payment method key')
81
+ ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Sale needs an amount');
82
+ }
83
+
84
+ /**
85
+ * Ensures an amount has been set.
86
+ *
87
+ * @param array $actionCounts
88
+ *
89
+ * @return bool
90
+ */
91
+ protected function amountNotNull($actionCounts)
92
+ {
93
+ return isset($actionCounts['amount']);
94
+ }
95
+
96
+ /**
97
+ * Ensures a paymentMethodKey has been set.
98
+ *
99
+ * @param array $actionCounts
100
+ *
101
+ * @return bool
102
+ */
103
+ protected function paymentMethodKeyNotNull($actionCounts)
104
+ {
105
+ return isset($actionCounts['paymentMethodKey']) && $actionCounts['paymentMethodKey'] == 1;
106
+ }
107
+ }
lib/SecureSubmit/src/Services/Fluent/Gateway/Check/HpsCheckServiceReturnBuilder.php CHANGED
@@ -37,8 +37,8 @@ class HpsCheckServiceReturnBuilder extends HpsBuilderAbstract
37
  {
38
  parent::execute();
39
 
40
- $returnSvc = new HpsCheckService($this->service->servicesConfig());
41
- return $returnSvc->returnCheck(
42
  $this->check,
43
  $this->amount,
44
  $this->clientTransactionId
37
  {
38
  parent::execute();
39
 
40
+ return $this->service->_buildTransaction(
41
+ 'RETURN',
42
  $this->check,
43
  $this->amount,
44
  $this->clientTransactionId
lib/SecureSubmit/src/Services/Fluent/Gateway/Check/HpsCheckServiceSaleBuilder.php CHANGED
@@ -7,6 +7,8 @@
7
  * @method HpsCheckServiceSaleBuilder withCheck(HpsCheck $check)
8
  * @method HpsCheckServiceSaleBuilder withAmount(double $amount)
9
  * @method HpsCheckServiceSaleBuilder withClientTransactionId(string $clientTransactionId)
 
 
10
  */
11
  class HpsCheckServiceSaleBuilder extends HpsBuilderAbstract
12
  {
@@ -19,6 +21,12 @@ class HpsCheckServiceSaleBuilder extends HpsBuilderAbstract
19
  /** @var string|null */
20
  protected $clientTransactionId = null;
21
 
 
 
 
 
 
 
22
  /**
23
  * Instatiates a new HpsCheckServiceSaleBuilder
24
  *
@@ -37,11 +45,13 @@ class HpsCheckServiceSaleBuilder extends HpsBuilderAbstract
37
  {
38
  parent::execute();
39
 
40
- $saleSvc = new HpsCheckService($this->service->servicesConfig());
41
- return $saleSvc->sale(
42
  $this->check,
43
  $this->amount,
44
- $this->clientTransactionId
 
 
45
  );
46
  }
47
 
@@ -66,6 +76,9 @@ class HpsCheckServiceSaleBuilder extends HpsBuilderAbstract
66
  */
67
  protected function amountNotNull($actionCounts)
68
  {
 
 
 
69
  return isset($actionCounts['amount']);
70
  }
71
 
7
  * @method HpsCheckServiceSaleBuilder withCheck(HpsCheck $check)
8
  * @method HpsCheckServiceSaleBuilder withAmount(double $amount)
9
  * @method HpsCheckServiceSaleBuilder withClientTransactionId(string $clientTransactionId)
10
+ * @method HpsCheckServiceSaleBuilder withCheckVerify(bool $checkVerify)
11
+ * @method HpsCheckServiceSaleBuilder withACHVerify(bool $achVerify)
12
  */
13
  class HpsCheckServiceSaleBuilder extends HpsBuilderAbstract
14
  {
21
  /** @var string|null */
22
  protected $clientTransactionId = null;
23
 
24
+ /** @var bool */
25
+ protected $checkVerify = false;
26
+
27
+ /** @var bool */
28
+ protected $achVerify = false;
29
+
30
  /**
31
  * Instatiates a new HpsCheckServiceSaleBuilder
32
  *
45
  {
46
  parent::execute();
47
 
48
+ return $this->service->_buildTransaction(
49
+ 'SALE',
50
  $this->check,
51
  $this->amount,
52
+ $this->clientTransactionId,
53
+ $this->checkVerify,
54
+ $this->achVerify
55
  );
56
  }
57
 
76
  */
77
  protected function amountNotNull($actionCounts)
78
  {
79
+ if ($this->checkVerify || $this->achVerify) {
80
+ return true;
81
+ }
82
  return isset($actionCounts['amount']);
83
  }
84
 
lib/SecureSubmit/src/Services/Fluent/Gateway/Check/HpsCheckServiceVoidBuilder.php CHANGED
@@ -33,11 +33,20 @@ class HpsCheckServiceVoidBuilder extends HpsBuilderAbstract
33
  {
34
  parent::execute();
35
 
36
- $voidSvc = new HpsCheckService($this->service->servicesConfig());
37
- return $voidSvc->void(
38
- $this->transactionId,
39
- $this->clientTransactionId
40
- );
 
 
 
 
 
 
 
 
 
41
  }
42
 
43
  /**
33
  {
34
  parent::execute();
35
 
36
+ $xml = new DOMDocument();
37
+ $hpsTransaction = $xml->createElement('hps:Transaction');
38
+ $hpsCheckVoid = $xml->createElement('hps:CheckVoid');
39
+ $hpsBlock1 = $xml->createElement('hps:Block1');
40
+
41
+ if ($this->transactionId != null) {
42
+ $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId));
43
+ } else if ($this->clientTransactionId != null) {
44
+ $hpsBlock1->appendChild($xml->createElement('hps:ClientTxnId', $this->clientTransactionId));
45
+ }
46
+
47
+ $hpsCheckVoid->appendChild($hpsBlock1);
48
+ $hpsTransaction->appendChild($hpsCheckVoid);
49
+ return $this->service->_submitTransaction($hpsTransaction, 'CheckVoid');
50
  }
51
 
52
  /**
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceAuthorizeBuilder.php CHANGED
@@ -8,44 +8,80 @@
8
  * @method HpsCreditServiceAuthorizeBuilder withCurrency(string $currency)
9
  * @method HpsCreditServiceAuthorizeBuilder withCard(HpsCreditCard $card)
10
  * @method HpsCreditServiceAuthorizeBuilder withToken(HpsTokenData $token)
 
11
  * @method HpsCreditServiceAuthorizeBuilder withCardHolder(HpsCardHolder $cardHolder)
12
  * @method HpsCreditServiceAuthorizeBuilder withRequestMultiUseToken(bool $requestMultiUseToken)
13
  * @method HpsCreditServiceAuthorizeBuilder withDetails(HpsTransactionDetails $details)
14
  * @method HpsCreditServiceAuthorizeBuilder withTxnDescriptor(string $txnDescriptor)
15
  * @method HpsCreditServiceAuthorizeBuilder withAllowPartialAuth(bool $allowPartialAuth)
16
  * @method HpsCreditServiceAuthorizeBuilder withCpcReq(bool $cpcReq)
 
 
 
 
 
 
 
 
17
  */
18
  class HpsCreditServiceAuthorizeBuilder extends HpsBuilderAbstract
19
  {
20
  /** @var double|null */
21
- protected $amount = null;
22
 
23
  /** @var string|null */
24
- protected $currency = null;
25
 
26
  /** @var HpsCreditCard|null */
27
- protected $card = null;
28
 
29
  /** @var HpsTokenData|null */
30
- protected $token = null;
 
 
 
31
 
32
  /** @var HpsCardHolder|null */
33
- protected $cardHolder = null;
34
 
35
- /** @var bool|null */
36
- protected $requestMultiUseToken = false;
37
 
38
  /** @var HpsTransactionDetails|null */
39
- protected $details = null;
40
 
41
  /** @var string|null */
42
- protected $txnDescriptor = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
- /** @var bool|null */
45
- protected $allowPartialAuth = false;
46
 
47
- /** @var bool|null */
48
- protected $cpcReq = false;
49
 
50
  /**
51
  * Instatiates a new HpsCreditServiceAuthorizeBuilder
@@ -65,18 +101,93 @@ class HpsCreditServiceAuthorizeBuilder extends HpsBuilderAbstract
65
  {
66
  parent::execute();
67
 
68
- $authorizationSvc = new HpsCreditService($this->service->servicesConfig());
69
- return $authorizationSvc->authorize(
70
- $this->amount,
71
- $this->currency,
72
- isset($this->card) ? $this->card : $this->token,
73
- $this->cardHolder,
74
- $this->requestMultiUseToken,
75
- $this->details,
76
- $this->txnDescriptor,
77
- $this->allowPartialAuth,
78
- $this->cpcReq
79
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
 
82
  /**
8
  * @method HpsCreditServiceAuthorizeBuilder withCurrency(string $currency)
9
  * @method HpsCreditServiceAuthorizeBuilder withCard(HpsCreditCard $card)
10
  * @method HpsCreditServiceAuthorizeBuilder withToken(HpsTokenData $token)
11
+ * @method HpsCreditServiceAuthorizeBuilder withTrackData(HpsTrackData $trackData)
12
  * @method HpsCreditServiceAuthorizeBuilder withCardHolder(HpsCardHolder $cardHolder)
13
  * @method HpsCreditServiceAuthorizeBuilder withRequestMultiUseToken(bool $requestMultiUseToken)
14
  * @method HpsCreditServiceAuthorizeBuilder withDetails(HpsTransactionDetails $details)
15
  * @method HpsCreditServiceAuthorizeBuilder withTxnDescriptor(string $txnDescriptor)
16
  * @method HpsCreditServiceAuthorizeBuilder withAllowPartialAuth(bool $allowPartialAuth)
17
  * @method HpsCreditServiceAuthorizeBuilder withCpcReq(bool $cpcReq)
18
+ * @method HpsCreditServiceAuthorizeBuilder withAllowDuplicates(bool $allowDuplicates)
19
+ * @method HpsCreditServiceAuthorizeBuilder withPaymentData(HpsPaymentData $paymentData)
20
+ * @method HpsCreditServiceAuthorizeBuilder withCardPresent(bool $cardPresent)
21
+ * @method HpsCreditServiceAuthorizeBuilder withReaderPresent(bool $readerPresent)
22
+ * @method HpsCreditServiceAuthorizeBuilder withGratuity(double $gratuity)
23
+ * @method HpsCreditServiceAuthorizeBuilder withAutoSubstantiation(HpsAutoSubstantiation $autoSubstantiation)
24
+ * @method HpsCreditServiceAuthorizeBuilder withOriginalTxnReferenceData(HpsOriginalTxnReferenceData $originalTxnReferenceData)
25
+ * @method HpsCreditServiceAuthorizeBuilder withDirectMarketData(HpsDirectMarketData $directMarketData)
26
  */
27
  class HpsCreditServiceAuthorizeBuilder extends HpsBuilderAbstract
28
  {
29
  /** @var double|null */
30
+ protected $amount = null;
31
 
32
  /** @var string|null */
33
+ protected $currency = null;
34
 
35
  /** @var HpsCreditCard|null */
36
+ protected $card = null;
37
 
38
  /** @var HpsTokenData|null */
39
+ protected $token = null;
40
+
41
+ /** @var HpsTrackData|null */
42
+ protected $trackData = null;
43
 
44
  /** @var HpsCardHolder|null */
45
+ protected $cardHolder = null;
46
 
47
+ /** @var bool */
48
+ protected $requestMultiUseToken = false;
49
 
50
  /** @var HpsTransactionDetails|null */
51
+ protected $details = null;
52
 
53
  /** @var string|null */
54
+ protected $txnDescriptor = null;
55
+
56
+ /** @var bool */
57
+ protected $allowPartialAuth = false;
58
+
59
+ /** @var bool */
60
+ protected $cpcReq = false;
61
+
62
+ /** @var bool */
63
+ protected $allowDuplicates = false;
64
+
65
+ /** @var HpsPaymentData|null */
66
+ protected $paymentData = null;
67
+
68
+ /** @var bool */
69
+ protected $cardPresent = false;
70
+
71
+ /** @var bool */
72
+ protected $readerPresent = false;
73
+
74
+ /** @var double|null */
75
+ protected $gratuity = null;
76
+
77
+ /** @var HpsAutoSubstantiation|null */
78
+ protected $autoSubstantiation = null;
79
 
80
+ /** @var HpsOriginalTxnReferenceData|null */
81
+ protected $originalTxnReferenceData = null;
82
 
83
+ /** @var HpsDirectMarketData|null */
84
+ protected $directMarketData = null;
85
 
86
  /**
87
  * Instatiates a new HpsCreditServiceAuthorizeBuilder
101
  {
102
  parent::execute();
103
 
104
+ HpsInputValidation::checkCurrency($this->currency);
105
+ HpsInputValidation::checkAmount($this->amount);
106
+
107
+ $xml = new DOMDocument();
108
+ $hpsTransaction = $xml->createElement('hps:Transaction');
109
+ $hpsCreditAuth = $xml->createElement('hps:CreditAuth');
110
+ $hpsBlock1 = $xml->createElement('hps:Block1');
111
+
112
+ $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', ($this->allowDuplicates ? 'Y' : 'N')));
113
+ $hpsBlock1->appendChild($xml->createElement('hps:AllowPartialAuth', ($this->allowPartialAuth ? 'Y' : 'N')));
114
+ $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
115
+
116
+ if ($this->gratuity != null) {
117
+ $hpsBlock1->appendChild($xml->createElement('hps:GratuityAmtInfo', $this->gratuity));
118
+ }
119
+
120
+ if ($this->cardHolder != null) {
121
+ $hpsBlock1->appendChild($this->service->_hydrateCardHolderData($this->cardHolder, $xml));
122
+ }
123
+
124
+ $cardData = $xml->createElement('hps:CardData');
125
+ if ($this->card != null) {
126
+ $cardData->appendChild($this->service->_hydrateManualEntry(
127
+ $this->card,
128
+ $xml,
129
+ $this->cardPresent,
130
+ $this->readerPresent
131
+ ));
132
+ if ($this->card->encryptionData != null) {
133
+ $cardData->appendChild($this->service->_hydrateEncryptionData($this->card->encryptionData, $xml));
134
+ }
135
+ } else if ($this->token != null) {
136
+ $cardData->appendChild($this->service->_hydrateTokenData(
137
+ $this->token,
138
+ $xml,
139
+ $this->cardPresent,
140
+ $this->readerPresent
141
+ ));
142
+ } else if ($this->trackData != null) {
143
+ $cardData->appendChild($this->service->_hydrateTrackData($this->trackData, $xml));
144
+ if ($this->trackData->encryptionData != null) {
145
+ $cardData->appendChild($this->service->_hydrateEncryptionData($this->trackData->encryptionData, $xml));
146
+ }
147
+ } else if ($this->paymentData != null) {
148
+ $manualEntry = $xml->createElement('hps:ManualEntry');
149
+ $manualEntry->appendChild($xml->createElement('hps:CardNbr', $this->paymentData->applicationPrimaryAccountNumber));
150
+ $expDate = (string)$this->paymentData->applicationExpirationDate;
151
+ $manualEntry->appendChild($xml->createElement('hps:ExpMonth', substr($expDate, 2, 2)));
152
+ $manualEntry->appendChild($xml->createElement('hps:ExpYear', '20'.substr($expDate, 0, 2)));
153
+ $cardData->appendChild($manualEntry);
154
+ }
155
+
156
+ $cardData->appendChild($xml->createElement('hps:TokenRequest', ($this->requestMultiUseToken ? 'Y' : 'N')));
157
+
158
+ $hpsBlock1->appendChild($cardData);
159
+
160
+ if ($this->paymentData != null) {
161
+ $hpsBlock1->appendChild($this->service->_hydrateSecureEcommerce($this->paymentData->paymentData, $xml));
162
+ }
163
+
164
+ if ($this->cpcReq == true) {
165
+ $hpsBlock1->appendChild($xml->createElement('hps:CPCReq', 'Y'));
166
+ }
167
+
168
+ if ($this->details != null) {
169
+ $hpsBlock1->appendChild($this->service->_hydrateAdditionalTxnFields($this->details, $xml));
170
+ }
171
+
172
+ if ($this->txnDescriptor != null) {
173
+ $hpsBlock1->appendChild($xml->createElement('hps:TxnDescriptor', $this->txnDescriptor));
174
+ }
175
+
176
+ if ($this->autoSubstantiation != null) {
177
+ $hpsBlock1->appendChild($this->service->_hydrateAutoSubstantiation($this->autoSubstantiation, $xml));
178
+ }
179
+
180
+ if ($this->originalTxnReferenceData != null) {
181
+ $refElement = $xml->createElement('hps:OrigTxnRefData');
182
+ $refElement->appendChild($xml->createElement('hps:AuthCode', $this->originalTxnReferenceData->authorizationCode));
183
+ $refElement->appendChild($xml->createElement('hps:CardNbrLastFour', $this->originalTxnReferenceData->cardNumberLast4));
184
+ $hpsBlock1->appendChild($refElement);
185
+ }
186
+
187
+ $hpsCreditAuth->appendChild($hpsBlock1);
188
+ $hpsTransaction->appendChild($hpsCreditAuth);
189
+
190
+ return $this->service->_submitTransaction($hpsTransaction, 'CreditAuth', (isset($this->details->clientTransactionId) ? $this->details->clientTransactionId : null));
191
  }
192
 
193
  /**
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceCaptureBuilder.php CHANGED
@@ -45,14 +45,30 @@ class HpsCreditServiceCaptureBuilder extends HpsBuilderAbstract
45
  {
46
  parent::execute();
47
 
48
- $captureSvc = new HpsCreditService($this->service->servicesConfig());
49
- return $captureSvc->capture(
50
- $this->transactionId,
51
- $this->amount,
52
- $this->gratuity,
53
- $this->clientTransactionId,
54
- $this->directMarketData
55
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
 
58
  /**
45
  {
46
  parent::execute();
47
 
48
+ $xml = new DOMDocument();
49
+ $hpsTransaction = $xml->createElement('hps:Transaction');
50
+ $hpsCreditAddToBatch = $xml->createElement('hps:CreditAddToBatch');
51
+
52
+ $hpsCreditAddToBatch->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId));
53
+ if ($this->amount != null) {
54
+ $amount = sprintf("%0.2f", round($this->amount, 3));
55
+ $hpsCreditAddToBatch->appendChild($xml->createElement('hps:Amt', $amount));
56
+ }
57
+ if ($this->gratuity != null) {
58
+ $hpsCreditAddToBatch->appendChild($xml->createElement('hps:GratuityAmtInfo', $this->gratuity));
59
+ }
60
+
61
+ if ($this->directMarketData != null && $this->directMarketData->invoiceNumber != null) {
62
+ $hpsCreditAddToBatch->appendChild($this->_hydrateDirectMarketData($this->directMarketData, $xml));
63
+ }
64
+
65
+ $hpsTransaction->appendChild($hpsCreditAddToBatch);
66
+ $response = $this->doRequest($hpsTransaction);
67
+ $this->_processChargeGatewayResponse($response, 'CreditAddToBatch');
68
+
69
+ return $this->service
70
+ ->get($this->transactionId)
71
+ ->execute();
72
  }
73
 
74
  /**
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceChargeBuilder.php CHANGED
@@ -15,42 +15,59 @@
15
  * @method HpsCreditServiceChargeBuilder withAllowPartialAuth(bool $allowPartialAuth)
16
  * @method HpsCreditServiceChargeBuilder withCpcReq(bool $cpcReq)
17
  * @method HpsCreditServiceChargeBuilder withDirectMarketData(HpsDirectMarketData $directMarketData)
 
 
18
  */
19
  class HpsCreditServiceChargeBuilder extends HpsBuilderAbstract
20
  {
21
  /** @var double|null */
22
- protected $amount = null;
23
 
24
  /** @var string|null */
25
- protected $currency = null;
26
 
27
  /** @var HpsCreditCard|null */
28
- protected $card = null;
29
 
30
  /** @var HpsTokenData|null */
31
- protected $token = null;
32
 
33
  /** @var HpsCardHolder|null */
34
- protected $cardHolder = null;
35
 
36
  /** @var bool|null */
37
- protected $requestMultiUseToken = false;
38
 
39
  /** @var HpsTransactionDetails|null */
40
- protected $details = null;
41
 
42
  /** @var string|null */
43
- protected $txnDescriptor = null;
44
 
45
  /** @var bool|null */
46
- protected $allowPartialAuth = false;
47
 
48
  /** @var bool|null */
49
- protected $cpcReq = false;
50
 
51
  /** @var HpsDirectMarketData|null */
52
  protected $directMarketData = null;
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  /**
55
  * Instatiates a new HpsCreditServiceChargeBuilder
56
  *
@@ -69,19 +86,96 @@ class HpsCreditServiceChargeBuilder extends HpsBuilderAbstract
69
  {
70
  parent::execute();
71
 
72
- $chargeSvc = new HpsCreditService($this->service->servicesConfig());
73
- return $chargeSvc->charge(
74
- $this->amount,
75
- $this->currency,
76
- isset($this->card) ? $this->card : $this->token,
77
- $this->cardHolder,
78
- $this->requestMultiUseToken,
79
- $this->details,
80
- $this->txnDescriptor,
81
- $this->allowPartialAuth,
82
- $this->cpcReq,
83
- $this->directMarketData
84
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  }
86
 
87
  /**
@@ -92,9 +186,9 @@ class HpsCreditServiceChargeBuilder extends HpsBuilderAbstract
92
  private function setUpValidations()
93
  {
94
  $this
95
- ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Charge can only use one payment method')
96
  ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Charge needs an amount')
97
- ->addValidation(array($this, 'currencyNotNull'), 'HpsArgumentException', 'Charge needs an currency');
 
98
  }
99
 
100
  /**
@@ -108,12 +202,17 @@ class HpsCreditServiceChargeBuilder extends HpsBuilderAbstract
108
  */
109
  public function onlyOnePaymentMethod($actionCounts)
110
  {
111
- return (isset($actionCounts['card']) && $actionCounts['card'] == 1
112
- && (!isset($actionCounts['token'])
113
- || isset($actionCounts['token']) && $actionCounts['token'] == 0))
114
- || (isset($actionCounts['token']) && $actionCounts['token'] == 1
115
- && (!isset($actionCounts['card'])
116
- || isset($actionCounts['card']) && $actionCounts['card'] == 0));
 
 
 
 
 
117
  }
118
 
119
  /**
15
  * @method HpsCreditServiceChargeBuilder withAllowPartialAuth(bool $allowPartialAuth)
16
  * @method HpsCreditServiceChargeBuilder withCpcReq(bool $cpcReq)
17
  * @method HpsCreditServiceChargeBuilder withDirectMarketData(HpsDirectMarketData $directMarketData)
18
+ * @method HpsCreditServiceChargeBuilder withAllowDuplicates(bool $allowDuplicates)
19
+ * @method HpsCreditServiceChargeBuilder withGratuity(double $gratuity)
20
  */
21
  class HpsCreditServiceChargeBuilder extends HpsBuilderAbstract
22
  {
23
  /** @var double|null */
24
+ protected $amount = null;
25
 
26
  /** @var string|null */
27
+ protected $currency = null;
28
 
29
  /** @var HpsCreditCard|null */
30
+ protected $card = null;
31
 
32
  /** @var HpsTokenData|null */
33
+ protected $token = null;
34
 
35
  /** @var HpsCardHolder|null */
36
+ protected $cardHolder = null;
37
 
38
  /** @var bool|null */
39
+ protected $requestMultiUseToken = false;
40
 
41
  /** @var HpsTransactionDetails|null */
42
+ protected $details = null;
43
 
44
  /** @var string|null */
45
+ protected $txnDescriptor = null;
46
 
47
  /** @var bool|null */
48
+ protected $allowPartialAuth = false;
49
 
50
  /** @var bool|null */
51
+ protected $cpcReq = false;
52
 
53
  /** @var HpsDirectMarketData|null */
54
  protected $directMarketData = null;
55
 
56
+ /** @var bool|null */
57
+ protected $allowDuplicates = false;
58
+
59
+ /** @var double|null */
60
+ protected $gratuity = null;
61
+
62
+ /** @var bool|null */
63
+ protected $cardPresent = false;
64
+
65
+ /** @var bool|null */
66
+ protected $readerPresent = false;
67
+
68
+ protected $originalTxnReferenceData = null;
69
+ protected $paymentData = null;
70
+
71
  /**
72
  * Instatiates a new HpsCreditServiceChargeBuilder
73
  *
86
  {
87
  parent::execute();
88
 
89
+ HpsInputValidation::checkCurrency($this->currency);
90
+ HpsInputValidation::checkAmount($this->amount);
91
+
92
+ $xml = new DOMDocument();
93
+ $hpsTransaction = $xml->createElement('hps:Transaction');
94
+ $hpsCreditSale = $xml->createElement('hps:CreditSale');
95
+ $hpsBlock1 = $xml->createElement('hps:Block1');
96
+
97
+ $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', ($this->allowDuplicates ? 'Y' : 'N')));
98
+ $hpsBlock1->appendChild($xml->createElement('hps:AllowPartialAuth', ($this->allowPartialAuth ? 'Y' : 'N')));
99
+ $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
100
+
101
+ if ($this->gratuity != null) {
102
+ $hpsBlock1->appendChild($xml->createElement('hps:GratuityAmtInfo', $this->gratuity));
103
+ }
104
+
105
+ if ($this->cardHolder != null) {
106
+ $hpsBlock1->appendChild($this->service->_hydrateCardHolderData($this->cardHolder, $xml));
107
+ }
108
+
109
+ $cardData = $xml->createElement('hps:CardData');
110
+ if ($this->card != null) {
111
+ $cardData->appendChild($this->service->_hydrateManualEntry(
112
+ $this->card,
113
+ $xml,
114
+ $this->cardPresent,
115
+ $this->readerPresent
116
+ ));
117
+ if ($this->card->encryptionData != null) {
118
+ $cardData->appendChild($this->service->_hydrateEncryptionData(
119
+ $this->card->encryptionData
120
+ ));
121
+ }
122
+ } else if ($this->token != null) {
123
+ $cardData->appendChild($this->service->_hydrateTokenData(
124
+ $this->token,
125
+ $xml,
126
+ $this->cardPresent,
127
+ $this->readerPresent
128
+ ));
129
+ } else if ($this->trackData != null) {
130
+ $cardData->appendChild($this->service->_hydrateTrackData($this->trackData));
131
+ if ($this->trackData->encryptionData != null) {
132
+ $cardData->appendChild($this->service->_hydrateEncryptionData(
133
+ $this->trackData->encryptionData
134
+ ));
135
+ }
136
+ } else if ($this->paymentData != null) {
137
+ $manualEntry = $xml->createElement('hps:ManualEntry');
138
+ $manualEntry->appendChild($xml->createElement('hps:CardNbr', $this->paymentData->applicationPrimaryAccountNumber));
139
+ $expDate = $this->paymentData->applicationExpirationDate;
140
+ $manualEntry->appendChild($xml->createElement('hps:ExpMonth', substr($expDate, 2, 2)));
141
+ $manualEntry->appendChild($xml->createElement('hps:ExpYear', '20' . substr($expDate, 0, 2)));
142
+ $cardData->appendChild($manualEntry);
143
+ }
144
+
145
+ if ($this->cpcReq) {
146
+ $hpsBlock1->appendChild($xml->createElement('hps:CPCReq', 'Y'));
147
+ }
148
+
149
+ $cardData->appendChild($xml->createElement('hps:TokenRequest', ($this->requestMultiUseToken ? 'Y' : 'N')));
150
+
151
+ if ($this->details != null) {
152
+ $hpsBlock1->appendChild($this->service->_hydrateAdditionalTxnFields($this->details, $xml));
153
+ }
154
+
155
+ if ($this->txnDescriptor != null && $this->txnDescriptor != '') {
156
+ $hpsBlock1->appendChild($xml->createElement('hps:TxnDescriptor', $this->txnDescriptor));
157
+ }
158
+
159
+ if ($this->directMarketData != null && $this->directMarketData->invoiceNumber != null) {
160
+ $hpsBlock1->appendChild($this->service->_hydrateDirectMarketData($this->directMarketData, $xml));
161
+ }
162
+
163
+ if ($this->originalTxnReferenceData != null) {
164
+ $refElement = $xml->createElement('hps:OrigTxnRefData');
165
+ $refElement->appendChild($xml->createElement('hps:AuthCode', $this->originalTxnReferenceData->authorizationCode));
166
+ $refElement->appendChild($xml->createElement('hps:CardNbrLastFour', $this->originalTxnReferenceData->cardNumberLast4));
167
+ }
168
+
169
+ $hpsBlock1->appendChild($cardData);
170
+
171
+ if ($this->paymentData != null) {
172
+ $hpsBlock1->appendChild($this->service->_hydrateSecureEcommerce($this->paymentData->paymentData, $xml));
173
+ }
174
+
175
+ $hpsCreditSale->appendChild($hpsBlock1);
176
+ $hpsTransaction->appendChild($hpsCreditSale);
177
+
178
+ return $this->service->_submitTransaction($hpsTransaction, 'CreditSale', (isset($details->clientTransactionId) ? $details->clientTransactionId : null));
179
  }
180
 
181
  /**
186
  private function setUpValidations()
187
  {
188
  $this
 
189
  ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Charge needs an amount')
190
+ ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Charge can only use one payment method')
191
+ ->addValidation(array($this, 'currencyNotNull'), 'HpsArgumentException', 'Charge needs a currency');
192
  }
193
 
194
  /**
202
  */
203
  public function onlyOnePaymentMethod($actionCounts)
204
  {
205
+ $methods = 0;
206
+ if (isset($actionCounts['card']) && $actionCounts['card'] == 1) {
207
+ $methods++;
208
+ }
209
+ if (isset($actionCounts['token']) && $actionCounts['token'] == 1) {
210
+ $methods++;
211
+ }
212
+ if (isset($actionCounts['trackData']) && $actionCounts['trackData'] == 1) {
213
+ $methods++;
214
+ }
215
+ return $methods == 1;
216
  }
217
 
218
  /**
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceCpcEditBuilder.php CHANGED
@@ -33,11 +33,14 @@ class HpsCreditServiceCpcEditBuilder extends HpsBuilderAbstract
33
  {
34
  parent::execute();
35
 
36
- $cpcEditSvc = new HpsCreditService($this->service->servicesConfig());
37
- return $cpcEditSvc->cpcEdit(
38
- $this->transactionId,
39
- $this->cpcData
40
- );
 
 
 
41
  }
42
 
43
  /**
33
  {
34
  parent::execute();
35
 
36
+ $xml = new DOMDocument();
37
+ $hpsTransaction = $xml->createElement('hps:Transaction');
38
+ $hpsPosCreditCPCEdit = $xml->createElement('hps:CreditCPCEdit');
39
+ $hpsPosCreditCPCEdit->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId));
40
+ $hpsPosCreditCPCEdit->appendChild($this->service->_hydrateCPCData($this->cpcData, $xml));
41
+ $hpsTransaction->appendChild($hpsPosCreditCPCEdit);
42
+
43
+ return $this->service->_submitTransaction($hpsTransaction, 'CreditCPCEdit');
44
  }
45
 
46
  /**
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceEditBuilder.php CHANGED
@@ -41,13 +41,26 @@ class HpsCreditServiceEditBuilder extends HpsBuilderAbstract
41
  {
42
  parent::execute();
43
 
44
- $editSvc = new HpsCreditService($this->service->servicesConfig());
45
- return $editSvc->edit(
46
- $this->transactionId,
47
- $this->amount,
48
- $this->gratuity,
49
- $this->clientTransactionId
50
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  }
52
 
53
  /**
41
  {
42
  parent::execute();
43
 
44
+ $xml = new DOMDocument();
45
+ $hpsTransaction = $xml->createElement('hps:Transaction');
46
+ $hpsCreditTxnEdit = $xml->createElement('hps:CreditTxnEdit');
47
+
48
+ $hpsCreditTxnEdit->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId));
49
+ if ($this->amount != null) {
50
+ $amount = sprintf('%0.2f', round($this->amount, 3));
51
+ $hpsCreditTxnEdit->appendChild($xml->createElement('hps:Amt', $amount));
52
+ }
53
+ if ($this->gratuity != null) {
54
+ $hpsCreditTxnEdit->appendChild($xml->createElement('hps:GratuityAmtInfo', $this->gratuity));
55
+ }
56
+
57
+ $hpsTransaction->appendChild($hpsCreditTxnEdit);
58
+ $trans = $this->service->_submitTransaction($hpsTransaction, 'CreditTxnEdit', $this->clientTransactionId);
59
+
60
+ $trans->responseCode = '00';
61
+ $trans->responseText = '';
62
+
63
+ return $trans;
64
  }
65
 
66
  /**
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceGetBuilder.php CHANGED
@@ -29,8 +29,17 @@ class HpsCreditServiceGetBuilder extends HpsBuilderAbstract
29
  {
30
  parent::execute();
31
 
32
- $getSvc = new HpsCreditService($this->service->servicesConfig());
33
- return $getSvc->get($this->transactionId);
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
  /**
29
  {
30
  parent::execute();
31
 
32
+ if ($this->transactionId <= 0) {
33
+ throw new HpsArgumentException('Invalid Transaction Id');
34
+ }
35
+
36
+ $xml = new DOMDocument();
37
+ $hpsTransaction = $xml->createElement('hps:Transaction');
38
+ $hpsReportTxnDetail = $xml->createElement('hps:ReportTxnDetail');
39
+ $hpsReportTxnDetail->appendChild($xml->createElement('hps:TxnId', $this->transactionId));
40
+ $hpsTransaction->appendChild($hpsReportTxnDetail);
41
+
42
+ return $this->service->_submitTransaction($hpsTransaction, 'ReportTxnDetail');
43
  }
44
 
45
  /**
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceListTransactionsBuilder.php CHANGED
@@ -38,12 +38,22 @@ class HpsCreditServiceListTransactionsBuilder extends HpsBuilderAbstract
38
  {
39
  parent::execute();
40
 
41
- $listTransactionsSvc = new HpsCreditService($this->service->servicesConfig());
42
- return $listTransactionsSvc->listTransactions(
43
- $this->startDate,
44
- $this->endDate,
45
- $this->filterBy
46
- );
 
 
 
 
 
 
 
 
 
 
47
  }
48
 
49
  /**
38
  {
39
  parent::execute();
40
 
41
+ date_default_timezone_set("UTC");
42
+ $dateFormat = 'Y-m-d\TH:i:s.00\Z';
43
+ $current = new DateTime();
44
+ $currentTime = $current->format($dateFormat);
45
+
46
+ HpsInputValidation::checkDateNotFuture($this->startDate);
47
+ HpsInputValidation::checkDateNotFuture($this->endDate);
48
+
49
+ $xml = new DOMDocument();
50
+ $hpsTransaction = $xml->createElement('hps:Transaction');
51
+ $hpsReportActivity = $xml->createElement('hps:ReportActivity');
52
+ $hpsReportActivity->appendChild($xml->createElement('hps:RptStartUtcDT', $this->startDate));
53
+ $hpsReportActivity->appendChild($xml->createElement('hps:RptEndUtcDT', $this->endDate));
54
+ $hpsTransaction->appendChild($hpsReportActivity);
55
+
56
+ return $this->service->_submitTransaction($hpsTransaction, 'ReportActivity');
57
  }
58
 
59
  /**
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceOfflineAuthBuilder.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * A fluent interface for creating and executing a offline auth
5
+ * transaction through the HpsCreditService.
6
+ *
7
+ * @method HpsCreditServiceOfflineAuthBuilder withAmount(double $amount)
8
+ * @method HpsCreditServiceOfflineAuthBuilder withCurrency(string $currency)
9
+ * @method HpsCreditServiceOfflineAuthBuilder withCard(HpsCreditCard $card)
10
+ * @method HpsCreditServiceOfflineAuthBuilder withToken(HpsTokenData $token)
11
+ * @method HpsCreditServiceOfflineAuthBuilder withTrackData(HpsTrackData $trackData)
12
+ * @method HpsCreditServiceOfflineAuthBuilder withCardHolder(HpsCardHolder $cardHolder)
13
+ * @method HpsCreditServiceOfflineAuthBuilder withRequestMultiUseToken(bool $requestMultiUseToken)
14
+ * @method HpsCreditServiceOfflineAuthBuilder withDetails(HpsTransactionDetails $details)
15
+ * @method HpsCreditServiceOfflineAuthBuilder withTxnDescriptor(string $txnDescriptor)
16
+ * @method HpsCreditServiceOfflineAuthBuilder withCpcReq(bool $cpcReq)
17
+ * @method HpsCreditServiceOfflineAuthBuilder withDirectMarketData(HpsDirectMarketData $directMarketData)
18
+ * @method HpsCreditServiceOfflineAuthBuilder withAllowDuplicates(bool $allowDuplicates)
19
+ * @method HpsCreditServiceOfflineAuthBuilder withPaymentData(HpsPaymentData $paymentData)
20
+ * @method HpsCreditServiceOfflineAuthBuilder withCardPresent(bool $cardPresent)
21
+ * @method HpsCreditServiceOfflineAuthBuilder withReaderPresent(bool $readerPresent)
22
+ * @method HpsCreditServiceOfflineAuthBuilder withGratuity(double $gratuity)
23
+ * @method HpsCreditServiceOfflineAuthBuilder withAutoSubstantiation(HpsAutoSubstantiation $autoSubstantiation)
24
+ * @method HpsCreditServiceOfflineAuthBuilder withOfflineAuthCode(string $offlineAuthCode)
25
+ */
26
+ class HpsCreditServiceOfflineAuthBuilder extends HpsBuilderAbstract
27
+ {
28
+ /** @var double|null */
29
+ protected $amount = null;
30
+
31
+ /** @var string|null */
32
+ protected $currency = null;
33
+
34
+ /** @var HpsCreditCard|null */
35
+ protected $card = null;
36
+
37
+ /** @var HpsTokenData|null */
38
+ protected $token = null;
39
+
40
+ /** @var HpsTrackData|null */
41
+ protected $trackData = null;
42
+
43
+ /** @var HpsCardHolder|null */
44
+ protected $cardHolder = null;
45
+
46
+ /** @var bool */
47
+ protected $requestMultiUseToken = false;
48
+
49
+ /** @var HpsTransactionDetails|null */
50
+ protected $details = null;
51
+
52
+ /** @var string|null */
53
+ protected $txnDescriptor = null;
54
+
55
+ /** @var bool */
56
+ protected $cpcReq = false;
57
+
58
+ /** @var HpsDirectMarketData|null */
59
+ protected $directMarketData = null;
60
+
61
+ /** @var bool */
62
+ protected $allowDuplicates = false;
63
+
64
+ /** @var HpsPaymentData|null */
65
+ protected $paymentData = null;
66
+
67
+ /** @var bool */
68
+ protected $cardPresent = false;
69
+
70
+ /** @var bool */
71
+ protected $readerPresent = false;
72
+
73
+ /** @var double|null */
74
+ protected $gratuity = null;
75
+
76
+ /** @var HpsAutoSubstantiation|null */
77
+ protected $autoSubstantiation = null;
78
+
79
+ /** @var string|null */
80
+ protected $offlineAuthCode = null;
81
+
82
+ /**
83
+ * Instatiates a new HpsCreditServiceOfflineAuthBuilder
84
+ *
85
+ * @param HpsSoapGatewayService $service
86
+ */
87
+ public function __construct(HpsSoapGatewayService $service)
88
+ {
89
+ parent::__construct($service);
90
+ $this->setUpValidations();
91
+ }
92
+
93
+ /**
94
+ * Creates a offline auth transaction through the HpsCreditService
95
+ */
96
+ public function execute()
97
+ {
98
+ parent::execute();
99
+
100
+ $xml = new DOMDocument();
101
+ $hpsTransaction = $xml->createElement('hps:Transaction');
102
+ $hpsCreditOfflineAuth = $xml->createElement('hps:CreditOfflineAuth');
103
+ $hpsBlock1 = $xml->createElement('hps:Block1');
104
+
105
+ $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', ($this->allowDuplicates ? 'Y' : 'N')));
106
+ $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
107
+
108
+ if ($this->gratuity != null) {
109
+ $hpsBlock1->appendChild($xml->createElement('hps:GratuityAmtInfo', $this->gratuity));
110
+ }
111
+
112
+ if ($this->cardHolder != null) {
113
+ $hpsBlock1->appendChild($this->service->_hydrateCardHolderData($this->cardHolder));
114
+ }
115
+
116
+ $cardData = $xml->createElement('hps:CardData');
117
+ if ($this->card != null) {
118
+ $cardData->appendChild($this->service->_hydrateManualEntry(
119
+ $this->card,
120
+ $xml,
121
+ $this->cardPresent,
122
+ $this->readerPresent
123
+ ));
124
+ } else if ($this->token != null) {
125
+ $cardData->appendChild($this->service->_hydrateTokenData(
126
+ $this->token,
127
+ $xml,
128
+ $this->cardPresent,
129
+ $this->readerPresent
130
+ ));
131
+ } else if ($this->trackData != null) {
132
+ $cardData->appendChild($this->service->_hydrateTrackData($this->trackData, $xml));
133
+ if ($this->trackData->encryptionData != null) {
134
+ $cardData->appendChild($this->service->_hydrateEncryptionData($this->trackData->encryptionData));
135
+ }
136
+ } else if ($this->paymentData != null) {
137
+ $manualEntry = $xml->createElement('hps:ManualEntry');
138
+ $manualEntry->appendChild($xml->createElement('hps:CardNbr', $this->paymentData->applicationPrimaryAccountNumber));
139
+ $expDate = (string)$this->paymentData->applicationExpirationDate;
140
+ $manualEntry->appendChild($xml->createElement('hps:ExpMonth', substr($expDate, 2, 2)));
141
+ $manualEntry->appendChild($xml->createElement('hps:ExpYear', substr($expDate, 0, 2)));
142
+ $cardData->appendChild($manualEntry);
143
+ }
144
+
145
+ $cardData->appendChild($xml->createElement('hps:TokenRequest', ($this->requestMultiUseToken ? 'Y' : 'N')));
146
+
147
+ $hpsBlock1->appendChild($cardData);
148
+
149
+ if ($this->paymentData != null) {
150
+ $hpsBlock1->appendChild($this->service->_hydrateSecureEcommerce($this->paymentData->paymentData));
151
+ }
152
+
153
+ if ($this->cpcReq == true) {
154
+ $hpsBlock1->appendChild($xml->createElement('hps:CPCReq', 'Y'));
155
+ }
156
+
157
+ if ($this->txnDescriptor != null) {
158
+ $hpsBlock1->appendChild($xml->createElement('hps:TxnDescriptor', $this->txnDescriptor));
159
+ }
160
+
161
+ if ($this->autoSubstantiation != null) {
162
+ $hpsBlock1->appendChild($this->service->_hydrateAutoSubstantiation($this->autoSubstantiation));
163
+ }
164
+
165
+ if ($this->offlineAuthCode != null) {
166
+ $hpsBlock1->appendChild($xml->createElement('hps:OfflineAuthCode', $this->offlineAuthCode));
167
+ }
168
+
169
+ $hpsCreditOfflineAuth->appendChild($hpsBlock1);
170
+ $hpsTransaction->appendChild($hpsCreditOfflineAuth);
171
+
172
+ return $this->service->_submitTransaction($hpsTransaction, 'CreditOfflineAuth', (isset($this->details->clientTransactionId) ? $this->details->clientTransactionId : null));
173
+ }
174
+
175
+ /**
176
+ * Setups up validations for building offline auths.
177
+ *
178
+ * @return null
179
+ */
180
+ private function setUpValidations()
181
+ {
182
+ $this
183
+ ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Offline Auth can only use one payment method');
184
+ }
185
+
186
+ /**
187
+ * Ensures there is only one payment method, and checks that
188
+ * there is only one card or one token in use. Both cannot be
189
+ * used.
190
+ *
191
+ * @param array $actionCounts
192
+ *
193
+ * @return bool
194
+ */
195
+ public function onlyOnePaymentMethod($actionCounts)
196
+ {
197
+ $methods = 0;
198
+ if (isset($actionCounts['card']) && $actionCounts['card'] == 1) {
199
+ $methods++;
200
+ }
201
+ if (isset($actionCounts['token']) && $actionCounts['token'] == 1) {
202
+ $methods++;
203
+ }
204
+ if (isset($actionCounts['trackData']) && $actionCounts['trackData'] == 1) {
205
+ $methods++;
206
+ }
207
+ return $methods == 1;
208
+ }
209
+ }
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceOfflineChargeBuilder.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * A fluent interface for creating and executing a offline charge
5
+ * transaction through the HpsCreditService.
6
+ *
7
+ * @method HpsCreditServiceOfflineChargeBuilder withAmount(double $amount)
8
+ * @method HpsCreditServiceOfflineChargeBuilder withCurrency(string $currency)
9
+ * @method HpsCreditServiceOfflineChargeBuilder withCard(HpsCreditCard $card)
10
+ * @method HpsCreditServiceOfflineChargeBuilder withToken(HpsTokenData $token)
11
+ * @method HpsCreditServiceOfflineChargeBuilder withTrackData(HpsTrackData $trackData)
12
+ * @method HpsCreditServiceOfflineChargeBuilder withCardHolder(HpsCardHolder $cardHolder)
13
+ * @method HpsCreditServiceOfflineChargeBuilder withRequestMultiUseToken(bool $requestMultiUseToken)
14
+ * @method HpsCreditServiceOfflineChargeBuilder withDetails(HpsTransactionDetails $details)
15
+ * @method HpsCreditServiceOfflineChargeBuilder withTxnDescriptor(string $txnDescriptor)
16
+ * @method HpsCreditServiceOfflineChargeBuilder withCpcReq(bool $cpcReq)
17
+ * @method HpsCreditServiceOfflineChargeBuilder withDirectMarketData(HpsDirectMarketData $directMarketData)
18
+ * @method HpsCreditServiceOfflineChargeBuilder withAllowDuplicates(bool $allowDuplicates)
19
+ * @method HpsCreditServiceOfflineChargeBuilder withPaymentData(HpsPaymentData $paymentData)
20
+ * @method HpsCreditServiceOfflineChargeBuilder withCardPresent(bool $cardPresent)
21
+ * @method HpsCreditServiceOfflineChargeBuilder withReaderPresent(bool $readerPresent)
22
+ * @method HpsCreditServiceOfflineChargeBuilder withGratuity(double $gratuity)
23
+ * @method HpsCreditServiceOfflineChargeBuilder withAutoSubstantiation(HpsAutoSubstantiation $autoSubstantiation)
24
+ * @method HpsCreditServiceOfflineChargeBuilder withOfflineAuthCode(string $offlineAuthCode)
25
+ */
26
+ class HpsCreditServiceOfflineChargeBuilder extends HpsBuilderAbstract
27
+ {
28
+ /** @var double|null */
29
+ protected $amount = null;
30
+
31
+ /** @var string|null */
32
+ protected $currency = null;
33
+
34
+ /** @var HpsCreditCard|null */
35
+ protected $card = null;
36
+
37
+ /** @var HpsTokenData|null */
38
+ protected $token = null;
39
+
40
+ /** @var HpsTrackData|null */
41
+ protected $trackData = null;
42
+
43
+ /** @var HpsCardHolder|null */
44
+ protected $cardHolder = null;
45
+
46
+ /** @var bool */
47
+ protected $requestMultiUseToken = false;
48
+
49
+ /** @var HpsTransactionDetails|null */
50
+ protected $details = null;
51
+
52
+ /** @var string|null */
53
+ protected $txnDescriptor = null;
54
+
55
+ /** @var bool */
56
+ protected $cpcReq = false;
57
+
58
+ /** @var HpsDirectMarketData|null */
59
+ protected $directMarketData = null;
60
+
61
+ /** @var bool */
62
+ protected $allowDuplicates = false;
63
+
64
+ /** @var HpsPaymentData|null */
65
+ protected $paymentData = null;
66
+
67
+ /** @var bool */
68
+ protected $cardPresent = false;
69
+
70
+ /** @var bool */
71
+ protected $readerPresent = false;
72
+
73
+ /** @var double|null */
74
+ protected $gratuity = null;
75
+
76
+ /** @var HpsAutoSubstantiation|null */
77
+ protected $autoSubstantiation = null;
78
+
79
+ /** @var string|null */
80
+ protected $offlineAuthCode = null;
81
+ /**
82
+ * Creates a offline charge transaction through the HpsCreditService
83
+ */
84
+ public function execute()
85
+ {
86
+ parent::execute();
87
+
88
+ $xml = new DOMDocument();
89
+ $hpsTransaction = $xml->createElement('hps:Transaction');
90
+ $hpsCreditOfflineAuth = $xml->createElement('hps:CreditOfflineAuth');
91
+ $hpsBlock1 = $xml->createElement('hps:Block1');
92
+
93
+ $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', ($this->allowDuplicates ? 'Y' : 'N')));
94
+ $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
95
+
96
+ if ($this->gratuity != null) {
97
+ $hpsBlock1->appendChild($xml->createElement('hps:GratuityAmtInfo', $this->gratuity));
98
+ }
99
+
100
+ if ($this->cardHolder != null) {
101
+ $hpsBlock1->appendChild($this->service->_hydrateCardHolderData($this->cardHolder));
102
+ }
103
+
104
+ $cardData = $xml->createElement('hps:CardData');
105
+ if ($this->card != null) {
106
+ $cardData->appendChild($this->service->_hydrateManualEntry(
107
+ $this->card,
108
+ $xml,
109
+ $this->cardPresent,
110
+ $this->readerPresent
111
+ ));
112
+ if ($this->card->encryptionData != null) {
113
+ $cardData->appendChild($this->service->_hydrateEncryptionData($this->card->encryptionData));
114
+ }
115
+ } else if ($this->token != null) {
116
+ $cardData->appendChild($this->service->_hydrateTokenData(
117
+ $this->token,
118
+ $xml,
119
+ $this->cardPresent,
120
+ $this->readerPresent
121
+ ));
122
+ } else if ($this->trackData != null) {
123
+ $cardData->appendChild($this->service->_hydrateTrackData($this->trackData, $xml));
124
+ if ($this->trackData->encryptionData != null) {
125
+ $cardData->appendChild($this->service->_hydrateEncryptionData($this->trackData->encryptionData));
126
+ }
127
+ } else if ($this->paymentData != null) {
128
+ $manualEntry = $xml->createElement('hps:ManualEntry');
129
+ $manualEntry->appendChild($xml->createElement('hps:CardNbr', $this->paymentData->applicationPrimaryAccountNumber));
130
+ $expDate = (string)$this->paymentData->applicationExpirationDate;
131
+ $manualEntry->appendChild($xml->createElement('hps:ExpMonth', substr($expDate, 2, 2)));
132
+ $manualEntry->appendChild($xml->createElement('hps:ExpYear', '20'.substr($expDate, 0, 2)));
133
+ $cardData->appendChild($manualEntry);
134
+ }
135
+
136
+ $cardData->appendChild($xml->createElement('hps:TokenRequest', ($this->requestMultiUseToken ? 'Y' : 'N')));
137
+
138
+ $hpsBlock1->appendChild($cardData);
139
+
140
+ if ($this->paymentData != null) {
141
+ $hpsBlock1->appendChild($this->service->_hydrateSecureEcommerce($this->paymentData->paymentData));
142
+ }
143
+
144
+ if ($this->cpcReq == true) {
145
+ $hpsBlock1->appendChild($xml->createElement('hps:CPCReq', 'Y'));
146
+ }
147
+
148
+ if ($this->txnDescriptor != null) {
149
+ $hpsBlock1->appendChild($xml->createElement('hps:TxnDescriptor', $this->txnDescriptor));
150
+ }
151
+
152
+ if ($this->autoSubstantiation != null) {
153
+ $hpsBlock1->appendChild($this->service->_hydrateAutoSubstantiation($this->autoSubstantiation));
154
+ }
155
+
156
+ if ($this->offlineAuthCode != null) {
157
+ $hpsBlock1->appendChild($xml->createElement('hps:OfflineAuthCode', $this->offlineAuthCode));
158
+ }
159
+
160
+ $hpsCreditOfflineAuth->appendChild($hpsBlock1);
161
+ $hpsTransaction->appendChild($hpsCreditOfflineAuth);
162
+
163
+ return $this->service->_submitTransaction($hpsTransaction, 'CreditOfflineAuth', (isset($this->details->clientTransactionId) ? $this->details->clientTransactionId : null));
164
+ }
165
+ }
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServicePrepaidAddValueBuilder.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * A fluent interface for creating and executing an add value
5
+ * transaction through the HpsCreditService.
6
+ *
7
+ * @method HpsCreditServicePrepaidAddValueBuilder withAmount(double $amount)
8
+ * @method HpsCreditServicePrepaidAddValueBuilder withCurrency(string $currency)
9
+ * @method HpsCreditServicePrepaidAddValueBuilder withAllowDuplicates(bool $allowDuplicates)
10
+ * @method HpsCreditServicePrepaidAddValueBuilder withCard(HpsCreditCard $card)
11
+ * @method HpsCreditServicePrepaidAddValueBuilder withToken(HpsTokenData $token)
12
+ * @method HpsCreditServicePrepaidAddValueBuilder withTrackData(HpsTrackData $trackData)
13
+ */
14
+ class HpsCreditServicePrepaidAddValueBuilder extends HpsBuilderAbstract
15
+ {
16
+ /** @var double|null */
17
+ protected $amount = null;
18
+
19
+ /** @var string|null */
20
+ protected $currency = null;
21
+
22
+ /** @var bool */
23
+ protected $allowDuplicates = false;
24
+
25
+ /** @var HpsCreditCard|null */
26
+ protected $card = null;
27
+
28
+ /** @var HpsTokenData|null */
29
+ protected $token = null;
30
+
31
+ /** @var HpsTrackData|null */
32
+ protected $trackData = null;
33
+
34
+ /**
35
+ * Instatiates a new HpsCreditServicePrepaidAddValueBuilder
36
+ *
37
+ * @param HpsSoapGatewayService $service
38
+ */
39
+ public function __construct(HpsSoapGatewayService $service)
40
+ {
41
+ parent::__construct($service);
42
+ $this->setUpValidations();
43
+ }
44
+
45
+ /**
46
+ * Creates an add value transaction through the HpsCreditService
47
+ */
48
+ public function execute()
49
+ {
50
+ parent::execute();
51
+
52
+ $xml = new DOMDocument();
53
+ $hpsTransaction = $xml->createElement('hps:Transaction');
54
+ $hpsCreditAuth = $xml->createElement('hps:PrePaidAddValue');
55
+ $hpsBlock1 = $xml->createElement('hps:Block1');
56
+
57
+ $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
58
+ $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', ($this->allowDuplicates ? 'Y' : 'N')));
59
+
60
+ $cardData = $xml->createElement('hps:CardData');
61
+ if ($this->card != null) {
62
+ $cardData->appendChild($this->service->_hydrateManualEntry($this->card, $xml));
63
+ } else if ($this->trackData != null) {
64
+ $cardData->appendChild($this->service->_hydrateTrackData($this->trackData, $xml));
65
+ } else if ($this->token != null) {
66
+ $tokenData = $xml->createElement('hps:TokenData');
67
+ $tokenData->appendChild($xml->createElement('hps:TokenValue', $this->token->tokenValue));
68
+ $cardData->appendChild($tokenData);
69
+ }
70
+
71
+ $hpsBlock1->appendChild($cardData);
72
+ $hpsCreditAuth->appendChild($hpsBlock1);
73
+ $hpsTransaction->appendChild($hpsCreditAuth);
74
+
75
+ return $this->service->_submitTransaction($hpsTransaction, 'PrePaidAddValue');
76
+ }
77
+
78
+ /**
79
+ * Setups up validations for building balance inquiries.
80
+ *
81
+ * @return null
82
+ */
83
+ private function setUpValidations()
84
+ {
85
+ $this
86
+ ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Add Value can only use one payment method');
87
+ }
88
+
89
+ /**
90
+ * Ensures there is only one payment method, and checks that
91
+ * there is only one card or one token in use. Both cannot be
92
+ * used.
93
+ *
94
+ * @param array $actionCounts
95
+ *
96
+ * @return bool
97
+ */
98
+ public function onlyOnePaymentMethod($actionCounts)
99
+ {
100
+ $methods = 0;
101
+ if (isset($actionCounts['card']) && $actionCounts['card'] == 1) {
102
+ $methods++;
103
+ }
104
+ if (isset($actionCounts['token']) && $actionCounts['token'] == 1) {
105
+ $methods++;
106
+ }
107
+ if (isset($actionCounts['trackData']) && $actionCounts['trackData'] == 1) {
108
+ $methods++;
109
+ }
110
+ return $methods == 1;
111
+ }
112
+ }
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServicePrepaidBalanceInquiryBuilder.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * A fluent interface for creating and executing a balance inquiry
5
+ * transaction through the HpsCreditService.
6
+ *
7
+ * @method HpsCreditServicePrepaidBalanceInquiryBuilder withCard(HpsCreditCard $card)
8
+ * @method HpsCreditServicePrepaidBalanceInquiryBuilder withToken(HpsTokenData $token)
9
+ * @method HpsCreditServicePrepaidBalanceInquiryBuilder withTrackData(HpsTrackData $trackData)
10
+ * @method HpsCreditServicePrepaidBalanceInquiryBuilder withCardHolder(HpsCardHolder $cardHolder)
11
+ */
12
+ class HpsCreditServicePrepaidBalanceInquiryBuilder extends HpsBuilderAbstract
13
+ {
14
+ /** @var HpsCreditCard|null */
15
+ protected $card = null;
16
+
17
+ /** @var HpsTokenData|null */
18
+ protected $token = null;
19
+
20
+ /** @var HpsTrackData|null */
21
+ protected $trackData = null;
22
+
23
+ /** @var HpsCardHolder|null */
24
+ protected $cardHolder = null;
25
+
26
+ /**
27
+ * Instatiates a new HpsCreditServicePrepaidBalanceInquiryBuilder
28
+ *
29
+ * @param HpsSoapGatewayService $service
30
+ */
31
+ public function __construct(HpsSoapGatewayService $service)
32
+ {
33
+ parent::__construct($service);
34
+ $this->setUpValidations();
35
+ }
36
+
37
+ /**
38
+ * Creates a balance inquiry transaction through the HpsCreditService
39
+ */
40
+ public function execute()
41
+ {
42
+ parent::execute();
43
+
44
+ $xml = new DOMDocument();
45
+ $hpsTransaction = $xml->createElement('hps:Transaction');
46
+ $hpsCreditAuth = $xml->createElement('hps:PrePaidBalanceInquiry');
47
+ $hpsBlock1 = $xml->createElement('hps:Block1');
48
+
49
+ $cardData = $xml->createElement('hps:CardData');
50
+ if ($this->card != null) {
51
+ $cardData->appendChild($this->service->_hydrateManualEntry($this->card, $xml));
52
+ } else if ($this->trackData != null) {
53
+ $cardData->appendChild($this->service->_hydrateTrackData($this->trackData, $xml));
54
+ } else if ($this->token != null) {
55
+ $tokenData = $xml->createElement('hps:TokenData');
56
+ $tokenData->appendChild($xml->createElement('hps:TokenValue', $this->token->tokenValue));
57
+ $cardData->appendChild($tokenData);
58
+ }
59
+ $hpsBlock1->appendChild($cardData);
60
+
61
+ if ($this->cardHolder != null) {
62
+ $hpsBlock1->appendChild($this->service->_hydrateCardHolderData($this->cardHolder, $xml));
63
+ }
64
+
65
+ $hpsCreditAuth->appendChild($hpsBlock1);
66
+ $hpsTransaction->appendChild($hpsCreditAuth);
67
+
68
+ return $this->service->_submitTransaction($hpsTransaction, 'PrePaidBalanceInquiry');
69
+ }
70
+
71
+ /**
72
+ * Setups up validations for building balance inquiries.
73
+ *
74
+ * @return null
75
+ */
76
+ private function setUpValidations()
77
+ {
78
+ $this
79
+ ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Balance Inquiry can only use one payment method');
80
+ }
81
+
82
+ /**
83
+ * Ensures there is only one payment method, and checks that
84
+ * there is only one card or one token in use. Both cannot be
85
+ * used.
86
+ *
87
+ * @param array $actionCounts
88
+ *
89
+ * @return bool
90
+ */
91
+ public function onlyOnePaymentMethod($actionCounts)
92
+ {
93
+ $methods = 0;
94
+ if (isset($actionCounts['card']) && $actionCounts['card'] == 1) {
95
+ $methods++;
96
+ }
97
+ if (isset($actionCounts['token']) && $actionCounts['token'] == 1) {
98
+ $methods++;
99
+ }
100
+ if (isset($actionCounts['trackData']) && $actionCounts['trackData'] == 1) {
101
+ $methods++;
102
+ }
103
+ return $methods == 1;
104
+ }
105
+ }
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceRecurringBuilder.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * A fluent interface for creating and executing a recurring billing
5
+ * transaction through the HpsCreditService.
6
+ *
7
+ * @method HpsCreditServiceRecurringBuilder withSchedule(HpsPayPlanSchedule|string $schedule)
8
+ * @method HpsCreditServiceRecurringBuilder withAmount(double $amount)
9
+ * @method HpsCreditServiceRecurringBuilder withCard(HpsCreditCard $card)
10
+ * @method HpsCreditServiceRecurringBuilder withToken(HpsTokenData $token)
11
+ * @method HpsCreditServiceRecurringBuilder withPaymentMethodKey(string $paymentMethodKey)
12
+ * @method HpsCreditServiceRecurringBuilder withOneTime(bool $oneTime)
13
+ * @method HpsCreditServiceRecurringBuilder withCardHolder(HpsCardHolder $cardHolder)
14
+ * @method HpsCreditServiceRecurringBuilder withDetails(HpsTransactionDetails $details)
15
+ * @method HpsCreditServiceRecurringBuilder withAllowDuplicates(bool $allowDuplicates)
16
+ */
17
+ class HpsCreditServiceRecurringBuilder extends HpsBuilderAbstract
18
+ {
19
+ /** @var HpsPayPlanSchedule|string|null */
20
+ protected $schedule = null;
21
+
22
+ /** @var double|null */
23
+ protected $amount = null;
24
+
25
+ /** @var HpsCreditCard|null */
26
+ protected $card = null;
27
+
28
+ /** @var HpsTokenData|null */
29
+ protected $token = null;
30
+
31
+ /** @var string|null */
32
+ protected $paymentMethodKey = null;
33
+
34
+ /** @var bool */
35
+ protected $oneTime = false;
36
+
37
+ /** @var HpsCardHolder|null */
38
+ protected $cardHolder = null;
39
+
40
+ /** @var HpsTransactionDetails|null */
41
+ protected $details = null;
42
+
43
+ /** @var bool */
44
+ protected $allowDuplicates = false;
45
+
46
+ /**
47
+ * Instatiates a new HpsCreditServiceRecurringBuilder
48
+ *
49
+ * @param HpsSoapGatewayService $service
50
+ */
51
+ public function __construct(HpsSoapGatewayService $service)
52
+ {
53
+ parent::__construct($service);
54
+ $this->setUpValidations();
55
+ }
56
+
57
+ /**
58
+ * Creates a recurring billing transaction through the HpsCreditService
59
+ */
60
+ public function execute()
61
+ {
62
+ parent::execute();
63
+
64
+ HpsInputValidation::checkAmount($this->amount);
65
+
66
+ $xml = new DOMDocument();
67
+ $hpsTransaction = $xml->createElement('hps:Transaction');
68
+ $hpsRecurringBilling = $xml->createElement('hps:RecurringBilling');
69
+ $hpsBlock1 = $xml->createElement('hps:Block1');
70
+
71
+ $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', 'Y'));
72
+ $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
73
+ if ($this->cardHolder != null) {
74
+ $hpsBlock1->appendChild($this->_hydrateCardHolderData($this->cardHolder, $xml));
75
+ }
76
+ if ($this->details != null) {
77
+ $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($this->details, $xml));
78
+ }
79
+
80
+ if ($this->card != null) {
81
+ $cardData = $xml->createElement('hps:CardData');
82
+ $cardData->appendChild($this->_hydrateManualEntry($this->card, $xml));
83
+ $hpsBlock1->appendChild($cardData);
84
+ } else if ($this->token != null) {
85
+ $cardData = $xml->createElement('hps:CardData');
86
+ $tokenData = $xml->createElement('hps:TokenData');
87
+ $tokenData->appendChild($xml->createElement('hps:TokenValue', $this->token->tokenValue));
88
+ $cardData->appendChild($tokenData);
89
+ $hpsBlock1->appendChild($cardData);
90
+ } else if ($this->paymentMethodKey != null) {
91
+ $hpsBlock1->appendChild($xml->createElement('hps:PaymentMethodKey', $this->paymentMethodKey));
92
+ }
93
+
94
+ $recurringData = $xml->createElement('hps:RecurringData');
95
+ if ($this->schedule != null) {
96
+ $id = $this->schedule;
97
+ if ($this->schedule instanceof HpsPayPlanSchedule) {
98
+ $id = $this->schedule->scheduleIdentifier;
99
+ }
100
+ $recurringData->appendChild($xml->createElement('hps:ScheduleID', $id));
101
+ }
102
+ $recurringData->appendChild($xml->createElement('hps:OneTime', ($this->oneTime ? 'Y' : 'N')));
103
+
104
+ $hpsBlock1->appendChild($recurringData);
105
+ $hpsRecurringBilling->appendChild($hpsBlock1);
106
+ $hpsTransaction->appendChild($hpsRecurringBilling);
107
+
108
+ return $this->service->_submitTransaction($hpsTransaction, 'RecurringBilling', (isset($this->details->clientTransactionId) ? $this->details->clientTransactionId : null));
109
+ }
110
+
111
+ /**
112
+ * Setups up validations for building recurring billings.
113
+ *
114
+ * @return null
115
+ */
116
+ private function setUpValidations()
117
+ {
118
+ $this
119
+ ->addValidation(array($this, 'onlyOnePaymentMethod'), 'HpsArgumentException', 'Recurring Billing can only use one payment method')
120
+ ->addValidation(array($this, 'amountNotNull'), 'HpsArgumentException', 'Recurring Billing needs an amount');
121
+ }
122
+
123
+ /**
124
+ * Ensures there is only one payment method, and checks that
125
+ * there is only one card or one token in use. Both cannot be
126
+ * used.
127
+ *
128
+ * @param array $actionCounts
129
+ *
130
+ * @return bool
131
+ */
132
+ public function onlyOnePaymentMethod($actionCounts)
133
+ {
134
+ $methods = 0;
135
+
136
+ if (isset($actionCounts['card']) && $actionCounts['card'] == 1) {
137
+ $methods++;
138
+ }
139
+
140
+ if (isset($actionCounts['token']) && $actionCounts['token'] == 1) {
141
+ $methods++;
142
+ }
143
+
144
+ if (isset($actionCounts['paymentMethodKey']) && $actionCounts['paymentMethodKey'] == 1) {
145
+ $methods++;
146
+ }
147
+
148
+ return $methods == 1;
149
+ }
150
+
151
+ /**
152
+ * Ensures an amount has been set.
153
+ *
154
+ * @param array $actionCounts
155
+ *
156
+ * @return bool
157
+ */
158
+ protected function amountNotNull($actionCounts)
159
+ {
160
+ return isset($actionCounts['amount']);
161
+ }
162
+ }
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceRefundBuilder.php CHANGED
@@ -11,29 +11,37 @@
11
  * @method HpsCreditServiceRefundBuilder withTransactionId(HpsTokenData $transactionId)
12
  * @method HpsCreditServiceRefundBuilder withCardHolder(HpsCardHolder $cardHolder)
13
  * @method HpsCreditServiceRefundBuilder withDetails(HpsTransactionDetails $details)
 
 
14
  */
15
  class HpsCreditServiceRefundBuilder extends HpsBuilderAbstract
16
  {
17
  /** @var double|null */
18
- protected $amount = null;
19
 
20
  /** @var string|null */
21
- protected $currency = null;
22
 
23
  /** @var HpsCreditCard|null */
24
- protected $card = null;
25
 
26
  /** @var HpsTokenData|null */
27
- protected $token = null;
28
 
29
  /** @var string|null */
30
- protected $transactionId = null;
31
 
32
  /** @var HpsCardHolder|null */
33
- protected $cardHolder = null;
34
 
35
  /** @var HpsTransactionDetails|null */
36
- protected $details = null;
 
 
 
 
 
 
37
 
38
  /**
39
  * Instatiates a new HpsCreditServiceRefundBuilder
@@ -53,14 +61,47 @@ class HpsCreditServiceRefundBuilder extends HpsBuilderAbstract
53
  {
54
  parent::execute();
55
 
56
- $refundSvc = new HpsCreditService($this->service->servicesConfig());
57
- return $refundSvc->refund(
58
- $this->amount,
59
- $this->currency,
60
- isset($this->card) ? $this->card : (isset($this->token) ? $this->token : $this->transactionId),
61
- $this->cardHolder,
62
- $this->details
63
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
65
 
66
  /**
11
  * @method HpsCreditServiceRefundBuilder withTransactionId(HpsTokenData $transactionId)
12
  * @method HpsCreditServiceRefundBuilder withCardHolder(HpsCardHolder $cardHolder)
13
  * @method HpsCreditServiceRefundBuilder withDetails(HpsTransactionDetails $details)
14
+ * @method HpsCreditServiceRefundBuilder withDirectMarketData(HpsDirectMarketData $directMarketData)
15
+ * @method HpsCreditServiceRefundBuilder withAllowDuplicates(bool $allowDuplicates)
16
  */
17
  class HpsCreditServiceRefundBuilder extends HpsBuilderAbstract
18
  {
19
  /** @var double|null */
20
+ protected $amount = null;
21
 
22
  /** @var string|null */
23
+ protected $currency = null;
24
 
25
  /** @var HpsCreditCard|null */
26
+ protected $card = null;
27
 
28
  /** @var HpsTokenData|null */
29
+ protected $token = null;
30
 
31
  /** @var string|null */
32
+ protected $transactionId = null;
33
 
34
  /** @var HpsCardHolder|null */
35
+ protected $cardHolder = null;
36
 
37
  /** @var HpsTransactionDetails|null */
38
+ protected $details = null;
39
+
40
+ /** @var HpsDirectMarketData|null */
41
+ protected $directMarketData = null;
42
+
43
+ /** @var bool */
44
+ protected $allowDuplicates = false;
45
 
46
  /**
47
  * Instatiates a new HpsCreditServiceRefundBuilder
61
  {
62
  parent::execute();
63
 
64
+ HpsInputValidation::checkCurrency($this->currency);
65
+ HpsInputValidation::checkAmount($this->amount);
66
+
67
+ $xml = new DOMDocument();
68
+ $hpsTransaction = $xml->createElement('hps:Transaction');
69
+ $hpsCreditReturn = $xml->createElement('hps:CreditReturn');
70
+ $hpsBlock1 = $xml->createElement('hps:Block1');
71
+
72
+ $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', ($this->allowDuplicates ? 'Y' : 'N')));
73
+ $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
74
+
75
+ if ($this->cardHolder != null) {
76
+ $hpsBlock1->appendChild($this->service->_hydrateCardHolderData($this->cardHolder, $xml));
77
+ }
78
+
79
+ if ($this->card != null) {
80
+ $cardData = $xml->createElement('hps:CardData');
81
+ $cardData->appendChild($this->service->_hydrateManualEntry(
82
+ $this->card,
83
+ $xml
84
+ ));
85
+ $hpsBlock1->appendChild($cardData);
86
+ } else if ($this->token != null) {
87
+ $cardData = $xml->createElement('hps:CardData');
88
+ $cardData->appendChild($this->service->_hydrateTokenData(
89
+ $this->token,
90
+ $xml
91
+ ));
92
+ $hpsBlock1->appendChild($cardData);
93
+ } else {
94
+ $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId));
95
+ }
96
+
97
+ if ($this->details != null) {
98
+ $hpsBlock1->appendChild($this->service->_hydrateAdditionalTxnFields($this->details, $xml));
99
+ }
100
+
101
+ $hpsCreditReturn->appendChild($hpsBlock1);
102
+ $hpsTransaction->appendChild($hpsCreditReturn);
103
+
104
+ return $this->service->_submitTransaction($hpsTransaction, 'CreditReturn', (isset($this->details->clientTransactionId) ? $this->details->clientTransationId : null));
105
  }
106
 
107
  /**
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceReverseBuilder.php CHANGED
@@ -5,6 +5,7 @@
5
  * transaction through the HpsCreditService.
6
  *
7
  * @method HpsCreditServiceReverseBuilder withAmount(double $amount)
 
8
  * @method HpsCreditServiceReverseBuilder withCurrency(string $currency)
9
  * @method HpsCreditServiceReverseBuilder withCard(HpsCreditCard $card)
10
  * @method HpsCreditServiceReverseBuilder withToken(HpsTokenData $token)
@@ -14,22 +15,25 @@
14
  class HpsCreditServiceReverseBuilder extends HpsBuilderAbstract
15
  {
16
  /** @var double|null */
17
- protected $amount = null;
 
 
 
18
 
19
  /** @var string|null */
20
- protected $currency = null;
21
 
22
  /** @var HpsCreditCard|null */
23
- protected $card = null;
24
 
25
  /** @var HpsTokenData|null */
26
- protected $token = null;
27
 
28
  /** @var string|null */
29
- protected $transactionId = null;
30
 
31
  /** @var HpsTransactionDetails|null */
32
- protected $details = null;
33
 
34
  /**
35
  * Instatiates a new HpsCreditServiceReverseBuilder
@@ -49,13 +53,46 @@ class HpsCreditServiceReverseBuilder extends HpsBuilderAbstract
49
  {
50
  parent::execute();
51
 
52
- $reverseSvc = new HpsCreditService($this->service->servicesConfig());
53
- return $reverseSvc->reverse(
54
- isset($this->card) ? $this->card : (isset($this->token) ? $this->token : $this->transactionId),
55
- $this->amount,
56
- $this->currency,
57
- $this->details
58
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
60
 
61
  /**
5
  * transaction through the HpsCreditService.
6
  *
7
  * @method HpsCreditServiceReverseBuilder withAmount(double $amount)
8
+ * @method HpsCreditServiceReverseBuilder withAuthAmount(double $authAmount)
9
  * @method HpsCreditServiceReverseBuilder withCurrency(string $currency)
10
  * @method HpsCreditServiceReverseBuilder withCard(HpsCreditCard $card)
11
  * @method HpsCreditServiceReverseBuilder withToken(HpsTokenData $token)
15
  class HpsCreditServiceReverseBuilder extends HpsBuilderAbstract
16
  {
17
  /** @var double|null */
18
+ protected $amount = null;
19
+
20
+ /** @var double|null */
21
+ protected $authAmount = null;
22
 
23
  /** @var string|null */
24
+ protected $currency = null;
25
 
26
  /** @var HpsCreditCard|null */
27
+ protected $card = null;
28
 
29
  /** @var HpsTokenData|null */
30
+ protected $token = null;
31
 
32
  /** @var string|null */
33
+ protected $transactionId = null;
34
 
35
  /** @var HpsTransactionDetails|null */
36
+ protected $details = null;
37
 
38
  /**
39
  * Instatiates a new HpsCreditServiceReverseBuilder
53
  {
54
  parent::execute();
55
 
56
+ HpsInputValidation::checkCurrency($this->currency);
57
+ HpsInputValidation::checkAmount($this->amount);
58
+
59
+ $xml = new DOMDocument();
60
+ $hpsTransaction = $xml->createElement('hps:Transaction');
61
+ $hpsCreditReversal = $xml->createElement('hps:CreditReversal');
62
+ $hpsBlock1 = $xml->createElement('hps:Block1');
63
+
64
+ $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
65
+
66
+ if ($this->authAmount != null) {
67
+ $hpsBlock1->appendChild($xml->createElement('hps:AuthAmt', $this->authAmount));
68
+ }
69
+
70
+ if ($this->card != null) {
71
+ $cardData = $xml->createElement('hps:CardData');
72
+ $cardData->appendChild($this->service->_hydrateManualEntry(
73
+ $this->card,
74
+ $xml
75
+ ));
76
+ $hpsBlock1->appendChild($cardData);
77
+ } else if ($this->token != null) {
78
+ $cardData = $xml->createElement('hps:CardData');
79
+ $cardData->appendChild($this->service->_hydrateTokenData(
80
+ $this->token,
81
+ $xml
82
+ ));
83
+ $hpsBlock1->appendChild($cardData);
84
+ } else {
85
+ $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId));
86
+ }
87
+
88
+ if ($this->details != null) {
89
+ $hpsBlock1->appendChild($this->service->_hydrateAdditionalTxnFields($this->details, $xml));
90
+ }
91
+
92
+ $hpsCreditReversal->appendChild($hpsBlock1);
93
+ $hpsTransaction->appendChild($hpsCreditReversal);
94
+
95
+ return $this->service->_submitTransaction($hpsTransaction, 'CreditReversal', (isset($this->details->clientTransactionId) ? $this->details->clientTransationId : null));
96
  }
97
 
98
  /**
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceVerifyBuilder.php CHANGED
@@ -6,9 +6,12 @@
6
  *
7
  * @method HpsCreditServiceVerifyBuilder withCard(HpsCreditCard $card)
8
  * @method HpsCreditServiceVerifyBuilder withToken(HpsTokenData $token)
 
9
  * @method HpsCreditServiceVerifyBuilder withCardHolder(HpsCardHolder $cardHolder)
10
  * @method HpsCreditServiceVerifyBuilder withRequestMultiUseToken(bool $requestMultiUseToken)
11
  * @method HpsCreditServiceVerifyBuilder withClientTransactionId(string $clientTransactionId)
 
 
12
  */
13
  class HpsCreditServiceVerifyBuilder extends HpsBuilderAbstract
14
  {
@@ -18,15 +21,24 @@ class HpsCreditServiceVerifyBuilder extends HpsBuilderAbstract
18
  /** @var HpsTokenData|null */
19
  protected $token = null;
20
 
 
 
 
21
  /** @var HpsCardHolder|null */
22
  protected $cardHolder = null;
23
 
24
- /** @var bool|null */
25
  protected $requestMultiUseToken = false;
26
 
27
  /** @var string|null */
28
  protected $clientTransactionId = null;
29
 
 
 
 
 
 
 
30
  /**
31
  * Instatiates a new HpsCreditServiceVerifyBuilder
32
  *
@@ -45,13 +57,50 @@ class HpsCreditServiceVerifyBuilder extends HpsBuilderAbstract
45
  {
46
  parent::execute();
47
 
48
- $verifySvc = new HpsCreditService($this->service->servicesConfig());
49
- return $verifySvc->verify(
50
- isset($this->card) ? $this->card : $this->token,
51
- $this->cardHolder,
52
- $this->requestMultiUseToken,
53
- $this->clientTransactionId
54
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
56
 
57
  /**
6
  *
7
  * @method HpsCreditServiceVerifyBuilder withCard(HpsCreditCard $card)
8
  * @method HpsCreditServiceVerifyBuilder withToken(HpsTokenData $token)
9
+ * @method HpsCreditServiceVerifyBuilder withTrackData(HpsTrackData $trackData)
10
  * @method HpsCreditServiceVerifyBuilder withCardHolder(HpsCardHolder $cardHolder)
11
  * @method HpsCreditServiceVerifyBuilder withRequestMultiUseToken(bool $requestMultiUseToken)
12
  * @method HpsCreditServiceVerifyBuilder withClientTransactionId(string $clientTransactionId)
13
+ * @method HpsCreditServiceVerifyBuilder withCardPresent(bool $cardPresent)
14
+ * @method HpsCreditServiceVerifyBuilder withReaderPresent(bool $readerPresent)
15
  */
16
  class HpsCreditServiceVerifyBuilder extends HpsBuilderAbstract
17
  {
21
  /** @var HpsTokenData|null */
22
  protected $token = null;
23
 
24
+ /** @var HpsTrackData|null */
25
+ protected $trackData = null;
26
+
27
  /** @var HpsCardHolder|null */
28
  protected $cardHolder = null;
29
 
30
+ /** @var bool */
31
  protected $requestMultiUseToken = false;
32
 
33
  /** @var string|null */
34
  protected $clientTransactionId = null;
35
 
36
+ /** @var bool */
37
+ protected $cardPresent = false;
38
+
39
+ /** @var bool */
40
+ protected $readerPresent = false;
41
+
42
  /**
43
  * Instatiates a new HpsCreditServiceVerifyBuilder
44
  *
57
  {
58
  parent::execute();
59
 
60
+ $xml = new DOMDocument();
61
+ $hpsTransaction = $xml->createElement('hps:Transaction');
62
+ $hpsCreditAccountVerify = $xml->createElement('hps:CreditAccountVerify');
63
+ $hpsBlock1 = $xml->createElement('hps:Block1');
64
+
65
+ if ($this->cardHolder != null) {
66
+ $hpsBlock1->appendChild($this->service->_hydrateCardHolderData($this->cardHolder, $xml));
67
+ }
68
+
69
+ $cardData = $xml->createElement('hps:CardData');
70
+ if ($this->card != null) {
71
+ $cardData->appendChild($this->service->_hydrateManualEntry(
72
+ $this->card,
73
+ $xml,
74
+ $this->cardPresent,
75
+ $this->readerPresent
76
+ ));
77
+ if ($this->card->encryptionData != null) {
78
+ $cardData->appendChild($this->service->_hydrateEncryptionData(
79
+ $this->card->encryptionData
80
+ ));
81
+ }
82
+ } else if ($this->token != null) {
83
+ $cardData->appendChild($this->service->_hydrateTokenData(
84
+ $this->token,
85
+ $xml,
86
+ $this->cardPresent,
87
+ $this->readerPresent
88
+ ));
89
+ } else if ($this->trackData != null) {
90
+ $cardData->appendChild($this->service->_hydrateTrackData($this->trackData));
91
+ if ($this->trackData->encryptionData != null) {
92
+ $cardData->appendChild($this->service->_hydrateEncryptionData(
93
+ $this->trackData->encryptionData
94
+ ));
95
+ }
96
+ }
97
+ $cardData->appendChild($xml->createElement('hps:TokenRequest', ($this->requestMultiUseToken) ? 'Y' : 'N'));
98
+
99
+ $hpsBlock1->appendChild($cardData);
100
+ $hpsCreditAccountVerify->appendChild($hpsBlock1);
101
+ $hpsTransaction->appendChild($hpsCreditAccountVerify);
102
+
103
+ return $this->service->_submitTransaction($hpsTransaction, 'CreditAccountVerify', $this->clientTransactionId);
104
  }
105
 
106
  /**
lib/SecureSubmit/src/Services/Fluent/Gateway/Credit/HpsCreditServiceVoidBuilder.php CHANGED
@@ -33,8 +33,13 @@ class HpsCreditServiceVoidBuilder extends HpsBuilderAbstract
33
  {
34
  parent::execute();
35
 
36
- $voidSvc = new HpsCreditService($this->service->servicesConfig());
37
- return $voidSvc->void($this->transactionId);
 
 
 
 
 
38
  }
39
 
40
  /**
33
  {
34
  parent::execute();
35
 
36
+ $xml = new DOMDocument();
37
+ $hpsTransaction = $xml->createElement('hps:Transaction');
38
+ $hpsCreditVoid = $xml->createElement('hps:CreditVoid');
39
+ $hpsCreditVoid->appendChild($xml->createElement('hps:GatewayTxnId', $this->transactionId));
40
+ $hpsTransaction->appendChild($hpsCreditVoid);
41
+
42
+ return $this->service->_submitTransaction($hpsTransaction, 'CreditVoid', $this->clientTransactionId);
43
  }
44
 
45
  /**
lib/SecureSubmit/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceAliasBuilder.php CHANGED
@@ -37,12 +37,22 @@ class HpsGiftCardServiceAliasBuilder extends HpsBuilderAbstract
37
  {
38
  parent::execute();
39
 
40
- $aliasSvc = new HpsGiftCardService($this->service->servicesConfig());
41
- return $aliasSvc->alias(
42
- $this->action,
43
- $this->card,
44
- $this->alias
45
- );
 
 
 
 
 
 
 
 
 
 
46
  }
47
 
48
  /**
@@ -67,6 +77,10 @@ class HpsGiftCardServiceAliasBuilder extends HpsBuilderAbstract
67
  */
68
  protected function cardNotNull($actionCounts)
69
  {
 
 
 
 
70
  return isset($actionCounts['card']);
71
  }
72
 
37
  {
38
  parent::execute();
39
 
40
+ $xml = new DOMDocument();
41
+ $hpsTransaction = $xml->createElement('hps:Transaction');
42
+ $hpsGiftAlias = $xml->createElement('hps:GiftCardAlias');
43
+ $hpsBlock1 = $xml->createElement('hps:Block1');
44
+
45
+ $hpsBlock1->appendChild($xml->createElement('hps:Action', $this->action));
46
+ $hpsBlock1->appendChild($xml->createElement('hps:Alias', $this->alias));
47
+
48
+ if ($this->card != null) {
49
+ $hpsBlock1->appendChild($this->service->_hydrateGiftCardData($this->card, $xml));
50
+ }
51
+
52
+ $hpsGiftAlias->appendChild($hpsBlock1);
53
+ $hpsTransaction->appendChild($hpsGiftAlias);
54
+
55
+ return $this->service->_submitTransaction($hpsTransaction, 'GiftCardAlias');
56
  }
57
 
58
  /**
77
  */
78
  protected function cardNotNull($actionCounts)
79
  {
80
+ if ($this->action == 'CREATE') {
81
+ return $this->card == null;
82
+ }
83
+
84
  return isset($actionCounts['card']);
85
  }
86
 
lib/SecureSubmit/src/Services/Fluent/Gateway/GiftCard/HpsGiftCardServiceSaleBuilder.php CHANGED
@@ -45,14 +45,33 @@ class HpsGiftCardServiceSaleBuilder extends HpsBuilderAbstract
45
  {
46
  parent::execute();
47
 
48
- $saleSvc = new HpsGiftCardService($this->service->servicesConfig());
49
- return $saleSvc->sale(
50
- $this->card,
51
- $this->amount,
52
- $this->currency,
53
- $this->gratuity,
54
- $this->tax
55
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
 
58
  /**
45
  {
46
  parent::execute();
47
 
48
+ HpsInputValidation::checkAmount($this->amount);
49
+ $this->currency = strtolower($this->currency);
50
+
51
+ $xml = new DOMDocument();
52
+ $hpsTransaction = $xml->createElement('hps:Transaction');
53
+ $hpsGiftSale = $xml->createElement('hps:GiftCardSale');
54
+ $hpsBlock1 = $xml->createElement('hps:Block1');
55
+
56
+ $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
57
+ $hpsBlock1->appendChild($this->service->_hydrateGiftCardData($this->card, $xml));
58
+
59
+ if (in_array($this->currency, array('points', 'usd'))) {
60
+ $hpsBlock1->appendChild($xml->createElement('hps:Currency', strtoupper($this->currency)));
61
+ }
62
+
63
+ if ($this->gratuity != null) {
64
+ $hpsBlock1->appendChild($xml->createElement('hps:GratuityAmtInfo', $this->gratuity));
65
+ }
66
+
67
+ if ($this->tax != null) {
68
+ $hpsBlock1->appendChild($xml->createElement('hps:TaxAmtInfo', $this->tax));
69
+ }
70
+
71
+ $hpsGiftSale->appendChild($hpsBlock1);
72
+ $hpsTransaction->appendChild($hpsGiftSale);
73
+
74
+ return $this->service->_submitTransaction($hpsTransaction, 'GiftCardSale');
75
  }
76
 
77
  /**
lib/SecureSubmit/src/Services/Fluent/Gateway/HpsFluentCheckService.php CHANGED
@@ -13,18 +13,20 @@ class HpsFluentCheckService extends HpsSoapGatewayService
13
  return $this;
14
  }
15
 
16
- public function override($amount = null)
17
  {
18
- $builder = new HpsCheckServiceOverrideBuilder($this);
19
- return $builder
20
- ->withAmount($amount);
21
  }
22
 
23
- public function returnCheck($amount = null)
24
  {
25
- $builder = new HpsCheckServiceReturnBuilder($this);
26
- return $builder
27
- ->withAmount($amount);
 
 
 
 
28
  }
29
 
30
  public function sale($amount = null)
@@ -34,10 +36,78 @@ class HpsFluentCheckService extends HpsSoapGatewayService
34
  ->withAmount($amount);
35
  }
36
 
37
- public function void($transactionId = null)
38
  {
39
- $builder = new HpsCheckServiceVoidBuilder($this);
40
- return $builder
41
- ->withTransactionId($transactionId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
  }
13
  return $this;
14
  }
15
 
16
+ public function override()
17
  {
18
+ return new HpsCheckServiceOverrideBuilder($this);
 
 
19
  }
20
 
21
+ public function recurring($amount = null)
22
  {
23
+ $builder = new HpsCheckServiceRecurringBuilder($this);
24
+ return $builder->withAmount($amount);
25
+ }
26
+
27
+ public function returnCheck()
28
+ {
29
+ return new HpsCheckServiceReturnBuilder($this);
30
  }
31
 
32
  public function sale($amount = null)
36
  ->withAmount($amount);
37
  }
38
 
39
+ public function void()
40
  {
41
+ return new HpsCheckServiceVoidBuilder($this);
42
+ }
43
+
44
+ public function _buildTransaction($action, HpsCheck $check, $amount, $clientTransactionId = null, $checkVerify = false, $achVerify = false)
45
+ {
46
+ if ($amount != null) {
47
+ HpsInputValidation::checkAmount($amount);
48
+ }
49
+
50
+ if ($check->secCode == HpsSECCode::CCD &&
51
+ ($check->checkHolder == null || $check->checkHolder->checkName == null)) {
52
+ throw new HpsInvalidRequestException(
53
+ HpsExceptionCodes::MISSING_CHECK_NAME,
54
+ 'For SEC code CCD, the check name is required',
55
+ 'check_name'
56
+ );
57
+ }
58
+
59
+ $xml = new DOMDocument();
60
+ $hpsTransaction = $xml->createElement('hps:Transaction');
61
+ $hpsCheckSale = $xml->createElement('hps:CheckSale');
62
+ $hpsBlock1 = $xml->createElement('hps:Block1');
63
+
64
+ $hpsBlock1->appendChild($xml->createElement('hps:Amt', sprintf("%0.2f", round($amount, 3))));
65
+ $hpsBlock1->appendChild($this->_hydrateCheckData($check, $xml));
66
+ $hpsBlock1->appendChild($xml->createElement('hps:CheckAction', $action));
67
+ $hpsBlock1->appendChild($xml->createElement('hps:SECCode', $check->secCode));
68
+
69
+ if ($checkVerify || $achVerify) {
70
+ $verifyElement = $xml->createElement('hps:VerifyInfo');
71
+ if ($checkVerify) {
72
+ $verifyElement->appendChild($xml->createElement('hps:CheckVerify', ($checkVerify ? 'Y' : 'N')));
73
+ }
74
+ if ($achVerify) {
75
+ $verifyElement->appendChild($xml->createElement('hps:ACHVerify', ($achVerify ? 'Y' : 'N')));
76
+ }
77
+ $hpsBlock1->appendChild($verifyElement);
78
+ }
79
+
80
+ if ($check->checkType != null) {
81
+ $hpsBlock1->appendChild($xml->createElement('hps:CheckType', $check->checkType));
82
+ }
83
+ if ($check->dataEntryMode != null) {
84
+ $hpsBlock1->appendChild($xml->createElement('hps:DataEntryMode', $check->dataEntryMode));
85
+ }
86
+ if ($check->checkHolder != null) {
87
+ $hpsBlock1->appendChild($this->_hydrateConsumerInfo($check, $xml));
88
+ }
89
+
90
+ $hpsCheckSale->appendChild($hpsBlock1);
91
+ $hpsTransaction->appendChild($hpsCheckSale);
92
+
93
+ return $this->_submitTransaction($hpsTransaction, 'CheckSale', $clientTransactionId);
94
+ }
95
+
96
+ public function _submitTransaction($transaction, $txnType, $clientTransactionId = null)
97
+ {
98
+ $rsp = $this->doRequest($transaction, $clientTransactionId);
99
+ HpsGatewayResponseValidation::checkResponse($rsp, $txnType);
100
+ $response = HpsCheckResponse::fromDict($rsp, $txnType);
101
+
102
+ if ($response->responseCode != 0) {
103
+ throw new HpsCheckException(
104
+ $rsp->Header->GatewayTxnId,
105
+ $response->details,
106
+ $response->responseCode,
107
+ $response->responseText
108
+ );
109
+ }
110
+
111
+ return $response;
112
  }
113
  }
lib/SecureSubmit/src/Services/Fluent/Gateway/HpsFluentCreditService.php CHANGED
@@ -36,9 +36,11 @@ class HpsFluentCreditService extends HpsSoapGatewayService
36
  ->withCurrency('usd');
37
  }
38
 
39
- public function cpcEdit()
40
  {
41
- return new HpsCreditServiceCpcEditBuilder($this);
 
 
42
  }
43
 
44
  public function edit()
@@ -58,6 +60,41 @@ class HpsFluentCreditService extends HpsSoapGatewayService
58
  return new HpsCreditServiceListTransactionsBuilder($this);
59
  }
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  public function refund($amount = null)
62
  {
63
  $builder = new HpsCreditServiceRefundBuilder($this);
@@ -85,4 +122,144 @@ class HpsFluentCreditService extends HpsSoapGatewayService
85
  return $builder
86
  ->withTransactionId($transactionId);
87
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  }
36
  ->withCurrency('usd');
37
  }
38
 
39
+ public function cpcEdit($transactionId = null)
40
  {
41
+ $builder = new HpsCreditServiceCpcEditBuilder($this);
42
+ return $builder
43
+ ->withTransactionId($transactionId);
44
  }
45
 
46
  public function edit()
60
  return new HpsCreditServiceListTransactionsBuilder($this);
61
  }
62
 
63
+ public function offlineAuth($amount = null)
64
+ {
65
+ $builder = new HpsCreditServiceOfflineAuthBuilder($this);
66
+ return $builder
67
+ ->withAmount($amount)
68
+ ->withCurrency('usd');
69
+ }
70
+
71
+ public function offlineCharge($amount = null)
72
+ {
73
+ $builder = new HpsCreditServiceOfflineChargeBuilder($this);
74
+ return $builder
75
+ ->withAmount($amount)
76
+ ->withCurrency('usd');
77
+ }
78
+
79
+ public function prepaidBalanceInquiry()
80
+ {
81
+ return new HpsCreditServicePrepaidBalanceInquiryBuilder($this);
82
+ }
83
+
84
+ public function prepaidAddValue($amount = null)
85
+ {
86
+ $builder = new HpsCreditServicePrepaidAddValueBuilder($this);
87
+ return $builder
88
+ ->withAmount($amount)
89
+ ->withCurrency('usd');
90
+ }
91
+
92
+ public function recurring($amount = null)
93
+ {
94
+ $builder = new HpsCreditServiceRecurringBuilder($this);
95
+ return $builder->withAmount($amount);
96
+ }
97
+
98
  public function refund($amount = null)
99
  {
100
  $builder = new HpsCreditServiceRefundBuilder($this);
122
  return $builder
123
  ->withTransactionId($transactionId);
124
  }
125
+
126
+ private function _processChargeGatewayResponse($response, $expectedType)
127
+ {
128
+ $gatewayRspCode = (isset($response->Header->GatewayRspCode) ? $response->Header->GatewayRspCode : null);
129
+ $transactionId = (isset($response->Header->GatewayTxnId) ? $response->Header->GatewayTxnId : null);
130
+
131
+ if ($gatewayRspCode == '0') {
132
+ return;
133
+ }
134
+
135
+ if ($gatewayRspCode == '30') {
136
+ try {
137
+ $this->reverse($transactionId, $this->_amount, $this->_currency);
138
+ } catch (Exception $e) {
139
+ throw new HpsGatewayException(
140
+ HpsExceptionCodes::GATEWAY_TIMEOUT_REVERSAL_ERROR,
141
+ 'Error occurred while reversing a charge due to HPS gateway timeout',
142
+ $e
143
+ );
144
+ }
145
+ }
146
+
147
+ HpsGatewayResponseValidation::checkResponse($response, $expectedType);
148
+ }
149
+
150
+ private function _processChargeIssuerResponse($response, $expectedType)
151
+ {
152
+ $transactionId = (isset($response->Header->GatewayTxnId) ? $response->Header->GatewayTxnId : null);
153
+ $item = $response->Transaction->$expectedType;
154
+
155
+ if ($item != null) {
156
+ $responseCode = (isset($item->RspCode) ? $item->RspCode : null);
157
+ $responseText = (isset($item->RspText) ? $item->RspText : null);
158
+
159
+ if ($responseCode != null) {
160
+ // check if we need to do a reversal
161
+ if ($responseCode == '91') {
162
+ try {
163
+ $this->reverse($transactionId, $this->_amount, $this->_currency);
164
+ } catch (HpsGatewayException $e) {
165
+ // if the transaction wasn't found; throw the original timeout exception
166
+ if ($e->details->gatewayResponseCode == 3) {
167
+ HpsIssuerResponseValidation::checkResponse($transactionId, $responseCode, $responseText);
168
+ }
169
+ throw new HpsCreditException(
170
+ $transactionId,
171
+ HpsExceptionCodes::ISSUER_TIMEOUT_REVERSAL_ERROR,
172
+ 'Error occurred while reversing a charge due to HPS issuer timeout',
173
+ $e
174
+ );
175
+ } catch (HpsException $e) {
176
+ throw new HpsCreditException(
177
+ $transactionId,
178
+ HpsExceptionCodes::ISSUER_TIMEOUT_REVERSAL_ERROR,
179
+ 'Error occurred while reversing a charge due to HPS issuer timeout',
180
+ $e
181
+ );
182
+ }
183
+ }
184
+ HpsIssuerResponseValidation::checkResponse($transactionId, $responseCode, $responseText);
185
+ }
186
+ }
187
+ }
188
+
189
+ public function _submitTransaction($transaction, $txnType, $clientTxnId = null, $cardData = null)
190
+ {
191
+ try {
192
+ $response = $this->doRequest($transaction, $clientTxnId);
193
+ } catch (HpsException $e) {
194
+ if ($e->innerException != null && $e->innerException->getMessage() == 'gateway_time-out') {
195
+ if (in_array($txnType, array('CreditSale', 'CreditAuth'))) {
196
+ try {
197
+ $this->reverse($cardData, $this->_amount, $this->_currency);
198
+ } catch (Exception $e) {
199
+ throw new HpsGatewayException('0', HpsExceptionCodes::GATEWAY_TIMEOUT_REVERSAL_ERROR);
200
+ }
201
+ }
202
+ throw new HpsException('An error occurred and the gateway has timed out', 'gateway_timeout', $e, 'gateway_timeout');
203
+ }
204
+ throw $e;
205
+ }
206
+ $this->_processChargeGatewayResponse($response, $txnType);
207
+ $this->_processChargeIssuerResponse($response, $txnType);
208
+
209
+ $rvalue = null;
210
+ switch ($txnType) {
211
+ case 'ReportTxnDetail':
212
+ $rvalue = HpsReportTransactionDetails::fromDict($response, $txnType);
213
+ break;
214
+ case 'ReportActivity':
215
+ $rvalue = HpsReportTransactionSummary::fromDict($response, $txnType, $this->_filterBy);
216
+ break;
217
+ case 'CreditSale':
218
+ $rvalue = HpsCharge::fromDict($response, $txnType);
219
+ break;
220
+ case 'CreditAccountVerify':
221
+ $rvalue = HpsAccountVerify::fromDict($response, $txnType);
222
+ break;
223
+ case 'CreditAuth':
224
+ $rvalue = HpsAuthorization::fromDict($response, $txnType);
225
+ break;
226
+ case 'CreditReturn':
227
+ $rvalue = HpsRefund::fromDict($response, $txnType);
228
+ break;
229
+ case 'CreditReversal':
230
+ $rvalue = HpsReversal::fromDict($response, $txnType);
231
+ break;
232
+ case 'CreditVoid':
233
+ $rvalue = HpsVoid::fromDict($response, $txnType);
234
+ break;
235
+ case 'CreditCPCEdit':
236
+ $rvalue = HpsCPCEdit::fromDict($response, $txnType);
237
+ break;
238
+ case 'CreditTxnEdit':
239
+ $rvalue = HpsTransaction::fromDict($response, $txnType);
240
+ break;
241
+ case 'RecurringBilling':
242
+ $rvalue = HpsRecurringBilling::fromDict($response, $txnType);
243
+ break;
244
+ case 'CreditAdditionalAuth':
245
+ $rvalue = HpsAuthorization::fromDict($response, $txnType);
246
+ break;
247
+ case 'PrePaidBalanceInquiry':
248
+ $rvalue = HpsAuthorization::fromDict($response, $txnType);
249
+ break;
250
+ case 'PrePaidAddValue':
251
+ $rvalue = HpsAuthorization::fromDict($response, $txnType);
252
+ break;
253
+ case 'CreditOfflineAuth':
254
+ $rvalue = HpsOfflineAuthorization::fromDict($response, $txnType);
255
+ break;
256
+ case 'CreditOfflineAuth':
257
+ $rvalue = HpsOfflineAuthorization::fromDict($response, $txnType);
258
+ break;
259
+ default:
260
+ break;
261
+ }
262
+
263
+ return $rvalue;
264
+ }
265
  }
lib/SecureSubmit/src/Services/Fluent/Gateway/HpsFluentGiftCardService.php CHANGED
@@ -28,12 +28,9 @@ class HpsFluentGiftCardService extends HpsSoapGatewayService
28
  ->withAmount($amount);
29
  }
30
 
31
- public function alias($amount = null)
32
  {
33
- $builder = new HpsGiftCardServiceAliasBuilder($this);
34
- return $builder
35
- ->withAmount($amount)
36
- ->withCurrency('usd');
37
  }
38
 
39
  public function balance()
@@ -81,4 +78,55 @@ class HpsFluentGiftCardService extends HpsSoapGatewayService
81
  return $builder
82
  ->withTransactionId($transactionId);
83
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  }
28
  ->withAmount($amount);
29
  }
30
 
31
+ public function alias()
32
  {
33
+ return new HpsGiftCardServiceAliasBuilder($this);
 
 
 
34
  }
35
 
36
  public function balance()
78
  return $builder
79
  ->withTransactionId($transactionId);
80
  }
81
+
82
+ public function _submitTransaction($transaction, $txnType, $clientTxnId = null)
83
+ {
84
+ $response = $this->doRequest($transaction, $clientTxnId);
85
+
86
+ HpsGatewayResponseValidation::checkResponse($response, $txnType);
87
+ HpsIssuerResponseValidation::checkResponse(
88
+ $response->Header->GatewayTxnId,
89
+ $response->Transaction->$txnType->RspCode,
90
+ $response->Transaction->$txnType->RspText,
91
+ 'gift'
92
+ );
93
+
94
+ $rvalue = '';
95
+ switch ($txnType) {
96
+ case 'GiftCardActivate':
97
+ $rvalue = HpsGiftCardActivate::fromDict($response, $txnType, 'HpsGiftCardActivate');
98
+ break;
99
+ case 'GiftCardAddValue':
100
+ $rvalue = HpsGiftCardAddValue::fromDict($response, $txnType, 'HpsGiftCardAddValue');
101
+ break;
102
+ case 'GiftCardAlias':
103
+ $rvalue = HpsGiftCardAlias::fromDict($response, $txnType, 'HpsGiftCardAlias');
104
+ break;
105
+ case 'GiftCardBalance':
106
+ $rvalue = HpsGiftCardBalance::fromDict($response, $txnType, 'HpsGiftCardBalance');
107
+ break;
108
+ case 'GiftCardDeactivate':
109
+ $rvalue = HpsGiftCardDeactivate::fromDict($response, $txnType, 'HpsGiftCardDeactivate');
110
+ break;
111
+ case 'GiftCardReplace':
112
+ $rvalue = HpsGiftCardReplace::fromDict($response, $txnType, 'HpsGiftCardReplace');
113
+ break;
114
+ case 'GiftCardReward':
115
+ $rvalue = HpsGiftCardReward::fromDict($response, $txnType, 'HpsGiftCardReward');
116
+ break;
117
+ case 'GiftCardSale':
118
+ $rvalue = HpsGiftCardSale::fromDict($response, $txnType, 'HpsGiftCardSale');
119
+ break;
120
+ case 'GiftCardVoid':
121
+ $rvalue = HpsGiftCardVoid::fromDict($response, $txnType, 'HpsGiftCardVoid');
122
+ break;
123
+ case 'GiftCardReversal':
124
+ $rvalue = HpsGiftCardReversal::fromDict($response, $txnType, 'HpsGiftCardReversal');
125
+ break;
126
+ default:
127
+ break;
128
+ }
129
+
130
+ return $rvalue;
131
+ }
132
  }
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanCustomerServiceAddBuilder.php DELETED
@@ -1,76 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanCustomerServiceAddBuilder withData(array $data)
5
- * @method HpsPayPlanCustomerServiceAddBuilder withConfig(HpsServiceConfig $config)
6
- */
7
- class HpsPayPlanCustomerServiceAddBuilder extends HpsBuilderAbstract
8
- {
9
- /** @var array */
10
- protected $data = array();
11
-
12
- /**
13
- * Instatiates a new HpsPayPlanCustomerServiceAddBuilder
14
- *
15
- * @param HpsRestGatewayService $service
16
- */
17
- public function __construct(HpsRestGatewayService $service)
18
- {
19
- parent::__construct($service);
20
- $this->setUpValidations();
21
- }
22
-
23
- /**
24
- * Creates an add transaction through the HpsPayPlanCustomerService
25
- */
26
- public function execute()
27
- {
28
- parent::execute();
29
-
30
- $service = new HpsPayPlanCustomerService($this->service->servicesConfig());
31
- $obj = new HpsPayPlanCustomer();
32
-
33
- foreach ($this->data as $k => $v) {
34
- $obj->$k = $v;
35
- }
36
- unset($usableData, $k, $v);
37
-
38
- return $service->add($obj);
39
- }
40
-
41
- /**
42
- * Setups up validations for building customer
43
- * adds.
44
- *
45
- * @return null
46
- */
47
- private function setUpValidations()
48
- {
49
- $this
50
- ->addValidation(array($this, 'dataNotEmpty'), 'HpsArgumentException', 'Add needs a non-empty data set');
51
- }
52
-
53
- /**
54
- * Ensures the data set is not empty.
55
- *
56
- * @param array $actionCounts
57
- *
58
- * @return bool
59
- */
60
- protected function dataNotEmpty($actionCounts)
61
- {
62
- return !empty($this->data);
63
- }
64
-
65
- /**
66
- * @param string $key
67
- * @param mixed $value
68
- *
69
- * @return HpsPayPlanCustomerServiceAddBuilder
70
- */
71
- public function set($key, $value)
72
- {
73
- $this->data[$key] = $value;
74
- return $this;
75
- }
76
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanCustomerServiceDeleteBuilder.php DELETED
@@ -1,76 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanCustomerServiceDeleteBuilder withData(array $data)
5
- * @method HpsPayPlanCustomerServiceDeleteBuilder withCustomer(HpsPayPlanCustomer $customer)
6
- * @method HpsPayPlanCustomerServiceDeleteBuilder withCustomerKey(string $customerKey)
7
- */
8
- class HpsPayPlanCustomerServiceDeleteBuilder extends HpsBuilderAbstract
9
- {
10
- /** @var array */
11
- protected $data = array();
12
-
13
- /** @var HpsPayPlanCustomer|null */
14
- protected $customer = null;
15
-
16
- /** @var string|null */
17
- protected $customerKey = null;
18
-
19
- /**
20
- * Instatiates a new HpsPayPlanCustomerServiceDeleteBuilder
21
- *
22
- * @param HpsRestGatewayService $service
23
- */
24
- public function __construct(HpsRestGatewayService $service)
25
- {
26
- parent::__construct($service);
27
- $this->setUpValidations();
28
- }
29
-
30
- /**
31
- * Creates an delete transaction through the HpsPayPlanCustomerService
32
- */
33
- public function execute()
34
- {
35
- parent::execute();
36
-
37
- if ($this->customer != null) {
38
- $this->customerKey = $this->customer->customerKey;
39
- }
40
-
41
- $service = new HpsPayPlanCustomerService($this->service->servicesConfig());
42
-
43
- return $service->delete($this->customerKey);
44
- }
45
-
46
- /**
47
- * Setups up validations for building customer
48
- * deletes.
49
- *
50
- * @return null
51
- */
52
- private function setUpValidations()
53
- {
54
- $this
55
- ->addValidation(array($this, 'onlyOneCustomerIdentifier'), 'HpsArgumentException', 'Delete can only use one customer identifier ($customer or $customerKey)');
56
- }
57
-
58
- /**
59
- * Ensures there is only one customer identifier, and
60
- * checks that there is only one customer or one
61
- * customerKey in use. Both cannot be used.
62
- *
63
- * @param array $actionCounts
64
- *
65
- * @return bool
66
- */
67
- public function onlyOneCustomerIdentifier($actionCounts)
68
- {
69
- return (isset($actionCounts['customer']) && $actionCounts['customer'] == 1
70
- && (!isset($actionCounts['customerKey'])
71
- || isset($actionCounts['customerKey']) && $actionCounts['customerKey'] == 0))
72
- || (isset($actionCounts['customerKey']) && $actionCounts['customerKey'] == 1
73
- && (!isset($actionCounts['customer'])
74
- || isset($actionCounts['customer']) && $actionCounts['customer'] == 0));
75
- }
76
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanCustomerServiceEditBuilder.php DELETED
@@ -1,122 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanCustomerServiceEditBuilder withData(array $data)
5
- * @method HpsPayPlanCustomerServiceEditBuilder withCustomer(HpsPaymentCustomer $customer)
6
- * @method HpsPayPlanCustomerServiceEditBuilder withCustomerKey(string $customerKey)
7
- */
8
- class HpsPayPlanCustomerServiceEditBuilder extends HpsBuilderAbstract
9
- {
10
- /** @var array */
11
- protected $data = array();
12
-
13
- /** @var HpsPaymentCustomer|null */
14
- protected $customer = null;
15
-
16
- /** @var string|null */
17
- protected $customerKey = null;
18
-
19
- /**
20
- * Instatiates a new HpsPayPlanCustomerServiceEditBuilder
21
- *
22
- * @param HpsRestGatewayService $service
23
- */
24
- public function __construct(HpsRestGatewayService $service)
25
- {
26
- parent::__construct($service);
27
- $this->setUpValidations();
28
- }
29
-
30
- /**
31
- * Creates an edit transaction through the HpsPayPlanCustomerService
32
- */
33
- public function execute()
34
- {
35
- parent::execute();
36
-
37
- if ($this->customer != null) {
38
- $this->customerKey = $this->customer->customerKey;
39
- }
40
-
41
- $service = new HpsPayPlanCustomerService($this->service->servicesConfig());
42
- $obj = new HpsPayPlanCustomer();
43
- $obj->customerKey = $this->customerKey;
44
-
45
- $usableData = array_intersect_key(
46
- $this->data,
47
- array_flip(HpsPayPlanCustomer::getEditableFields())
48
- );
49
- foreach ($usableData as $k => $v) {
50
- $obj->$k = $v;
51
- }
52
- unset($usableData, $k, $v);
53
-
54
- return $service->edit($obj);
55
- }
56
-
57
- /**
58
- * Setups up validations for building customer
59
- * edits.
60
- *
61
- * @return null
62
- */
63
- private function setUpValidations()
64
- {
65
- $this
66
- ->addValidation(array($this, 'onlyOneCustomerIdentifier'), 'HpsArgumentException', 'Edit can only use one customer identifier ($customer or $customerKey)')
67
- ->addValidation(array($this, 'dataNotEmpty'), 'HpsArgumentException', 'Edit needs a non-empty data set');
68
- }
69
-
70
- /**
71
- * Ensures there is only one customer identifier, and
72
- * checks that there is only one customer or one
73
- * customerKey in use. Both cannot be used.
74
- *
75
- * @param array $actionCounts
76
- *
77
- * @return bool
78
- */
79
- public function onlyOneCustomerIdentifier($actionCounts)
80
- {
81
- return (isset($actionCounts['customer']) && $actionCounts['customer'] == 1
82
- && (!isset($actionCounts['customerKey'])
83
- || isset($actionCounts['customerKey']) && $actionCounts['customerKey'] == 0))
84
- || (isset($actionCounts['customerKey']) && $actionCounts['customerKey'] == 1
85
- && (!isset($actionCounts['customer'])
86
- || isset($actionCounts['customer']) && $actionCounts['customer'] == 0));
87
- }
88
-
89
- /**
90
- * Ensures the data set is not empty.
91
- *
92
- * @param array $actionCounts
93
- *
94
- * @return bool
95
- */
96
- protected function dataNotEmpty($actionCounts)
97
- {
98
- return !empty($this->data);
99
- }
100
-
101
- /**
102
- * @param string $key
103
- * @param mixed $value
104
- *
105
- * @return HpsPayPlanCustomerServiceEditBuilder
106
- */
107
- public function update($key, $value)
108
- {
109
- $this->data[$key] = $value;
110
- return $this;
111
- }
112
-
113
- /**
114
- * @param string $key
115
- *
116
- * @return HpsPayPlanCustomerServiceEditBuilder
117
- */
118
- public function ignore($key)
119
- {
120
- return $this->update($key, null);
121
- }
122
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanCustomerServiceGetBuilder.php DELETED
@@ -1,76 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanCustomerServiceGetBuilder withData(array $data)
5
- * @method HpsPayPlanCustomerServiceGetBuilder withCustomer(HpsPayPlanCustomer $customer)
6
- * @method HpsPayPlanCustomerServiceGetBuilder withCustomerKey(string $customerKey)
7
- */
8
- class HpsPayPlanCustomerServiceGetBuilder extends HpsBuilderAbstract
9
- {
10
- /** @var array */
11
- protected $data = array();
12
-
13
- /** @var HpsPayPlanCustomer|null */
14
- protected $customer = null;
15
-
16
- /** @var string|null */
17
- protected $customerKey = null;
18
-
19
- /**
20
- * Instatiates a new HpsPayPlanCustomerServiceGetBuilder
21
- *
22
- * @param HpsRestGatewayService $service
23
- */
24
- public function __construct(HpsRestGatewayService $service)
25
- {
26
- parent::__construct($service);
27
- $this->setUpValidations();
28
- }
29
-
30
- /**
31
- * Creates an get transaction through the HpsPayPlanCustomerService
32
- */
33
- public function execute()
34
- {
35
- parent::execute();
36
-
37
- if ($this->customer != null) {
38
- $this->customerKey = $this->customer->customerKey;
39
- }
40
-
41
- $service = new HpsPayPlanCustomerService($this->service->servicesConfig());
42
-
43
- return $service->get($this->customerKey);
44
- }
45
-
46
- /**
47
- * Setups up validations for building customer
48
- * gets.
49
- *
50
- * @return null
51
- */
52
- private function setUpValidations()
53
- {
54
- $this
55
- ->addValidation(array($this, 'onlyOneCustomerIdentifier'), 'HpsArgumentException', 'Get can only use one customer identifier ($customer or $customerKey)');
56
- }
57
-
58
- /**
59
- * Ensures there is only one customer identifier, and
60
- * checks that there is only one customer or one
61
- * customerKey in use. Both cannot be used.
62
- *
63
- * @param array $actionCounts
64
- *
65
- * @return bool
66
- */
67
- public function onlyOneCustomerIdentifier($actionCounts)
68
- {
69
- return (isset($actionCounts['customer']) && $actionCounts['customer'] == 1
70
- && (!isset($actionCounts['customerKey'])
71
- || isset($actionCounts['customerKey']) && $actionCounts['customerKey'] == 0))
72
- || (isset($actionCounts['customerKey']) && $actionCounts['customerKey'] == 1
73
- && (!isset($actionCounts['customer'])
74
- || isset($actionCounts['customer']) && $actionCounts['customer'] == 0));
75
- }
76
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanCustomerServiceSearchBuilder.php DELETED
@@ -1,83 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanCustomerServiceSearchBuilder withData(array $data)
5
- */
6
- class HpsPayPlanCustomerServiceSearchBuilder extends HpsBuilderAbstract
7
- {
8
- /** @var array */
9
- protected $data = array();
10
-
11
- /**
12
- * Instatiates a new HpsPayPlanCustomerServiceSearchBuilder
13
- *
14
- * @param HpsRestGatewayService $service
15
- */
16
- public function __construct(HpsRestGatewayService $service)
17
- {
18
- parent::__construct($service);
19
- $this->setUpValidations();
20
- }
21
-
22
- /**
23
- * Creates an search transaction through the HpsPayPlanCustomerService
24
- */
25
- public function execute()
26
- {
27
- parent::execute();
28
-
29
- $service = new HpsPayPlanCustomerService($this->service->servicesConfig());
30
- $usableData = array_intersect_key(
31
- $this->data,
32
- array_flip(HpsPayPlanCustomer::getSearchableFields())
33
- );
34
-
35
- return $service->search($usableData);
36
- }
37
-
38
- /**
39
- * Setups up validations for building customer
40
- * searches.
41
- *
42
- * @return null
43
- */
44
- private function setUpValidations()
45
- {
46
- $this
47
- ->addValidation(array($this, 'dataNotEmpty'), 'HpsArgumentException', 'Search needs a non-empty data set');
48
- }
49
-
50
- /**
51
- * Ensures the data set is not empty.
52
- *
53
- * @param array $actionCounts
54
- *
55
- * @return bool
56
- */
57
- protected function dataNotEmpty($actionCounts)
58
- {
59
- return !empty($this->data);
60
- }
61
-
62
- /**
63
- * @param string $key
64
- * @param mixed $value
65
- *
66
- * @return HpsPayPlanCustomerServiceSearchBuilder
67
- */
68
- public function filter($key, $value)
69
- {
70
- $this->data[$key] = $value;
71
- return $this;
72
- }
73
-
74
- /**
75
- * @param string $key
76
- *
77
- * @return HpsPayPlanCustomerServiceSearchBuilder
78
- */
79
- public function ignore($key)
80
- {
81
- return $this->filter($key, null);
82
- }
83
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanPaymentMethodServiceAddBuilder.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanPaymentMethodServiceAddBuilder withData(array $data)
5
- */
6
- class HpsPayPlanPaymentMethodServiceAddBuilder extends HpsBuilderAbstract
7
- {
8
- /** @var array */
9
- protected $data = array();
10
-
11
- /**
12
- * Instatiates a new HpsPayPlanPaymentMethodServiceAddBuilder
13
- *
14
- * @param HpsRestGatewayService $service
15
- */
16
- public function __construct(HpsRestGatewayService $service)
17
- {
18
- parent::__construct($service);
19
- $this->setUpValidations();
20
- }
21
-
22
- /**
23
- * Creates an add transaction through the HpsPayPlanPaymentMethodService
24
- */
25
- public function execute()
26
- {
27
- parent::execute();
28
-
29
- $service = new HpsPayPlanPaymentMethodService($this->service->servicesConfig());
30
- $obj = new HpsPayPlanPaymentMethod();
31
-
32
- foreach ($this->data as $k => $v) {
33
- $obj->$k = $v;
34
- }
35
- unset($usableData, $k, $v);
36
-
37
- return $service->add($obj);
38
- }
39
-
40
- /**
41
- * Setups up validations for building payment method
42
- * adds.
43
- *
44
- * @return null
45
- */
46
- private function setUpValidations()
47
- {
48
- $this
49
- ->addValidation(array($this, 'dataNotEmpty'), 'HpsArgumentException', 'Add needs a non-empty data set');
50
- }
51
-
52
- /**
53
- * Ensures the data set is not empty.
54
- *
55
- * @param array $actionCounts
56
- *
57
- * @return bool
58
- */
59
- protected function dataNotEmpty($actionCounts)
60
- {
61
- return !empty($this->data);
62
- }
63
-
64
- /**
65
- * @param string $key
66
- * @param mixed $value
67
- *
68
- * @return HpsPayPlanPaymentMethodServiceAddBuilder
69
- */
70
- public function set($key, $value)
71
- {
72
- $this->data[$key] = $value;
73
- return $this;
74
- }
75
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanPaymentMethodServiceDeleteBuilder.php DELETED
@@ -1,76 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanPaymentMethodServiceDeleteBuilder withData(array $data)
5
- * @method HpsPayPlanPaymentMethodServiceDeleteBuilder withPaymentMethod(HpsPayPlanPaymentMethod $paymentMethod)
6
- * @method HpsPayPlanPaymentMethodServiceDeleteBuilder withPaymentMethodKey(string $paymentMethodKey)
7
- */
8
- class HpsPayPlanPaymentMethodServiceDeleteBuilder extends HpsBuilderAbstract
9
- {
10
- /** @var array */
11
- protected $data = array();
12
-
13
- /** @var HpsPayPlanPaymentMethod|null */
14
- protected $paymentMethod = null;
15
-
16
- /** @var string|null */
17
- protected $paymentMethodKey = null;
18
-
19
- /**
20
- * Instatiates a new HpsPayPlanPaymentMethodServiceDeleteBuilder
21
- *
22
- * @param HpsRestGatewayService $service
23
- */
24
- public function __construct(HpsRestGatewayService $service)
25
- {
26
- parent::__construct($service);
27
- $this->setUpValidations();
28
- }
29
-
30
- /**
31
- * Creates an delete transaction through the HpsPayPlanPaymentMethodService
32
- */
33
- public function execute()
34
- {
35
- parent::execute();
36
-
37
- if ($this->paymentMethod != null) {
38
- $this->paymentMethodKey = $this->paymentMethod->paymentMethodKey;
39
- }
40
-
41
- $service = new HpsPayPlanPaymentMethodService($this->service->servicesConfig());
42
-
43
- return $service->delete($this->paymentMethodKey);
44
- }
45
-
46
- /**
47
- * Setups up validations for building payment method
48
- * deletes.
49
- *
50
- * @return null
51
- */
52
- private function setUpValidations()
53
- {
54
- $this
55
- ->addValidation(array($this, 'onlyOnePaymentMethodIdentifier'), 'HpsArgumentException', 'Delete can only use one payment method identifier ($paymentMethod or $paymentMethodKey)');
56
- }
57
-
58
- /**
59
- * Ensures there is only one payment method identifier, and
60
- * checks that there is only one paymentMethod or one
61
- * paymentMethodKey in use. Both cannot be used.
62
- *
63
- * @param array $actionCounts
64
- *
65
- * @return bool
66
- */
67
- public function onlyOnePaymentMethodIdentifier($actionCounts)
68
- {
69
- return (isset($actionCounts['paymentMethod']) && $actionCounts['paymentMethod'] == 1
70
- && (!isset($actionCounts['paymentMethodKey'])
71
- || isset($actionCounts['paymentMethodKey']) && $actionCounts['paymentMethodKey'] == 0))
72
- || (isset($actionCounts['paymentMethodKey']) && $actionCounts['paymentMethodKey'] == 1
73
- && (!isset($actionCounts['paymentMethod'])
74
- || isset($actionCounts['paymentMethod']) && $actionCounts['paymentMethod'] == 0));
75
- }
76
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanPaymentMethodServiceEditBuilder.php DELETED
@@ -1,122 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanPaymentMethodServiceEditBuilder withData(array $data)
5
- * @method HpsPayPlanPaymentMethodServiceEditBuilder withPaymentMethod(HpsPayPlanPaymentMethod $paymentMethod)
6
- * @method HpsPayPlanPaymentMethodServiceEditBuilder withPaymentMethodKey(string $paymentMethodKey)
7
- */
8
- class HpsPayPlanPaymentMethodServiceEditBuilder extends HpsBuilderAbstract
9
- {
10
- /** @var array */
11
- protected $data = array();
12
-
13
- /** @var HpsPayPlanPaymentMethod|null */
14
- protected $paymentMethod = null;
15
-
16
- /** @var string|null */
17
- protected $paymentMethodKey = null;
18
-
19
- /**
20
- * Instatiates a new HpsPayPlanPaymentMethodServiceEditBuilder
21
- *
22
- * @param HpsRestGatewayService $service
23
- */
24
- public function __construct(HpsRestGatewayService $service)
25
- {
26
- parent::__construct($service);
27
- $this->setUpValidations();
28
- }
29
-
30
- /**
31
- * Creates an edit transaction through the HpsPayPlanPaymentMethodService
32
- */
33
- public function execute()
34
- {
35
- parent::execute();
36
-
37
- if ($this->paymentMethod != null) {
38
- $this->paymentMethodKey = $this->paymentMethod->paymentMethodKey;
39
- }
40
-
41
- $service = new HpsPayPlanPaymentMethodService($this->service->servicesConfig());
42
- $obj = new HpsPayPlanPaymentMethod();
43
- $obj->paymentMethodKey = $this->paymentMethodKey;
44
-
45
- $usableData = array_intersect_key(
46
- $this->data,
47
- array_flip(HpsPayPlanPaymentMethod::getEditableFields())
48
- );
49
- foreach ($usableData as $k => $v) {
50
- $obj->$k = $v;
51
- }
52
- unset($usableData, $k, $v);
53
-
54
- return $service->edit($obj);
55
- }
56
-
57
- /**
58
- * Setups up validations for building payment method
59
- * edits.
60
- *
61
- * @return null
62
- */
63
- private function setUpValidations()
64
- {
65
- $this
66
- ->addValidation(array($this, 'onlyOnePaymentMethodIdentifier'), 'HpsArgumentException', 'Edit can only use one payment method identifier ($paymentMethod or $paymentMethodKey)')
67
- ->addValidation(array($this, 'dataNotEmpty'), 'HpsArgumentException', 'Edit needs a non-empty data set');
68
- }
69
-
70
- /**
71
- * Ensures there is only one payment method identifier, and
72
- * checks that there is only one paymentMethod or one
73
- * paymentMethodKey in use. Both cannot be used.
74
- *
75
- * @param array $actionCounts
76
- *
77
- * @return bool
78
- */
79
- public function onlyOnePaymentMethodIdentifier($actionCounts)
80
- {
81
- return (isset($actionCounts['paymentMethod']) && $actionCounts['paymentMethod'] == 1
82
- && (!isset($actionCounts['paymentMethodKey'])
83
- || isset($actionCounts['paymentMethodKey']) && $actionCounts['paymentMethodKey'] == 0))
84
- || (isset($actionCounts['paymentMethodKey']) && $actionCounts['paymentMethodKey'] == 1
85
- && (!isset($actionCounts['paymentMethod'])
86
- || isset($actionCounts['paymentMethod']) && $actionCounts['paymentMethod'] == 0));
87
- }
88
-
89
- /**
90
- * Ensures the data set is not empty.
91
- *
92
- * @param array $actionCounts
93
- *
94
- * @return bool
95
- */
96
- protected function dataNotEmpty($actionCounts)
97
- {
98
- return !empty($this->data);
99
- }
100
-
101
- /**
102
- * @param string $key
103
- * @param mixed $value
104
- *
105
- * @return HpsPayPlanPaymentMethodServiceEditBuilder
106
- */
107
- public function update($key, $value)
108
- {
109
- $this->data[$key] = $value;
110
- return $this;
111
- }
112
-
113
- /**
114
- * @param string $key
115
- *
116
- * @return HpsPayPlanPaymentMethodServiceEditBuilder
117
- */
118
- public function ignore($key)
119
- {
120
- return $this->update($key, null);
121
- }
122
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanPaymentMethodServiceGetBuilder.php DELETED
@@ -1,76 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanPaymentMethodServiceGetBuilder withData(array $data)
5
- * @method HpsPayPlanPaymentMethodServiceGetBuilder withPaymentMethod(HpsPayPlanPaymentMethod $paymentMethod)
6
- * @method HpsPayPlanPaymentMethodServiceGetBuilder withPaymentMethodKey(string $paymentMethodKey)
7
- */
8
- class HpsPayPlanPaymentMethodServiceGetBuilder extends HpsBuilderAbstract
9
- {
10
- /** @var array */
11
- protected $data = array();
12
-
13
- /** @var HpsPayPlanPaymentMethod|null */
14
- protected $paymentMethod = null;
15
-
16
- /** @var string|null */
17
- protected $paymentMethodKey = null;
18
-
19
- /**
20
- * Instatiates a new HpsPayPlanPaymentMethodServiceGetBuilder
21
- *
22
- * @param HpsRestGatewayService $service
23
- */
24
- public function __construct(HpsRestGatewayService $service)
25
- {
26
- parent::__construct($service);
27
- $this->setUpValidations();
28
- }
29
-
30
- /**
31
- * Creates an get transaction through the HpsPayPlanPaymentMethodService
32
- */
33
- public function execute()
34
- {
35
- parent::execute();
36
-
37
- if ($this->paymentMethod != null) {
38
- $this->paymentMethodKey = $this->paymentMethod->paymentMethodKey;
39
- }
40
-
41
- $service = new HpsPayPlanPaymentMethodService($this->service->servicesConfig());
42
-
43
- return $service->get($this->paymentMethodKey);
44
- }
45
-
46
- /**
47
- * Setups up validations for building payment method
48
- * gets.
49
- *
50
- * @return null
51
- */
52
- private function setUpValidations()
53
- {
54
- $this
55
- ->addValidation(array($this, 'onlyOnePaymentMethodIdentifier'), 'HpsArgumentException', 'Get can only use one payment method identifier ($paymentMethod or $paymentMethodKey)');
56
- }
57
-
58
- /**
59
- * Ensures there is only one payment method identifier, and
60
- * checks that there is only one paymentMethod or one
61
- * paymentMethodKey in use. Both cannot be used.
62
- *
63
- * @param array $actionCounts
64
- *
65
- * @return bool
66
- */
67
- public function onlyOnePaymentMethodIdentifier($actionCounts)
68
- {
69
- return (isset($actionCounts['paymentMethod']) && $actionCounts['paymentMethod'] == 1
70
- && (!isset($actionCounts['paymentMethodKey'])
71
- || isset($actionCounts['paymentMethodKey']) && $actionCounts['paymentMethodKey'] == 0))
72
- || (isset($actionCounts['paymentMethodKey']) && $actionCounts['paymentMethodKey'] == 1
73
- && (!isset($actionCounts['paymentMethod'])
74
- || isset($actionCounts['paymentMethod']) && $actionCounts['paymentMethod'] == 0));
75
- }
76
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanPaymentMethodServiceSearchBuilder.php DELETED
@@ -1,83 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanPaymentMethodServiceSearchBuilder withData(array $data)
5
- */
6
- class HpsPayPlanPaymentMethodServiceSearchBuilder extends HpsBuilderAbstract
7
- {
8
- /** @var array */
9
- protected $data = array();
10
-
11
- /**
12
- * Instatiates a new HpsPayPlanPaymentMethodServiceSearchBuilder
13
- *
14
- * @param HpsRestGatewayService $service
15
- */
16
- public function __construct(HpsRestGatewayService $service)
17
- {
18
- parent::__construct($service);
19
- $this->setUpValidations();
20
- }
21
-
22
- /**
23
- * Creates an search transaction through the HpsPayPlanPaymentMethodService
24
- */
25
- public function execute()
26
- {
27
- parent::execute();
28
-
29
- $service = new HpsPayPlanPaymentMethodService($this->service->servicesConfig());
30
- $usableData = array_intersect_key(
31
- $this->data,
32
- array_flip(HpsPayPlanPaymentMethod::getSearchableFields())
33
- );
34
-
35
- return $service->search($usableData);
36
- }
37
-
38
- /**
39
- * Setups up validations for building payment method
40
- * searches.
41
- *
42
- * @return null
43
- */
44
- private function setUpValidations()
45
- {
46
- $this
47
- ->addValidation(array($this, 'dataNotEmpty'), 'HpsArgumentException', 'Search needs a non-empty data set');
48
- }
49
-
50
- /**
51
- * Ensures the data set is not empty.
52
- *
53
- * @param array $actionCounts
54
- *
55
- * @return bool
56
- */
57
- protected function dataNotEmpty($actionCounts)
58
- {
59
- return !empty($this->data);
60
- }
61
-
62
- /**
63
- * @param string $key
64
- * @param mixed $value
65
- *
66
- * @return HpsPayPlanPaymentMethodServiceSearchBuilder
67
- */
68
- public function filter($key, $value)
69
- {
70
- $this->data[$key] = $value;
71
- return $this;
72
- }
73
-
74
- /**
75
- * @param string $key
76
- *
77
- * @return HpsPayPlanPaymentMethodServiceSearchBuilder
78
- */
79
- public function ignore($key)
80
- {
81
- return $this->filter($key, null);
82
- }
83
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanScheduleServiceAddBuilder.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanScheduleServiceAddBuilder withData(array $data)
5
- */
6
- class HpsPayPlanScheduleServiceAddBuilder extends HpsBuilderAbstract
7
- {
8
- /** @var array */
9
- protected $data = array();
10
-
11
- /**
12
- * Instatiates a new HpsPayPlanScheduleServiceAddBuilder
13
- *
14
- * @param HpsRestGatewayService $service
15
- */
16
- public function __construct(HpsRestGatewayService $service)
17
- {
18
- parent::__construct($service);
19
- $this->setUpValidations();
20
- }
21
-
22
- /**
23
- * Creates an add transaction through the HpsPayPlanScheduleService
24
- */
25
- public function execute()
26
- {
27
- parent::execute();
28
-
29
- $service = new HpsPayPlanScheduleService($this->service->servicesConfig());
30
- $obj = new HpsPayPlanSchedule();
31
-
32
- foreach ($this->data as $k => $v) {
33
- $obj->$k = $v;
34
- }
35
- unset($usableData, $k, $v);
36
-
37
- return $service->add($obj);
38
- }
39
-
40
- /**
41
- * Setups up validations for building payment schedule
42
- * adds.
43
- *
44
- * @return null
45
- */
46
- private function setUpValidations()
47
- {
48
- $this
49
- ->addValidation(array($this, 'dataNotEmpty'), 'HpsArgumentException', 'Add needs a non-empty data set');
50
- }
51
-
52
- /**
53
- * Ensures the data set is not empty.
54
- *
55
- * @param array $actionCounts
56
- *
57
- * @return bool
58
- */
59
- protected function dataNotEmpty($actionCounts)
60
- {
61
- return !empty($this->data);
62
- }
63
-
64
- /**
65
- * @param string $key
66
- * @param mixed $value
67
- *
68
- * @return HpsPayPlanScheduleServiceAddBuilder
69
- */
70
- public function set($key, $value)
71
- {
72
- $this->data[$key] = $value;
73
- return $this;
74
- }
75
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanScheduleServiceDeleteBuilder.php DELETED
@@ -1,76 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanScheduleServiceDeleteBuilder withData(array $data)
5
- * @method HpsPayPlanScheduleServiceDeleteBuilder withSchedule(HpsPayPlanSchedule $paymentSchedule)
6
- * @method HpsPayPlanScheduleServiceDeleteBuilder withScheduleKey(string $paymentScheduleKey)
7
- */
8
- class HpsPayPlanScheduleServiceDeleteBuilder extends HpsBuilderAbstract
9
- {
10
- /** @var array */
11
- protected $data = array();
12
-
13
- /** @var HpsPayPlanSchedule|null */
14
- protected $paymentSchedule = null;
15
-
16
- /** @var string|null */
17
- protected $paymentScheduleKey = null;
18
-
19
- /**
20
- * Instatiates a new HpsPayPlanScheduleServiceDeleteBuilder
21
- *
22
- * @param HpsRestGatewayService $service
23
- */
24
- public function __construct(HpsRestGatewayService $service)
25
- {
26
- parent::__construct($service);
27
- $this->setUpValidations();
28
- }
29
-
30
- /**
31
- * Creates an delete transaction through the HpsPayPlanScheduleService
32
- */
33
- public function execute()
34
- {
35
- parent::execute();
36
-
37
- if ($this->paymentSchedule != null) {
38
- $this->paymentScheduleKey = $this->paymentSchedule->paymentScheduleKey;
39
- }
40
-
41
- $service = new HpsPayPlanScheduleService($this->service->servicesConfig());
42
-
43
- return $service->delete($this->paymentScheduleKey);
44
- }
45
-
46
- /**
47
- * Setups up validations for building payment schedule
48
- * deletes.
49
- *
50
- * @return null
51
- */
52
- private function setUpValidations()
53
- {
54
- $this
55
- ->addValidation(array($this, 'onlyOneScheduleIdentifier'), 'HpsArgumentException', 'Delete can only use one payment schedule identifier ($paymentSchedule or $paymentScheduleKey)');
56
- }
57
-
58
- /**
59
- * Ensures there is only one payment schedule identifier, and
60
- * checks that there is only one paymentSchedule or one
61
- * paymentScheduleKey in use. Both cannot be used.
62
- *
63
- * @param array $actionCounts
64
- *
65
- * @return bool
66
- */
67
- public function onlyOneScheduleIdentifier($actionCounts)
68
- {
69
- return (isset($actionCounts['paymentSchedule']) && $actionCounts['paymentSchedule'] == 1
70
- && (!isset($actionCounts['paymentScheduleKey'])
71
- || isset($actionCounts['paymentScheduleKey']) && $actionCounts['paymentScheduleKey'] == 0))
72
- || (isset($actionCounts['paymentScheduleKey']) && $actionCounts['paymentScheduleKey'] == 1
73
- && (!isset($actionCounts['paymentSchedule'])
74
- || isset($actionCounts['paymentSchedule']) && $actionCounts['paymentSchedule'] == 0));
75
- }
76
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanScheduleServiceEditBuilder.php DELETED
@@ -1,122 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanScheduleServiceEditBuilder withData(array $data)
5
- * @method HpsPayPlanScheduleServiceEditBuilder withSchedule(HpsPayPlanSchedule $paymentSchedule)
6
- * @method HpsPayPlanScheduleServiceEditBuilder withScheduleKey(string $paymentScheduleKey)
7
- */
8
- class HpsPayPlanScheduleServiceEditBuilder extends HpsBuilderAbstract
9
- {
10
- /** @var array */
11
- protected $data = array();
12
-
13
- /** @var HpsPayPlanSchedule|null */
14
- protected $paymentSchedule = null;
15
-
16
- /** @var string|null */
17
- protected $paymentScheduleKey = null;
18
-
19
- /**
20
- * Instatiates a new HpsPayPlanScheduleServiceEditBuilder
21
- *
22
- * @param HpsRestGatewayService $service
23
- */
24
- public function __construct(HpsRestGatewayService $service)
25
- {
26
- parent::__construct($service);
27
- $this->setUpValidations();
28
- }
29
-
30
- /**
31
- * Creates an edit transaction through the HpsPayPlanScheduleService
32
- */
33
- public function execute()
34
- {
35
- parent::execute();
36
-
37
- if ($this->paymentSchedule != null) {
38
- $this->paymentScheduleKey = $this->paymentSchedule->paymentScheduleKey;
39
- }
40
-
41
- $service = new HpsPayPlanScheduleService($this->service->servicesConfig());
42
- $obj = new HpsPayPlanSchedule();
43
- $obj->paymentScheduleKey = $this->paymentScheduleKey;
44
-
45
- $usableData = array_intersect_key(
46
- $this->data,
47
- array_flip(HpsPayPlanSchedule::getEditableFields())
48
- );
49
- foreach ($usableData as $k => $v) {
50
- $obj->$k = $v;
51
- }
52
- unset($usableData, $k, $v);
53
-
54
- return $service->edit($obj);
55
- }
56
-
57
- /**
58
- * Setups up validations for building payment schedule
59
- * edits.
60
- *
61
- * @return null
62
- */
63
- private function setUpValidations()
64
- {
65
- $this
66
- ->addValidation(array($this, 'onlyOneScheduleIdentifier'), 'HpsArgumentException', 'Edit can only use one payment schedule identifier ($paymentSchedule or $paymentScheduleKey)')
67
- ->addValidation(array($this, 'dataNotEmpty'), 'HpsArgumentException', 'Edit needs a non-empty data set');
68
- }
69
-
70
- /**
71
- * Ensures there is only one payment schedule identifier, and
72
- * checks that there is only one paymentSchedule or one
73
- * paymentScheduleKey in use. Both cannot be used.
74
- *
75
- * @param array $actionCounts
76
- *
77
- * @return bool
78
- */
79
- public function onlyOneScheduleIdentifier($actionCounts)
80
- {
81
- return (isset($actionCounts['paymentSchedule']) && $actionCounts['paymentSchedule'] == 1
82
- && (!isset($actionCounts['paymentScheduleKey'])
83
- || isset($actionCounts['paymentScheduleKey']) && $actionCounts['paymentScheduleKey'] == 0))
84
- || (isset($actionCounts['paymentScheduleKey']) && $actionCounts['paymentScheduleKey'] == 1
85
- && (!isset($actionCounts['paymentSchedule'])
86
- || isset($actionCounts['paymentSchedule']) && $actionCounts['paymentSchedule'] == 0));
87
- }
88
-
89
- /**
90
- * Ensures the data set is not empty.
91
- *
92
- * @param array $actionCounts
93
- *
94
- * @return bool
95
- */
96
- protected function dataNotEmpty($actionCounts)
97
- {
98
- return !empty($this->data);
99
- }
100
-
101
- /**
102
- * @param string $key
103
- * @param mixed $value
104
- *
105
- * @return HpsPayPlanScheduleServiceEditBuilder
106
- */
107
- public function update($key, $value)
108
- {
109
- $this->data[$key] = $value;
110
- return $this;
111
- }
112
-
113
- /**
114
- * @param string $key
115
- *
116
- * @return HpsPayPlanScheduleServiceEditBuilder
117
- */
118
- public function ignore($key)
119
- {
120
- return $this->update($key, null);
121
- }
122
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanScheduleServiceGetBuilder.php DELETED
@@ -1,76 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanScheduleServiceGetBuilder withData(array $data)
5
- * @method HpsPayPlanScheduleServiceGetBuilder withSchedule(HpsPayPlanSchedule $paymentSchedule)
6
- * @method HpsPayPlanScheduleServiceGetBuilder withScheduleKey(string $paymentScheduleKey)
7
- */
8
- class HpsPayPlanScheduleServiceGetBuilder extends HpsBuilderAbstract
9
- {
10
- /** @var array */
11
- protected $data = array();
12
-
13
- /** @var HpsPayPlanSchedule|null */
14
- protected $paymentSchedule = null;
15
-
16
- /** @var string|null */
17
- protected $paymentScheduleKey = null;
18
-
19
- /**
20
- * Instatiates a new HpsPayPlanScheduleServiceGetBuilder
21
- *
22
- * @param HpsRestGatewayService $service
23
- */
24
- public function __construct(HpsRestGatewayService $service)
25
- {
26
- parent::__construct($service);
27
- $this->setUpValidations();
28
- }
29
-
30
- /**
31
- * Creates an get transaction through the HpsPayPlanScheduleService
32
- */
33
- public function execute()
34
- {
35
- parent::execute();
36
-
37
- if ($this->paymentSchedule != null) {
38
- $this->paymentScheduleKey = $this->paymentSchedule->paymentScheduleKey;
39
- }
40
-
41
- $service = new HpsPayPlanScheduleService($this->service->servicesConfig());
42
-
43
- return $service->get($this->paymentScheduleKey);
44
- }
45
-
46
- /**
47
- * Setups up validations for building payment schedule
48
- * gets.
49
- *
50
- * @return null
51
- */
52
- private function setUpValidations()
53
- {
54
- $this
55
- ->addValidation(array($this, 'onlyOneScheduleIdentifier'), 'HpsArgumentException', 'Get can only use one payment schedule identifier ($paymentSchedule or $paymentScheduleKey)');
56
- }
57
-
58
- /**
59
- * Ensures there is only one payment schedule identifier, and
60
- * checks that there is only one paymentSchedule or one
61
- * paymentScheduleKey in use. Both cannot be used.
62
- *
63
- * @param array $actionCounts
64
- *
65
- * @return bool
66
- */
67
- public function onlyOneScheduleIdentifier($actionCounts)
68
- {
69
- return (isset($actionCounts['paymentSchedule']) && $actionCounts['paymentSchedule'] == 1
70
- && (!isset($actionCounts['paymentScheduleKey'])
71
- || isset($actionCounts['paymentScheduleKey']) && $actionCounts['paymentScheduleKey'] == 0))
72
- || (isset($actionCounts['paymentScheduleKey']) && $actionCounts['paymentScheduleKey'] == 1
73
- && (!isset($actionCounts['paymentSchedule'])
74
- || isset($actionCounts['paymentSchedule']) && $actionCounts['paymentSchedule'] == 0));
75
- }
76
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Fluent/Gateway/PayPlan/HpsPayPlanScheduleServiceSearchBuilder.php DELETED
@@ -1,83 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @method HpsPayPlanScheduleServiceSearchBuilder withData(array $data)
5
- */
6
- class HpsPayPlanScheduleServiceSearchBuilder extends HpsBuilderAbstract
7
- {
8
- /** @var array */
9
- protected $data = array();
10
-
11
- /**
12
- * Instatiates a new HpsPayPlanScheduleServiceSearchBuilder
13
- *
14
- * @param HpsRestGatewayService $service
15
- */
16
- public function __construct(HpsRestGatewayService $service)
17
- {
18
- parent::__construct($service);
19
- $this->setUpValidations();
20
- }
21
-
22
- /**
23
- * Creates an search transaction through the HpsPayPlanScheduleService
24
- */
25
- public function execute()
26
- {
27
- parent::execute();
28
-
29
- $service = new HpsPayPlanScheduleService($this->service->servicesConfig());
30
- $usableData = array_intersect_key(
31
- $this->data,
32
- array_flip(HpsPayPlanSchedule::getSearchableFields())
33
- );
34
-
35
- return $service->search($usableData);
36
- }
37
-
38
- /**
39
- * Setups up validations for building payment schedule
40
- * searches.
41
- *
42
- * @return null
43
- */
44
- private function setUpValidations()
45
- {
46
- $this
47
- ->addValidation(array($this, 'dataNotEmpty'), 'HpsArgumentException', 'Search needs a non-empty data set');
48
- }
49
-
50
- /**
51
- * Ensures the data set is not empty.
52
- *
53
- * @param array $actionCounts
54
- *
55
- * @return bool
56
- */
57
- protected function dataNotEmpty($actionCounts)
58
- {
59
- return !empty($this->data);
60
- }
61
-
62
- /**
63
- * @param string $key
64
- * @param mixed $value
65
- *
66
- * @return HpsPayPlanScheduleServiceSearchBuilder
67
- */
68
- public function filter($key, $value)
69
- {
70
- $this->data[$key] = $value;
71
- return $this;
72
- }
73
-
74
- /**
75
- * @param string $key
76
- *
77
- * @return HpsPayPlanScheduleServiceSearchBuilder
78
- */
79
- public function ignore($key)
80
- {
81
- return $this->filter($key, null);
82
- }
83
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/SecureSubmit/src/Services/Gateway/AltPayment/HpsAltPaymentService.php CHANGED
@@ -36,7 +36,7 @@ class HpsAltPaymentService extends HpsSoapGatewayService
36
 
37
  $xml = new DOMDocument();
38
  $transaction = $xml->createElement('hps:Transaction');
39
- $capture = $xml->createElement('hps:AltPaymentAddToBatch');
40
 
41
  $capture->appendChild($xml->createElement('hps:TransactionType', $this->_transactionType));
42
  $capture->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId));
@@ -50,7 +50,7 @@ class HpsAltPaymentService extends HpsSoapGatewayService
50
 
51
  $capture->appendChild($payment);
52
  $transaction->appendChild($capture);
53
- return $this->_submitTransaction($transaction, 'AltPaymentAddToBatch');
54
  }
55
 
56
  public function createSession($amount, $currency, HpsBuyerData $buyer, HpsPaymentData $payment, HpsShippingInfo $shippingAddress = null, $lineItems = null)
@@ -157,6 +157,18 @@ class HpsAltPaymentService extends HpsSoapGatewayService
157
  $this->_transactionType = $type;
158
  }
159
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  protected function hydrateBuyerData(HpsBuyerData $buyer, DOMDocument $xml)
161
  {
162
  $data = $xml->createElement('hps:Buyer');
@@ -284,6 +296,14 @@ class HpsAltPaymentService extends HpsSoapGatewayService
284
  if ($item != null) {
285
  $responseCode = (isset($item->RspCode) ? $item->RspCode : null);
286
  $responseMessage = (isset($item->RspMessage) ? $item->RspMessage : null);
 
 
 
 
 
 
 
 
287
  HpsProcessorResponseValidation::checkResponse($transactionId, $responseCode, $responseMessage, $item);
288
  }
289
  }
@@ -291,7 +311,7 @@ class HpsAltPaymentService extends HpsSoapGatewayService
291
  private function _submitTransaction($transaction, $txnType, $clientTxnId = null, $cardData = null)
292
  {
293
  try {
294
- $response = $this->doTransaction($transaction, $clientTxnId);
295
  } catch (HpsException $e) {
296
  if ($e->innerException != null && $e->innerException->getMessage() == 'gateway_time-out') {
297
  // if (in_array($txnType, array('CreditSale', 'CreditAuth'))) {
@@ -323,8 +343,8 @@ class HpsAltPaymentService extends HpsSoapGatewayService
323
  case 'AltPaymentAuth':
324
  $rvalue = HpsAltPaymentAuth::fromDict($response, $txnType);
325
  break;
326
- case 'AltPaymentAddToBatch':
327
- $rvalue = HpsAltPaymentAddToBatch::fromDict($response, $txnType);
328
  break;
329
  case 'AltPaymentReturn':
330
  $rvalue = HpsAltPaymentReturn::fromDict($response, $txnType);
@@ -332,6 +352,8 @@ class HpsAltPaymentService extends HpsSoapGatewayService
332
  case 'AltPaymentVoid':
333
  $rvalue = HpsAltPaymentVoid::fromDict($response, $txnType);
334
  break;
 
 
335
  default:
336
  break;
337
  }
36
 
37
  $xml = new DOMDocument();
38
  $transaction = $xml->createElement('hps:Transaction');
39
+ $capture = $xml->createElement('hps:AltPaymentCapture');
40
 
41
  $capture->appendChild($xml->createElement('hps:TransactionType', $this->_transactionType));
42
  $capture->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId));
50
 
51
  $capture->appendChild($payment);
52
  $transaction->appendChild($capture);
53
+ return $this->_submitTransaction($transaction, 'AltPaymentCapture');
54
  }
55
 
56
  public function createSession($amount, $currency, HpsBuyerData $buyer, HpsPaymentData $payment, HpsShippingInfo $shippingAddress = null, $lineItems = null)
157
  $this->_transactionType = $type;
158
  }
159
 
160
+ public function status($transactionId)
161
+ {
162
+ $xml = new DOMDocument();
163
+ $transaction = $xml->createElement('hps:Transaction');
164
+ $status = $xml->createElement('hps:GetTransactionStatus');
165
+
166
+ $status->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId));
167
+
168
+ $transaction->appendChild($status);
169
+ return $this->_submitTransaction($transaction, 'GetTransactionStatus');
170
+ }
171
+
172
  protected function hydrateBuyerData(HpsBuyerData $buyer, DOMDocument $xml)
173
  {
174
  $data = $xml->createElement('hps:Buyer');
296
  if ($item != null) {
297
  $responseCode = (isset($item->RspCode) ? $item->RspCode : null);
298
  $responseMessage = (isset($item->RspMessage) ? $item->RspMessage : null);
299
+
300
+ if ($responseCode == null && isset($item->TransactionStatus->RspCode)) {
301
+ $responseCode = $item->TransactionStatus->RspCode;
302
+ }
303
+ if ($responseMessage == null && isset($item->TransactionStatus->RspText)) {
304
+ $responseMessage = $item->TransactionStatus->RspText;
305
+ }
306
+
307
  HpsProcessorResponseValidation::checkResponse($transactionId, $responseCode, $responseMessage, $item);
308
  }
309
  }
311
  private function _submitTransaction($transaction, $txnType, $clientTxnId = null, $cardData = null)
312
  {
313
  try {
314
+ $response = $this->doRequest($transaction, $clientTxnId);
315
  } catch (HpsException $e) {
316
  if ($e->innerException != null && $e->innerException->getMessage() == 'gateway_time-out') {
317
  // if (in_array($txnType, array('CreditSale', 'CreditAuth'))) {
343
  case 'AltPaymentAuth':
344
  $rvalue = HpsAltPaymentAuth::fromDict($response, $txnType);
345
  break;
346
+ case 'AltPaymentCapture':
347
+ $rvalue = HpsAltPaymentCapture::fromDict($response, $txnType);
348
  break;
349
  case 'AltPaymentReturn':
350
  $rvalue = HpsAltPaymentReturn::fromDict($response, $txnType);
352
  case 'AltPaymentVoid':
353
  $rvalue = HpsAltPaymentVoid::fromDict($response, $txnType);
354
  break;
355
+ case 'GetTransactionStatus':
356
+ $rvalue = HpsTransactionStatus::fromDict($response, $txnType);
357
  default:
358
  break;
359
  }
lib/SecureSubmit/src/Services/Gateway/AltPayment/HpsMasterPassService.php ADDED
@@ -0,0 +1,601 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MasterPass using Cardinal Commerce
4
+ *
5
+ * PHP Version 5.2+
6
+ *
7
+ * @category PHP
8
+ * @package HPS
9
+ * @author Heartland Payment Systems <EntApp_DevPortal@e-hps.com>
10
+ * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom
11
+ * @link https://github.com/hps/heartland-php
12
+ */
13
+
14
+ /**
15
+ * MasterPass using Cardinal Commerce
16
+ *
17
+ * @category PHP
18
+ * @package HPS
19
+ * @author Heartland Payment Systems <EntApp_DevPortal@e-hps.com>
20
+ * @license https://github.com/hps/heartland-php/blob/master/LICENSE.txt Custom
21
+ * @link https://github.com/hps/heartland-php
22
+ */
23
+ class HpsMasterPassService
24
+ extends HpsCentinelGatewayService
25
+ implements HpsAltPaymentServiceInterface
26
+ {
27
+ protected static $currencyCodes = array(
28
+ 'usd' => '840',
29
+ );
30
+
31
+ /**
32
+ * Updates the Merchant’s front-end order number with their back-end order
33
+ * number in the Centinel system. The Merchant’s original order number is
34
+ * persisted and searchable. The transaction expects the OrderId and
35
+ * OrderNumber values to correspond to the original Lookup response message.
36
+ *
37
+ * @param string $orderId order id from Cardinal
38
+ * @param HpsOrderData $orderData Cardinal/MasterPass specific data
39
+ */
40
+ public function addOrderNumber(
41
+ $orderId,
42
+ HpsOrderData $orderData
43
+ ) {
44
+ $payload = array(
45
+ 'OrderId' => $orderId,
46
+ 'OrderNumber' => $orderData->orderNumber,
47
+ 'TransactionType' => 'WT',
48
+ );
49
+ return $this->submitTransaction($payload, 'cmpi_add_order_number');
50
+ }
51
+
52
+ /**
53
+ * Responsible for returning the status of the MasterPass transaction to the
54
+ * Merchant. The message will return the status of the transaction, enabling
55
+ * the Merchant to handle the order according to the outcome. In the event
56
+ * that the ErrorNo element is 0 (zero) then the PAResStatus value will define
57
+ * how the transaction should be processed. Based on the transaction outcome
58
+ * the Merchant's order management system should be updated and the appropriate
59
+ * message should be displayed to the consumer. In the event that a nonzero
60
+ * ErrorNo value is returned or PAResStatus value is not Y, the consumer should
61
+ * be prompted for an alternate form of payment.
62
+ *
63
+ * @param string $orderId order id from Cardinal
64
+ * @param string $oauthToken oauth token from MasterPass
65
+ * @param string $oauthVerifier oauth verifier from MasterPass
66
+ * @param string $payload payload data from Cardinal
67
+ * @param string $resourceUrl resource URL from MasterPass
68
+ * @param HpsOrderData $orderData Cardinal/MasterPass specific data
69
+ *
70
+ * @return object
71
+ */
72
+ public function authenticate(
73
+ $orderId,
74
+ $oauthToken,
75
+ $oauthVerifier,
76
+ $payload,
77
+ $resourceUrl,
78
+ HpsOrderData $orderData = null
79
+ ) {
80
+ $data = array(
81
+ 'OrderId' => $orderId,
82
+ 'PAResPayload' => $payload,
83
+ 'Status' => $orderData->transactionStatus,
84
+ 'TransactionType' => 'WT',
85
+ );
86
+
87
+ if ($orderData->checkoutType === HpsCentinelCheckoutType::PAIRING ||
88
+ $orderData->checkoutType === HpsCentinelCheckoutType::PAIRING_CHECKOUT
89
+ ) {
90
+ $data['PairingToken'] = $orderData->pairingToken;
91
+ $data['PairingVerifier'] = $orderData->pairingVerifier;
92
+ }
93
+
94
+ if ($orderData->checkoutType === null ||
95
+ $orderData->checkoutType === HpsCentinelCheckoutType::LIGHTBOX ||
96
+ $orderData->checkoutType === HpsCentinelCheckoutType::PAIRING_CHECKOUT
97
+ ) {
98
+ $data['CheckoutResourceUrl'] = $resourceUrl;
99
+ $data['OAuthToken'] = $oauthToken;
100
+ $data['OAuthVerifier'] = $oauthVerifier;
101
+ }
102
+
103
+ return $this->submitTransaction($data, 'cmpi_authenticate');
104
+ }
105
+
106
+ /**
107
+ * Responsible for authorizing the transaction. Once authorized, the
108
+ * transaction amount can be captured at a later point in time. Once the
109
+ * Merchant is ready to perform the actual Authorization of funds the
110
+ * Authorize message should be processes referencing the original OrderId
111
+ * returned in the Lookup message. This authorization request checks the
112
+ * availability of the Customer’s funds to obtain an honor period for
113
+ * capture/settlement.
114
+ *
115
+ * @param string $orderId order id from Cardinal
116
+ * @param mixed $amount amount to be authorized
117
+ * @param string $currency currency code
118
+ * @param HpsBuyerData $buyer buyer information
119
+ * @param HpsPaymentData $payment payment information
120
+ * @param HpsShippingInfo $shippingAddress shipping information
121
+ * @param array<int, HpsLineItem> $lineItems line items from order
122
+ * @param HpsOrderData $orderData Cardinal/MasterPass specific
123
+ * data
124
+ *
125
+ * @return object
126
+ */
127
+ public function authorize(
128
+ $orderId,
129
+ $amount,
130
+ $currency,
131
+ HpsBuyerData $buyer = null,
132
+ HpsPaymentData $payment = null,
133
+ HpsShippingInfo $shippingAddress = null,
134
+ $lineItems = null,
135
+ HpsOrderData $orderData = null
136
+ ) {
137
+ $payload = array(
138
+ 'TransactionType' => 'WT',
139
+ 'Amount' => $this->formatAmount($amount),
140
+ 'OrderId' => $orderId,
141
+ 'CurrencyCode' => $this->currencyStringToNumeric($currency),
142
+ );
143
+ if ($buyer !== null) {
144
+ $payload = array_merge($payload, $this->hydrateBuyerData($buyer));
145
+ }
146
+ if ($payment !== null) {
147
+ $payload = array_merge($payload, $this->hydratePaymentData($payment));
148
+ }
149
+ if ($shippingAddress !== null) {
150
+ $payload = array_merge($payload, $this->hydrateShippingInfo($shippingAddress));
151
+ }
152
+ if ($lineItems !== null) {
153
+ $payload = array_merge($payload, $this->hydrateLineItems($lineItems));
154
+ }
155
+ return $this->submitTransaction($payload, 'cmpi_authorize');
156
+ }
157
+
158
+ /**
159
+ * Responsible for settling funds from previous authorization transaction.
160
+ * Payment for the complete or partial amount of the authorization is available.
161
+ * Multiple captures can be processed against a single Authorization up to 100%
162
+ * of the authorization.
163
+ *
164
+ * @param string $orderId order id from Cardinal
165
+ * @param mixed $amount amount to be authorized
166
+ * @param HpsOrderData $orderData Cardinal/MasterPass specific data
167
+ *
168
+ * @return object
169
+ */
170
+ public function capture(
171
+ $orderId,
172
+ $amount,
173
+ HpsOrderData $orderData = null
174
+ ) {
175
+ $payload = array(
176
+ 'Amount' => $this->formatAmount($amount),
177
+ 'CurrencyCode' => $this->currencyStringToNumeric($orderData->currencyCode),
178
+ 'OrderId' => $orderId,
179
+ 'OrderNumber' => $orderData->orderNumber,
180
+ 'TransactionType' => 'WT',
181
+ );
182
+ return $this->submitTransaction($payload, 'cmpi_capture');
183
+ }
184
+
185
+ /**
186
+ * Responsible for initiating the MasterPass transaction. The Lookup Message
187
+ * is constructed and sent to the Centinel platform for processing. The Lookup
188
+ * Message requires transaction specific data elements to be formatted on the
189
+ * request message. Please refer to the Message API section for the complete
190
+ * list of required message elements.
191
+ *
192
+ * The Centinel platform will then redirect the consumer back to the TermUrl
193
+ * representing a web page on the merchant's website. At that point, the
194
+ * merchant will process the Authenticate message to retrieve the status from
195
+ * the MasterPass processing.
196
+ *
197
+ * @param mixed $amount amount to be authorized
198
+ * @param string $currency currency code
199
+ * @param HpsBuyerData $buyer buyer information
200
+ * @param HpsPaymentData $payment payment information
201
+ * @param HpsShippingInfo $shippingAddress shipping information
202
+ * @param array<int, HpsLineItem> $lineItems line items from order
203
+ * @param HpsOrderData $orderData Cardinal/MasterPass specific
204
+ * data
205
+ *
206
+ * @return object
207
+ */
208
+ public function createSession(
209
+ $amount,
210
+ $currency,
211
+ HpsBuyerData $buyer,
212
+ HpsPaymentData $payment,
213
+ HpsShippingInfo $shippingAddress = null,
214
+ $lineItems = null,
215
+ HpsOrderData $orderData = null
216
+ ) {
217
+ $payload = array(
218
+ 'TransactionType' => 'WT',
219
+ 'OverridePaymentMethod' => 'MPPWLT',
220
+ 'Amount' => $this->formatAmount($amount),
221
+ 'CurrencyCode' => $this->currencyStringToNumeric($currency),
222
+ 'OverrideCheckoutType' => $this->getCheckoutType($orderData),
223
+ 'ConnectTimeout' => '10000',
224
+ 'TransactionMode' => 'S',
225
+ 'OrderNumber' => $orderData->orderNumber,
226
+ 'IPAddress' => $orderData->ipAddress,
227
+ 'BrowserHeader' => $orderData->browserHeader,
228
+ 'UserAgent' => $orderData->userAgent,
229
+ 'OriginUrl' => $orderData->originUrl,
230
+ 'TermUrl' => $orderData->termUrl,
231
+ );
232
+ if ($orderData->orderId !== null) {
233
+ $payload['OrderId'] = $orderData->orderId;
234
+ }
235
+ if ($buyer !== null) {
236
+ $payload = array_merge($payload, $this->hydrateBuyerData($buyer));
237
+ }
238
+ if ($payment !== null) {
239
+ $payload = array_merge($payload, $this->hydratePaymentData($payment));
240
+ }
241
+ if ($shippingAddress !== null) {
242
+ $payload = array_merge($payload, $this->hydrateShippingInfo($shippingAddress));
243
+ }
244
+ if ($lineItems !== null) {
245
+ $payload = array_merge($payload, $this->hydrateLineItems($lineItems));
246
+ }
247
+ return $this->submitTransaction($payload, 'cmpi_lookup');
248
+ }
249
+
250
+ /**
251
+ * Gives Merchants the ability to provide the consumer the opportunity to
252
+ * pre-select their checkout options before completing checkout.
253
+ *
254
+ * @param string $longAccessToken Access token from Cardinal/MasterPass
255
+ * @param HpsOrderData $orderData Cardinal/MasterPass specific data
256
+ *
257
+ * @return object
258
+ */
259
+ public function preApproval(
260
+ $longAccessToken,
261
+ HpsOrderData $orderData = null
262
+ ) {
263
+ $payload = array(
264
+ 'LongAccessToken' => $longAccessToken,
265
+ 'SubMsgType' => 'cmpi_preapproval',
266
+ 'TransactionType' => 'WT',
267
+ );
268
+ return $this->submitTransaction($payload, 'cmpi_baseserver_api');
269
+ }
270
+
271
+ /**
272
+ * Responsible for crediting the consumer some portion or all of the original
273
+ * settlement amount. Multiple refunds can be processed against the original
274
+ * capture transaction.
275
+ *
276
+ * @param string $orderId order id from Cardinal
277
+ * @param boolean $isPartial flag for partial refund
278
+ * @param string $partialAmount partial amount to be refunded
279
+ * @param HpsOrderData $orderData Cardinal/MasterPass specific data
280
+ *
281
+ * @return object
282
+ */
283
+ public function refund(
284
+ $orderId,
285
+ $isPartial = false,
286
+ $amount = null,
287
+ HpsOrderData $orderData = null
288
+ ) {
289
+ $payload = array(
290
+ 'Amount' => $this->formatAmount($amount),
291
+ 'CurrencyCode' => $this->currencyStringToNumeric($orderData->currencyCode),
292
+ 'OrderId' => $orderId,
293
+ 'TransactionType' => 'WT',
294
+ );
295
+ return $this->submitTransaction($payload, 'cmpi_refund');
296
+ }
297
+
298
+ /**
299
+ * Responsible for authorizing the transaction. Once authorized, the
300
+ * transaction amount can be captured at a later point in time. Once the
301
+ * Merchant is ready to perform the actual Authorization of funds the
302
+ * Authorize message should be processes referencing the original OrderId
303
+ * returned in the Lookup message. This authorization request checks the
304
+ * availability of the Customer’s funds to obtain an honor period for
305
+ * capture/settlement.
306
+ *
307
+ * @param string $orderId order id from Cardinal
308
+ * @param mixed $amount amount to be authorized
309
+ * @param string $currency currency code
310
+ * @param HpsBuyerData $buyer buyer information
311
+ * @param HpsPaymentData $payment payment information
312
+ * @param HpsShippingInfo $shippingAddress shipping information
313
+ * @param array<int, HpsLineItem> $lineItems line items from order
314
+ * @param HpsOrderData $orderData Cardinal/MasterPass specific
315
+ * data
316
+ *
317
+ * @return object
318
+ */
319
+ public function sale(
320
+ $orderId,
321
+ $amount,
322
+ $currency,
323
+ HpsBuyerData $buyer,
324
+ HpsPaymentData $payment,
325
+ HpsShippingInfo $shippingAddress = null,
326
+ $lineItems = null,
327
+ HpsOrderData $orderData = null
328
+ ) {
329
+ $authorization = $this->authorize(
330
+ $orderId,
331
+ $amount,
332
+ $currency,
333
+ $buyer,
334
+ $payment,
335
+ $shippingAddress,
336
+ $lineItems,
337
+ $orderData
338
+ );
339
+ if (null === $orderData) {
340
+ $orderData = new HpsOrderData();
341
+ }
342
+ $orderData->currencyCode = $currency;
343
+ $capture = $this->capture(
344
+ $orderId,
345
+ $this->formatAmount($amount),
346
+ $orderData
347
+ );
348
+ return (object)array(
349
+ 'authorization' => $authorization,
350
+ 'capture' => $capture,
351
+ );
352
+ }
353
+
354
+ /**
355
+ * Cancels an authorized transaction with MasterPass. Any hold on consumer
356
+ * funds will be removed when the transaction is voided.
357
+ *
358
+ * @param string $orderId order id from Cardinal
359
+ * @param HpsOrderData $orderData Cardinal/MasterPass specific data
360
+ *
361
+ * @return object
362
+ */
363
+ public function void(
364
+ $orderId,
365
+ HpsOrderData $orderData = null
366
+ ) {
367
+ $payload = array(
368
+ 'OrderId' => $orderId,
369
+ );
370
+ return $this->submitTransaction($payload, 'cmpi_void');
371
+ }
372
+
373
+ /**
374
+ * Gets information about a MasterPass session
375
+ *
376
+ * @param string $orderId order id from Cardinal
377
+ * @param HpsOrderData $orderData Cardinal/MasterPass specific data
378
+ *
379
+ * @return object
380
+ */
381
+ public function sessionInfo(
382
+ $orderId,
383
+ HpsOrderData $orderData = null
384
+ ) {
385
+ }
386
+
387
+ protected function getCheckoutType(HpsOrderData $orderData)
388
+ {
389
+ return isset($orderData->checkoutType) ? $orderData->checkoutType : 'lightbox';
390
+ }
391
+
392
+ /**
393
+ * Converts a 3-letter currency code to 3-digit ISO 4217 version
394
+ *
395
+ * @param string $currency currency code
396
+ *
397
+ * @raises HpsArgumentException
398
+ * @return string
399
+ */
400
+ protected function currencyStringToNumeric($currency)
401
+ {
402
+ if (!in_array(strtolower($currency), array_keys(self::$currencyCodes))) {
403
+ throw new HpsArgumentException(
404
+ 'Currency is not supported',
405
+ HpsExceptionCodes::INVALID_CURRENCY
406
+ );
407
+ }
408
+ return self::$currencyCodes[strtolower($currency)];
409
+ }
410
+
411
+ /**
412
+ * Converts HpsBuyerData into expected format for Cardinal
413
+ *
414
+ * @param HpsBuyerData $buyer buyer information
415
+ *
416
+ * @return array<string, string>
417
+ */
418
+ protected function hydrateBuyerData(HpsBuyerData $buyer)
419
+ {
420
+ return array(
421
+ 'BillingAddress1' => $buyer->address->address,
422
+ 'BillingCity' => $buyer->address->city,
423
+ 'BillingCountryCode' => $buyer->countryCode,
424
+ 'BillingFirstName' => $buyer->firstName,
425
+ 'BillingLastName' => $buyer->lastName,
426
+ 'BillingMiddleName' => $buyer->middleName,
427
+ 'BillingPhone' => $buyer->phoneNumber,
428
+ 'BillingPostalCode' => $buyer->address->zip,
429
+ 'BillingState' => $buyer->address->state,
430
+ );
431
+ }
432
+
433
+ /**
434
+ * Converts HpsLineItem's into expected format for Cardinal
435
+ *
436
+ * @param array<int, HpsLineItem> $items line items from order
437
+ *
438
+ * @return array<string, string>
439
+ */
440
+ protected function hydrateLineItems($items)
441
+ {
442
+ $result = array();
443
+ if ($items == null) {
444
+ return $result;
445
+ }
446
+
447
+ foreach ($items as $i => $item) {
448
+ $result = array_merge(
449
+ $result,
450
+ array(
451
+ 'Item_Name_' . $i => $item->name,
452
+ 'Item_Desc_' . $i => $item->description,
453
+ 'Item_Price_' . $i => $this->formatAmount($item->amount),
454
+ 'Item_Quantity_' . $i => $item->quantity,
455
+ 'Item_SKU_' . $i => $item->number,
456
+ )
457
+ );
458
+ }
459
+
460
+ return $result;
461
+ }
462
+
463
+ /**
464
+ * Converts HpsShippingInfo into expected format for Cardinal
465
+ *
466
+ * @param HpsPaymentData $payment payment information
467
+ *
468
+ * @return array<string, string>
469
+ */
470
+ protected function hydratePaymentData(HpsPaymentData $payment)
471
+ {
472
+ return array(
473
+ 'TaxAmount' => $this->formatAmount($payment->taxAmount),
474
+ 'ShippingAmount' => $this->formatAmount($payment->shippingAmount),
475
+ );
476
+ }
477
+
478
+ /**
479
+ * Converts HpsShippingInfo into expected format for Cardinal
480
+ *
481
+ * @param HpsShippingInfo $shipping shipping information
482
+ *
483
+ * @return array<string, string>
484
+ */
485
+ protected function hydrateShippingInfo(HpsShippingInfo $shipping)
486
+ {
487
+ return array(
488
+ 'ShippingAddress1' => $shipping->address->address,
489
+ 'ShippingCity' => $shipping->address->city,
490
+ 'ShippingCountryCode' => $shipping->countryCode,
491
+ 'ShippingFirstName' => $shipping->firstName,
492
+ 'ShippingLastName' => $shipping->lastName,
493
+ 'ShippingMiddleName' => $shipping->middleName,
494
+ 'ShippingPhone' => $shipping->phoneNumber,
495
+ 'ShippingPostalCode' => $shipping->address->zip,
496
+ 'ShippingState' => $shipping->address->state,
497
+ );
498
+ }
499
+
500
+ /**
501
+ * Formats the amount in form of cents
502
+ *
503
+ * @param mixed $amount
504
+ *
505
+ * @return string
506
+ */
507
+ protected function formatAmount($amount)
508
+ {
509
+ return sprintf('%s', ceil(intval($amount) * 100));
510
+ // return $amount;
511
+ }
512
+
513
+ /**
514
+ * Processes the response from Cardinal
515
+ *
516
+ * @param object $response response from Cardinal
517
+ *
518
+ * @return null
519
+ */
520
+ protected function processGatewayResponse($response)
521
+ {
522
+ $gatewayRspCode = isset($response->ErrorNo)
523
+ ? (string)$response->ErrorNo
524
+ : null;
525
+
526
+ if ($gatewayRspCode == '0') {
527
+ return;
528
+ }
529
+
530
+ throw new HpsException((string)$response->ErrorDesc);
531
+ }
532
+
533
+ /**
534
+ * Processes the response from MasterPass
535
+ *
536
+ * @param object $response response from Cardinal
537
+ *
538
+ * @return null
539
+ */
540
+ protected function processProcessorResponse($response)
541
+ {
542
+ $statusCode = isset($response->StatusCode)
543
+ ? (string)$response->StatusCode
544
+ : null;
545
+
546
+ if ($statusCode == null || $statusCode == 'Y') {
547
+ return;
548
+ }
549
+
550
+ throw new HpsException((string)$response->ErrorDesc);
551
+ }
552
+
553
+ /**
554
+ * Submits a transaction to the gateway
555
+ *
556
+ * @param array<string, string> $request request payload
557
+ * @param string $txnType type of transaction to be ran
558
+ *
559
+ * @return object
560
+ */
561
+ protected function submitTransaction(
562
+ $request,
563
+ $txnType
564
+ ) {
565
+ $request = array_merge($request, array('MsgType' => $txnType));
566
+ $response = $this->doRequest($request);
567
+
568
+ $this->processGatewayResponse($response);
569
+ $this->processProcessorResponse($response);
570
+
571
+ $result = null;
572
+
573
+ switch ($txnType) {
574
+ case 'cmpi_lookup':
575
+ $result = HpsCardinalMPILookupResponse::fromObject($response);
576
+ break;
577
+ case 'cmpi_authenticate':
578
+ $result = HpsCardinalMPIAuthenticateResponse::fromObject($response);
579
+ break;
580
+ case 'cmpi_baseserver_api':
581
+ $result = HpsCardinalMPIPreapprovalResponse::fromObject($response);
582
+ break;
583
+ case 'cmpi_authorize':
584
+ $result = HpsCardinalMPIAuthorizeResponse::fromObject($response);
585
+ break;
586
+ case 'cmpi_capture':
587
+ $result = HpsCardinalMPICaptureResponse::fromObject($response);
588
+ break;
589
+ case 'cmpi_refund':
590
+ $result = HpsCardinalMPIRefundResponse::fromObject($response);
591
+ break;
592
+ case 'cmpi_void':
593
+ $result = HpsCardinalMPIVoidResponse::fromObject($response);
594
+ break;
595
+ case 'cmpi_add_order_number':
596
+ $result = HpsCardinalMPIAddOrderNumberResponse::fromObject($response);
597
+ break;
598
+ }
599
+ return $result;
600
+ }
601
+ }
lib/SecureSubmit/src/Services/Gateway/HpsBatchService.php CHANGED
@@ -14,7 +14,7 @@ class HpsBatchService extends HpsSoapGatewayService
14
  $hpsBatchClose = $xml->createElement('hps:BatchClose');
15
  $hpsTransaction->appendChild($hpsBatchClose);
16
 
17
- $response = $this->doTransaction($hpsTransaction);
18
  HpsGatewayResponseValidation::checkResponse($response, 'BatchClose');
19
 
20
  //Process the response
14
  $hpsBatchClose = $xml->createElement('hps:BatchClose');
15
  $hpsTransaction->appendChild($hpsBatchClose);
16
 
17
+ $response = $this->doRequest($hpsTransaction);
18
  HpsGatewayResponseValidation::checkResponse($response, 'BatchClose');
19
 
20
  //Process the response
lib/SecureSubmit/src/Services/Gateway/HpsCentinelGatewayService.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsCentinelGatewayService
4
+ extends HpsGatewayServiceAbstract
5
+ implements HpsGatewayServiceInterface
6
+ {
7
+ public function doRequest($request, $options = null)
8
+ {
9
+ $request = array_merge($request, array(
10
+ 'Version' => $this->_config->version,
11
+ 'ProcessorId' => $this->_config->processorId,
12
+ 'MerchantId' => $this->_config->merchantId,
13
+ 'TransactionPwd' => $this->_config->transactionPwd,
14
+ ));
15
+
16
+ $xml = new DOMDocument('1.0', 'utf-8');
17
+ $envelope = $xml->createElement('CardinalMPI');
18
+ foreach ($request as $k => $v) {
19
+ $envelope->appendChild($xml->createElement($k, $v));
20
+ }
21
+ $xml->appendChild($envelope);
22
+
23
+ $url = $this->_config->serviceUri();
24
+ $xmlData = $xml->saveXML();
25
+ $data = 'cmpi_msg=' . urlencode($xmlData);
26
+ $header = array(
27
+ 'Content-type: application/x-www-form-urlencoded;charset="utf-8"',
28
+ 'Accept: text/xml',
29
+ 'Content-length: '.strlen($data),
30
+ );
31
+ // error_log($xmlData);
32
+
33
+ return $this->submitRequest($url, $header, $data);
34
+ }
35
+
36
+ public function processResponse($curlResponse, $curlInfo, $curlError)
37
+ {
38
+ // error_log($curlResponse);
39
+ switch ($curlInfo['http_code']) {
40
+ case '200':
41
+ return simplexml_load_string($curlResponse);
42
+ break;
43
+ case '500':
44
+ $faultString = '';
45
+ throw new HpsException($faultString);
46
+ break;
47
+ default:
48
+ throw new HpsException('Unexpected response');
49
+ break;
50
+ }
51
+ }
52
+ }
lib/SecureSubmit/src/Services/Gateway/HpsCheckService.php CHANGED
@@ -85,7 +85,7 @@ class HpsCheckService extends HpsSoapGatewayService
85
  $hpsTransaction = $xml->createElement('hps:Transaction');
86
  $hpsCheckSale = $xml->createElement('hps:CheckSale');
87
  $hpsBlock1 = $xml->createElement('hps:Block1');
88
-
89
  $hpsBlock1->appendChild($xml->createElement('hps:Amt', sprintf("%0.2f", round($amount, 3))));
90
  $hpsBlock1->appendChild($this->_hydrateCheckData($check, $xml));
91
  $hpsBlock1->appendChild($xml->createElement('hps:CheckAction', $action));
@@ -106,7 +106,11 @@ class HpsCheckService extends HpsSoapGatewayService
106
 
107
  private function _submitTransaction($transaction, $txnType, $clientTransactionId = null)
108
  {
109
- $rsp = $this->doTransaction($transaction, $clientTransactionId);
 
 
 
 
110
  HpsGatewayResponseValidation::checkResponse($rsp, $txnType);
111
  $response = HpsCheckResponse::fromDict($rsp, $txnType);
112
 
85
  $hpsTransaction = $xml->createElement('hps:Transaction');
86
  $hpsCheckSale = $xml->createElement('hps:CheckSale');
87
  $hpsBlock1 = $xml->createElement('hps:Block1');
88
+
89
  $hpsBlock1->appendChild($xml->createElement('hps:Amt', sprintf("%0.2f", round($amount, 3))));
90
  $hpsBlock1->appendChild($this->_hydrateCheckData($check, $xml));
91
  $hpsBlock1->appendChild($xml->createElement('hps:CheckAction', $action));
106
 
107
  private function _submitTransaction($transaction, $txnType, $clientTransactionId = null)
108
  {
109
+ $options = array();
110
+ if ($clientTransactionId !== null) {
111
+ $options['clientTransactionId'] = $clientTransactionId;
112
+ }
113
+ $rsp = $this->doRequest($transaction, $options);
114
  HpsGatewayResponseValidation::checkResponse($rsp, $txnType);
115
  $response = HpsCheckResponse::fromDict($rsp, $txnType);
116
 
lib/SecureSubmit/src/Services/Gateway/HpsCreditService.php CHANGED
@@ -71,7 +71,11 @@ class HpsCreditService extends HpsSoapGatewayService
71
  }
72
 
73
  $hpsTransaction->appendChild($hpsCreditAddToBatch);
74
- $response = $this->doTransaction($hpsTransaction);
 
 
 
 
75
  $this->_processChargeGatewayResponse($response, 'CreditAddToBatch');
76
 
77
  return $this->get($transactionId);
@@ -176,9 +180,9 @@ class HpsCreditService extends HpsSoapGatewayService
176
  {
177
  $xml = new DOMDocument();
178
  $hpsTransaction = $xml->createElement('hps:Transaction');
179
- $hpsPosCreditCPCEdit = $xml->createElement('hps:CreditCPCEdit');
180
- $hpsPosCreditCPCEdit->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId));
181
- $hpsPosCreditCPCEdit->appendChild($this->_hydrateCPCData($cpcData, $xml));
182
  $hpsTransaction->appendChild($hpsPosCreditCPCEdit);
183
 
184
  return $this->_submitTransaction($hpsTransaction, 'CreditCPCEdit');
@@ -236,9 +240,9 @@ class HpsCreditService extends HpsSoapGatewayService
236
 
237
  $xml = new DOMDocument();
238
  $hpsTransaction = $xml->createElement('hps:Transaction');
239
- $hpsReportActivity = $xml->createElement('hps:ReportActivity');
240
- $hpsReportActivity->appendChild($xml->createElement('hps:RptStartUtcDT', $startDate));
241
- $hpsReportActivity->appendChild($xml->createElement('hps:RptEndUtcDT', $endDate));
242
  $hpsTransaction->appendChild($hpsReportActivity);
243
 
244
  return $this->_submitTransaction($hpsTransaction, 'ReportActivity');
@@ -350,8 +354,8 @@ class HpsCreditService extends HpsSoapGatewayService
350
  {
351
  $xml = new DOMDocument();
352
  $hpsTransaction = $xml->createElement('hps:Transaction');
353
- $hpsCreditVoid = $xml->createElement('hps:CreditVoid');
354
- $hpsCreditVoid->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId));
355
  $hpsTransaction->appendChild($hpsCreditVoid);
356
 
357
  return $this->_submitTransaction($hpsTransaction, 'CreditVoid', $clientTransactionId);
@@ -422,8 +426,13 @@ class HpsCreditService extends HpsSoapGatewayService
422
 
423
  private function _submitTransaction($transaction, $txnType, $clientTxnId = null, $cardData = null)
424
  {
 
 
 
 
 
425
  try {
426
- $response = $this->doTransaction($transaction, $clientTxnId);
427
  } catch (HpsException $e) {
428
  if ($e->innerException != null && $e->innerException->getMessage() == 'gateway_time-out') {
429
  if (in_array($txnType, array('CreditSale', 'CreditAuth'))) {
71
  }
72
 
73
  $hpsTransaction->appendChild($hpsCreditAddToBatch);
74
+ $options = array();
75
+ if ($clientTransactionId != null) {
76
+ $options['clientTransactionId'] = $clientTransactionId;
77
+ }
78
+ $response = $this->doRequest($hpsTransaction, $options);
79
  $this->_processChargeGatewayResponse($response, 'CreditAddToBatch');
80
 
81
  return $this->get($transactionId);
180
  {
181
  $xml = new DOMDocument();
182
  $hpsTransaction = $xml->createElement('hps:Transaction');
183
+ $hpsPosCreditCPCEdit = $xml->createElement('hps:CreditCPCEdit');
184
+ $hpsPosCreditCPCEdit->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId));
185
+ $hpsPosCreditCPCEdit->appendChild($this->_hydrateCPCData($cpcData, $xml));
186
  $hpsTransaction->appendChild($hpsPosCreditCPCEdit);
187
 
188
  return $this->_submitTransaction($hpsTransaction, 'CreditCPCEdit');
240
 
241
  $xml = new DOMDocument();
242
  $hpsTransaction = $xml->createElement('hps:Transaction');
243
+ $hpsReportActivity = $xml->createElement('hps:ReportActivity');
244
+ $hpsReportActivity->appendChild($xml->createElement('hps:RptStartUtcDT', $startDate));
245
+ $hpsReportActivity->appendChild($xml->createElement('hps:RptEndUtcDT', $endDate));
246
  $hpsTransaction->appendChild($hpsReportActivity);
247
 
248
  return $this->_submitTransaction($hpsTransaction, 'ReportActivity');
354
  {
355
  $xml = new DOMDocument();
356
  $hpsTransaction = $xml->createElement('hps:Transaction');
357
+ $hpsCreditVoid = $xml->createElement('hps:CreditVoid');
358
+ $hpsCreditVoid->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId));
359
  $hpsTransaction->appendChild($hpsCreditVoid);
360
 
361
  return $this->_submitTransaction($hpsTransaction, 'CreditVoid', $clientTransactionId);
426
 
427
  private function _submitTransaction($transaction, $txnType, $clientTxnId = null, $cardData = null)
428
  {
429
+ $options = array();
430
+ if ($clientTxnId != null) {
431
+ $options['clientTransactionId'] = $clientTxnId;
432
+ }
433
+
434
  try {
435
+ $response = $this->doRequest($transaction, $options);
436
  } catch (HpsException $e) {
437
  if ($e->innerException != null && $e->innerException->getMessage() == 'gateway_time-out') {
438
  if (in_array($txnType, array('CreditSale', 'CreditAuth'))) {
lib/SecureSubmit/src/Services/Gateway/HpsDebitService.php CHANGED
@@ -20,7 +20,7 @@ class HpsDebitService extends HpsSoapGatewayService
20
  * @param HpsCardHolder $cardHolder Card holder information.
21
  * @param HpsTransactionDetails $details Group containing additional transaction fields to be included in detail reporting.
22
  * @param string $clientTransactionId Optional client transaction ID.
23
- *
24
  * @return HpsDebitAddValue The AddValue (Authorization) response.
25
  */
26
  public function addValue($amount, $currency, $trackData, $pinBlock, HpsEncryptionData $encryptionData = null, $allowDuplicates = false, HpsCardHolder $cardHolder = null, HpsTransactionDetails $details = null, $clientTransactionId = null)
@@ -68,7 +68,7 @@ class HpsDebitService extends HpsSoapGatewayService
68
  * @param HpsEncryptionData $encryptionData E3 encryption data group.
69
  * @param HpsTransactionDetails $details Group containing additional transaction fields to be included in detail reporting.
70
  * @param string $clientTransactionId Optional client transaction ID.
71
- *
72
  * @return HpsDebit The Return (Authorization) results.
73
  */
74
  public function returnDebit($transactionId, $amount, $trackData, $pinBlock, $allowDuplicates = false, HpsCardHolder $cardHolder = null, HpsEncryptionData $encryptionData = null, HpsTransactionDetails $details = null, $clientTransactionId = null)
@@ -111,7 +111,7 @@ class HpsDebitService extends HpsSoapGatewayService
111
  * @param HpsEncryptionData $encryptionData E3 encryption data group.
112
  * @param HpsTransactionDetails $details Group containing additional transaction fields to be included in detail reporting.
113
  * @param string $clientTransactionId Optional client transaction ID.
114
- *
115
  * @return HpsDebit The reversal result.
116
  */
117
  public function reverse($transactionId, $amount, $trackData, $authorizedAmount = null, HpsEncryptionData $encryptionData = null, HpsTransactionDetails $details = null, $clientTransactionId = null)
@@ -165,7 +165,7 @@ class HpsDebitService extends HpsSoapGatewayService
165
  * @param HpsCardHolder $cardHolder Card holder information.
166
  * @param HpsTransactionDetails $details Group containing additional transaction fields to be included in detail reporting.
167
  * @param string $clientTransactionId Optional client transaction ID.
168
- *
169
  * @return HpsDebit The Debit Charge result.
170
  */
171
  public function charge($amount, $currency, $trackData, $pinBlock, HpsEncryptionData $encryptionData = null, $allowDuplicates = false, $cashBackAmount = null, $allowPartialAuth = false, HpsCardHolder $cardHolder = null, HpsTransactionDetails $details = null, $clientTransactionId = null)
@@ -265,8 +265,13 @@ class HpsDebitService extends HpsSoapGatewayService
265
 
266
  private function _submitTransaction($transaction, $txnType, $clientTxnId = null, $cardData = null)
267
  {
 
 
 
 
 
268
  try {
269
- $response = $this->doTransaction($transaction, $clientTxnId);
270
  } catch (HpsException $e) {
271
  if ($e->innerException != null && $e->innerException->getMessage() == 'gateway_time-out') {
272
  if ($txnType == 'DebitSale') {
20
  * @param HpsCardHolder $cardHolder Card holder information.
21
  * @param HpsTransactionDetails $details Group containing additional transaction fields to be included in detail reporting.
22
  * @param string $clientTransactionId Optional client transaction ID.
23
+ *
24
  * @return HpsDebitAddValue The AddValue (Authorization) response.
25
  */
26
  public function addValue($amount, $currency, $trackData, $pinBlock, HpsEncryptionData $encryptionData = null, $allowDuplicates = false, HpsCardHolder $cardHolder = null, HpsTransactionDetails $details = null, $clientTransactionId = null)
68
  * @param HpsEncryptionData $encryptionData E3 encryption data group.
69
  * @param HpsTransactionDetails $details Group containing additional transaction fields to be included in detail reporting.
70
  * @param string $clientTransactionId Optional client transaction ID.
71
+ *
72
  * @return HpsDebit The Return (Authorization) results.
73
  */
74
  public function returnDebit($transactionId, $amount, $trackData, $pinBlock, $allowDuplicates = false, HpsCardHolder $cardHolder = null, HpsEncryptionData $encryptionData = null, HpsTransactionDetails $details = null, $clientTransactionId = null)
111
  * @param HpsEncryptionData $encryptionData E3 encryption data group.
112
  * @param HpsTransactionDetails $details Group containing additional transaction fields to be included in detail reporting.
113
  * @param string $clientTransactionId Optional client transaction ID.
114
+ *
115
  * @return HpsDebit The reversal result.
116
  */
117
  public function reverse($transactionId, $amount, $trackData, $authorizedAmount = null, HpsEncryptionData $encryptionData = null, HpsTransactionDetails $details = null, $clientTransactionId = null)
165
  * @param HpsCardHolder $cardHolder Card holder information.
166
  * @param HpsTransactionDetails $details Group containing additional transaction fields to be included in detail reporting.
167
  * @param string $clientTransactionId Optional client transaction ID.
168
+ *
169
  * @return HpsDebit The Debit Charge result.
170
  */
171
  public function charge($amount, $currency, $trackData, $pinBlock, HpsEncryptionData $encryptionData = null, $allowDuplicates = false, $cashBackAmount = null, $allowPartialAuth = false, HpsCardHolder $cardHolder = null, HpsTransactionDetails $details = null, $clientTransactionId = null)
265
 
266
  private function _submitTransaction($transaction, $txnType, $clientTxnId = null, $cardData = null)
267
  {
268
+ $options = array();
269
+ if ($clientTxnId !== null) {
270
+ $options['clientTransactionId'] = $clientTxnId;
271
+ }
272
+
273
  try {
274
+ $response = $this->doRequest($transaction, $options);
275
  } catch (HpsException $e) {
276
  if ($e->innerException != null && $e->innerException->getMessage() == 'gateway_time-out') {
277
  if ($txnType == 'DebitSale') {
lib/SecureSubmit/src/Services/Gateway/HpsGiftCardService.php CHANGED
@@ -222,13 +222,18 @@ class HpsGiftCardService extends HpsSoapGatewayService
222
 
223
  private function _submitTransaction($transaction, $txnType, $clientTxnId = null)
224
  {
225
- $response = $this->doTransaction($transaction, $clientTxnId);
 
 
 
 
226
 
227
  HpsGatewayResponseValidation::checkResponse($response, $txnType);
228
  HpsIssuerResponseValidation::checkResponse(
229
  $response->Header->GatewayTxnId,
230
  $response->Transaction->$txnType->RspCode,
231
- $response->Transaction->$txnType->RspText
 
232
  );
233
 
234
  $rvalue = '';
222
 
223
  private function _submitTransaction($transaction, $txnType, $clientTxnId = null)
224
  {
225
+ $options = array();
226
+ if ($clientTxnId != null) {
227
+ $options['clientTransactionId'] = $clientTxnId;
228
+ }
229
+ $response = $this->doRequest($transaction, $options);
230
 
231
  HpsGatewayResponseValidation::checkResponse($response, $txnType);
232
  HpsIssuerResponseValidation::checkResponse(
233
  $response->Header->GatewayTxnId,
234
  $response->Transaction->$txnType->RspCode,
235
+ $response->Transaction->$txnType->RspText,
236
+ 'gift'
237
  );
238
 
239
  $rvalue = '';
lib/SecureSubmit/src/Services/Gateway/HpsPayPlanService.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsPayPlanService
4
+ {
5
+ protected $customer = null;
6
+ protected $paymentMethod = null;
7
+ protected $schedule = null;
8
+
9
+ public function __construct(HpsServicesConfig $config = null)
10
+ {
11
+ $this->customer = new HpsPayPlanCustomerService($config);
12
+ $this->paymentMethod = new HpsPayPlanPaymentMethodService($config);
13
+ $this->schedule = new HpsPayPlanScheduleService($config);
14
+ }
15
+
16
+ public function setServicesConfig(HpsServicesConfig $config)
17
+ {
18
+ $this->customer->setServicesConfig($config);
19
+ $this->paymentMethod->setServicesConfig($config);
20
+ $this->schedule->setServicesConfig($config);
21
+ }
22
+
23
+ /// Customer methods
24
+
25
+ public function addCustomer(HpsPayPlanCustomer $customer)
26
+ {
27
+ return $this->customer->add($customer);
28
+ }
29
+
30
+ public function editCustomer(HpsPayPlanCustomer $customer)
31
+ {
32
+ return $this->customer->edit($customer);
33
+ }
34
+
35
+ public function findAllCustomers($searchFields = array())
36
+ {
37
+ return $this->customer->findAll($searchFields);
38
+ }
39
+
40
+ public function getCustomer($customer)
41
+ {
42
+ return $this->customer->get($customer);
43
+ }
44
+
45
+ public function deleteCustomer($customer, $forceDelete = false)
46
+ {
47
+ return $this->customer->delete($customer, $forceDelete);
48
+ }
49
+
50
+ /// PaymentMethod methods
51
+
52
+ public function addPaymentMethod(HpsPayPlanPaymentMethod $paymentMethod)
53
+ {
54
+ return $this->paymentMethod->add($paymentMethod);
55
+ }
56
+
57
+ public function editPaymentMethod(HpsPayPlanPaymentMethod $paymentMethod)
58
+ {
59
+ return $this->paymentMethod->edit($paymentMethod);
60
+ }
61
+
62
+ public function findAllPaymentMethods($searchFields = array())
63
+ {
64
+ return $this->paymentMethod->findAll($searchFields);
65
+ }
66
+
67
+ public function getPaymentMethod($paymentMethod)
68
+ {
69
+ return $this->paymentMethod->get($paymentMethod);
70
+ }
71
+
72
+ public function deletePaymentMethod($paymentMethod, $forceDelete = false)
73
+ {
74
+ return $this->paymentMethod->delete($paymentMethod, $forceDelete);
75
+ }
76
+
77
+ /// Schedule methods
78
+
79
+ public function addSchedule(HpsPayPlanSchedule $schedule)
80
+ {
81
+ return $this->schedule->add($schedule);
82
+ }
83
+
84
+ public function editSchedule(HpsPayPlanSchedule $schedule)
85
+ {
86
+ return $this->schedule->edit($schedule);
87
+ }
88
+
89
+ public function findAllSchedules($searchFields = array())
90
+ {
91
+ return $this->schedule->findAll($searchFields);
92
+ }
93
+
94
+ public function getSchedule($schedule)
95
+ {
96
+ return $this->schedule->get($schedule);
97
+ }
98
+
99
+ public function deleteSchedule($schedule, $forceDelete = false)
100
+ {
101
+ return $this->schedule->delete($schedule, $forceDelete);
102
+ }
103
+ }
lib/SecureSubmit/src/Services/Gateway/HpsRestGatewayService.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  class HpsRestGatewayService extends HpsGatewayServiceAbstract
4
  {
5
- const CERT_URL = '';
6
- const PROD_URL = '';
7
  const UAT_URL = 'https://api-uat.heartlandportico.com/payplan.v2';
8
  protected $limit = null;
9
  protected $offset = null;
@@ -22,8 +22,10 @@ class HpsRestGatewayService extends HpsGatewayServiceAbstract
22
  return $this;
23
  }
24
 
25
- protected function doRequest($verb, $endpoint, $data = null)
26
  {
 
 
27
  $url = $this->_gatewayUrlForKey() . '/' . $endpoint;
28
 
29
  if (isset($this->limit) && isset($this->offset)) {
@@ -64,11 +66,13 @@ class HpsRestGatewayService extends HpsGatewayServiceAbstract
64
  $header[] = 'HPS-Identity: '.implode(',', $identity);
65
  }
66
  $keyType = HpsServicesConfig::KEY_TYPE_SECRET;
 
67
  return $this->submitRequest($url, $header, $encodedData, $verb, $keyType);
68
  }
69
 
70
  protected function processResponse($curlResponse, $curlInfo, $curlError)
71
  {
 
72
  $response = json_decode($curlResponse);
73
 
74
  switch ($curlInfo['http_code']) {
@@ -87,7 +91,7 @@ class HpsRestGatewayService extends HpsGatewayServiceAbstract
87
 
88
  protected function hydrateObject($result, $type)
89
  {
90
- return $type::fromStdClass($result);
91
  }
92
 
93
  protected function hydrateSearchResults($resultSet, $type)
2
 
3
  class HpsRestGatewayService extends HpsGatewayServiceAbstract
4
  {
5
+ const CERT_URL = 'https://cert.api2.heartlandportico.com/Portico.PayPlan.v2';
6
+ const PROD_URL = 'https://api2.heartlandportico.com/payplan.v2';
7
  const UAT_URL = 'https://api-uat.heartlandportico.com/payplan.v2';
8
  protected $limit = null;
9
  protected $offset = null;
22
  return $this;
23
  }
24
 
25
+ protected function doRequest($data = null, $options = array())
26
  {
27
+ $endpoint = isset($options['endpoint']) ? $options['endpoint'] : '';
28
+ $verb = isset($options['verb']) ? $options['verb'] : 'GET';
29
  $url = $this->_gatewayUrlForKey() . '/' . $endpoint;
30
 
31
  if (isset($this->limit) && isset($this->offset)) {
66
  $header[] = 'HPS-Identity: '.implode(',', $identity);
67
  }
68
  $keyType = HpsServicesConfig::KEY_TYPE_SECRET;
69
+ // print "\n" . $encodedData;
70
  return $this->submitRequest($url, $header, $encodedData, $verb, $keyType);
71
  }
72
 
73
  protected function processResponse($curlResponse, $curlInfo, $curlError)
74
  {
75
+ // print "\n" . $curlResponse;
76
  $response = json_decode($curlResponse);
77
 
78
  switch ($curlInfo['http_code']) {
91
 
92
  protected function hydrateObject($result, $type)
93
  {
94
+ return call_user_func(array($type, 'fromStdClass'), $result);
95
  }
96
 
97
  protected function hydrateSearchResults($resultSet, $type)
lib/SecureSubmit/src/Services/Gateway/HpsSoapGatewayService.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
 
3
- class HpsSoapGatewayService extends HpsGatewayServiceAbstract
4
  {
5
- public function doTransaction($transaction, $clientTransactionId = null)
6
  {
7
  $xml = new DOMDocument('1.0', 'utf-8');
8
  $soapEnvelope = $xml->createElement('soapenv:Envelope');
@@ -29,8 +29,8 @@ class HpsSoapGatewayService extends HpsGatewayServiceAbstract
29
  $hpsHeader->appendChild($xml->createElement('hps:VersionNbr', $this->_config->versionNumber));
30
  $hpsHeader->appendChild($xml->createElement('hps:SiteTrace', $this->_config->siteTrace));
31
  }
32
- if ($clientTransactionId != null) {
33
- $hpsHeader->appendChild($xml->createElement('hps:ClientTxnId', $clientTransactionId));
34
  }
35
 
36
  $hpsVersion->appendChild($hpsHeader);
@@ -50,14 +50,14 @@ class HpsSoapGatewayService extends HpsGatewayServiceAbstract
50
  'Content-length: '.strlen($xml->saveXML()),
51
  );
52
  $data = $xml->saveXML();
53
- Mage::log($data);
54
 
55
  return $this->submitRequest($url, $header, $data);
56
  }
57
 
58
- protected function processResponse($curlResponse, $curlInfo, $curlError)
59
  {
60
- Mage::log($curlResponse);
61
  switch ($curlInfo['http_code']) {
62
  case '200':
63
  $responseObject = $this->_XML2Array($curlResponse);
@@ -74,7 +74,7 @@ class HpsSoapGatewayService extends HpsGatewayServiceAbstract
74
  }
75
  }
76
 
77
- protected function _hydrateAdditionalTxnFields($details, DOMDocument $xml)
78
  {
79
  $additionalTxnFields = $xml->createElement('hps:AdditionalTxnFields');
80
 
@@ -93,7 +93,7 @@ class HpsSoapGatewayService extends HpsGatewayServiceAbstract
93
  return $additionalTxnFields;
94
  }
95
 
96
- protected function _hydrateCardHolderData(HpsCardHolder $cardHolder, DOMDocument $xml)
97
  {
98
  $cardHolderData = $xml->createElement('hps:CardHolderData');
99
  $cardHolderData->appendChild($xml->createElement('hps:CardHolderFirstName', $cardHolder->firstName));
@@ -108,7 +108,7 @@ class HpsSoapGatewayService extends HpsGatewayServiceAbstract
108
  return $cardHolderData;
109
  }
110
 
111
- protected function _hydrateCheckData(HpsCheck $check, DOMDocument $xml)
112
  {
113
  $checkData = $xml->createElement('hps:AccountInfo');
114
 
@@ -135,7 +135,7 @@ class HpsSoapGatewayService extends HpsGatewayServiceAbstract
135
  return $checkData;
136
  }
137
 
138
- protected function _hydrateConsumerInfo(HpsCheck $check, DOMDocument $xml)
139
  {
140
  $consumerInfo = $xml->createElement('hps:ConsumerInfo');
141
 
@@ -178,20 +178,37 @@ class HpsSoapGatewayService extends HpsGatewayServiceAbstract
178
  $consumerInfo->appendChild($xml->createElement('hps:PhoneNumber', $check->checkHolder->phone));
179
  }
180
 
 
 
 
 
 
 
 
 
 
 
 
181
  return $consumerInfo;
182
  }
183
 
184
- protected function _hydrateCPCData(HpsCPCData $cpcData, DOMDocument $xml)
185
  {
186
  $cpcDataElement = $xml->createElement('hps:CPCData');
187
- $cpcDataElement->appendChild($xml->createElement('hps:CardHolderPONbr', $cpcData->CardHolderPONbr));
188
- $cpcDataElement->appendChild($xml->createElement('hps:TaxAmt', $cpcData->TaxAmt));
189
- $cpcDataElement->appendChild($xml->createElement('hps:TaxType', $cpcData->TaxType));
 
 
 
 
 
 
190
 
191
  return $cpcDataElement;
192
  }
193
 
194
- protected function _hydrateDirectMarketData(HpsDirectMarketData $data, DOMDocument $xml)
195
  {
196
  $directMktDataElement = $xml->createElement('hps:DirectMktData');
197
  $directMktDataElement->appendChild($xml->createElement('hps:DirectMktInvoiceNbr', $data->invoiceNumber));
@@ -201,7 +218,7 @@ class HpsSoapGatewayService extends HpsGatewayServiceAbstract
201
  return $directMktDataElement;
202
  }
203
 
204
- protected function _hydrateEncryptionData(HpsEncryptionData $encryptionData, DOMDocument $xml)
205
  {
206
  $encData = $xml->createElement('hps:EncryptionData');
207
  if ($encryptionData->encryptedTrackNumber != null) {
@@ -213,23 +230,31 @@ class HpsSoapGatewayService extends HpsGatewayServiceAbstract
213
  return $encData;
214
  }
215
 
216
- protected function _hydrateGiftCardData(HpsGiftCard $giftCard, DOMDocument $xml, $elementName = 'CardData')
217
  {
218
  $giftCardData = $xml->createElement('hps:'.$elementName);
219
- if ($giftCard->isTrackData == true) {
220
- $giftCardData->appendChild($xml->createElement('hps:TrackData', $giftCard->number));
221
- } else {
222
  $giftCardData->appendChild($xml->createElement('hps:CardNbr', $giftCard->number));
 
 
 
 
 
 
223
  }
224
 
225
  if ($giftCard->encryptionData != null) {
226
  $giftCardData->appendChild($this->_hydrateEncryptionData($giftCard->encryptionData, $xml));
227
  }
228
 
 
 
 
 
229
  return $giftCardData;
230
  }
231
 
232
- protected function _hydrateManualEntry(HpsCreditCard $card, DOMDocument $xml)
233
  {
234
  $manualEntry = $xml->createElement('hps:ManualEntry');
235
 
@@ -249,21 +274,61 @@ class HpsSoapGatewayService extends HpsGatewayServiceAbstract
249
  $manualEntry->appendChild($xml->createElement('hps:CVV2', $card->cvv));
250
  }
251
 
252
- $manualEntry->appendChild($xml->createElement('hps:CardPresent', 'N'));
253
- $manualEntry->appendChild($xml->createElement('hps:ReaderPresent', 'N'));
254
 
255
  return $manualEntry;
256
  }
257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  private function _gatewayUrlForKey()
259
  {
260
  if ($this->_config->secretApiKey != null && $this->_config->secretApiKey != "") {
261
  if (strpos($this->_config->secretApiKey, '_cert_') !== false) {
262
- return "https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx";
263
  } else if (strpos($this->_config->secretApiKey, '_uat_') !== false) {
264
  return "https://posgateway.uat.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx";
265
  } else {
266
- return "https://posgateway.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx";
267
  }
268
  } else {
269
  return $this->_config->soapServiceUri;
1
  <?php
2
 
3
+ class HpsSoapGatewayService extends HpsGatewayServiceAbstract implements HpsGatewayServiceInterface
4
  {
5
+ public function doRequest($transaction, $options = array())
6
  {
7
  $xml = new DOMDocument('1.0', 'utf-8');
8
  $soapEnvelope = $xml->createElement('soapenv:Envelope');
29
  $hpsHeader->appendChild($xml->createElement('hps:VersionNbr', $this->_config->versionNumber));
30
  $hpsHeader->appendChild($xml->createElement('hps:SiteTrace', $this->_config->siteTrace));
31
  }
32
+ if (isset($options['clientTransactionId'])) {
33
+ $hpsHeader->appendChild($xml->createElement('hps:ClientTxnId', $options['clientTransactionId']));
34
  }
35
 
36
  $hpsVersion->appendChild($hpsHeader);
50
  'Content-length: '.strlen($xml->saveXML()),
51
  );
52
  $data = $xml->saveXML();
53
+ // print "\n" . $data;
54
 
55
  return $this->submitRequest($url, $header, $data);
56
  }
57
 
58
+ public function processResponse($curlResponse, $curlInfo, $curlError)
59
  {
60
+ // print "\n" . $curlResponse;
61
  switch ($curlInfo['http_code']) {
62
  case '200':
63
  $responseObject = $this->_XML2Array($curlResponse);
74
  }
75
  }
76
 
77
+ public function _hydrateAdditionalTxnFields($details, DOMDocument $xml)
78
  {
79
  $additionalTxnFields = $xml->createElement('hps:AdditionalTxnFields');
80
 
93
  return $additionalTxnFields;
94
  }
95
 
96
+ public function _hydrateCardHolderData(HpsCardHolder $cardHolder, DOMDocument $xml)
97
  {
98
  $cardHolderData = $xml->createElement('hps:CardHolderData');
99
  $cardHolderData->appendChild($xml->createElement('hps:CardHolderFirstName', $cardHolder->firstName));
108
  return $cardHolderData;
109
  }
110
 
111
+ public function _hydrateCheckData(HpsCheck $check, DOMDocument $xml)
112
  {
113
  $checkData = $xml->createElement('hps:AccountInfo');
114
 
135
  return $checkData;
136
  }
137
 
138
+ public function _hydrateConsumerInfo(HpsCheck $check, DOMDocument $xml)
139
  {
140
  $consumerInfo = $xml->createElement('hps:ConsumerInfo');
141
 
178
  $consumerInfo->appendChild($xml->createElement('hps:PhoneNumber', $check->checkHolder->phone));
179
  }
180
 
181
+ if ($check->checkHolder->ssl4 != null || $check->checkHolder->dobYear != null) {
182
+ $identityInfo = $xml->createElement('hps:IdentityInfo');
183
+ if ($check->checkHolder->ssl4 != null) {
184
+ $identityInfo->appendChild($xml->createElement('hps:SSNL4', $check->checkHolder->ssl4));
185
+ }
186
+ if ($check->checkHolder->dobYear != null) {
187
+ $identityInfo->appendChild($xml->createElement('hps:DOBYear', $check->checkHolder->dobYear));
188
+ }
189
+ $consumerInfo->appendChild($identityInfo);
190
+ }
191
+
192
  return $consumerInfo;
193
  }
194
 
195
+ public function _hydrateCPCData(HpsCPCData $cpcData, DOMDocument $xml)
196
  {
197
  $cpcDataElement = $xml->createElement('hps:CPCData');
198
+ if (isset($cpcData->cardHolderPONbr)) {
199
+ $cpcDataElement->appendChild($xml->createElement('hps:CardHolderPONbr', $cpcData->cardHolderPONbr));
200
+ }
201
+ if (isset($cpcData->taxAmt)) {
202
+ $cpcDataElement->appendChild($xml->createElement('hps:TaxAmt', $cpcData->taxAmt));
203
+ }
204
+ if (isset($cpcData->taxType)) {
205
+ $cpcDataElement->appendChild($xml->createElement('hps:TaxType', $cpcData->taxType));
206
+ }
207
 
208
  return $cpcDataElement;
209
  }
210
 
211
+ public function _hydrateDirectMarketData(HpsDirectMarketData $data, DOMDocument $xml)
212
  {
213
  $directMktDataElement = $xml->createElement('hps:DirectMktData');
214
  $directMktDataElement->appendChild($xml->createElement('hps:DirectMktInvoiceNbr', $data->invoiceNumber));
218
  return $directMktDataElement;
219
  }
220
 
221
+ public function _hydrateEncryptionData(HpsEncryptionData $encryptionData, DOMDocument $xml)
222
  {
223
  $encData = $xml->createElement('hps:EncryptionData');
224
  if ($encryptionData->encryptedTrackNumber != null) {
230
  return $encData;
231
  }
232
 
233
+ public function _hydrateGiftCardData(HpsGiftCard $giftCard, DOMDocument $xml, $elementName = 'CardData')
234
  {
235
  $giftCardData = $xml->createElement('hps:'.$elementName);
236
+ if ($giftCard->number != null) {
 
 
237
  $giftCardData->appendChild($xml->createElement('hps:CardNbr', $giftCard->number));
238
+ } else if ($giftCard->trackData != null) {
239
+ $giftCardData->appendChild($xml->createElement('hps:TrackData', $giftCard->trackData));
240
+ } else if ($giftCard->alias != null) {
241
+ $giftCardData->appendChild($xml->createElement('hps:Alias', $giftCard->alias));
242
+ } else if ($giftCard->tokenValue != null) {
243
+ $giftCardData->appendChild($xml->createElement('hps:TokenValue', $giftCard->tokenValue));
244
  }
245
 
246
  if ($giftCard->encryptionData != null) {
247
  $giftCardData->appendChild($this->_hydrateEncryptionData($giftCard->encryptionData, $xml));
248
  }
249
 
250
+ if ($giftCard->pin != null) {
251
+ $giftCardData->appendChild($xml->createElement('hps:PIN', $giftCard->pin));
252
+ }
253
+
254
  return $giftCardData;
255
  }
256
 
257
+ public function _hydrateManualEntry(HpsCreditCard $card, DOMDocument $xml, $cardPresent = false, $readerPresent = false)
258
  {
259
  $manualEntry = $xml->createElement('hps:ManualEntry');
260
 
274
  $manualEntry->appendChild($xml->createElement('hps:CVV2', $card->cvv));
275
  }
276
 
277
+ $manualEntry->appendChild($xml->createElement('hps:CardPresent', ($cardPresent ? 'Y' : 'N')));
278
+ $manualEntry->appendChild($xml->createElement('hps:ReaderPresent', ($readerPresent ? 'Y' : 'N')));
279
 
280
  return $manualEntry;
281
  }
282
 
283
+ public function _hydrateSecureEcommerce($paymentData, $xml)
284
+ {
285
+ $secureEcommerce = $xml->createElement('hps:SecureECommerce');
286
+ $secureEcommerce->appendChild($xml->createElement('hps:TypeOfPaymentData', $paymentData->secure3d));
287
+
288
+ $paymentDataElement = $xml->createElement('hps:PaymentData', $paymentData->onlinePaymentCryptogram);
289
+ $paymentDataElementEncoding = $xml->createAttribute('encoding');
290
+ $paymentDataElementEncoding->value = 'base64';
291
+ $paymentDataElement->appendChild($paymentDataElementEncoding);
292
+
293
+ if ($paymentData->eciIndicator != null && $paymentData->eciIndicator != '') {
294
+ $secureEcommerce->appendChild($xml->createElement('hps:ECommerceIndicator', $paymentData->eciIndicator));
295
+ }
296
+
297
+ return $secureEcommerce;
298
+ }
299
+
300
+ public function _hydrateTokenData($token, DOMDocument $xml, $cardPresent = false, $readerPresent = false)
301
+ {
302
+ if (!$token instanceof HpsTokenData) {
303
+ $token = new HpsTokenData();
304
+ $token->tokenValue = $token;
305
+ }
306
+
307
+ $tokenData = $xml->createElement('hps:TokenData');
308
+ $tokenData->appendChild($xml->createElement('hps:TokenValue', $token->tokenValue));
309
+ $tokenData->appendChild($xml->createElement('hps:CardPresent', ($cardPresent ? 'Y' : 'N')));
310
+ $tokenData->appendChild($xml->createElement('hps:ReaderPresent', ($readerPresent ? 'Y' : 'N')));
311
+ return $tokenData;
312
+ }
313
+
314
+ public function _hydrateTrackData(HpsTrackData $trackData, $xml)
315
+ {
316
+ $trackDataElement = $xml->createElement('hps:TrackData', $trackData->value);
317
+ $trackDataElementMethod = $xml->createAttribute('method');
318
+ $trackDataElementMethod->value = $trackData->method;
319
+ $trackDataElement->appendChild($trackDataElementMethod);
320
+ return $trackDataElement;
321
+ }
322
+
323
  private function _gatewayUrlForKey()
324
  {
325
  if ($this->_config->secretApiKey != null && $this->_config->secretApiKey != "") {
326
  if (strpos($this->_config->secretApiKey, '_cert_') !== false) {
327
+ return "https://cert.api2.heartlandportico.com/Hps.Exchange.PosGateway/PosGatewayService.asmx";
328
  } else if (strpos($this->_config->secretApiKey, '_uat_') !== false) {
329
  return "https://posgateway.uat.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx";
330
  } else {
331
+ return "https://api2.heartlandportico.com/Hps.Exchange.PosGateway/PosGatewayService.asmx";
332
  }
333
  } else {
334
  return $this->_config->soapServiceUri;
lib/SecureSubmit/src/Services/Gateway/HpsTokenService.php CHANGED
@@ -12,9 +12,9 @@ class HpsTokenService extends HpsRestGatewayService
12
 
13
  $components = explode("_", $publicAPIKey);
14
  if (count($components) == 3 && strtolower($components[1]) == "prod") {
15
- $this->_url = "https://api.heartlandportico.com/SecureSubmit.v1/api/token";
16
  } else {
17
- $this->_url = "https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway.Hpf.v1/api/token";
18
  }
19
  }
20
 
12
 
13
  $components = explode("_", $publicAPIKey);
14
  if (count($components) == 3 && strtolower($components[1]) == "prod") {
15
+ $this->_url = "https://api2.heartlandportico.com/SecureSubmit.v1/api/token";
16
  } else {
17
+ $this->_url = "https://cert.api2.heartlandportico.com/Hps.Exchange.PosGateway.Hpf.v1/api/token";
18
  }
19
  }
20
 
lib/SecureSubmit/src/Services/Gateway/PayPlan/HpsPayPlanCustomerService.php CHANGED
@@ -4,14 +4,21 @@ class HpsPayPlanCustomerService extends HpsRestGatewayService
4
  {
5
  public function add(HpsPayPlanCustomer $customer)
6
  {
7
- $result = $this->doRequest('POST', 'customers', $customer->getEditableFieldsWithValues());
 
 
 
 
8
  return $this->hydrateObject($result, 'HpsPayPlanCustomer');
9
  }
10
 
11
  public function edit(HpsPayPlanCustomer $customer)
12
  {
13
  $data = $customer->getEditableFieldsWithValues();
14
- $result = $this->doRequest('PUT', 'customers/'.$customer->customerKey, $data);
 
 
 
15
  return $this->hydrateObject($result, 'HpsPayPlanCustomer');
16
  }
17
 
@@ -21,7 +28,10 @@ class HpsPayPlanCustomerService extends HpsRestGatewayService
21
  // in a JSON document
22
  $data = $searchFields === array() ? (object)array() : $searchFields;
23
  $results = $this
24
- ->doRequest('POST', 'searchCustomers', $data);
 
 
 
25
 
26
  return $this->hydrateSearchResults($results, 'HpsPayPlanCustomer');
27
  }
@@ -34,7 +44,10 @@ class HpsPayPlanCustomerService extends HpsRestGatewayService
34
  } else {
35
  $id = $customer;
36
  }
37
- $result = $this->doRequest('GET', 'customers/'.$id);
 
 
 
38
  return $this->hydrateObject($result, 'HpsPayPlanCustomer');
39
  }
40
 
@@ -50,6 +63,9 @@ class HpsPayPlanCustomerService extends HpsRestGatewayService
50
  $data = array(
51
  'forceDelete' => $forceDelete,
52
  );
53
- return $this->doRequest('DELETE', 'customers/'.$id, $data);
 
 
 
54
  }
55
  }
4
  {
5
  public function add(HpsPayPlanCustomer $customer)
6
  {
7
+ $data = $customer->getEditableFieldsWithValues();
8
+ $result = $this->doRequest($data, array(
9
+ 'verb' => 'POST',
10
+ 'endpoint' => 'customers',
11
+ ));
12
  return $this->hydrateObject($result, 'HpsPayPlanCustomer');
13
  }
14
 
15
  public function edit(HpsPayPlanCustomer $customer)
16
  {
17
  $data = $customer->getEditableFieldsWithValues();
18
+ $result = $this->doRequest($data, array(
19
+ 'verb' => 'PUT',
20
+ 'endpoint' => 'customers/'.$customer->customerKey,
21
+ ));
22
  return $this->hydrateObject($result, 'HpsPayPlanCustomer');
23
  }
24
 
28
  // in a JSON document
29
  $data = $searchFields === array() ? (object)array() : $searchFields;
30
  $results = $this
31
+ ->doRequest($data, array(
32
+ 'verb' => 'POST',
33
+ 'endpoint' => 'searchCustomers',
34
+ ));
35
 
36
  return $this->hydrateSearchResults($results, 'HpsPayPlanCustomer');
37
  }
44
  } else {
45
  $id = $customer;
46
  }
47
+ $result = $this->doRequest(null, array(
48
+ 'verb' => 'GET',
49
+ 'endpoint' => 'customers/'.$id,
50
+ ));
51
  return $this->hydrateObject($result, 'HpsPayPlanCustomer');
52
  }
53
 
63
  $data = array(
64
  'forceDelete' => $forceDelete,
65
  );
66
+ return $this->doRequest($data, array(
67
+ 'verb' => 'DELETE',
68
+ 'endpoint' => 'customers/'.$id,
69
+ ));
70
  }
71
  }
lib/SecureSubmit/src/Services/Gateway/PayPlan/HpsPayPlanPaymentMethodService.php CHANGED
@@ -30,7 +30,10 @@ class HpsPayPlanPaymentMethodService extends HpsRestGatewayService
30
  // in a JSON document
31
  $data = $searchFields === array() ? (object)array() : $searchFields;
32
  $results = $this
33
- ->doRequest('POST', 'searchPaymentMethods', $data);
 
 
 
34
 
35
  return $this->hydrateSearchResults($results, 'HpsPayPlanPaymentMethod');
36
  }
@@ -43,7 +46,10 @@ class HpsPayPlanPaymentMethodService extends HpsRestGatewayService
43
  } else {
44
  $id = $paymentMethod;
45
  }
46
- $result = $this->doRequest('GET', 'paymentMethods/'.$id);
 
 
 
47
  return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod');
48
  }
49
 
@@ -59,34 +65,60 @@ class HpsPayPlanPaymentMethodService extends HpsRestGatewayService
59
  $data = array(
60
  'forceDelete' => $forceDelete,
61
  );
62
- return $this->doRequest('DELETE', 'paymentMethods/'.$id, $data);
 
 
 
63
  }
64
 
65
-
66
  private function addCreditCard(HpsPayPlanPaymentMethod $paymentMethod)
67
  {
68
  $data = $paymentMethod->getEditableFieldsWithValues();
69
  $data['customerKey'] = $paymentMethod->customerKey;
70
- $data['accountNumber'] = $paymentMethod->accountNumber;
71
- return $this->doRequest('POST', 'paymentMethodsCreditCard', $data);
 
 
 
 
 
 
 
 
72
  }
73
 
74
  private function editCreditCard(HpsPayPlanPaymentMethod $paymentMethod)
75
  {
76
  $data = $paymentMethod->getEditableFieldsWithValues();
77
- return $this->doRequest('PUT', 'paymentMethodsCreditCard/'.$paymentMethod->paymentMethodKey, $data);
 
 
 
 
78
  }
79
 
80
  private function addACH(HpsPayPlanPaymentMethod $paymentMethod)
81
  {
82
  $data = $paymentMethod->getEditableFieldsWithValues();
83
  $data['customerKey'] = $paymentMethod->customerKey;
84
- return $this->doRequest('POST', 'paymentMethodsACH', $data);
 
 
 
 
 
 
 
 
85
  }
86
 
87
  private function editACH(HpsPayPlanPaymentMethod $paymentMethod)
88
  {
89
  $data = $paymentMethod->getEditableFieldsWithValues();
90
- return $this->doRequest('PUT', 'paymentMethodsACH/'.$paymentMethod->paymentMethodKey, $data);
 
 
 
 
91
  }
92
  }
30
  // in a JSON document
31
  $data = $searchFields === array() ? (object)array() : $searchFields;
32
  $results = $this
33
+ ->doRequest($data, array(
34
+ 'verb' => 'POST',
35
+ 'endpoint' => 'searchPaymentMethods',
36
+ ));
37
 
38
  return $this->hydrateSearchResults($results, 'HpsPayPlanPaymentMethod');
39
  }
46
  } else {
47
  $id = $paymentMethod;
48
  }
49
+ $result = $this->doRequest(null, array(
50
+ 'verb' => 'GET',
51
+ 'endpoint' => 'paymentMethods/'.$id
52
+ ));
53
  return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod');
54
  }
55
 
65
  $data = array(
66
  'forceDelete' => $forceDelete,
67
  );
68
+ return $this->doRequest($data, array(
69
+ 'verb' => 'DELETE',
70
+ 'endpoint' => 'paymentMethods/'.$id,
71
+ ));
72
  }
73
 
 
74
  private function addCreditCard(HpsPayPlanPaymentMethod $paymentMethod)
75
  {
76
  $data = $paymentMethod->getEditableFieldsWithValues();
77
  $data['customerKey'] = $paymentMethod->customerKey;
78
+ if (isset($paymentMethod->accountNumber)) {
79
+ $data['accountNumber'] = $paymentMethod->accountNumber;
80
+ } else if (isset($paymentMethod->paymentToken)) {
81
+ $data['paymentToken'] = $paymentMethod->paymentToken;
82
+ }
83
+ $result = $this->doRequest($data, array(
84
+ 'verb' => 'POST',
85
+ 'endpoint' => 'paymentMethodsCreditCard',
86
+ ));
87
+ return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod');
88
  }
89
 
90
  private function editCreditCard(HpsPayPlanPaymentMethod $paymentMethod)
91
  {
92
  $data = $paymentMethod->getEditableFieldsWithValues();
93
+ $result = $this->doRequest($data, array(
94
+ 'verb' => 'PUT',
95
+ 'endpoint' => 'paymentMethodsCreditCard/'.$paymentMethod->paymentMethodKey,
96
+ ));
97
+ return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod');
98
  }
99
 
100
  private function addACH(HpsPayPlanPaymentMethod $paymentMethod)
101
  {
102
  $data = $paymentMethod->getEditableFieldsWithValues();
103
  $data['customerKey'] = $paymentMethod->customerKey;
104
+ $data['accountNumber'] = $paymentMethod->accountNumber;
105
+ $data['accountType'] = $paymentMethod->accountType;
106
+ $data['achType'] = $paymentMethod->achType;
107
+ $data['routingNumber'] = $paymentMethod->routingNumber;
108
+ $result = $this->doRequest($data, array(
109
+ 'verb' => 'POST',
110
+ 'endpoint' => 'paymentMethodsACH',
111
+ ));
112
+ return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod');
113
  }
114
 
115
  private function editACH(HpsPayPlanPaymentMethod $paymentMethod)
116
  {
117
  $data = $paymentMethod->getEditableFieldsWithValues();
118
+ $result = $this->doRequest($data, array(
119
+ 'verb' => 'PUT',
120
+ 'endpoint' => 'paymentMethodsACH/'.$paymentMethod->paymentMethodKey,
121
+ ));
122
+ return $this->hydrateObject($result, 'HpsPayPlanPaymentMethod');
123
  }
124
  }
lib/SecureSubmit/src/Services/Gateway/PayPlan/HpsPayPlanScheduleService.php CHANGED
@@ -7,14 +7,20 @@ class HpsPayPlanScheduleService extends HpsRestGatewayService
7
  $data = $schedule->getEditableFieldsWithValues();
8
  $data['customerKey'] = $schedule->customerKey;
9
  $data['numberOfPayments'] = $schedule->numberOfPayments;
10
- $result = $this->doRequest('POST', 'schedules', $data);
 
 
 
11
  return $this->hydrateObject($result, 'HpsPayPlanSchedule');
12
  }
13
 
14
  public function edit(HpsPayPlanSchedule $schedule)
15
  {
16
  $data = $schedule->getEditableFieldsWithValues();
17
- $result = $this->doRequest('PUT', 'schedules/'.$schedule->scheduleKey, $data);
 
 
 
18
  return $this->hydrateObject($result, 'HpsPayPlanSchedule');
19
  }
20
 
@@ -24,7 +30,10 @@ class HpsPayPlanScheduleService extends HpsRestGatewayService
24
  // in a JSON document
25
  $data = $searchFields === array() ? (object)array() : $searchFields;
26
  $results = $this
27
- ->doRequest('POST', 'searchSchedules', $data);
 
 
 
28
 
29
  return $this->hydrateSearchResults($results, 'HpsPayPlanSchedule');
30
  }
@@ -37,7 +46,10 @@ class HpsPayPlanScheduleService extends HpsRestGatewayService
37
  } else {
38
  $id = $schedule;
39
  }
40
- $result = $this->doRequest('GET', 'schedules/'.$id);
 
 
 
41
  return $this->hydrateObject($result, 'HpsPayPlanSchedule');
42
  }
43
 
@@ -53,6 +65,9 @@ class HpsPayPlanScheduleService extends HpsRestGatewayService
53
  $data = array(
54
  'forceDelete' => $forceDelete,
55
  );
56
- return $this->doRequest('DELETE', 'schedules/'.$id, $data);
 
 
 
57
  }
58
  }
7
  $data = $schedule->getEditableFieldsWithValues();
8
  $data['customerKey'] = $schedule->customerKey;
9
  $data['numberOfPayments'] = $schedule->numberOfPayments;
10
+ $result = $this->doRequest($data, array(
11
+ 'verb' => 'POST',
12
+ 'endpoint' => 'schedules',
13
+ ));
14
  return $this->hydrateObject($result, 'HpsPayPlanSchedule');
15
  }
16
 
17
  public function edit(HpsPayPlanSchedule $schedule)
18
  {
19
  $data = $schedule->getEditableFieldsWithValues();
20
+ $result = $this->doRequest($data, array(
21
+ 'verb' => 'PUT',
22
+ 'endpoint' => 'schedules/'.$schedule->scheduleKey,
23
+ ));
24
  return $this->hydrateObject($result, 'HpsPayPlanSchedule');
25
  }
26
 
30
  // in a JSON document
31
  $data = $searchFields === array() ? (object)array() : $searchFields;
32
  $results = $this
33
+ ->doRequest($data, array(
34
+ 'verb' => 'POST',
35
+ 'endpoint' => 'searchSchedules',
36
+ ));
37
 
38
  return $this->hydrateSearchResults($results, 'HpsPayPlanSchedule');
39
  }
46
  } else {
47
  $id = $schedule;
48
  }
49
+ $result = $this->doRequest(null, array(
50
+ 'verb' => 'GET',
51
+ 'endpoint' => 'schedules/'.$id,
52
+ ));
53
  return $this->hydrateObject($result, 'HpsPayPlanSchedule');
54
  }
55
 
65
  $data = array(
66
  'forceDelete' => $forceDelete,
67
  );
68
+ return $this->doRequest($data, array(
69
+ 'verb' => 'DELETE',
70
+ 'endpoint' => 'schedules/'.$id,
71
+ ));
72
  }
73
  }
lib/SecureSubmit/src/Services/HpsCentinelConfig.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HpsCentinelConfig implements HpsConfigInterface
4
+ {
5
+ public $proccesorId = null;
6
+ public $merchantId = null;
7
+ public $transactionPwd = null;
8
+ public $version = 1.7;
9
+ public $useProxy = false;
10
+ public $proxyOptions = null;
11
+ public $serviceUri = 'https://centineltest.cardinalcommerce.com/maps/txns.asp';
12
+
13
+ public function serviceUri()
14
+ {
15
+ return $this->serviceUri;
16
+ }
17
+
18
+ public function setServiceUri(string $value)
19
+ {
20
+ $this->serviceUri = $value;
21
+ }
22
+
23
+ public function validate($keyType)
24
+ {
25
+ return true;
26
+ }
27
+ }
lib/SecureSubmit/src/Services/HpsServicesConfig.php CHANGED
@@ -1,10 +1,7 @@
1
  <?php
2
 
3
- class HpsServicesConfig
4
  {
5
- const KEY_TYPE_SECRET = 'secret';
6
- const KEY_TYPE_PUBLIC = 'public';
7
- const KEY_TYPE_UNKNOWN = 'unknown';
8
  public $credentialToken = null;
9
  public $secretApiKey = null;
10
  public $publicApiKey = null;
@@ -18,7 +15,7 @@ class HpsServicesConfig
18
  public $siteTrace = null;
19
  public $useProxy = null;
20
  public $proxyOptions = null;
21
- public $soapServiceUri = "https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx";
22
  public $payPlanBaseUri = null;
23
 
24
  public function serviceUri()
@@ -31,11 +28,10 @@ class HpsServicesConfig
31
  $this->soapServiceUri = $value;
32
  }
33
 
34
- public function validateApiKey($keyType)
35
  {
36
- return true;
37
- // return ($keyType == self::KEY_TYPE_PUBLIC && $this->validatePublicApiKey())
38
- // || ($keyType == self::KEY_TYPE_SECRET && $this->validateSecretApiKey());
39
  }
40
 
41
  public function getKeyType($keyType)
1
  <?php
2
 
3
+ class HpsServicesConfig implements HpsConfigInterface
4
  {
 
 
 
5
  public $credentialToken = null;
6
  public $secretApiKey = null;
7
  public $publicApiKey = null;
15
  public $siteTrace = null;
16
  public $useProxy = null;
17
  public $proxyOptions = null;
18
+ public $soapServiceUri = "https://cert.api2.heartlandportico.com/Hps.Exchange.PosGateway/PosGatewayService.asmx";
19
  public $payPlanBaseUri = null;
20
 
21
  public function serviceUri()
28
  $this->soapServiceUri = $value;
29
  }
30
 
31
+ public function validate($keyType)
32
  {
33
+ return ($keyType == self::KEY_TYPE_PUBLIC && $this->validatePublicApiKey())
34
+ || ($keyType == self::KEY_TYPE_SECRET && $this->validateSecretApiKey());
 
35
  }
36
 
37
  public function getKeyType($keyType)
lib/SecureSubmit/src/Services/index.php CHANGED
@@ -1 +1 @@
1
- <?php
1
+ <?php
lib/SecureSubmit/src/index.php CHANGED
@@ -1 +1 @@
1
- <?php
1
+ <?php
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Hps_Securesubmit</name>
4
- <version>1.0.7</version>
5
  <stability>stable</stability>
6
  <license uri="https://github.com/hps/heartland-magento-extension/blob/master/LICENSE">Custom</license>
7
  <channel>community</channel>
@@ -10,11 +10,18 @@
10
  <description>Use Heartland Payment Systems SecureSubmit platform to charge, authorize, void, refund and partial refund credit cards.&#xD;
11
  &#xD;
12
  Allow customers to store their cards for reduced friction at next checkout using our multi-use card tokenization process which helps reduce PCI scope.</description>
13
- <notes>Allows for newer versions of PHP to install the extension through Magento Connect</notes>
 
 
 
 
 
 
 
14
  <authors><author><name>Heartland Payment Systems</name><user>markhagan</user><email>EntApp_DevPortal@e-hps.com</email></author></authors>
15
- <date>2015-12-15</date>
16
- <time>18:58:58</time>
17
- <contents><target name="magecommunity"><dir name="Hps"><dir name="Securesubmit"><dir name="Block"><dir name="Adminhtml"><file name="Form.php" hash="ab296bcf9018c73690bb0f5ab381381d"/><dir name="Paypal"><dir name="Settlement"><dir name="Report"><file name="Grid.php" hash="06a2fe96172be2af5cd1087fd72c91ad"/></dir><file name="Report.php" hash="eb1824305f2e290647f33a590872d5f7"/></dir></dir></dir><file name="Form.php" hash="a2e7bd1c2457cc7f12cb114b6957fefb"/><file name="Info.php" hash="3fa6b51d26f335e5ca52ee58a4399a3c"/><dir name="Paypal"><dir name="Credit"><file name="Form.php" hash="bf5dfaed60db99e60cb29a2e6aba82a3"/></dir><file name="Form.php" hash="0ee38aa63acf96cb650f7a9f2357ff84"/><file name="Info.php" hash="e23c3c2cb2ad60b05e24c1ecdd057d9a"/><dir name="Review"><file name="Billing.php" hash="62a22e1f5bd65c4d9369b5794779ffe9"/><file name="Details.php" hash="57d97c8a2c3b7ddac7dc4cda43e4363f"/><file name="Shipping.php" hash="694374b68714b6d58d9af8b9fb15d502"/></dir><file name="Review.php" hash="87c8f3bf319799b33170bec9f42e2544"/><file name="Shortcut.php" hash="4874a291018d9a6651d03cb9aeb54e07"/></dir></dir><dir name="Controller"><dir name="Paypal"><file name="Abstract.php" hash="0accc2a086374ab6f8260bd9e1a30337"/></dir></dir><dir name="Helper"><file name="Data.php" hash="04aeff6f94f56a49cf7527518c6212a1"/></dir><dir name="Model"><dir name="Api"><file name="Abstract.php" hash="77651db9410c0a7eca66f888cfd1eab5"/><file name="Paypal.php" hash="96439865e72b6c260138f650bd31a9ec"/></dir><file name="Config.php" hash="43c18bb31f7d774de93b1c1c0c541f82"/><file name="Payment.php" hash="3c72d498069ead0f0898bc5f3525f847"/><dir name="Paypal"><file name="Cart.php" hash="b64c4896eba58fc573f228656453d448"/><file name="Checkout.php" hash="ef815ce706cf67bac08853673e8bee7c"/><file name="Credit.php" hash="1f84b1addec3ff6887c81e6d240cc1ee"/></dir><file name="Paypal.php" hash="96ad238d35a79d31e9541f8755a24dde"/><file name="Report.php" hash="7f5e5bf0c652b37cf8c42eb553c8b3e0"/><dir name="Resource"><dir name="Report"><file name="Collection.php" hash="5870728a842922bbbff9c50173a90bd4"/></dir><file name="Report.php" hash="59598e2958a864119925c6e847b66121"/><file name="Setup.php" hash="f568cb09a6a06fc3d52f145684997416"/><dir name="Storedcard"><file name="Collection.php" hash="021134d46837197e800f54a4b90b0048"/></dir><file name="Storedcard.php" hash="f2a993c8e4236bc03b1273a33a03b5d0"/></dir><file name="Session.php" hash="136b4146cea2f596847f0b838ec3f532"/><dir name="Source"><file name="Cctype.php" hash="b5f75e4a3284f79b2cfab926b193c98b"/><file name="PaymentAction.php" hash="9fc55ebaaeaccba6c40597d25a1cf9d3"/></dir><file name="Storedcard.php" hash="82c7228d2182a0cba979dc4c66a2321c"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Proxy.php" hash="97028069630bddf2b94cb1b5b0886076"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Hps"><dir name="Paypal"><file name="ReportsController.php" hash="bdb457590d4de2a7b9fe0055220e08f5"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/><file name="._.DS_Store" hash="f0d9d90674bab5908378533975df5a01"/></dir></dir><file name="PaypalController.php" hash="bf8e1033a2320ab9d9f70d99ff40c598"/><file name="StoredcardController.php" hash="cb9e5f7de4f52fd7a764a87f0f4699a8"/></dir><dir name="etc"><file name="adminhtml.xml" hash="8dc53c22d22cd633ebd6c06e7262c741"/><file name="config.xml" hash="b3fde0de1a10e823ce680317738fd802"/><file name="system.xml" hash="be8a2c1d74b72b45bd14eed62cc5a5e7"/></dir><dir name="sql"><dir name="hps_securesubmit_setup"><file name="install-1.0.0.php" hash="57917d8b3b29830eb1a219466df4555b"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="510826261ea81ea6a09d4ea84c59d41d"/><file name="mysql4-upgrade-1.0.1-1.1.0.php" hash="4044126ddfe49f5add3c530fcb6565fb"/></dir></dir><file name=".DS_Store" hash="4a6d92e7f95a9f9208c420e97eb1d4ea"/></dir></dir></target><target name="mageweb"><dir name="js"><dir name="securesubmit"><file name="admin-checkout.js" hash="1493f7f32243bad6d4facd577a375198"/><file name="checkout-form.js" hash="18ab8f124105d3aa22623ba6b8b76d25"/><file name="secure.submit-1.0.1.js" hash="a149dc8efcfa3b507d6b2b3c784d9db3"/></dir></dir></target><target name="magelib"><dir name="SecureSubmit"><file name="Hps.php" hash="8855d261c2df0de3fe7ad8e6e59668ad"/><file name="LICENSE.txt" hash="de081f847a769f89be5a1f80862005ba"/><file name="PRIVACY.txt" hash="58cdc5fbbff24a84a838b0174b254f70"/><file name="README.md" hash="bf88790111a10eb3643d62489b66c4d0"/><dir name="entities"><file name="HpsAccountVerify.php" hash="a910342548320ba07ebc4c9cda2f7c96"/><file name="HpsAddress.php" hash="2e4554c509e1de8e8cb6b0d1f599d657"/><file name="HpsAuthorization.php" hash="c46f0ad9033d3197e641c1b63bd90c7e"/><file name="HpsBatch.php" hash="46ee0321f3c9f3824fdb930736c8df7e"/><file name="HpsCardHolder.php" hash="f74938b2f53d703c777def01adde5e91"/><file name="HpsCharge.php" hash="5e94b3094db8e4f231a456cedce40985"/><file name="HpsChargeExceptions.php" hash="927b346fdac882cf97fd46b5e740e363"/><file name="HpsCreditCard.php" hash="9394bb9cd123d572d2f3376f3ce52594"/><file name="HpsItemChoiceTypePosResponseVer10Transaction.php" hash="3516bf8acb77af8d4a36d02ed991d09e"/><file name="HpsRefund.php" hash="05a8dae7c7e0faf1e67ae628eca75ea2"/><file name="HpsReportTransactionDetails.php" hash="ad0221581bf4ee24410c1ed4aac4d305"/><file name="HpsReportTransactionSummary.php" hash="1d46cce9a3274f25c092171e034479bc"/><file name="HpsReversal.php" hash="1ffd02ea88816b9a7ef5579d6219d6b8"/><file name="HpsTokenData.php" hash="bfc42e3ed9ff078598d694565d7fd3be"/><file name="HpsTransaction.php" hash="fd2bb80e28f9143bb25a3df1508fb927"/><file name="HpsTransactionDetails.php" hash="ded777de86d2b93882b2779283247b64"/><file name="HpsTransactionHeader.php" hash="114de2d7b3648143d0ef16588dfbc1af"/><file name="HpsTransactionType.php" hash="58a73f5915ff2d3f9d89935232e90796"/><file name="HpsVoid.php" hash="09902616437fd001ec17cde2b6dd9780"/></dir><file name="index.php" hash="feabe5cc691b088d6ade3e04d6b120fc"/><dir name="infrastructure"><file name="AVSResponseCodeHandler.php" hash="b376458f6bbf14907fd96b6b17566861"/><file name="ApiConnectionException.php" hash="8b6e2d5e4d7e3368adb34e1ab20412b0"/><file name="AuthenticationException.php" hash="4685a4fa0209ed56ef0ee38868f52840"/><file name="CardException.php" hash="09bf8965e0e101dcaf560c0927812306"/><file name="Exceptions.json" hash="8f7cbcb2b18963603ee3a62d6888c36d"/><file name="HpsConfiguration.php" hash="48ed3ba9eed035d5e57d245f5174b5bc"/><file name="HpsException.php" hash="ad9fbec07d00343bb53f71a835874ea4"/><file name="HpsExceptionMapper.php" hash="5f81eacdaea3ccb756a89b04ec4c20d6"/><file name="HpsSdkCodes.php" hash="b827c7268a5743a5fd45e992eeab2450"/><file name="InvalidRequestException.php" hash="a01ca17d036ce2e6410647aa1bd25491"/></dir><dir name="services"><file name="HpsBatchService.php" hash="b33260d307dd557d6fd287b32638c1aa"/><file name="HpsChargeService.php" hash="b3ae575ac87b364e4e847440792fa7c3"/><file name="HpsService.php" hash="52aefe6d72b1e4118fdd8ec04b75e28c"/><file name="HpsTokenService.php" hash="bfdee5e18ebdc2133f3512040e0da766"/></dir><dir name="src"><dir name="Abstractions"><file name="HpsBuilderAbstract.php" hash="6498e7b7e00716574a9dd238d1d7da5e"/><file name="HpsGatewayServiceAbstract.php" hash="3a13e35a1d3ea514ea67aadda34095f0"/><file name="HpsPayPlanResourceAbstract.php" hash="df262df6345c4932626e60afecdeb478"/><file name="HpsPayPlanResourceInterface.php" hash="22dd33e354f46218d2872eab956d57c1"/></dir><dir name="Entities"><dir name="AltPayment"><file name="HpsAltPaymentAddToBatch.php" hash="209a67ef29955f4e311a7b63242a019c"/><file name="HpsAltPaymentAuth.php" hash="179ac60bb7d4fbf8e536efb8f875ad65"/><file name="HpsAltPaymentCreateSession.php" hash="fc3c655d80d1e2559ad0606e72842cb8"/><file name="HpsAltPaymentReturn.php" hash="990b0596137a8833c145bdd55af802cb"/><file name="HpsAltPaymentSale.php" hash="c818e0a33ce76568cc6dc12a828c027f"/><file name="HpsAltPaymentSessionInfo.php" hash="a89b480b53bb0eb81ad71630d8712ba5"/><file name="HpsAltPaymentVoid.php" hash="aa60698f841c95d6d0c68ce42412a216"/><file name="HpsBuyerData.php" hash="bced7dbbfef25c606586f248a03afda3"/><file name="HpsLineItem.php" hash="4ff06a280975312365cf10a730636682"/><file name="HpsPaymentData.php" hash="c53ad30c9a01df727e5fff81e57cfbc4"/><file name="HpsShippingInfo.php" hash="fc29c5f4abfd1902d1f890ba4c60b2f5"/></dir><dir name="Batch"><file name="HpsBatch.php" hash="d9af4664e64172cb8edaeaa1ea7c7337"/></dir><dir name="Check"><file name="HpsCheck.php" hash="8fb85bd4d608e72a9690285ec46fa6d2"/><file name="HpsCheckHolder.php" hash="58f865b34faf2790fef26066de775a15"/><file name="HpsCheckResponse.php" hash="ff3c752bc85554424e62ed7efbc053f2"/><file name="HpsCheckResponseDetails.php" hash="28928ceb2dea574603a376aed1691a90"/></dir><dir name="Credit"><file name="HpsAccountVerify.php" hash="527a69e5a39153b764e6c14e0d98bf34"/><file name="HpsAuthorization.php" hash="7ec1bbfa6efa5bc48432b5de81eda314"/><file name="HpsCPCData.php" hash="54f7d36b10ef067c1bbc1d31866f020b"/><file name="HpsCPCEdit.php" hash="f04b0089485ba9e7eacba8e15815ec97"/><file name="HpsCardHolder.php" hash="ffee4609a3ffa886a386a12dea3f4508"/><file name="HpsCharge.php" hash="512fb9e459b336a9e256d8f1e08e36b9"/><file name="HpsChargeExceptions.php" hash="c7df102696a205a4c5689c48878ac5f3"/><file name="HpsCreditCard.php" hash="a64984f73b32c98120b44c7ab11407a9"/><file name="HpsRecurringBilling.php" hash="9da8f9b16179729b77615f04993b05bf"/><file name="HpsRefund.php" hash="aa4664916ebb94b8f2066fd7c17b0fd4"/><file name="HpsReportTransactionDetails.php" hash="9e81fbeb3b8d37231e65e9b38e026363"/><file name="HpsReportTransactionSummary.php" hash="dd157b169ffb8e71dd158fe1bf592c1a"/><file name="HpsReversal.php" hash="350191a2d38189ef8e098ed1f922c1d3"/><file name="HpsVoid.php" hash="bf6216cea2f130789a045fc226c54cd0"/></dir><dir name="Debit"><file name="HpsDebitAddValue.php" hash="9053c701093889f864dd36af208f4f71"/><file name="HpsDebitReturn.php" hash="519cb73c6fc4ce716453d5ff94f437a0"/><file name="HpsDebitReversal.php" hash="223f6db72f0219ef25eb0f0adec4e9be"/><file name="HpsDebitSale.php" hash="74fa1e1425cfe6294146c879a4049aa8"/></dir><dir name="Fluent"><file name="HpsBuilderAction.php" hash="8649cc2c53fd961f350070193fedb5c6"/><file name="HpsUnknownPropertyException.php" hash="d019e8645fae6f984ad7b7ea3cebb546"/></dir><dir name="Gift"><file name="HpsEncryptionData.php" hash="4b8d70dd2617504237ee9473b948e358"/><file name="HpsGiftCard.php" hash="73f4d366045409b50c6d4426d3cfd8f2"/><file name="HpsGiftCardActivate.php" hash="8fce968cabe957f092086571eac6fa52"/><file name="HpsGiftCardAddValue.php" hash="131a9d7cbc711a4e3e85c66049028f30"/><file name="HpsGiftCardAlias.php" hash="133d2d4701c5aa88fa0eece6ee69de06"/><file name="HpsGiftCardBalance.php" hash="9b9fe395d218c79c55faf28fd736b431"/><file name="HpsGiftCardDeactivate.php" hash="323ca5a67c6ff0169925192952881db5"/><file name="HpsGiftCardReplace.php" hash="f122a7d924a56fcc406bc8b1c82ac2b2"/><file name="HpsGiftCardReversal.php" hash="88ba755e52f41311206add4fa8ee5e09"/><file name="HpsGiftCardReward.php" hash="f758e8c5462d336236ae0d257789cdaf"/><file name="HpsGiftCardSale.php" hash="0f758ef6653215be643abaea4964352a"/><file name="HpsGiftCardVoid.php" hash="f0294740f5b7f545167d5fb258f4dcdd"/></dir><file name="HpsAddress.php" hash="8de2c8ea4a2b0a440d1b4bc0bf8321b8"/><file name="HpsConsumer.php" hash="1254142dfa0821cbb0bf154cf51f34d2"/><file name="HpsDirectMarketData.php" hash="e476ccc0c25c1681fa624365be6b8306"/><file name="HpsTokenData.php" hash="18ab9125315bb8e5f9cb272966dac22b"/><file name="HpsTransaction.php" hash="f109d2d26ba237afb2dc17bc287f63a9"/><file name="HpsTransactionDetails.php" hash="4e77261d0aced118b49e26ef786beace"/><file name="HpsTransactionHeader.php" hash="ebd21539f84425f0e2fc57c6049a26a1"/><dir name="PayPlan"><file name="HpsPayPlanCustomer.php" hash="2714a7525fb3830fc018544ea0622ab5"/><file name="HpsPayPlanPaymentMethod.php" hash="2d38df9da8b03f37aae752480e831257"/><file name="HpsPayPlanSchedule.php" hash="b87e28803ca7bddac9a42feaed0a5155"/></dir><file name="index.php" hash="feabe5cc691b088d6ade3e04d6b120fc"/></dir><dir name="Infrastructure"><dir name="Enums"><file name="HpsACHType.php" hash="1ff5593689a404cb0179c2b5cb5fe19e"/><file name="HpsAccountType.php" hash="760d91e120f443c326e6c7586aa61092"/><file name="HpsCardBrand.php" hash="9532bb7c40811c114a1eeeffa8b9732c"/><file name="HpsCheckType.php" hash="d60c676d93c8ada169deb14ddc8e64e7"/><file name="HpsDataEntryMode.php" hash="c323d884a7a305f9af647ea1d9a4177e"/><file name="HpsExceptionCodes.php" hash="94e6177576e9e9938e60a5bb386315d4"/><file name="HpsGiftCardAliasAction.php" hash="ebcb27c6fb800e17693ed4af2e8a8943"/><file name="HpsItemChoiceTypePosResponseVer10Transaction.php" hash="686225a07738db2233a2228bec6baabf"/><file name="HpsPayPlanAccountType.php" hash="4d383c42a990fb077fae49386c08b870"/><file name="HpsPayPlanCustomerStatus.php" hash="3ff092e8dd97f2a2474fb64103cb238f"/><file name="HpsPayPlanPaymentMethodStatus.php" hash="b020c52de7987ed3011cb97e4d440c6a"/><file name="HpsPayPlanPaymentMethodType.php" hash="1f77c5c8528815f05803c1381cb4151a"/><file name="HpsPayPlanScheduleDuration.php" hash="05101e6fe3b725b43917b59770f2dbb1"/><file name="HpsPayPlanScheduleFrequency.php" hash="0b3f029c64315ee9c8701d23319941c1"/><file name="HpsPayPlanScheduleStatus.php" hash="3579b52ccf36e576fd2dfb36118716f6"/><file name="HpsSECCode.php" hash="551661613c127c068f139083338b92d1"/><file name="HpsTaxType.php" hash="ba0e05330880810e58370f2f3490ca81"/><file name="HpsTransactionType.php" hash="a38b3f4c654a4fa3b2c2d64b8afacf24"/></dir><file name="HpsApiConnectionException.php" hash="ac5a8064a7c2a1616035a5702f36cd50"/><file name="HpsArgumentException.php" hash="855c43e88fc24b582cfe56875d7cff42"/><file name="HpsAuthenticationException.php" hash="6feb2fdc5499b460274524aa469d9a7d"/><file name="HpsCheckException.php" hash="94870f2438217b3275d05fb943a0a8c0"/><file name="HpsConfiguration.php" hash="962030209b58ea19c1b92330ce10e90c"/><file name="HpsCreditException.php" hash="a16bf1ecd6a2c866b7b40351aab3df34"/><file name="HpsCreditExceptionDetails.php" hash="d71c54b2846283a8f97aae74a747dfd9"/><file name="HpsException.php" hash="8d2025b7fae9f0f756341b876a0dab41"/><file name="HpsGatewayException.php" hash="cdd6db6c8436e3e78ee15cdd7a043a9d"/><file name="HpsGatewayExceptionDetails.php" hash="16dd36360e2237ca89e056c61766bcdd"/><file name="HpsInvalidRequestException.php" hash="7877e48463ef3f488bb92423ae445412"/><file name="HpsProcessorException.php" hash="ba28a92f0e551053506dcc391c5bc431"/><file name="HpsProcessorExceptionDetails.php" hash="6a569aacf045c19ade6472a857a3a274"/><dir name="Validation"><file name="HpsGatewayResponseValidation.php" hash="da8321b85030758d4a0d8bdd60222fc0"/><file name="HpsInputValidation.php" hash="1f51837f70c322f2a7c1cc39df752b1a"/><file name="HpsIssuerResponseValidation.php" hash="81d4625dc46e67bc59569620eed035c3"/><file name="HpsProcessorResponseValidation.php" hash="8dd4e86f84a509e756a74f499363407c"/></dir><file name="index.php" hash="feabe5cc691b088d6ade3e04d6b120fc"/></dir><dir name="Services"><dir name="Fluent"><dir name="Gateway"><dir name="Check"><file name="HpsCheckServiceOverrideBuilder.php" hash="fff87fca19d16cdc84586842540cd455"/><file name="HpsCheckServiceReturnBuilder.php" hash="4e953a852c9ab7526f1698c3e119a620"/><file name="HpsCheckServiceSaleBuilder.php" hash="0c2fa60711bd1c5ed8e890d423c0178f"/><file name="HpsCheckServiceVoidBuilder.php" hash="b7b40a6979a7f9407f6979f9e09295a0"/></dir><dir name="Credit"><file name="HpsCreditServiceAuthorizeBuilder.php" hash="0bf4ed6c057282754abdaaa86f40e236"/><file name="HpsCreditServiceCaptureBuilder.php" hash="2344fc2c40d52820bb0a74859e88168e"/><file name="HpsCreditServiceChargeBuilder.php" hash="13835b698c89eeb2e272de7e8037f469"/><file name="HpsCreditServiceCpcEditBuilder.php" hash="2f377011fb9ab5a36e1e63bafc6967cc"/><file name="HpsCreditServiceEditBuilder.php" hash="06755dd0baa05b3d7c621b981a209c73"/><file name="HpsCreditServiceGetBuilder.php" hash="0c90dfd82b9d5876010996bc3a5724a2"/><file name="HpsCreditServiceListTransactionsBuilder.php" hash="590c8e3f0cb5abd7f37f83bd9efca4fe"/><file name="HpsCreditServiceRefundBuilder.php" hash="74989514e3f90faac7af7ea42ff45cde"/><file name="HpsCreditServiceReverseBuilder.php" hash="de7e71f7ae431776381fee9214b2438d"/><file name="HpsCreditServiceVerifyBuilder.php" hash="7058d38bdfa9219fef1fad1976e81332"/><file name="HpsCreditServiceVoidBuilder.php" hash="590bc78af55b5d851cdd24043530fa84"/></dir><dir name="Debit"><file name="HpsDebitServiceAddValueBuilder.php" hash="5f972b68a5afa062cbf911bfb3a946bc"/><file name="HpsDebitServiceChargeBuilder.php" hash="26aafce2a87bbbd8231a039209c49657"/><file name="HpsDebitServiceReturnBuilder.php" hash="2e11267e12bdd338b953db352a373961"/><file name="HpsDebitServiceReverseBuilder.php" hash="b088431d3ba0726d44cc418e92267958"/></dir><dir name="GiftCard"><file name="HpsGiftCardServiceActivateBuilder.php" hash="65e3ebd1c6ded3860b238d03e542fe3b"/><file name="HpsGiftCardServiceAddValueBuilder.php" hash="432582c9fd6617c86b373f5fe0b14fb1"/><file name="HpsGiftCardServiceAliasBuilder.php" hash="23b6e876818560166497f556905cfcfb"/><file name="HpsGiftCardServiceBalanceBuilder.php" hash="6bebaac04d059204a2408d693f77c449"/><file name="HpsGiftCardServiceDeactivateBuilder.php" hash="92b16b331414c40ea11de330bd447273"/><file name="HpsGiftCardServiceReplaceBuilder.php" hash="063e6b33a673c23553047a6f72927b2a"/><file name="HpsGiftCardServiceReverseBuilder.php" hash="2f7b96b1f9608cb7e3526ecb9b15558f"/><file name="HpsGiftCardServiceRewardBuilder.php" hash="242fbe42ab731b138e4d74be4cde4e9a"/><file name="HpsGiftCardServiceSaleBuilder.php" hash="e0a87760bf2584ba07694bbb6534d3f5"/><file name="HpsGiftCardServiceVoidBuilder.php" hash="fff556a586bb09d22f521a90d30fb809"/></dir><file name="HpsFluentCheckService.php" hash="f722f875ed58a2be6e40b8a9dab66bb1"/><file name="HpsFluentCreditService.php" hash="301eeb5b6998cbd0f34990b0c0a54272"/><file name="HpsFluentDebitService.php" hash="63e86fe32a92c80cc5bd163283da6c64"/><file name="HpsFluentGiftCardService.php" hash="8a93e1afe2efc6f4e4db673fa61deee6"/><dir name="PayPlan"><file name="HpsPayPlanCustomerServiceAddBuilder.php" hash="e24d3255eeb44df4a9188ee6355f4af3"/><file name="HpsPayPlanCustomerServiceDeleteBuilder.php" hash="8b7646782d20308550b2fcd7e60cd1b1"/><file name="HpsPayPlanCustomerServiceEditBuilder.php" hash="e46190e3926f77b2a6bebb01140273b6"/><file name="HpsPayPlanCustomerServiceGetBuilder.php" hash="01b327c5c7f0e08918d7e49af338f364"/><file name="HpsPayPlanCustomerServiceSearchBuilder.php" hash="d411d14b4f52787ec9cad99087a4dbe9"/><file name="HpsPayPlanPaymentMethodServiceAddBuilder.php" hash="0409afd2934a875932985ce972aaa63b"/><file name="HpsPayPlanPaymentMethodServiceDeleteBuilder.php" hash="decec6ded5a4f0105592d8e223e40546"/><file name="HpsPayPlanPaymentMethodServiceEditBuilder.php" hash="5b73f43349c59f51f6c0af593900b530"/><file name="HpsPayPlanPaymentMethodServiceGetBuilder.php" hash="7d36bab7be54328de460d10cb7517aa7"/><file name="HpsPayPlanPaymentMethodServiceSearchBuilder.php" hash="1abf6bd6f2f3dc23513a1ee053d7a324"/><file name="HpsPayPlanScheduleServiceAddBuilder.php" hash="ec46e983b59f36dffc721c38e1783451"/><file name="HpsPayPlanScheduleServiceDeleteBuilder.php" hash="575e48a5d83820219d1af19a4c6f74b8"/><file name="HpsPayPlanScheduleServiceEditBuilder.php" hash="5665c1807226305456ecba027b04162b"/><file name="HpsPayPlanScheduleServiceGetBuilder.php" hash="c5b892091c1b2a32db3d48fa64b62e65"/><file name="HpsPayPlanScheduleServiceSearchBuilder.php" hash="68462acb4bdae55ff1895e53e36ebcaa"/></dir></dir></dir><dir name="Gateway"><dir name="AltPayment"><file name="HpsAltPaymentService.php" hash="4598ceace95ee666cb38dfc3546053e1"/><file name="HpsPayPalService.php" hash="c91eebb0eca8bdda2505b78c4746db28"/></dir><file name="HpsBatchService.php" hash="96c99c3a4c0ef3bcd73ec804912caeb7"/><file name="HpsCheckService.php" hash="c3c5b51aea67ef20ed657a7814344e95"/><file name="HpsCreditService.php" hash="4f2e15d27ab65d4e862b926891ffc8eb"/><file name="HpsDebitService.php" hash="3e1de3f705a9bb48a01fb132894264a3"/><file name="HpsGiftCardService.php" hash="b386c0d74b5c8eb74bc1c7f584bf99ad"/><file name="HpsRestGatewayService.php" hash="07c2a91fa455394c671c8b0018d8d65c"/><file name="HpsSoapGatewayService.php" hash="196ce540ca0c3bbed9b19472b80de3bd"/><file name="HpsTokenService.php" hash="f5bf762400e9c67ac28451693b31ebbe"/><dir name="PayPlan"><file name="HpsPayPlanCustomerService.php" hash="5eb04d200802380de80360e3bb96234b"/><file name="HpsPayPlanPaymentMethodService.php" hash="17d8c5c0b74f88d6f8c76bcc65175279"/><file name="HpsPayPlanScheduleService.php" hash="cddffbf0c2d36ba2e3448b21453c17eb"/></dir></dir><file name="HpsServicesConfig.php" hash="90f781e4a916517073b3e071aba7ad18"/><file name="index.php" hash="feabe5cc691b088d6ade3e04d6b120fc"/></dir><file name="index.php" hash="feabe5cc691b088d6ade3e04d6b120fc"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="securesubmit.xml" hash="cc04e952cc17ea3462931a9e7a655316"/></dir><dir name="template"><dir name="securesubmit"><file name="form.phtml" hash="b6329408b11e9e979494a923e639f6cf"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="securesubmit.xml" hash="8aca5736bbba6ec8341cf9510c0ea5ab"/></dir><dir name="template"><dir name="securesubmit"><file name="form.phtml" hash="313ae740ba48618afac2797fddb162c9"/><dir name="paypal"><dir name="review"><file name="details.phtml" hash="0dc5e1201e7e424f089c15fc83a1c70f"/><dir name="shipping"><file name="method.phtml" hash="cc426553636aa08840bee1c4778d89e4"/></dir></dir><file name="review.phtml" hash="cfc643de65b962ba27306587357f45d3"/><file name="shortcut.phtml" hash="268bfac86e653ec5981cd201075f4105"/></dir><file name="storedcards.phtml" hash="3412f0560d4ba696dc9bc3ed996e0577"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Hps_Securesubmit.xml" hash="d5aed3f48a45f8e611b68d1e6f34c959"/></dir></target></contents>
18
  <compatible/>
19
- <dependencies><required><php><min>5.2.0</min><max>5.6.16</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Hps_Securesubmit</name>
4
+ <version>1.2.0</version>
5
  <stability>stable</stability>
6
  <license uri="https://github.com/hps/heartland-magento-extension/blob/master/LICENSE">Custom</license>
7
  <channel>community</channel>
10
  <description>Use Heartland Payment Systems SecureSubmit platform to charge, authorize, void, refund and partial refund credit cards.&#xD;
11
  &#xD;
12
  Allow customers to store their cards for reduced friction at next checkout using our multi-use card tokenization process which helps reduce PCI scope.</description>
13
+ <notes>Fix: card saving&#xD;
14
+ Update: cleanup credit card payment class&#xD;
15
+ Update: certification/test URL to support PCI 3.1&#xD;
16
+ Feature: multishipping&#xD;
17
+ Feature: Added advanced fraud logic and options for credit card payments&#xD;
18
+ Feature: Heartland gift&#xD;
19
+ Feature: PayPal support&#xD;
20
+ Feature: MasterPass support</notes>
21
  <authors><author><name>Heartland Payment Systems</name><user>markhagan</user><email>EntApp_DevPortal@e-hps.com</email></author></authors>
22
+ <date>2016-03-31</date>
23
+ <time>17:29:55</time>
24
+ <contents><target name="magecommunity"><dir name="Hps"><dir name="Securesubmit"><dir name="Block"><dir name="Adminhtml"><file name="Form.php" hash="ab296bcf9018c73690bb0f5ab381381d"/><dir name="Paypal"><dir name="Settlement"><dir name="Report"><dir name="Form"><file name="Form.php" hash="da5a943526a729a4e78def46c63d0109"/></dir><file name="Form.php" hash="ecc3101a2a399dc71ae544bbe7bb9595"/><file name="Grid.php" hash="35b62c9ab2fe5b5e9a9394e11167f50c"/></dir><file name="Report.php" hash="19171fb1fad872b0ebff9692de1415fd"/></dir></dir></dir><file name="Form.php" hash="031741c6abad215430305c3758b3a362"/><file name="Info.php" hash="6517436417704a229e89274952a66b16"/><dir name="Masterpass"><dir name="Client"><file name="Js.php" hash="ed427387b93d2753d8e8ada51c0d8f37"/></dir><file name="Connect.php" hash="b5e362f21c219ec61c4df7dff561ace6"/><file name="Form.php" hash="6abc4c67143380fad13efec247a18af4"/><file name="Info.php" hash="b8f714200c8f74cd8a0a9547fafc3637"/><dir name="Review"><file name="Billing.php" hash="c5bc2f64c2dc30e8ca1458cd286a16ee"/><file name="Details.php" hash="c324f315b2dfda8263151612ec73f513"/><file name="Shipping.php" hash="aeb5f38aa185e9d3acbb7ce5d4c4b841"/></dir><file name="Review.php" hash="b6e4dbd308c44215e50fa94dd22a32b0"/></dir><dir name="Paypal"><dir name="Credit"><file name="Form.php" hash="68fc4811e8f2d9a1b502454533fe5bca"/></dir><file name="Form.php" hash="776d2aab11db7d212061ca9a30936af1"/><dir name="Incontext"><file name="Js.php" hash="d09bf9157c0b7c5f6dba16d8cdac557d"/></dir><file name="Info.php" hash="9c1948c538383376b1dc1b4c76c31e95"/><dir name="Review"><file name="Billing.php" hash="62a22e1f5bd65c4d9369b5794779ffe9"/><file name="Details.php" hash="57d97c8a2c3b7ddac7dc4cda43e4363f"/><file name="Shipping.php" hash="694374b68714b6d58d9af8b9fb15d502"/></dir><file name="Review.php" hash="87c8f3bf319799b33170bec9f42e2544"/><file name="Shortcut.php" hash="26f13ae7afac41ce88fb1cd4042b61b5"/></dir></dir><dir name="Helper"><dir name="Altpayment"><file name="Abstract.php" hash="5a98b81b495abb362bbaca4d401685b2"/></dir><file name="Data.php" hash="35a26dab0e14154f2ee80a498f788d7c"/><file name="Masterpass.php" hash="69489b7cae8b99fe216f522b19f3d448"/><file name="Paypal.php" hash="5c266d327fe2a48c5530d962e9cc544b"/></dir><dir name="Model"><dir name="Altpayment"><file name="Cart.php" hash="1dc83b97c44463e954efc8ee1c9e62b8"/></dir><file name="Masterpass.php" hash="063acd12e22bdc26d7591cbabf7e3005"/><file name="Payment.php" hash="61129a29dcc0c7b6657fcb5c91aeaa78"/><dir name="Paypal"><file name="Credit.php" hash="3548d6c4308df9d377cc1dd0d40f0f4d"/></dir><file name="Paypal.php" hash="c3eb2058ff6860e85a9310944c989301"/><file name="Report.php" hash="7f5e5bf0c652b37cf8c42eb553c8b3e0"/><dir name="Resource"><dir name="Report"><file name="Collection.php" hash="5870728a842922bbbff9c50173a90bd4"/></dir><file name="Report.php" hash="59598e2958a864119925c6e847b66121"/><file name="Setup.php" hash="8bdfbde89d786809d8aa2637efb1d2ae"/><dir name="Storedcard"><file name="Collection.php" hash="756c3c2d6dd5384f37847a028ac12fee"/></dir><file name="Storedcard.php" hash="d43320b704eb1e37c77a5ac20401c557"/></dir><file name="Session.php" hash="136b4146cea2f596847f0b838ec3f532"/><dir name="Source"><file name="Cctype.php" hash="d2dfff6147dc5c2748c7e9767b1fd1cb"/><file name="PaymentAction.php" hash="3c900b82e9af73a372d9f5f36bc1c264"/></dir><file name="Storedcard.php" hash="50897a56669c5938d4613579b603df93"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Proxy.php" hash="29ea9cb11927cd1e43055a42101eea36"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Hps"><dir name="Paypal"><file name="ReportsController.php" hash="914711bc008ec9e240918be7e77d1d54"/></dir></dir><file name="StoredcardController.php" hash="1e968134bf3b60a5f49544ddd1df8f03"/></dir><file name="GiftcardController.php" hash="17b5a07d1d277281199f8f01d8280420"/><file name="MasterpassController.php" hash="2fb95214db3d3d017dd022743636ec50"/><file name="PaypalController.php" hash="962ce3dc3e738689d6ec6b122ed46001"/><file name="StoredcardController.php" hash="57116e86203df6f24a12fcd93186b534"/></dir><dir name="etc"><file name="adminhtml.xml" hash="8dc53c22d22cd633ebd6c06e7262c741"/><file name="config.xml" hash="0a5d2c0241c3d737081c7e923d2f5276"/><file name="system.xml" hash="813d66d3fe8bde89912b9e6fa8355ba0"/></dir><dir name="sql"><dir name="hps_securesubmit_setup"><file name="install-1.0.0.php" hash="d424731dcb784aad59dad0bcce431375"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="510826261ea81ea6a09d4ea84c59d41d"/><file name="mysql4-upgrade-1.0.1-1.1.0.php" hash="01e948ea2939f9b0b69bb6748adc53f2"/><file name="mysql4-upgrade-1.1.0-1.2.0.php" hash="84cf1a359fc5a5600e1d98ba0089d911"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="securesubmit"><file name="admin-checkout.js" hash="14d970828f50bb463dc3f7cdaca97e1d"/><file name="checkout-form.js" hash="14cc8b51bc2073e922aa54f28300e0a2"/><dir name="masterpass"><file name="lightbox.js" hash="b534647c7c06b5ce90caf4cdd6166f91"/></dir><dir name="paypal"><file name="incontext.js" hash="e3810f12033fa9822db756a22622f799"/></dir><file name="secure.submit-1.0.1.js" hash="988d59dadbc272b869bc9e56cbd7518e"/></dir></dir></target><target name="magelib"><dir name="SecureSubmit"><file name="Hps.php" hash="aeeb39dae09306051eec2cf455fcb6a8"/><file name="LICENSE.txt" hash="de081f847a769f89be5a1f80862005ba"/><file name="PRIVACY.txt" hash="58cdc5fbbff24a84a838b0174b254f70"/><file name="README.md" hash="8320a396aa5544e61fe2e8f2adb09505"/><file name="index.php" hash="feabe5cc691b088d6ade3e04d6b120fc"/><dir name="src"><dir name="Abstractions"><file name="HpsAltPaymentServiceInterface.php" hash="bbbacdf42b798458ca46921b3ddb9eaf"/><file name="HpsBuilderAbstract.php" hash="6498e7b7e00716574a9dd238d1d7da5e"/><file name="HpsConfigInterface.php" hash="6541819ca5724269db6e1a9ed456d52e"/><file name="HpsGatewayServiceAbstract.php" hash="6e6631e0cfea0001a6fff4bf57d13068"/><file name="HpsGatewayServiceInterface.php" hash="c2b49802b328648d8510433b5c82f71f"/><file name="HpsPayPlanResourceAbstract.php" hash="df262df6345c4932626e60afecdeb478"/><file name="HpsPayPlanResourceInterface.php" hash="22dd33e354f46218d2872eab956d57c1"/></dir><dir name="Entities"><dir name="AltPayment"><file name="HpsAltPaymentAddToBatch.php" hash="1684714c0cd14d6d33288a44f43c9dd6"/><file name="HpsAltPaymentAuth.php" hash="4f2748e2b95cffed6bd0e62f75af71eb"/><file name="HpsAltPaymentCapture.php" hash="51a86062c15c6f8de15147b5b53f89a4"/><file name="HpsAltPaymentCreateSession.php" hash="4e83acd11a03e7dfcf904f2421d858b3"/><file name="HpsAltPaymentResponse.php" hash="860336d2015560f889c41773574b97ab"/><file name="HpsAltPaymentReturn.php" hash="0b9d8cb0f67ddf113b99ca64ab6019a3"/><file name="HpsAltPaymentSale.php" hash="f390a9a4af50f7a8a863c607f7e3357f"/><file name="HpsAltPaymentSessionInfo.php" hash="3c50068d48634178a4259d789e1ddf1a"/><file name="HpsAltPaymentVoid.php" hash="429f0fbec31ae4842c494b0a8af47ddb"/><file name="HpsBuyerData.php" hash="4fd94d96a547378d2974fa386c89223f"/><file name="HpsCardinalMPIAddOrderNumberResponse.php" hash="a2f2c09eb9e7020e7af97819fe065dc3"/><file name="HpsCardinalMPIAuthenticateResponse.php" hash="6868b0bc55d8e3409684e795d1db92fc"/><file name="HpsCardinalMPIAuthorizeResponse.php" hash="566a64988246220b00da62078ae32068"/><file name="HpsCardinalMPIAuthresponseResponse.php" hash="a53fb4863feb909ccb0d2f2cc254562f"/><file name="HpsCardinalMPICaptureResponse.php" hash="29de876ce9bc632016fceab91dca22ac"/><file name="HpsCardinalMPILookupResponse.php" hash="7171aff90865b67db79559f7b2f579ba"/><file name="HpsCardinalMPIPreapprovalResponse.php" hash="e9408b385ca4f32de5f1adf96a36c42d"/><file name="HpsCardinalMPIRefundResponse.php" hash="71dbbff6f6383a19b0feb91f8771dbe5"/><file name="HpsCardinalMPIResponse.php" hash="d3729129967b1da049287e200e4d46e2"/><file name="HpsCardinalMPIVoidResponse.php" hash="2796de53634fccca806a4a4143779f81"/><file name="HpsLineItem.php" hash="4ff06a280975312365cf10a730636682"/><file name="HpsOrderData.php" hash="5d3ae0110d44f4786d4398861735a259"/><file name="HpsPaymentData.php" hash="2bd9ddc10ecdaebdbb5bf0e3cf71f642"/><file name="HpsShippingInfo.php" hash="63b621ebba4ae1711aca57073b0abec7"/></dir><dir name="Batch"><file name="HpsBatch.php" hash="d9af4664e64172cb8edaeaa1ea7c7337"/></dir><dir name="Check"><file name="HpsCheck.php" hash="8fb85bd4d608e72a9690285ec46fa6d2"/><file name="HpsCheckHolder.php" hash="58f865b34faf2790fef26066de775a15"/><file name="HpsCheckResponse.php" hash="ff3c752bc85554424e62ed7efbc053f2"/><file name="HpsCheckResponseDetails.php" hash="28928ceb2dea574603a376aed1691a90"/></dir><dir name="Credit"><file name="HpsAccountVerify.php" hash="527a69e5a39153b764e6c14e0d98bf34"/><file name="HpsAuthorization.php" hash="7ec1bbfa6efa5bc48432b5de81eda314"/><file name="HpsCPCData.php" hash="f246c4aa1eec482ba84966c563aeb970"/><file name="HpsCPCEdit.php" hash="f04b0089485ba9e7eacba8e15815ec97"/><file name="HpsCardHolder.php" hash="ffee4609a3ffa886a386a12dea3f4508"/><file name="HpsCharge.php" hash="512fb9e459b336a9e256d8f1e08e36b9"/><file name="HpsChargeExceptions.php" hash="c7df102696a205a4c5689c48878ac5f3"/><file name="HpsCreditCard.php" hash="6aa3d449b0648997c4c532c1e3603cbb"/><file name="HpsOfflineAuthorization.php" hash="6f11736d36cfde0d9d79c94e92f60c8b"/><file name="HpsRecurringBilling.php" hash="9da8f9b16179729b77615f04993b05bf"/><file name="HpsRefund.php" hash="aa4664916ebb94b8f2066fd7c17b0fd4"/><file name="HpsReportTransactionDetails.php" hash="014672dc58e5680f57f5d6cb8b0f8ee6"/><file name="HpsReportTransactionSummary.php" hash="441b01c652db42213264980e6f693b40"/><file name="HpsReversal.php" hash="350191a2d38189ef8e098ed1f922c1d3"/><file name="HpsVoid.php" hash="bf6216cea2f130789a045fc226c54cd0"/></dir><dir name="Debit"><file name="HpsDebitAddValue.php" hash="9053c701093889f864dd36af208f4f71"/><file name="HpsDebitReturn.php" hash="519cb73c6fc4ce716453d5ff94f437a0"/><file name="HpsDebitReversal.php" hash="223f6db72f0219ef25eb0f0adec4e9be"/><file name="HpsDebitSale.php" hash="74fa1e1425cfe6294146c879a4049aa8"/></dir><dir name="Fluent"><file name="HpsBuilderAction.php" hash="8649cc2c53fd961f350070193fedb5c6"/><file name="HpsUnknownPropertyException.php" hash="d019e8645fae6f984ad7b7ea3cebb546"/></dir><dir name="Gift"><file name="HpsGiftCard.php" hash="c8bad2a5336689e3192ea223a97760bf"/><file name="HpsGiftCardActivate.php" hash="097ac7c36cae11b8c40a3f1414518e49"/><file name="HpsGiftCardAddValue.php" hash="131a9d7cbc711a4e3e85c66049028f30"/><file name="HpsGiftCardAlias.php" hash="133d2d4701c5aa88fa0eece6ee69de06"/><file name="HpsGiftCardBalance.php" hash="9b9fe395d218c79c55faf28fd736b431"/><file name="HpsGiftCardDeactivate.php" hash="323ca5a67c6ff0169925192952881db5"/><file name="HpsGiftCardReplace.php" hash="f122a7d924a56fcc406bc8b1c82ac2b2"/><file name="HpsGiftCardReversal.php" hash="88ba755e52f41311206add4fa8ee5e09"/><file name="HpsGiftCardReward.php" hash="f758e8c5462d336236ae0d257789cdaf"/><file name="HpsGiftCardSale.php" hash="0f758ef6653215be643abaea4964352a"/><file name="HpsGiftCardVoid.php" hash="f0294740f5b7f545167d5fb258f4dcdd"/></dir><file name="HpsAddress.php" hash="8de2c8ea4a2b0a440d1b4bc0bf8321b8"/><file name="HpsConsumer.php" hash="1254142dfa0821cbb0bf154cf51f34d2"/><file name="HpsDirectMarketData.php" hash="1925c204d19cb9233ec8178e3b5cdc50"/><file name="HpsEncryptionData.php" hash="1e4845abc6c42e8f0265e2679b05efb6"/><file name="HpsTokenData.php" hash="18ab9125315bb8e5f9cb272966dac22b"/><file name="HpsTrackData.php" hash="4656f37b7c4c777d0c63b4102efe5a1a"/><file name="HpsTransaction.php" hash="f109d2d26ba237afb2dc17bc287f63a9"/><file name="HpsTransactionDetails.php" hash="4e77261d0aced118b49e26ef786beace"/><file name="HpsTransactionHeader.php" hash="ebd21539f84425f0e2fc57c6049a26a1"/><file name="HpsTransactionStatus.php" hash="a5a67f8fe3780f66b045cc4314660dc5"/><dir name="PayPlan"><file name="HpsPayPlanAmount.php" hash="25706476e264124567d704f981745b13"/><file name="HpsPayPlanCustomer.php" hash="2714a7525fb3830fc018544ea0622ab5"/><file name="HpsPayPlanPaymentMethod.php" hash="fd3077d63e6f31c2d8a4c60c78a678ea"/><file name="HpsPayPlanSchedule.php" hash="4c9fe8bd7db0810fd108e51b81bdf590"/></dir><file name="index.php" hash="ce407ff5715c837d02b1aba7975bf512"/><file name=".DS_Store" hash="92d42bd310aa7f6dd74d14e6cdd2b9e9"/></dir><dir name="Infrastructure"><dir name="Enums"><file name="HpsACHType.php" hash="1ff5593689a404cb0179c2b5cb5fe19e"/><file name="HpsAccountType.php" hash="760d91e120f443c326e6c7586aa61092"/><file name="HpsCardBrand.php" hash="9532bb7c40811c114a1eeeffa8b9732c"/><file name="HpsCentinelCheckoutType.php" hash="7370920cb980bbfc54c741a981cd79bb"/><file name="HpsCheckType.php" hash="d60c676d93c8ada169deb14ddc8e64e7"/><file name="HpsDataEntryMode.php" hash="c323d884a7a305f9af647ea1d9a4177e"/><file name="HpsExceptionCodes.php" hash="95322648a2093ed3982c6bb724f3507a"/><file name="HpsGiftCardAliasAction.php" hash="ebcb27c6fb800e17693ed4af2e8a8943"/><file name="HpsItemChoiceTypePosResponseVer10Transaction.php" hash="686225a07738db2233a2228bec6baabf"/><file name="HpsPayPlanAccountType.php" hash="4d383c42a990fb077fae49386c08b870"/><file name="HpsPayPlanCustomerStatus.php" hash="3ff092e8dd97f2a2474fb64103cb238f"/><file name="HpsPayPlanPaymentMethodStatus.php" hash="b020c52de7987ed3011cb97e4d440c6a"/><file name="HpsPayPlanPaymentMethodType.php" hash="1f77c5c8528815f05803c1381cb4151a"/><file name="HpsPayPlanScheduleDuration.php" hash="05101e6fe3b725b43917b59770f2dbb1"/><file name="HpsPayPlanScheduleFrequency.php" hash="0b3f029c64315ee9c8701d23319941c1"/><file name="HpsPayPlanScheduleStatus.php" hash="3579b52ccf36e576fd2dfb36118716f6"/><file name="HpsSECCode.php" hash="551661613c127c068f139083338b92d1"/><file name="HpsTaxType.php" hash="ba0e05330880810e58370f2f3490ca81"/><file name="HpsTrackDataMethod.php" hash="446069e9786f9585c3490140b29ae52f"/><file name="HpsTransactionType.php" hash="a38b3f4c654a4fa3b2c2d64b8afacf24"/></dir><file name="HpsApiConnectionException.php" hash="ac5a8064a7c2a1616035a5702f36cd50"/><file name="HpsArgumentException.php" hash="855c43e88fc24b582cfe56875d7cff42"/><file name="HpsAuthenticationException.php" hash="6feb2fdc5499b460274524aa469d9a7d"/><file name="HpsCheckException.php" hash="94870f2438217b3275d05fb943a0a8c0"/><file name="HpsConfiguration.php" hash="010996727d89c485c1d11463e5c53a8e"/><file name="HpsCreditException.php" hash="a16bf1ecd6a2c866b7b40351aab3df34"/><file name="HpsCreditExceptionDetails.php" hash="d71c54b2846283a8f97aae74a747dfd9"/><file name="HpsException.php" hash="8d2025b7fae9f0f756341b876a0dab41"/><file name="HpsGatewayException.php" hash="cdd6db6c8436e3e78ee15cdd7a043a9d"/><file name="HpsGatewayExceptionDetails.php" hash="16dd36360e2237ca89e056c61766bcdd"/><file name="HpsInvalidRequestException.php" hash="7877e48463ef3f488bb92423ae445412"/><file name="HpsProcessorError.php" hash="ff7f1f2c5327417b4997f9e36fa7c887"/><file name="HpsProcessorException.php" hash="ba28a92f0e551053506dcc391c5bc431"/><file name="HpsProcessorExceptionDetails.php" hash="6a569aacf045c19ade6472a857a3a274"/><dir name="Validation"><file name="HpsGatewayResponseValidation.php" hash="06fb818263b18b58974a569d0c986667"/><file name="HpsInputValidation.php" hash="1f51837f70c322f2a7c1cc39df752b1a"/><file name="HpsIssuerResponseValidation.php" hash="613377f8ca249df078c909e4d7674bfb"/><file name="HpsProcessorResponseValidation.php" hash="ff19a569f8bdd6ef7b58a460cf06b4e8"/></dir><file name="index.php" hash="ce407ff5715c837d02b1aba7975bf512"/></dir><dir name="Services"><dir name="Fluent"><dir name="Gateway"><dir name="Check"><file name="HpsCheckServiceOverrideBuilder.php" hash="5b4a49a897f87d2a332182a1ccd67d0c"/><file name="HpsCheckServiceRecurringBuilder.php" hash="c86a2fd5165a65c78e38e3bbb1b9636c"/><file name="HpsCheckServiceReturnBuilder.php" hash="5ce46356468714f65ad827e1593977cc"/><file name="HpsCheckServiceSaleBuilder.php" hash="b823e74642e165772f5cb03beffacce7"/><file name="HpsCheckServiceVoidBuilder.php" hash="17305b04474285a8b64007c549180ba5"/></dir><dir name="Credit"><file name="HpsCreditServiceAuthorizeBuilder.php" hash="51997a17ee9a1aaacd40d9d2c8d69c17"/><file name="HpsCreditServiceCaptureBuilder.php" hash="fd6512f3b72f9051eaf7c3daeff2cb48"/><file name="HpsCreditServiceChargeBuilder.php" hash="3421b227fe594f0cb1533b4496c805bd"/><file name="HpsCreditServiceCpcEditBuilder.php" hash="7401c33a56c5a3c6a23f5f70101a4926"/><file name="HpsCreditServiceEditBuilder.php" hash="cdcf661c4182625212ec724b52eb8491"/><file name="HpsCreditServiceGetBuilder.php" hash="05b0cafe715a4d3ceb3c88b99b0c8dc1"/><file name="HpsCreditServiceListTransactionsBuilder.php" hash="a7765dfadc8e21177cc453a1e7dfd715"/><file name="HpsCreditServiceOfflineAuthBuilder.php" hash="d86d2425c6bbf28854a31d09a9f802b8"/><file name="HpsCreditServiceOfflineChargeBuilder.php" hash="0ee9ecf6b499a16f01fa2a7b94af00ca"/><file name="HpsCreditServicePrepaidAddValueBuilder.php" hash="997b48104fcdbd791a3b990515f2527e"/><file name="HpsCreditServicePrepaidBalanceInquiryBuilder.php" hash="7e7dd067d79281c32417b6d338825acd"/><file name="HpsCreditServiceRecurringBuilder.php" hash="560c8b86eeb9e4e468642eaa739ebe03"/><file name="HpsCreditServiceRefundBuilder.php" hash="4d5ab9c2a11c18a47e416bd90dffc5e8"/><file name="HpsCreditServiceReverseBuilder.php" hash="7960e9efa00ceb0d0c5368715c07d424"/><file name="HpsCreditServiceVerifyBuilder.php" hash="62027b344ee5444ccd1534358a405857"/><file name="HpsCreditServiceVoidBuilder.php" hash="0029756571343a1d8c6380874f6f5b6b"/></dir><dir name="Debit"><file name="HpsDebitServiceAddValueBuilder.php" hash="5f972b68a5afa062cbf911bfb3a946bc"/><file name="HpsDebitServiceChargeBuilder.php" hash="26aafce2a87bbbd8231a039209c49657"/><file name="HpsDebitServiceReturnBuilder.php" hash="2e11267e12bdd338b953db352a373961"/><file name="HpsDebitServiceReverseBuilder.php" hash="b088431d3ba0726d44cc418e92267958"/></dir><dir name="GiftCard"><file name="HpsGiftCardServiceActivateBuilder.php" hash="65e3ebd1c6ded3860b238d03e542fe3b"/><file name="HpsGiftCardServiceAddValueBuilder.php" hash="432582c9fd6617c86b373f5fe0b14fb1"/><file name="HpsGiftCardServiceAliasBuilder.php" hash="1b096debfa6678af2d6ddecfa82a638e"/><file name="HpsGiftCardServiceBalanceBuilder.php" hash="6bebaac04d059204a2408d693f77c449"/><file name="HpsGiftCardServiceDeactivateBuilder.php" hash="92b16b331414c40ea11de330bd447273"/><file name="HpsGiftCardServiceReplaceBuilder.php" hash="063e6b33a673c23553047a6f72927b2a"/><file name="HpsGiftCardServiceReverseBuilder.php" hash="2f7b96b1f9608cb7e3526ecb9b15558f"/><file name="HpsGiftCardServiceRewardBuilder.php" hash="242fbe42ab731b138e4d74be4cde4e9a"/><file name="HpsGiftCardServiceSaleBuilder.php" hash="8af2977da26e3707e42569ad7bf4c4a5"/><file name="HpsGiftCardServiceVoidBuilder.php" hash="fff556a586bb09d22f521a90d30fb809"/></dir><file name="HpsFluentCheckService.php" hash="e89511e006e914bdd4daf6765a49e97b"/><file name="HpsFluentCreditService.php" hash="58e0d0480066fec8c5c6e31eaa275d12"/><file name="HpsFluentDebitService.php" hash="63e86fe32a92c80cc5bd163283da6c64"/><file name="HpsFluentGiftCardService.php" hash="53697a755fc90256b940c74282693b0d"/></dir></dir><dir name="Gateway"><dir name="AltPayment"><file name="HpsAltPaymentService.php" hash="1f1005e0e3a6689de344f71d0cac072a"/><file name="HpsMasterPassService.php" hash="fe9fd2d944d3fe4f1a7a8172018e512a"/><file name="HpsPayPalService.php" hash="c91eebb0eca8bdda2505b78c4746db28"/></dir><file name="HpsBatchService.php" hash="2a4c11a4f7c78ec1e3b461b3803826c5"/><file name="HpsCentinelGatewayService.php" hash="40300a57982ccd5325b7bd0986a8bcc4"/><file name="HpsCheckService.php" hash="17eac57a5f3a6f24e31000325ad9ac1d"/><file name="HpsCreditService.php" hash="013fea32beefc95961ba25e746f620db"/><file name="HpsDebitService.php" hash="0ea76c01b3c817fcaea876bff28681b3"/><file name="HpsGiftCardService.php" hash="e1deb113c685845e2af2bb0ff793ea4d"/><file name="HpsPayPlanService.php" hash="ce5d2c003e72be8328634d92ab8ae6eb"/><file name="HpsRestGatewayService.php" hash="3a0b4217eb4e9d8c92d298914e539a04"/><file name="HpsSoapGatewayService.php" hash="969751eb742eeb7d7a99d5d61d2d2afb"/><file name="HpsTokenService.php" hash="b1dad4289201b399f89ad1d29a799d39"/><dir name="PayPlan"><file name="HpsPayPlanCustomerService.php" hash="cda074fca2230c26919a813cc2d71b5c"/><file name="HpsPayPlanPaymentMethodService.php" hash="61dd42308d203251f4483d68561c191b"/><file name="HpsPayPlanScheduleService.php" hash="e8c81640a7440a19ed3590894a31a1f1"/></dir></dir><file name="HpsCentinelConfig.php" hash="f43f7ea211a51883fb8a2173072027a8"/><file name="HpsServicesConfig.php" hash="f3d63dc7d089a8bcd248e4abc381e6a7"/><file name="index.php" hash="ce407ff5715c837d02b1aba7975bf512"/></dir><file name="index.php" hash="ce407ff5715c837d02b1aba7975bf512"/><file name=".DS_Store" hash="fb4d06cbd65ab29860d86984919afa4a"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="securesubmit.xml" hash="cc04e952cc17ea3462931a9e7a655316"/></dir><dir name="template"><dir name="securesubmit"><file name="form.phtml" hash="67a460ca8f034f4bfe3fbb8e7845f37f"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="securesubmit.xml" hash="95de11d6d6d8333a38b8a6c8d76403d8"/></dir><dir name="template"><dir name="securesubmit"><file name="form.phtml" hash="2f204037881dbb0b5ad1d5340e972999"/><dir name="masterpass"><file name="connect.phtml" hash="b5f47624447a44958ce4fa004c58c319"/><file name="form.phtml" hash="039d6a174ac24c45ece0d14b92b6c9c4"/><file name="js.phtml" hash="274e871b2d8270e3224b9ce12794c2c5"/><file name="mark.phtml" hash="fe27b341b5fb034e90ac35c92ef998d4"/><dir name="review"><file name="details.phtml" hash="0dc5e1201e7e424f089c15fc83a1c70f"/><dir name="shipping"><file name="method.phtml" hash="cc426553636aa08840bee1c4778d89e4"/></dir></dir><file name="review.phtml" hash="cfc643de65b962ba27306587357f45d3"/></dir><dir name="paypal"><dir name="incontext"><file name="js.phtml" hash="16b4ad23ea05464a55bb0390cd72e248"/><file name="payment.phtml" hash="b32d269057984f656422609015dd7d91"/></dir><dir name="review"><file name="details.phtml" hash="0dc5e1201e7e424f089c15fc83a1c70f"/><dir name="shipping"><file name="method.phtml" hash="cc426553636aa08840bee1c4778d89e4"/></dir></dir><file name="review.phtml" hash="cfc643de65b962ba27306587357f45d3"/><file name="shortcut.phtml" hash="268bfac86e653ec5981cd201075f4105"/></dir><file name="storedcards.phtml" hash="1fa4a862757a4e10a6067616515c5915"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Hps_Securesubmit.xml" hash="d5aed3f48a45f8e611b68d1e6f34c959"/></dir></target></contents>
25
  <compatible/>
26
+ <dependencies><required><php><min>5.2.0</min><max>5.6.19</max></php></required></dependencies>
27
  </package>