dlocalgo.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. // Copyright 2022 Hackware SpA <human@hackware.cl>
  3. // This file is part of "Hackware Web Services Payment" and licensed under
  4. // the terms of the GNU Affero General Public License version 3, or (at your
  5. // option) a later version. You should have received a copy of this license
  6. // along with the software. If not, see <https://www.gnu.org/licenses/>.
  7. $countries = explode(' ', env('DLOCALGO_COUNTRIES'));
  8. $country_props = [
  9. [
  10. 'const' => 'AR',
  11. 'title' => 'Argentina',
  12. 'description' =>
  13. 'Efectivo, transferencia bancaria y tarjetas' .
  14. ' en Argentina',
  15. 'image' => env('APP_URL') . '/img/flags/ar.svg',
  16. ],
  17. [
  18. 'const' => 'BO',
  19. 'title' => 'Bolivia',
  20. 'description' => 'Transferencia bancaria en' .
  21. ' Bolivia',
  22. 'image' => env('APP_URL') . '/img/flags/bo.svg',
  23. ],
  24. [
  25. 'const' => 'BR',
  26. 'title' => 'Brasil',
  27. 'description' =>
  28. 'Efectivo, transferencia bancaria y tarjetas' .
  29. ' en Brasil',
  30. 'image' => env('APP_URL') . '/img/flags/br.svg',
  31. ],
  32. [
  33. 'const' => 'CL',
  34. 'title' => 'Chile',
  35. 'description' =>
  36. 'Efectivo, transferencia bancaria y tarjetas' .
  37. ' en Chile',
  38. 'image' => env('APP_URL') . '/img/flags/cl.svg',
  39. ],
  40. [
  41. 'const' => 'CO',
  42. 'title' => 'Colombia',
  43. 'description' =>
  44. 'Efectivo, transferencia bancaria y tarjetas' .
  45. ' en Colombia',
  46. 'image' => env('APP_URL') . '/img/flags/co.svg',
  47. ],
  48. [
  49. 'const' => 'EC',
  50. 'title' => 'Ecuador',
  51. 'description' => 'Efectivo y tarjetas en Ecuador',
  52. 'image' => env('APP_URL') . '/img/flags/ec.svg',
  53. ],
  54. [
  55. 'const' => 'MX',
  56. 'title' => 'México',
  57. 'description' =>
  58. 'Efectivo, transferencia bancaria y tarjetas' .
  59. ' en México',
  60. 'image' => env('APP_URL') . '/img/flags/mx.svg',
  61. ],
  62. [
  63. 'const' => 'PA',
  64. 'title' => 'Panamá',
  65. 'description' => 'Tarjetas en Panamá',
  66. 'image' => env('APP_URL') . '/img/flags/pa.svg',
  67. ],
  68. [
  69. 'const' => 'PE',
  70. 'title' => 'Perú',
  71. 'description' =>
  72. 'Efectivo, transferencia bancaria y tarjetas' .
  73. ' en Perú',
  74. 'image' => env('APP_URL') . '/img/flags/pe.svg',
  75. ],
  76. [
  77. 'const' => 'PY',
  78. 'title' => 'Paraguay',
  79. 'description' => 'Efectivo y tarjetas en Paraguay',
  80. 'image' => env('APP_URL') . '/img/flags/py.svg',
  81. ],
  82. [
  83. 'const' => 'UY',
  84. 'title' => 'Uruguay',
  85. 'description' => 'Efectivo y tarjetas en Uruguay',
  86. 'image' => env('APP_URL') . '/img/flags/uy.svg',
  87. ]
  88. ];
  89. return [
  90. 'class' => '\Hawese\Payment\Gateways\DLocalGoGateway',
  91. 'countries' => $countries,
  92. 'test_mode' => env('DLOCALGO_TEST_MODE', false),
  93. 'credentials' => [
  94. 'apiKey' => env('DLOCALGO_API_KEY'),
  95. 'secretKey' => env('DLOCALGO_SECRET_KEY'),
  96. ],
  97. 'payment_methods' => [
  98. 'purchase' => 'country',
  99. ],
  100. 'schemas' => [
  101. 'purchase' => [
  102. 'required' => [
  103. 'currency',
  104. 'amount',
  105. ],
  106. 'standard_map' => [
  107. 'subject' => 'description',
  108. 'email' => ['payer' => 'email'],
  109. 'due_amount' => 'amount',
  110. 'payment_method' => 'country',
  111. 'currency' => 'currency'
  112. ],
  113. 'properties' => [
  114. 'description' => [
  115. 'title' => 'Descripción',
  116. 'type' => 'string',
  117. ],
  118. 'currency' => [
  119. 'title' => 'Moneda',
  120. 'type' => 'string',
  121. 'enum' => ['USD'],
  122. 'default' => 'USD',
  123. 'readOnly' => true,
  124. ],
  125. 'amount' => [
  126. 'title' => 'Monto',
  127. 'type' => 'number',
  128. 'multipleOf' => 0.01,
  129. ],
  130. 'payer' => [
  131. 'title' => 'Pagador',
  132. 'type' => 'object',
  133. 'properties' => [
  134. /*
  135. 'id' => [
  136. 'title' => 'id',
  137. 'type' => 'string',
  138. ],
  139. 'name' => [
  140. 'title' => 'Nombre',
  141. 'type' => 'string',
  142. ],
  143. */
  144. 'email' => [
  145. 'title' => 'Email',
  146. 'type' => 'string',
  147. 'format' => 'idn-email',
  148. ],
  149. /*
  150. 'phone' => [
  151. 'title' => 'Teléfono',
  152. 'type' => 'string',
  153. ],
  154. 'document_type' => [
  155. 'title' => 'Tipo de documento',
  156. 'type' => 'string',
  157. ],
  158. 'document' => [
  159. 'title' => 'Documento',
  160. 'type' => 'string',
  161. ],
  162. 'user_reference' => [
  163. 'title' => 'Referencia de usuario',
  164. 'type' => 'string',
  165. ],
  166. */
  167. ],
  168. ],
  169. 'country' => [
  170. 'title' => 'País',
  171. 'type' => 'string',
  172. 'oneOf' => array_filter(
  173. $country_props,
  174. function($prop) use ($countries) {
  175. return in_array($prop['const'], $countries);
  176. }
  177. ),
  178. ],
  179. ],
  180. ],
  181. ],
  182. ];