tipo: modificación del cpanel y gitignore de la carpeta vendor
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
nbproject/
|
||||
.idea
|
||||
*.iml
|
||||
vendor
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>OpenpayPHP</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.dltk.core.scriptbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.php.core.PHPNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
Vendored
+202
@@ -0,0 +1,202 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Vendored
+625
@@ -0,0 +1,625 @@
|
||||
-----------------------------------------------------------------------------
|
||||
Openpay API v1 Client for PHP (version 1.2.0)
|
||||
-----------------------------------------------------------------------------
|
||||
El objetivo de este proyecto es proporcionar un framework reutilizable para
|
||||
interacturar con el API de Openpay desde cualquier proyecto PHP.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Autor: Openpay SAPI de C.V. (soporte@openpay.mx)
|
||||
http://www.openpay.mx/
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
-- REQUERIMIENTOS --
|
||||
PHP 5.2 o posterior
|
||||
Extension de PHP cURL
|
||||
Extension de PHP JSON
|
||||
Extension de PHP Multibyte String
|
||||
|
||||
|
||||
-- INSTALACION --
|
||||
|
||||
Para poder utilizar la librería cliente de Openpay para PHP será necesario:
|
||||
1. Descomprimir el archivo Openpay.v1.zip dentro de un directorio del
|
||||
proyecto PHP en el cual se utilizará,
|
||||
|
||||
2. Incluir dentro de la(s) página(s) que hará(n) uso del cliente:
|
||||
|
||||
require(dirname(__FILE__) . '/Openpay.php');
|
||||
|
||||
|
||||
NOTA: En el ejemplo anterior, la librería está dentro del mismo directorio
|
||||
del script que se está ejecutando, en caso de que éste no sea el caso se
|
||||
deberá hacer los ajustes pertinentes en la ruta de la librería.
|
||||
|
||||
|
||||
-- IMPLEMENTACION --
|
||||
|
||||
Configuración
|
||||
|
||||
Antes de utilizar la librería será necesario configurar el ID de comercio
|
||||
(Merchant ID) y la llave privada que corresponda (API Key). Hay varias
|
||||
opciones:
|
||||
|
||||
1. Utilizar los métodos Openpay::setId() y Openpay::setApiKey(). Para
|
||||
utilizar este método solamente hay que pasar el dato correspondiente
|
||||
a ambos métodos:
|
||||
|
||||
Openpay::setId('moiep6umtcnanql3jrxp');
|
||||
Openpay::setApiKey('sk_3433941e467c4875b178ce26348b0fac');
|
||||
|
||||
2. Pasar ambos datos como parámetros al método Openpay::getInstance().
|
||||
Este método es muy similar al anterior, solamente que ambos parámetros se
|
||||
pasan simultáneamente al generador de la instancia. El orden de los
|
||||
métodos es Merchant ID y API Key, respectivamente
|
||||
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp',
|
||||
'sk_3433941e467c4875b178ce26348b0fac');
|
||||
|
||||
3. Configurar ambos datos como variables de ambiente. Este método permite la
|
||||
configuración de ambos datos pero a nivel de ambiente, lo cual tiene sus
|
||||
ventajas ya que no están expuestos directamente en un archivo (para mayor
|
||||
referencia leer la documentación de PHP). Esta opción no requiere de
|
||||
ninguna configuración a nivel script.
|
||||
|
||||
|
||||
Modo Sandbox
|
||||
|
||||
Cuando se está realizando la implementacion es posible que se desee hacer
|
||||
pruebas antes de que se hagan cobros normales a una tarjeta de crédito, para
|
||||
ello es posible utilizar el método OpenPay::setSandboxMode() el cual nos
|
||||
ayudará a activar o desactivar el modo de prueba en las peticiones que se hagan
|
||||
a OpenPay.
|
||||
|
||||
Openpay::setSandboxMode(FLAG);
|
||||
|
||||
Si es necesario, se puede utilizar el método Openpay::getSandboxMode() para
|
||||
determinar, en cualquier momento, cual es el estatus del modo sandbox:
|
||||
|
||||
Openpay::getSandboxMode(); // TRUE/FALSE, dependiendo si el modo está
|
||||
// activado o no.
|
||||
|
||||
|
||||
Generalidades librería PHP
|
||||
|
||||
Una vez configurado el cliente, para realizar operaciones con la librería será
|
||||
necesario obtener una instancia de la misma, esto se hace con el método
|
||||
Openpay::getInstance()
|
||||
|
||||
$openpay = Openpay::getInstance();
|
||||
|
||||
$openpay se tratará entonces, de la instancia del merchant desde la que se
|
||||
podrán llamar todos los recursos disponibles en la API de Openpay:
|
||||
|
||||
1. customers
|
||||
2. cards
|
||||
3. charges
|
||||
4. payouts
|
||||
5. fees
|
||||
6. plans
|
||||
|
||||
Todos los recursos se acceden como variables públicas, de tal manera, que si
|
||||
se desea agregar un nuevo cliente se podrá hacer de la siguiente manera:
|
||||
|
||||
$openpay->customers->add(PARAMETROS);
|
||||
|
||||
Hay que notar que las operaciones de todos y cada uno de los recursos,
|
||||
devolverán una instancia de dicho recurso, lo que en el ejemplo anterior querrá
|
||||
decir que la llamada a la operación add() en el recurso Customer devolverá una
|
||||
instancia del mismo recurso Customer, y así sucesivamente. La única excepción a
|
||||
este caso es cuando se obtiene un listado de recursos, en cuyo caso el dato
|
||||
devuelvo será un arreglo de recursos:
|
||||
|
||||
$customer = $openpay->customers->add(PARAMETROS);
|
||||
// devuelve UNA SOLA instancia del recurso Charge
|
||||
$charge = $customer->charges->create(PARAMETROS);
|
||||
|
||||
|
||||
$customer = $openpay->customers->add(PARAMETROS);
|
||||
// devuelve UN ARREGLO de instancias del recurso Charge
|
||||
$chargeList = $customer->charges->getList(PARAMETROS);
|
||||
|
||||
Los recursos derivados de Customer son:
|
||||
|
||||
1. cards
|
||||
2. bankaccounts
|
||||
3. charges
|
||||
4. transfers
|
||||
5. payouts
|
||||
6. suscriptions
|
||||
|
||||
Todos los parámetros deben ser arreglos asociativos de la forma:
|
||||
|
||||
'NOMBRE_PARAMETRO' => VALOR
|
||||
|
||||
Para mayor referencias respecto a los parámetros, datos obligatorios y valores
|
||||
ceptados, consultar la documentación del API Openpay.
|
||||
|
||||
|
||||
Manejo de errores
|
||||
|
||||
El API de Openpay genera distintos tipos de errores de acuerdo al problema que
|
||||
se haya detectado, por eso, a fin de que el manejo de los errores generados por
|
||||
la librería sea mejor y más administrable y eficiente, la librería PHP ha
|
||||
implementado excepciones para las diferentes situaciones:
|
||||
|
||||
1. OpenpayApiTransactionError. Esta categoría engloba todas aquellas
|
||||
situaciones en las que una transacción no se haya completado exitosamente,
|
||||
por ejemplo: tarjeta declinada, tarjeta con fondos insuficientes, cuenta
|
||||
destino desactivada, etc.
|
||||
2. OpenpayApiRequestError. Se refiere a los errores generados cuando se hace
|
||||
una petición al API. Ejemplos: formateo incorrecto en laos datos de la
|
||||
petición, valores incorrectos en los parámetros de la petición, errores
|
||||
internos en el servidor Openpay, etc.
|
||||
3. OpenpayApiConnectionError. Este tipo de errores son generados cuando la
|
||||
librería intenta contectarse al API, por ejemplo: timeouts, errores de
|
||||
servidores de dominio, etc.
|
||||
4. OpenpayApiAuthError. Se trata de errores de autenticación generados al
|
||||
momento de contarse al servidor Openpay, o bien, configuración incorrecta
|
||||
de las credenciales de autenticación (Merchant ID y Api Key).
|
||||
5. OpenpayApiError. Errores genéricos cuando se procesa una petición. Esta es
|
||||
la categoría de errores más general.
|
||||
|
||||
Todos los errores ponen disponibles el acceso a la información del error que
|
||||
regrese el API:
|
||||
|
||||
1. getDescription(): descripción del error generado por Openpay.
|
||||
2. getErrorCode(): código de error generado por Openpay. Cuando hay errores de
|
||||
3. petición o antes de generarla, este valor es igual a cero.
|
||||
4. getCategory(): categoría de error generada por Openpay. Cuando hay errores
|
||||
de petición o antes de generarla, este valor es igual a cadena vacía.
|
||||
5. getHttpCode(): código del error HTTP generado en la petición al API. Cuando
|
||||
hay errores de petición o antes de generarla, este valor es igual a cero.
|
||||
6. getRequestId(): código generado cuando se generó el error en el API. Cuando
|
||||
hay errores de petición o antes de generarla, este valor es igual a cadena
|
||||
vacía.
|
||||
|
||||
La implementación de errores se puede ejemplificar de la siguiente manera:
|
||||
|
||||
try {
|
||||
Openpay::setId('moiep6umtcnanql3jrxp');
|
||||
Openpay::setApiKey('sk_'); // esta línea generará un error debido a que el
|
||||
// formato de la llave privada es incorrecto
|
||||
Openpay::setSandboxMode(true);
|
||||
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$customer->name = 'Juan';
|
||||
$customer->last_name = 'Godinez';
|
||||
$customer->save();
|
||||
} catch (OpenpayApiTransactionError $e) {
|
||||
error('ERROR en la transacción: ' . $e->getMessage() .
|
||||
' [código de error: ' . $e->getErrorCode() .
|
||||
', categoría de error: ' . $e->getCategory() .
|
||||
', código HTTP: '. $e->getHttpCode() .
|
||||
', id petición: ' . $e->getRequestId() . ']');
|
||||
|
||||
} catch (OpenpayApiRequestError $e) {
|
||||
error('ERROR en la petición: ' . $e->getMessage());
|
||||
|
||||
} catch (OpenpayApiConnectionError $e) {
|
||||
error('ERROR en la conexión al API: ' . $e->getMessage());
|
||||
|
||||
} catch (OpenpayApiAuthError $e) {
|
||||
error('ERROR en la autenticación: ' . $e->getMessage());
|
||||
|
||||
} catch (OpenpayApiError $e) {
|
||||
error('ERROR en el API: ' . $e->getMessage());
|
||||
|
||||
} catch (Exception $e) {
|
||||
error('Error en el script: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
EJEMPLOS:
|
||||
|
||||
|
||||
Clientes
|
||||
|
||||
Agregar Cliente:
|
||||
$customerData = array(
|
||||
'name' => 'Teofilo',
|
||||
'last_name' => 'Velazco',
|
||||
'email' => 'teofilo@payments.com',
|
||||
'phone_number' => '4421112233',
|
||||
'address' => array(
|
||||
'line1' => 'Av. 5 de Febrero No. 1',
|
||||
'line2' => 'Col. Felipe Carrillo Puerto',
|
||||
'line3' => 'Zona industrial Carrillo Puerto',
|
||||
'postal_code' => '76920',
|
||||
'state' => 'Querétaro',
|
||||
'city' => 'Querétaro',
|
||||
'country_code' => 'MX'));
|
||||
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->add($customerData);
|
||||
|
||||
Obtener Cliente:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
|
||||
Obtener listado de Clientes:
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
$openpay = Openpay::getInstance();
|
||||
$customerList = $openpay->customers->getList($findData);
|
||||
|
||||
Actualización de datos del Cliente:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$customer->name = 'Juan';
|
||||
$customer->last_name = 'Godinez';
|
||||
$customer->save();
|
||||
|
||||
Eliminar Cliente:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$customer->delete();
|
||||
|
||||
|
||||
Tarjetas:
|
||||
|
||||
Agregar tarjeta a Cliente:
|
||||
$customerData = array(
|
||||
'name' => 'Teofilo',
|
||||
'last_name' => 'Velazco Pérez',
|
||||
'email' => 'teofilo@payments.com',
|
||||
'phone_number' => '4421112233',
|
||||
'address' => array(
|
||||
'line1' => 'Av. 5 de Febrero No. 1',
|
||||
'line2' => 'Col. Felipe Carrillo Puerto',
|
||||
'line3' => 'Zona industrial Carrillo Puerto',
|
||||
'postal_code' => '76920',
|
||||
'state' => 'Querétaro',
|
||||
'city' => 'Querétaro',
|
||||
'country_code' => 'MX'));
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$card = $customer->cards->add($cardData);
|
||||
|
||||
Obtener tarjeta de Cliente:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$card = $customer->cards->get('k9pn8qtsvr7k7gxoq1r5');
|
||||
|
||||
Obtener listado de tarjetas de Cliente:
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$cardList = $customer->cards->getList($findData);
|
||||
|
||||
Eliminar tarjeta de Cliente:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$card = $customer->cards->get('k9pn8qtsvr7k7gxoq1r5');
|
||||
$card->delete();
|
||||
|
||||
|
||||
Agregar tarjeta a Merchant:
|
||||
$openpay = Openpay::getInstance();
|
||||
$card = $openpay->cards->add($cardData);
|
||||
|
||||
Obtener tarjeta de Merchant:
|
||||
$openpay = Openpay::getInstance();
|
||||
$card = $openpay->cards->get('k9pn8qtsvr7k7gxoq1r5');
|
||||
|
||||
Obtener listado de tarjetas de Merchant:
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
$openpay = Openpay::getInstance();
|
||||
$cardList = $openpay->cards->getList($findData);
|
||||
|
||||
Eliminar tarjeta de Merchant:
|
||||
$openpay = Openpay::getInstance();
|
||||
$card = $openpay->cards->get('k9pn8qtsvr7k7gxoq1r5');
|
||||
$card->delete();
|
||||
|
||||
|
||||
Cuentas de Banco:
|
||||
|
||||
Agregar cuenta de banco a Cliente:
|
||||
$bankData = array(
|
||||
'clabe' => '072910007380090615',
|
||||
'alias' => 'Cuenta principal',
|
||||
'holder_name' => 'Teofilo Velazco');
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$bankaccount = $customer->bankaccounts->add($bankData);
|
||||
|
||||
Obtener cuenta de banco de Cliente:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$bankaccount = $customer->bankaccounts->get('b4vcouaavwuvkpufh0so');
|
||||
|
||||
Obtener listado de cuentas de banco de Cliente:
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$bankaccount = $customer->bankaccounts->getList($findData);
|
||||
|
||||
Eliminar cuenta de banco de Cliente:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$bankaccount = $customer->bankaccounts->get('b4vcouaavwuvkpufh0so');
|
||||
$bankaccount->delete();
|
||||
|
||||
|
||||
Cargos:
|
||||
|
||||
Hacer cargo a Cliente:
|
||||
$chargeData = array(
|
||||
'source_id' => 'tvyfwyfooqsmfnaprsuk',
|
||||
'method' => 'card',
|
||||
'amount' => 100,
|
||||
'description' => 'Cargo inicial a mi cuenta',
|
||||
'order_id' => 'ORDEN-00070');
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$charge = $customer->charges->create($chargeData);
|
||||
|
||||
|
||||
Obtener cargo de Cliente:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$charge = $customer->charges->get('tvyfwyfooqsmfnaprsuk');
|
||||
|
||||
Obtener listado de cargos de Cliente:
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$charge = $customer->charges->getList($findData);
|
||||
|
||||
Hacer devolucion de cargo a Cliente:
|
||||
$refundData = array(
|
||||
'description' => 'Reembolso' );
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$charge = $customer->charges->get('tvyfwyfooqsmfnaprsuk');
|
||||
$charge->refund($refundData);
|
||||
|
||||
Hacer cargo a Merchant:
|
||||
$chargeData = array(
|
||||
'method' => 'card',
|
||||
'source_id' => 'krfkkmbvdk3hewatruem',
|
||||
'amount' => 100,
|
||||
'description' => 'Cargo inicial a mi merchant',
|
||||
'order_id' => 'ORDEN-00071');
|
||||
$openpay = Openpay::getInstance();
|
||||
$charge = $openpay->charges->create($chargeData);
|
||||
debug($charge);
|
||||
|
||||
Obtener cargo de Merchant:
|
||||
$openpay = Openpay::getInstance();
|
||||
$charge = $openpay->charges->get('tvyfwyfooqsmfnaprsuk');
|
||||
|
||||
Obtener listado de cargos de Merchant:
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
$openpay = Openpay::getInstance();
|
||||
$charge = $openpay->charges->getList($findData);
|
||||
|
||||
Hacer devolución de cargo a Merchant:
|
||||
$refundData = array(
|
||||
'description' => 'Devolución' );
|
||||
$openpay = Openpay::getInstance();
|
||||
$charge = $openpay->charges->get('tvyfwyfooqsmfnaprsuk');
|
||||
$charge->refund($refundData);
|
||||
|
||||
|
||||
|
||||
Transferencias:
|
||||
|
||||
Hacer transferencia a Cliente:
|
||||
$transferData = array(
|
||||
'customer_id' => 'aqedin0owpu0kexr2eor',
|
||||
'amount' => 12.50,
|
||||
'description' => 'Cobro de Comisión',
|
||||
'order_id' => 'ORDEN-00061');
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$transfer = $customer->transfers->create($transferData);
|
||||
|
||||
Obtener transferencia de Cliente:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$transfer = $customer->transfers->get('tyxesptjtx1bodfdjmlb');
|
||||
|
||||
Obtener listado de transferencias a Cliente:
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$transfer = $customer->transfers->getList($findData);
|
||||
|
||||
|
||||
|
||||
Pagos:
|
||||
|
||||
Hacer pago a Cliente:
|
||||
$payoutData = array(
|
||||
'method' => 'card',
|
||||
'destination_id' => 'k9pn8qtsvr7k7gxoq1r5',
|
||||
'amount' => 1000,
|
||||
'description' => 'Retiro de saldo semanal',
|
||||
'order_id' => 'ORDEN-00062');
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$payout = $customer->payouts->create($payoutData);
|
||||
|
||||
Obtener pago a Cliente:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$payout = $customer->payouts->get('tysznlyigrkwnks6eq2c');
|
||||
|
||||
Obtener listado de pagos a Cliente:
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$payout = $customer->payouts->getList($findData);
|
||||
|
||||
Hacer pago a Merchant:
|
||||
$payoutData = array(
|
||||
'method' => 'card',
|
||||
'destination_id' => 'krfkkmbvdk3hewatruem',
|
||||
'amount' => 500,
|
||||
'description' => 'Retiro de saldo semanal',
|
||||
'order_id' => 'ORDEN-00072');
|
||||
$openpay = Openpay::getInstance();
|
||||
$payout = $openpay->payouts->create($payoutData);
|
||||
|
||||
Obtener pago a Merchant:
|
||||
$openpay = Openpay::getInstance();
|
||||
$payout = $openpay->payouts->get('t4tzkjspndtj9bnsop2i');
|
||||
|
||||
Obtener listado de pagos a Merchant:
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
$openpay = Openpay::getInstance();
|
||||
$payout = $openpay->payouts->getList($findData);
|
||||
|
||||
|
||||
|
||||
Comisiones:
|
||||
|
||||
Hacer cobro de comisión a Cliente
|
||||
$feeData = array(
|
||||
'customer_id' => 'a9ualumwnrcxkl42l6mh',
|
||||
'amount' => 12.50,
|
||||
'description' => 'Cobro de Comisión',
|
||||
'order_id' => 'ORDEN-00063');
|
||||
$openpay = Openpay::getInstance();
|
||||
$fee = $openpay->fees->create($feeData);
|
||||
|
||||
Obtener listadeo de comisiones de Cliente:
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
$openpay = Openpay::getInstance();
|
||||
$fee = $openpay->fees->getList($findData);
|
||||
|
||||
|
||||
|
||||
Planes:
|
||||
|
||||
Agregar plan:
|
||||
$planData = array(
|
||||
'amount' => 150.00,
|
||||
'status_after_retry' => 'cancelled',
|
||||
'retry_times' => 2,
|
||||
'name' => 'Plan Curso Verano',
|
||||
'repeat_unit' => 'month',
|
||||
'trial_days' => '30',
|
||||
'repeat_every' => '1',
|
||||
'currency' => 'MXN');
|
||||
$openpay = Openpay::getInstance();
|
||||
$plan = $openpay->plans->add($planData);
|
||||
|
||||
Obtener plan:
|
||||
$openpay = Openpay::getInstance();
|
||||
$plan = $openpay->plans->get('pduar9iitv4enjftuwyl');
|
||||
|
||||
Obtener listado de planes:
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
$openpay = Openpay::getInstance();
|
||||
$plan = $openpay->plans->getList($findData);
|
||||
debug($plan);
|
||||
|
||||
Actualizar plan:
|
||||
$openpay = Openpay::getInstance();
|
||||
$plan = $openpay->plans->get('pduar9iitv4enjftuwyl');
|
||||
$plan->name = 'Plan Curso de Verano 2014';
|
||||
$plan->save();
|
||||
|
||||
Eliminar plan:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$plan = $openpay->plans->get('pduar9iitv4enjftuwyl');
|
||||
$plan->delete();
|
||||
|
||||
Obtener listado de suscriptores al plan:
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
$openpay = Openpay::getInstance();
|
||||
$plan = $openpay->plans->get($planId);
|
||||
$subscription = $plan->subscriptions->getList($findData);
|
||||
|
||||
|
||||
|
||||
Suscripciones:
|
||||
|
||||
Agregar suscripcion de Cliente:
|
||||
$subscriptionData = array(
|
||||
'trial_days' => '90',
|
||||
'plan_id' => 'pduar9iitv4enjftuwyl',
|
||||
'card_id' => 'konvkvcd5ih8ta65umie');
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$subscription = $customer->subscriptions->add($subscriptionData);
|
||||
|
||||
Obtener suscripción de Cliente:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$subscription = $customer->subscriptions->get('s7ri24srbldoqqlfo4vp');
|
||||
|
||||
Obtener listado de suscripciones de Cliente:
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$subscription = $customer->subscriptions->getList($findData);
|
||||
|
||||
Actualizar suscripción de Cliente:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$subscription = $customer->subscriptions->get('s7ri24srbldoqqlfo4vp');
|
||||
$subscription->trial_end_date = '2014-12-31';
|
||||
$subscription->save();
|
||||
|
||||
Eliminar suscripción de Cliente:
|
||||
$openpay = Openpay::getInstance();
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$subscription = $customer->subscriptions->get('s7ri24srbldoqqlfo4vp');
|
||||
$subscription->delete();
|
||||
|
||||
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Openpay API v1 Client for PHP (version 2.1.0)
|
||||
*
|
||||
* Copyright © Openpay SAPI de C.V. All rights reserved.
|
||||
* http://www.openpay.mx/
|
||||
* soporte@openpay.mx
|
||||
*/
|
||||
|
||||
if (!function_exists('curl_init')) {
|
||||
throw new Exception('CURL PHP extension is required to run Openpay client.');
|
||||
}
|
||||
if (!function_exists('json_decode')) {
|
||||
throw new Exception('JSON PHP extension is required to run Openpay client.');
|
||||
}
|
||||
if (!function_exists('mb_detect_encoding')) {
|
||||
throw new Exception('Multibyte String PHP extension is required to run Openpay client.');
|
||||
}
|
||||
|
||||
require(dirname(__FILE__) . '/Openpay/Data/Openpay.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApi.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiAuthError.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiConnectionError.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiConnector.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiConsole.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiDerivedResource.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiError.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiRequestError.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiResourceBase.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiTransactionError.php');
|
||||
|
||||
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayBankAccount.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayBankAccountList.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayBine.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayCapture.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayCard.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayCardList.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayCharge.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayChargeList.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayCustomer.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayCustomerList.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayFee.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayFeeList.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayPayout.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayPayoutList.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayPlan.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayPlanList.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayPse.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayPseList.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayRefund.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpaySubscription.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpaySubscriptionList.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayToken.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayTransfer.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayTransferList.php');
|
||||
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayWebhook.php');
|
||||
?>
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Data;
|
||||
|
||||
class Openpay
|
||||
{
|
||||
|
||||
private static $instance = null;
|
||||
private static $id;
|
||||
private static $apiKey;
|
||||
private static $userAgent = '';
|
||||
private static $country;
|
||||
private static $apiEndpoint = '';
|
||||
private static $apiSandboxEndpoint = '';
|
||||
private static $sandboxMode = true;
|
||||
private static $classification = '';
|
||||
private static $publicIp;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function getInstance($id, $apiKey, $country, $publicIp)
|
||||
{
|
||||
if ($id != '') {
|
||||
self::setId($id);
|
||||
}
|
||||
if ($apiKey != '') {
|
||||
self::setApiKey($apiKey);
|
||||
}
|
||||
if ($country != '') {
|
||||
self::setCountry($country);
|
||||
self::setEndpointUrl($country);
|
||||
}
|
||||
if(!is_null($publicIp)){
|
||||
self::setPublicIp($publicIp);
|
||||
}
|
||||
$instance = OpenpayApi::getInstance(null);
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public static function setUserAgent($userAgent)
|
||||
{
|
||||
if ($userAgent != '') {
|
||||
self::$userAgent = $userAgent;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getUserAgent()
|
||||
{
|
||||
$userAgent = self::$userAgent;
|
||||
return $userAgent;
|
||||
}
|
||||
|
||||
public static function setClassificationMerchant($classification)
|
||||
{
|
||||
if ($classification != '') {
|
||||
self::$classification = $classification;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getClassificationMerchant()
|
||||
{
|
||||
$classification = self::$classification;
|
||||
return $classification;
|
||||
}
|
||||
|
||||
public static function setApiKey($key = '')
|
||||
{
|
||||
if ($key != '') {
|
||||
self::$apiKey = $key;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getApiKey()
|
||||
{
|
||||
$key = self::$apiKey;
|
||||
if (!$key) {
|
||||
$key = getenv('OPENPAY_API_KEY');
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
public static function setId($id = '')
|
||||
{
|
||||
if ($id != '') {
|
||||
self::$id = $id;
|
||||
}
|
||||
}
|
||||
|
||||
public static function setCountry($country = '')
|
||||
{
|
||||
if ($country != '') {
|
||||
self::$country = $country;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getCountry()
|
||||
{
|
||||
$country = self::$country;
|
||||
return $country;
|
||||
}
|
||||
|
||||
public static function getId()
|
||||
{
|
||||
$id = self::$id;
|
||||
if (!$id) {
|
||||
$id = getenv('OPENPAY_MERCHANT_ID');
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
public static function setPublicIp($publicIp = null)
|
||||
{
|
||||
if (!is_null($publicIp)) {
|
||||
self::$publicIp = $publicIp;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getPublicIp() {
|
||||
return self::$publicIp;
|
||||
|
||||
}
|
||||
|
||||
public static function getSandboxMode()
|
||||
{
|
||||
$sandbox = self::$sandboxMode;
|
||||
if (getenv('OPENPAY_PRODUCTION_MODE')) {
|
||||
$sandbox = (strtoupper(getenv('OPENPAY_PRODUCTION_MODE')) == 'FALSE');
|
||||
}
|
||||
return $sandbox;
|
||||
}
|
||||
|
||||
public static function setSandboxMode($mode)
|
||||
{
|
||||
self::$sandboxMode = $mode ? true : false;
|
||||
}
|
||||
|
||||
public static function getProductionMode()
|
||||
{
|
||||
$sandbox = self::$sandboxMode;
|
||||
if (getenv('OPENPAY_PRODUCTION_MODE')) {
|
||||
$sandbox = (strtoupper(getenv('OPENPAY_PRODUCTION_MODE')) == 'FALSE');
|
||||
}
|
||||
return !$sandbox;
|
||||
}
|
||||
|
||||
public static function setProductionMode($mode)
|
||||
{
|
||||
self::$sandboxMode = $mode ? false : true;
|
||||
}
|
||||
|
||||
public static function setEndpointUrl($country)
|
||||
{
|
||||
if ($country == 'MX') {
|
||||
if (self::getClassificationMerchant() != 'eglobal') {
|
||||
self::$apiEndpoint = 'https://api.openpay.mx/v1';
|
||||
self::$apiSandboxEndpoint = 'https://sandbox-api.openpay.mx/v1';
|
||||
} else {
|
||||
self::$apiEndpoint = 'https://api.ecommercebbva.com/v1';
|
||||
self::$apiSandboxEndpoint = 'https://sand-api.ecommercebbva.com/v1';
|
||||
}
|
||||
} elseif ($country == 'CO') {
|
||||
self::$apiEndpoint = 'https://api.openpay.co/v1';
|
||||
self::$apiSandboxEndpoint = 'https://sandbox-api.openpay.co/v1';
|
||||
} elseif ($country == 'PE') {
|
||||
self::$apiEndpoint = 'https://api.openpay.pe/v1';
|
||||
self::$apiSandboxEndpoint = 'https://sandbox-api.openpay.pe/v1';
|
||||
}
|
||||
}
|
||||
|
||||
public static function getEndpointUrl()
|
||||
{
|
||||
return (self::getSandboxMode() ? self::$apiSandboxEndpoint : self::$apiEndpoint);
|
||||
}
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Data;
|
||||
|
||||
class OpenpayApi extends OpenpayApiResourceBase
|
||||
{
|
||||
|
||||
protected $derivedResources = array(
|
||||
'Bine' => array(),
|
||||
'Customer' => array(),
|
||||
'Card' => array(),
|
||||
'Charge' => array(),
|
||||
'Pse' => array(),
|
||||
'Payout' => array(),
|
||||
'Fee' => array(),
|
||||
'Plan' => array(),
|
||||
'Webhook' => array(),
|
||||
'Token' => array());
|
||||
|
||||
public static function getInstance($r, $p = null)
|
||||
{
|
||||
if(version_compare(phpversion(), '8.3.0', '<')){
|
||||
$resourceName = get_class();
|
||||
} else {
|
||||
$resourceName = self::class;
|
||||
}
|
||||
return parent::getInstance($resourceName);
|
||||
}
|
||||
|
||||
public function getMerchantInfo()
|
||||
{
|
||||
return parent::getMerchantInfo();
|
||||
}
|
||||
|
||||
protected function getResourceUrlName($p = true)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getFullURL()
|
||||
{
|
||||
return $this->getUrl();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Data;
|
||||
|
||||
class OpenpayApiAuthError extends OpenpayApiError
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Data;
|
||||
|
||||
class OpenpayApiConnectionError extends OpenpayApiError
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Data;
|
||||
|
||||
use Openpay\Data\Openpay as Openpay;
|
||||
|
||||
class OpenpayApiConnector
|
||||
{
|
||||
|
||||
private static $instance;
|
||||
private $apiKey;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
$this->apiKey = '';
|
||||
}
|
||||
|
||||
private static function getInstance()
|
||||
{
|
||||
if (!self::$instance) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// ------------------ PRIVATE FUNCTIONS ------------------
|
||||
|
||||
private function _request($method, $url, $params)
|
||||
{
|
||||
if (!class_exists('Openpay\\Data\\Openpay')) {
|
||||
throw new OpenpayApiError("Library install error, there are some missing classes");
|
||||
}
|
||||
OpenpayApiConsole::trace('OpenpayApiConnector @_request');
|
||||
|
||||
$myId = Openpay::getId();
|
||||
if (!$myId) {
|
||||
throw new OpenpayApiAuthError("Empty or no Merchant ID provided");
|
||||
} else if (!preg_match('/^[a-z0-9]{20}$/i', $myId)) {
|
||||
throw new OpenpayApiAuthError("Invalid Merchant ID '" . $myId . "'");
|
||||
}
|
||||
|
||||
$myApiKey = Openpay::getApiKey();
|
||||
if (!$myApiKey) {
|
||||
throw new OpenpayApiAuthError("Empty or no Private Key provided");
|
||||
} else if (!preg_match('/^sk_[a-z0-9]{32}$/i', $myApiKey)) {
|
||||
throw new OpenpayApiAuthError("Invalid Private Key '" . $myApiKey . "'");
|
||||
}
|
||||
|
||||
$publicIp = Openpay::getPublicIp();
|
||||
if(is_null($publicIp)){
|
||||
throw new OpenpayApiAuthError("Empty or no public ip provided");
|
||||
} else if (!filter_var($publicIp, FILTER_VALIDATE_IP)){
|
||||
throw new OpenpayApiAuthError("Invalid public ip '" . $publicIp . "'");
|
||||
}
|
||||
|
||||
$absUrl = Openpay::getEndpointUrl();
|
||||
if (!$absUrl) {
|
||||
throw new OpenpayApiConnectionError("No API endpoint set");
|
||||
}
|
||||
$absUrl .= '/' . $myId . $url;
|
||||
|
||||
//$params = self::_encodeObjects($params);
|
||||
|
||||
$userAgent = Openpay::getUserAgent();
|
||||
|
||||
if (empty($userAgent))
|
||||
$headers = array('User-Agent: OpenpayPhp/v2');
|
||||
else
|
||||
$headers = array('User-Agent: ' . $userAgent);
|
||||
|
||||
array_push($headers, 'X-Forwarded-For: ' . $publicIp);
|
||||
|
||||
list($rbody, $rcode) = $this->_curlRequest($method, $absUrl, $headers, $params, $myApiKey);
|
||||
return $this->interpretResponse($rbody, $rcode);
|
||||
}
|
||||
|
||||
private function _curlRequest($method, $absUrl, $headers, $params, $auth = null)
|
||||
{
|
||||
OpenpayApiConsole::trace('OpenpayApiConnector @_curlRequest');
|
||||
|
||||
$opts = array();
|
||||
if (!is_array($headers)) {
|
||||
$headers = array();
|
||||
}
|
||||
|
||||
if ($method == 'get') {
|
||||
$opts[CURLOPT_HTTPGET] = 1;
|
||||
if (count($params) > 0) {
|
||||
$encoded = $this->encodeToQueryString($params);
|
||||
$absUrl = $absUrl . '?' . $encoded;
|
||||
}
|
||||
} else if ($method == 'post') {
|
||||
$data = $this->encodeToJson($params);
|
||||
$opts[CURLOPT_POST] = 1;
|
||||
$opts[CURLOPT_POSTFIELDS] = $data;
|
||||
array_push($headers, 'Content-Type: application/json');
|
||||
array_push($headers, 'Content-Length: ' . strlen($data));
|
||||
} else if ($method == 'put') {
|
||||
$data = $this->encodeToJson($params);
|
||||
$opts[CURLOPT_CUSTOMREQUEST] = 'PUT';
|
||||
$opts[CURLOPT_POSTFIELDS] = $data;
|
||||
array_push($headers, 'Content-Type: application/json');
|
||||
array_push($headers, 'Content-Length: ' . strlen($data));
|
||||
} else if ($method == 'delete') {
|
||||
$opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
|
||||
if (count($params) > 0) {
|
||||
$encoded = $this->encodeToQueryString($params);
|
||||
$absUrl = $absUrl . '?' . $encoded;
|
||||
}
|
||||
} else {
|
||||
throw new OpenpayApiError("Invalid request method '" . $method . "'");
|
||||
}
|
||||
|
||||
|
||||
$opts[CURLOPT_URL] = $absUrl;
|
||||
$opts[CURLOPT_RETURNTRANSFER] = TRUE;
|
||||
$opts[CURLOPT_CONNECTTIMEOUT] = 30;
|
||||
$opts[CURLOPT_TIMEOUT] = 80;
|
||||
$opts[CURLOPT_HTTPHEADER] = $headers;
|
||||
$opts[CURLOPT_SSL_VERIFYPEER] = TRUE;
|
||||
|
||||
if ($auth) {
|
||||
$opts[CURLOPT_USERPWD] = $auth . ':';
|
||||
}
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, $opts);
|
||||
|
||||
OpenpayApiConsole::debug('Executing cURL: ' . strtoupper($method) . ' > ' . $absUrl);
|
||||
|
||||
$rbody = curl_exec($curl);
|
||||
$errorCode = curl_errno($curl);
|
||||
|
||||
// if request fails because bad certificate verification, then
|
||||
// retry the request by using the CA certificates bundle
|
||||
// CURLE_SSL_CACERT || CURLE_SSL_CACERT_BADFILE
|
||||
if ($errorCode == 60 || $errorCode == 77) {
|
||||
curl_setopt($curl, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
|
||||
$rbody = curl_exec($curl);
|
||||
}
|
||||
|
||||
if ($rbody === false) {
|
||||
OpenpayApiConsole::error('cURL request error: ' . curl_errno($curl));
|
||||
$message = curl_error($curl);
|
||||
$errorCode = curl_errno($curl);
|
||||
curl_close($curl);
|
||||
|
||||
$this->handleCurlError($errorCode, $message);
|
||||
}
|
||||
$rcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if (mb_detect_encoding($rbody, 'UTF-8', true) != 'UTF-8') {
|
||||
OpenpayApiConsole::warn('Response body is not an UTF-8 string');
|
||||
}
|
||||
|
||||
OpenpayApiConsole::debug('cURL body: ' . $rbody);
|
||||
OpenpayApiConsole::debug('cURL code: ' . $rcode);
|
||||
|
||||
return array($rbody, $rcode);
|
||||
}
|
||||
|
||||
private function encodeToQueryString($arr, $prefix = null)
|
||||
{
|
||||
if (!is_array($arr))
|
||||
return $arr;
|
||||
|
||||
$r = array();
|
||||
foreach ($arr as $k => $v) {
|
||||
if (is_null($v))
|
||||
continue;
|
||||
|
||||
if ($prefix && $k && !is_int($k))
|
||||
$k = $prefix . "[" . $k . "]";
|
||||
else if ($prefix)
|
||||
$k = $prefix . "[]";
|
||||
|
||||
if (is_array($v)) {
|
||||
$r[] = $this->encodeToQueryString($v, $k, true);
|
||||
} else {
|
||||
$r[] = urlencode($k) . "=" . urlencode($v);
|
||||
}
|
||||
}
|
||||
$string = implode("&", $r);
|
||||
OpenpayApiConsole::debug('Query string: ' . $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
private function encodeToJson($arr)
|
||||
{
|
||||
$encoded = json_encode($arr);
|
||||
if (mb_detect_encoding($encoded, 'UTF-8', true) != 'UTF-8') {
|
||||
$encoded = utf8_encode($encoded);
|
||||
}
|
||||
OpenpayApiConsole::debug('JSON UTF8 string: ' . $encoded);
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
private function interpretResponse($responseBody, $responseCode)
|
||||
{
|
||||
OpenpayApiConsole::trace('OpenpayApiConnector @interpretResponse');
|
||||
try {
|
||||
// return json as an array NOT an object
|
||||
if (!empty($responseBody)) {
|
||||
$traslatedResponse = json_decode($responseBody, true);
|
||||
} else {
|
||||
$traslatedResponse = array();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new OpenpayApiRequestError("Invalid response: " . $responseBody, $responseCode);
|
||||
}
|
||||
|
||||
if ($responseCode < 200 || $responseCode >= 300) {
|
||||
OpenpayApiConsole::error('Request finished with HTTP code ' . $responseCode);
|
||||
$this->handleRequestError($responseBody, $responseCode, $traslatedResponse);
|
||||
return array();
|
||||
}
|
||||
return $traslatedResponse;
|
||||
}
|
||||
|
||||
private function handleRequestError($responseBody, $responseCode, $traslatedResponse)
|
||||
{
|
||||
if (!is_array($traslatedResponse) || !isset($traslatedResponse['error_code'])) {
|
||||
throw new OpenpayApiRequestError("Invalid response body received from Openpay API Server");
|
||||
}
|
||||
|
||||
$message = isset($traslatedResponse['description']) ? $traslatedResponse['description'] : 'No description';
|
||||
$error = $traslatedResponse['error_code'];
|
||||
$category = isset($traslatedResponse['category']) ? $traslatedResponse['category'] : null;
|
||||
$request_id = isset($traslatedResponse['request_id']) ? $traslatedResponse['request_id'] : null;
|
||||
$fraud_rules = isset($traslatedResponse['fraud_rules']) ? $traslatedResponse['fraud_rules'] : null;
|
||||
|
||||
switch ($responseCode) {
|
||||
|
||||
// Unauthorized - Forbidden
|
||||
case 401:
|
||||
case 403:
|
||||
throw new OpenpayApiAuthError($message, $error, $category, $request_id, $responseCode, $fraud_rules);
|
||||
break;
|
||||
|
||||
// Bad Request - Request Entity too large - Request Entity too large - Internal Server Error - Service Unavailable
|
||||
case 400:
|
||||
case 404:
|
||||
case 413:
|
||||
case 422:
|
||||
case 500:
|
||||
case 503:
|
||||
throw new OpenpayApiRequestError($message, $error, $category, $request_id, $responseCode, $fraud_rules);
|
||||
break;
|
||||
|
||||
// Payment Required - Conflict - Preconditon Failed - Unprocessable Entity - Locked
|
||||
case 402:
|
||||
case 409:
|
||||
case 412:
|
||||
case 423:
|
||||
throw new OpenpayApiTransactionError($message, $error, $category, $request_id, $responseCode, $fraud_rules);
|
||||
break;
|
||||
|
||||
// Not Found
|
||||
default:
|
||||
throw new OpenpayApiError($message, $error, $category, $request_id, $responseCode, $fraud_rules);
|
||||
}
|
||||
}
|
||||
|
||||
private function handleCurlError($errorCode, $message)
|
||||
{
|
||||
switch ($errorCode) {
|
||||
case CURLE_COULDNT_CONNECT:
|
||||
case CURLE_COULDNT_RESOLVE_HOST:
|
||||
case CURLE_OPERATION_TIMEOUTED:
|
||||
$msg = "Could not connect to Openpay. Please check your internet connection and try again";
|
||||
break;
|
||||
default:
|
||||
$msg = "Unexpected error connecting to Openpay";
|
||||
}
|
||||
|
||||
$msg .= " (Network error " . $errorCode . ")";
|
||||
throw new OpenpayApiConnectionError($msg);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// ------------------ PUBLIC FUNCTIONS -------------------
|
||||
|
||||
public static function request($method, $url, $params = null)
|
||||
{
|
||||
OpenpayApiConsole::trace('OpenpayApiConnector @request ' . $url);
|
||||
|
||||
if (!$params) {
|
||||
$params = array();
|
||||
}
|
||||
|
||||
$method = strtolower($method);
|
||||
if (!in_array($method, array('get', 'post', 'delete', 'put'))) {
|
||||
throw new OpenpayApiError("Invalid request method '" . $method . "'");
|
||||
}
|
||||
|
||||
$connector = self::getInstance();
|
||||
return $connector->_request($method, $url, $params);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Data;
|
||||
|
||||
class OpenpayApiConsole {
|
||||
|
||||
const CONSOLE_NONE = 0;
|
||||
const CONSOLE_TRACE = 2;
|
||||
const CONSOLE_DEBUG = 4;
|
||||
const CONSOLE_INFO = 8;
|
||||
const CONSOLE_WARNING = 16;
|
||||
const CONSOLE_ERROR = 32;
|
||||
const CONSOLE_CRITICAL = 64;
|
||||
const CONSOLE_ALL = 126;
|
||||
|
||||
private static $instance;
|
||||
private $level;
|
||||
private $toScreen;
|
||||
|
||||
private function __construct() {
|
||||
$this->level = self::CONSOLE_NONE;
|
||||
$this->toScreen = false;
|
||||
}
|
||||
|
||||
private function record($prefix, $text) {
|
||||
$output = $prefix . ': ' . print_r($text, true);
|
||||
if ($this->toScreen == true) {
|
||||
print_r('<pre>' . $output . '</pre>' . "\n");
|
||||
} else {
|
||||
syslog(LOG_INFO, $output);
|
||||
}
|
||||
}
|
||||
|
||||
private function checkFlag($flag, $value) {
|
||||
return (($flag & $value) == $flag);
|
||||
}
|
||||
|
||||
private static function getInstance() {
|
||||
if (self::$instance == null) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
private static function _log($type, $flag, $text) {
|
||||
$logger = self::getInstance();
|
||||
if ($logger->checkFlag($flag, $logger->level))
|
||||
$logger->record('[' . strtoupper($type) . ']', $text);
|
||||
}
|
||||
|
||||
// -----------------------------------------------
|
||||
public static function setLevel($level) {
|
||||
$instance = self::getInstance();
|
||||
$instance->level = $level;
|
||||
}
|
||||
|
||||
public static function printToScreen($flag) {
|
||||
$instance = self::getInstance();
|
||||
$instance->toScreen = ($flag ? true : false);
|
||||
}
|
||||
|
||||
public static function trace($text) {
|
||||
self::_log('trace', self::CONSOLE_TRACE, $text);
|
||||
}
|
||||
|
||||
public static function debug($text) {
|
||||
self::_log('debug', self::CONSOLE_DEBUG, $text);
|
||||
}
|
||||
|
||||
public static function info($text) {
|
||||
self::_log('info', self::CONSOLE_INFO, $text);
|
||||
}
|
||||
|
||||
public static function warn($text) {
|
||||
self::_log('warning', self::CONSOLE_WARNING, $text);
|
||||
}
|
||||
|
||||
public static function error($text) {
|
||||
self::_log('error', self::CONSOLE_ERROR, $text);
|
||||
}
|
||||
|
||||
public static function critical($text) {
|
||||
self::_log('critical', self::CONSOLE_CRITICAL, $text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Data;
|
||||
|
||||
class OpenpayApiDerivedResource extends OpenpayApiResourceBase {
|
||||
|
||||
private $cacheList = array();
|
||||
|
||||
protected static function getInstance($resourceName, $p = null) {
|
||||
if (class_exists($resourceName . 'List')) {
|
||||
$resource = $resourceName . 'List';
|
||||
return new $resource($resourceName);
|
||||
}
|
||||
return new self($resourceName);
|
||||
}
|
||||
|
||||
protected function addResource($resource, $id = null) {
|
||||
if (!$id && isset($resource->id)) {
|
||||
$id = $resource->id;
|
||||
} else if (is_string($id)) {
|
||||
$id = strtolower($id);
|
||||
} else {
|
||||
$id = count($this->cacheList) + 1;
|
||||
}
|
||||
if (!$this->isResourceListed($id)) {
|
||||
$resource->parent = $this;
|
||||
$this->cacheList[$id] = $resource;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getResource($id) {
|
||||
$id = strtolower($id);
|
||||
if ($this->isResourceListed($id)) {
|
||||
return $this->cacheList[$id];
|
||||
}
|
||||
}
|
||||
|
||||
protected function removeResource($id) {
|
||||
$id = strtolower($id);
|
||||
if ($this->isResourceListed($id)) {
|
||||
unset($this->cacheList[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function isResourceListed($id) {
|
||||
$id = strtolower($id);
|
||||
return (isset($this->cacheList[$id]) && !empty($this->cacheList[$id]));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// ------------------ PUBLIC FUNCTIONS -------------------
|
||||
|
||||
|
||||
public function add($params) {
|
||||
OpenpayApiConsole::trace('OpenpayApiDerivedResource @add');
|
||||
|
||||
// TODO: validate call when the parent has not a valid ID
|
||||
$resource = parent::_create($this->resourceName, $params, array('parent' => $this));
|
||||
$this->addResource($resource);
|
||||
return $resource;
|
||||
}
|
||||
|
||||
public function get($id) {
|
||||
OpenpayApiConsole::trace('OpenpayApiDerivedResource @get');
|
||||
|
||||
if ($this->isResourceListed($id)) {
|
||||
return $this->getResource($id);
|
||||
}
|
||||
$resource = parent::_retrieve($this->resourceName, $id, array('parent' => $this));
|
||||
$this->addResource($resource);
|
||||
return $resource;
|
||||
}
|
||||
|
||||
public function getList($params) {
|
||||
OpenpayApiConsole::trace('OpenpayApiDerivedResource @find');
|
||||
|
||||
$list = parent::_find($this->resourceName, $params, array('parent' => $this));
|
||||
foreach ($list as $resource) {
|
||||
$this->addResource($resource);
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Data;
|
||||
|
||||
use Exception;
|
||||
|
||||
class OpenpayApiError extends Exception
|
||||
{
|
||||
|
||||
protected $description;
|
||||
protected $error_code;
|
||||
protected $category;
|
||||
protected $http_code;
|
||||
protected $request_id;
|
||||
protected $fraud_rules;
|
||||
|
||||
public function __construct($message = null, $error_code = 0, $category = null, $request_id = null, $http_code = null, $fraud_rules = null) {
|
||||
parent::__construct($message, $error_code);
|
||||
$this->description = $message;
|
||||
$this->error_code = isset($error_code) ? $error_code : 0;
|
||||
$this->category = isset($category) ? $category : '';
|
||||
$this->http_code = isset($http_code) ? $http_code : 0;
|
||||
$this->request_id = isset($request_id) ? $request_id : '';
|
||||
$this->fraud_rules = isset($fraud_rules) ? $fraud_rules : array();
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function getErrorCode() {
|
||||
return $this->error_code;
|
||||
}
|
||||
|
||||
public function getCategory() {
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
public function getHttpCode() {
|
||||
return $this->http_code;
|
||||
}
|
||||
|
||||
public function getRequestId() {
|
||||
return $this->request_id;
|
||||
}
|
||||
|
||||
public function getFraudRules() {
|
||||
return $this->fraud_rules;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Data;
|
||||
|
||||
class OpenpayApiRequestError extends OpenpayApiError
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,389 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Data;
|
||||
|
||||
abstract class OpenpayApiResourceBase
|
||||
{
|
||||
|
||||
protected $id;
|
||||
protected $parent;
|
||||
protected $resourceName = '';
|
||||
protected $serializableData;
|
||||
protected $noSerializableData;
|
||||
protected $derivedResources;
|
||||
|
||||
protected function __construct($resourceName, $params = array()) {
|
||||
$this->resourceName = $resourceName;
|
||||
$this->serializableData = array();
|
||||
$this->noSerializableData = array();
|
||||
|
||||
if (!is_array($params)) {
|
||||
throw new OpenpayApiError("Invalid parameter type detected when instantiating an Openpay resource (passed '".gettype($params)."', array expected)");
|
||||
}
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'id') {
|
||||
$this->id = $value;
|
||||
continue;
|
||||
}
|
||||
if ($key == 'parent') {
|
||||
$this->parent = $value;
|
||||
continue;
|
||||
}
|
||||
$this->serializableData[$key] = $value;
|
||||
}
|
||||
|
||||
if ($derived = $this->derivedResources) {
|
||||
foreach ($derived as $k => $v) {
|
||||
$name = strtolower($k).'s';
|
||||
$this->derivedResources[$name] = $this->processAttribute($k, $v);
|
||||
|
||||
// unsets the original attribute
|
||||
unset($this->derivedResources[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function getInstance($resourceName, $props = null) {
|
||||
OpenpayApiConsole::trace('OpenpayApiResourceBase @getInstance > '.$resourceName);
|
||||
if (!class_exists($resourceName)) {
|
||||
throw new OpenpayApiError("Invalid Openpay resource type (class resource '".$resourceName."' is invalid)");
|
||||
}
|
||||
if (is_string($props)) {
|
||||
$props = array('id' => $props);
|
||||
} else if (!is_array($props)) {
|
||||
$props = array();
|
||||
}
|
||||
$resource = new $resourceName($resourceName, $props);
|
||||
return $resource;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// ------------------ PRIVATE FUNCTIONS ------------------
|
||||
|
||||
private function isList($var) {
|
||||
if (!is_array($var))
|
||||
return false;
|
||||
|
||||
foreach (array_keys($var) as $k) {
|
||||
if (!is_numeric($k))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function processAttribute($k, $v) {
|
||||
OpenpayApiConsole::trace('OpenpayApiResourceBase @processAttribute > '.$k);
|
||||
$value = null;
|
||||
|
||||
$resourceName = $this->getResourceName($k);
|
||||
if ($this->isResource($resourceName)) {
|
||||
// check is its a resource list
|
||||
if ($this->isList($v)) {
|
||||
$list = OpenpayApiDerivedResource::getInstance("Openpay\\Resources\\".$resourceName);
|
||||
$list->parent = $this;
|
||||
foreach ($v as $index => $objData) {
|
||||
$list->add($objData);
|
||||
}
|
||||
$value = $list;
|
||||
} else {
|
||||
$resource = self::getInstance("Openpay\\Resources\\".$resourceName);
|
||||
$resource->parent = $this;
|
||||
$resource->refreshData($v);
|
||||
$value = $resource;
|
||||
|
||||
if ($resourceName != $this->resourceName) {
|
||||
$this->registerInParent($resource);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (is_array($v)) {
|
||||
// if it's an array, then is an object an instance a standar class
|
||||
|
||||
$object = new \stdClass();
|
||||
foreach ($v as $key => $value) {
|
||||
$object->$key = $value;
|
||||
}
|
||||
$value = $object;
|
||||
} else {
|
||||
$value = $v;
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function getResourceName($name) {
|
||||
OpenpayApiConsole::trace('OpenpayApiResourceBase @getResourceName');
|
||||
if (substr($name, 0, strlen('Openpay')) == 'Openpay') {
|
||||
return $name;
|
||||
}
|
||||
return 'Openpay'.ucfirst($name);
|
||||
}
|
||||
|
||||
private function isResource($resourceName) {
|
||||
OpenpayApiConsole::trace('OpenpayApiResourceBase @isResource > '.$resourceName);
|
||||
// $resourceName = $this->getResourceName($name);
|
||||
|
||||
return class_exists("Openpay\\Resources\\".$resourceName);
|
||||
}
|
||||
|
||||
private function registerInParent($resource) {
|
||||
OpenpayApiConsole::trace('OpenpayApiResourceBase @registerInParent');
|
||||
$parent = $this->parent;
|
||||
if ($parent instanceof OpenpayApiDerivedResource) {
|
||||
$parent = $this->parent->parent;
|
||||
}
|
||||
|
||||
if (!is_object($parent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($container = $parent->getResource($resource->resourceName)) { // $resourceName
|
||||
if ($container instanceof OpenpayApiDerivedResource && method_exists($container, 'addResource')) {
|
||||
OpenpayApiConsole::trace('OpenpayApiResourceBase @registerInParent > registering derived resource in parent');
|
||||
$container->addResource($resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getSerializeParameters() {
|
||||
OpenpayApiConsole::trace('OpenpayApiResourceBase @getSerializeParameters');
|
||||
return $this->serializableData;
|
||||
}
|
||||
|
||||
private function getResource($resourceName) {
|
||||
if ($this->derivedResources !== null) {
|
||||
foreach ($this->derivedResources as $resource) {
|
||||
if ($resource->resourceName == $resourceName) {
|
||||
return $resource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// ----------------- PROTECTED FUNCTIONS -----------------
|
||||
|
||||
protected function refreshData($data) {
|
||||
OpenpayApiConsole::trace('OpenpayApiResourceBase @refreshData');
|
||||
|
||||
if (!$data) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!is_array($data)) {
|
||||
throw new OpenpayApiError("Invalid data received for processing, cannot update the Openpay resource");
|
||||
}
|
||||
|
||||
// unsets the unused attributes
|
||||
$removed = array_diff(array_keys($this->serializableData), array_keys($data));
|
||||
if (count($removed)) {
|
||||
OpenpayApiConsole::debug('OpenpayApiResourceBase @refreshData > removing unused data');
|
||||
foreach ($removed as $k) {
|
||||
if ($this->serializableData[$k]) {
|
||||
unset($this->serializableData[$k]);
|
||||
}
|
||||
if ($this->noSerializableData[$k]) {
|
||||
$this->noSerializableData[$k] = null;
|
||||
}
|
||||
if ($this->derivedResources[$k]) {
|
||||
//$this->derivedResources[$k] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
$k = strtolower($k);
|
||||
|
||||
$value = $this->processAttribute($k, $v);
|
||||
|
||||
if ($k == 'id') {
|
||||
if (!isset($this->id)) {
|
||||
$this->id = $v;
|
||||
}
|
||||
continue;
|
||||
|
||||
// by default, only protected vars & serializable data will be refresh
|
||||
// in this version, noSerializableData does not store any value
|
||||
} else if (property_exists($this, $k)) {
|
||||
$this->$k = $value;
|
||||
//if ($this->noSerializableData[$k]) {
|
||||
// $this->noSerializableData[$k] = $value;
|
||||
//}
|
||||
} else {
|
||||
$this->serializableData[$k] = $value;
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getResourceUrlName($pluralize = true) {
|
||||
$ResourceUrl = explode('\\', $this->resourceName);
|
||||
$class = $ResourceUrl[sizeof($ResourceUrl)-1];
|
||||
if (substr($class, 0, strlen('Openpay')) == 'Openpay') {
|
||||
$class = substr($class, strlen('Openpay'));
|
||||
}
|
||||
if (substr($class, -1 * strlen('List')) == 'List') {
|
||||
$class = substr($class, 0, -1 * strlen('List'));
|
||||
}
|
||||
if (substr($class, -1 * strlen('OpenpayPse')) == 'Pse') {
|
||||
$class = 'Pse';
|
||||
return strtolower(urlencode($class));
|
||||
}
|
||||
return strtolower(urlencode($class)).($pluralize ? 's' : '');
|
||||
}
|
||||
|
||||
protected function validateParams($params) {
|
||||
OpenpayApiConsole::trace('OpenpayApiResourceBase @validateParams');
|
||||
if (!is_array($params)) {
|
||||
throw new OpenpayApiRequestError("Invalid parameters type detected (type '".gettype($params)."' received, Array expected)");
|
||||
}
|
||||
}
|
||||
|
||||
protected function validateId($id) {
|
||||
OpenpayApiConsole::trace('OpenpayApiResourceBase @validateId');
|
||||
$class = $this->resourceName;
|
||||
if (substr($class, -1 * strlen('Bine')) != 'Bine') {
|
||||
if (!is_string($id) || !preg_match('/^[a-z][a-z0-9]{0,20}$/i', $id)) {
|
||||
throw new OpenpayApiRequestError("Invalid ID detected (value '".$id."' received, alphanumeric string not longer than 20 characters expected)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function getMerchantInfo(){
|
||||
$response = OpenpayApiConnector::request('get', '/' , null);
|
||||
return json_decode(json_encode($response));
|
||||
}
|
||||
|
||||
protected function _create($resourceName, $params, $props = null) {
|
||||
|
||||
$resource = self::getInstance($resourceName, $props);
|
||||
$resource->validateParams($params);
|
||||
|
||||
// TODO: handle errors, not return anything
|
||||
$response = OpenpayApiConnector::request('post', $resource->getUrl(), $params);
|
||||
return $resource->refreshData($response);
|
||||
}
|
||||
|
||||
protected function _retrieve($resourceName, $id, $props = null) {
|
||||
if ($props && is_array($props)) {
|
||||
$props['id'] = $id;
|
||||
} else {
|
||||
$props = array('id' => $id);
|
||||
}
|
||||
|
||||
$resource = self::getInstance($resourceName, $props);
|
||||
$resource->validateId($id);
|
||||
|
||||
$response = OpenpayApiConnector::request('get', $resource->getUrl());
|
||||
return $resource->refreshData($response);
|
||||
}
|
||||
|
||||
protected function _find($resourceName, $params, $props = null) {
|
||||
|
||||
$resource = self::getInstance($resourceName, $props);
|
||||
$resource->validateParams($params);
|
||||
|
||||
$list = array();
|
||||
$response = OpenpayApiConnector::request('get', $resource->getUrl(), $params);
|
||||
if ($this->isList($response)) {
|
||||
foreach ($response as $v) {
|
||||
$item = self::getInstance($resourceName);
|
||||
$item->refreshData($v);
|
||||
array_push($list, $item);
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
protected function _update() {
|
||||
$params = $this->getSerializeParameters();
|
||||
|
||||
if (count($params)) {
|
||||
$response = OpenpayApiConnector::request('put', $this->getUrl(), $params);
|
||||
return $this->refreshData($response);
|
||||
}
|
||||
}
|
||||
|
||||
protected function _updateCharge($params) {
|
||||
if (count($params)) {
|
||||
$response = OpenpayApiConnector::request('put', $this->getResourceUrlName(), $params);
|
||||
return $this->refreshData($response);
|
||||
}
|
||||
}
|
||||
|
||||
protected function _delete() {
|
||||
OpenpayApiConnector::request('delete', $this->getUrl(), null);
|
||||
|
||||
// remove from list, if parent is a list
|
||||
if ($this->id && $this->parent && method_exists($this->parent, 'removeResource')) {
|
||||
$this->parent->removeResource($this->id);
|
||||
}
|
||||
//$this->empty(); // TODO
|
||||
}
|
||||
|
||||
protected function _getAttributes($param) {
|
||||
$url = $this->getUrl().'/'.$param;
|
||||
$response = OpenpayApiConnector::request('get', $url, null);
|
||||
return json_decode(json_encode($response));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// ------------------ PUBLIC FUNCTIONS -------------------
|
||||
|
||||
public function getUrl() { // $includeId = true
|
||||
OpenpayApiConsole::trace('OpenpayApiResourceBase @getUrl > class/parent: '.get_class($this).'/'.($this->parent ? 'true' : 'false'));
|
||||
$parentUrl = '';
|
||||
|
||||
if ($this->parent) {
|
||||
$parentUrl = $this->parent->getUrl();
|
||||
if ($this->parent instanceof OpenpayApiDerivedResource) {
|
||||
return $parentUrl.($this->id ? '/'.$this->id : '');
|
||||
}
|
||||
}
|
||||
$resourceUrlName = $this->getResourceUrlName();
|
||||
return ($parentUrl != '' ? $parentUrl : '').($resourceUrlName != '' ? '/'.$resourceUrlName : '').($this->id ? '/'.$this->id : '');
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// -------------------- MAGIC METHODS --------------------
|
||||
|
||||
public function __set($key, $value) {
|
||||
OpenpayApiConsole::trace('OpenpayApiResourceBase @__set > '.$key.' = '.$value);
|
||||
if ($value === '' || !$value) {
|
||||
error_log("[OPENPAY Notice] The property '".$key."' will be set to en empty string which will be intepreted ad a NULL in request");
|
||||
}
|
||||
if (isset($this->$key) && is_array($value)) {
|
||||
// TODO: handle this properly, eg: interpret the array as an object and replace value as
|
||||
// $this->$key->replaceWith($value);
|
||||
throw new OpenpayApiError("The property '".$key."' cannot be assigned directly with an array");
|
||||
//} else if (property_exists($this, $key)) {
|
||||
// $this->$key = $value;
|
||||
} else if (isset($this->serializableData[$key])) {
|
||||
$this->serializableData[$key] = $value;
|
||||
} elseif (isset($this->derivedResources[$key])) {
|
||||
$this->derivedResources[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function __get($key) {
|
||||
if (property_exists($this, $key)) {
|
||||
return $this->$key;
|
||||
} else if (array_key_exists($key, $this->serializableData)) {
|
||||
return $this->serializableData[$key];
|
||||
} else if (array_key_exists($key, $this->derivedResources)) {
|
||||
return $this->derivedResources[$key];
|
||||
} else if (array_key_exists($key, $this->noSerializableData)) {
|
||||
return $this->noSerializableData[$key];
|
||||
} else {
|
||||
$resourceName = get_class($this);
|
||||
error_log("[OPENPAY Notice] Undefined property of $resourceName instance: $key"); // TODO error_log?
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Data;
|
||||
|
||||
class OpenpayApiTransactionError extends OpenpayApiError
|
||||
{
|
||||
|
||||
}
|
||||
+3451
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
|
||||
class OpenpayBankAccount extends OpenpayApiResourceBase
|
||||
{
|
||||
protected $bank_code;
|
||||
protected $bank_name;
|
||||
protected $creation_date;
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$this->_delete();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayBankAccountList extends OpenpayApiDerivedResource
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
|
||||
class OpenpayBine extends OpenpayApiResourceBase {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
|
||||
class OpenpayCapture extends OpenpayApiResourceBase {
|
||||
protected function getResourceUrlName($p = true){
|
||||
return parent::getResourceUrlName(false);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Openpay API v1 Client for PHP (version 2.2.*)
|
||||
*
|
||||
* Copyright © Openpay SAPI de C.V. All rights reserved.
|
||||
* http://www.openpay.mx/
|
||||
* soporte@openpay.mx
|
||||
*/
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayCard extends OpenpayApiResourceBase
|
||||
{
|
||||
|
||||
protected $type;
|
||||
protected $brand;
|
||||
protected $allows_charges;
|
||||
protected $allows_payouts;
|
||||
protected $creation_date;
|
||||
protected $bank_name;
|
||||
protected $bank_code;
|
||||
protected $customer_id;
|
||||
|
||||
public function delete() {
|
||||
$this->_delete();
|
||||
}
|
||||
|
||||
public function get($param) {
|
||||
return $this->_getAttributes($param);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayCardList extends OpenpayApiDerivedResource
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
|
||||
class OpenpayCharge extends OpenpayApiResourceBase
|
||||
{
|
||||
|
||||
protected $authorization;
|
||||
protected $creation_date;
|
||||
protected $currency;
|
||||
protected $customer_id;
|
||||
protected $operation_type;
|
||||
protected $status;
|
||||
protected $transaction_type;
|
||||
// temporal hack
|
||||
// TODO: checar porque no instancia Openpaycard al recibir el parametro
|
||||
protected $card;
|
||||
protected $derivedResources = array('Refund' => null, 'Capture' => null);
|
||||
|
||||
public function refund($params)
|
||||
{
|
||||
$resource = $this->derivedResources['refunds'];
|
||||
if ($resource) {
|
||||
return parent::_create($resource->resourceName, $params, array('parent' => $this));
|
||||
}
|
||||
}
|
||||
|
||||
public function capture($params)
|
||||
{
|
||||
$resource = $this->derivedResources['captures'];
|
||||
if ($resource) {
|
||||
return parent::_create($resource->resourceName, $params, array('parent' => $this));
|
||||
}
|
||||
}
|
||||
|
||||
public function update($params)
|
||||
{
|
||||
return $this->_updateCharge($params);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayChargeList extends OpenpayApiDerivedResource
|
||||
{
|
||||
|
||||
public function create($params)
|
||||
{
|
||||
return $this->add($params);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayCustomer extends OpenpayApiResourceBase {
|
||||
|
||||
protected $status;
|
||||
protected $creation_date;
|
||||
protected $balance;
|
||||
protected $clabe;
|
||||
protected $derivedResources = array(
|
||||
'Card' => array(),
|
||||
'BankAccount' => array(),
|
||||
'Charge' => array(),
|
||||
'Pse' => array(),
|
||||
'Transfer' => array(),
|
||||
'Payout' => array(),
|
||||
'Subscription' => array());
|
||||
|
||||
public function save() {
|
||||
return $this->_update();
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
$this->_delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayCustomerList extends OpenpayApiDerivedResource
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayFee extends OpenpayApiResourceBase
|
||||
{
|
||||
|
||||
protected $authorization;
|
||||
protected $creation_date;
|
||||
protected $currency;
|
||||
protected $operation_type;
|
||||
protected $status;
|
||||
protected $transaction_type;
|
||||
protected $error_message;
|
||||
protected $method;
|
||||
protected $derivedResources = array('Refund' => null);
|
||||
|
||||
public function refund($params) {
|
||||
$resource = $this->derivedResources['refunds'];
|
||||
if ($resource) {
|
||||
return parent::_create($resource->resourceName, $params, array('parent' => $this));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayFeeList extends OpenpayApiDerivedResource
|
||||
{
|
||||
|
||||
public function create($params)
|
||||
{
|
||||
return $this->add($params);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayPayout extends OpenpayApiResourceBase {
|
||||
protected $authorization;
|
||||
protected $creation_date;
|
||||
protected $currency;
|
||||
protected $operation_type;
|
||||
protected $status;
|
||||
protected $transaction_type;
|
||||
protected $error_message;
|
||||
protected $method;
|
||||
|
||||
// temporal hack
|
||||
// TODO: checar porque no instancia Openpaycard al recibir el parametro
|
||||
protected $card;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayPayoutList extends OpenpayApiDerivedResource
|
||||
{
|
||||
public function create($params)
|
||||
{
|
||||
return $this->add($params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayPlan extends OpenpayApiResourceBase {
|
||||
protected $creation_date;
|
||||
protected $currency;
|
||||
protected $amount;
|
||||
protected $repeat_every;
|
||||
protected $repeat_unit;
|
||||
protected $retry_times;
|
||||
protected $status;
|
||||
protected $status_after_retry;
|
||||
|
||||
protected $derivedResources = array('Subscription' => array());
|
||||
|
||||
public function save() {
|
||||
return $this->_update();
|
||||
}
|
||||
public function delete() {
|
||||
$this->_delete();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayPlanList extends OpenpayApiDerivedResource
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
|
||||
class OpenpayPse extends OpenpayApiResourceBase
|
||||
{
|
||||
|
||||
protected $authorization;
|
||||
protected $creation_date;
|
||||
protected $currency;
|
||||
protected $customer_id;
|
||||
protected $operation_type;
|
||||
protected $status;
|
||||
protected $transaction_type;
|
||||
protected $derivedResources = array();
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayPseList extends OpenpayApiDerivedResource
|
||||
{
|
||||
|
||||
public function create($params)
|
||||
{
|
||||
return $this->add($params);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
|
||||
class OpenpayRefund extends OpenpayApiResourceBase {
|
||||
protected function getResourceUrlName($p = true){
|
||||
return parent::getResourceUrlName(false);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpaySubscription extends OpenpayApiResourceBase {
|
||||
protected $status;
|
||||
protected $charge_date;
|
||||
protected $creation_date;
|
||||
protected $current_period_number;
|
||||
protected $period_end_date;
|
||||
protected $plan_id;
|
||||
protected $customer_id;
|
||||
|
||||
// temporal hack
|
||||
// TODO: checar porque no instancia Openpaycard al recibir el parametro
|
||||
protected $card;
|
||||
|
||||
public function save() {
|
||||
return $this->_update();
|
||||
}
|
||||
public function delete() {
|
||||
$this->_delete();
|
||||
}
|
||||
|
||||
public function __set($key, $value) {
|
||||
|
||||
if ($key == 'source_id') {
|
||||
if (!array_key_exists($key, $this->serializableData)) {
|
||||
$this->serializableData['source_id'] = $value;
|
||||
}
|
||||
} else {
|
||||
parent::__set($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpaySubscriptionList extends OpenpayApiDerivedResource
|
||||
{
|
||||
public function create($params)
|
||||
{
|
||||
return $this->add($params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
|
||||
class OpenpayToken extends OpenpayApiResourceBase
|
||||
{
|
||||
protected $card;
|
||||
|
||||
public function get($param) {
|
||||
return $this->_getAttributes($param);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayTransfer extends OpenpayApiResourceBase {
|
||||
protected $authorization;
|
||||
protected $creation_date;
|
||||
protected $currency;
|
||||
protected $operation_type;
|
||||
protected $status;
|
||||
protected $transaction_type;
|
||||
protected $error_message;
|
||||
protected $method;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiDerivedResource;
|
||||
|
||||
class OpenpayTransferList extends OpenpayApiDerivedResource
|
||||
{
|
||||
public function create($params)
|
||||
{
|
||||
return $this->add($params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Openpay\Resources;
|
||||
|
||||
use Openpay\Data\OpenpayApiResourceBase;
|
||||
|
||||
class OpenpayWebhook extends OpenpayApiResourceBase
|
||||
{
|
||||
|
||||
protected $url;
|
||||
protected $event_types;
|
||||
|
||||
public function save()
|
||||
{
|
||||
return $this->_update();
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$this->_delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Vendored
+892
@@ -0,0 +1,892 @@
|
||||

|
||||
|
||||
PHP client for Openpay API services (version 3.0.0)
|
||||
|
||||
This is a client implementing the payment services for Openpay at openpay.mx
|
||||
|
||||
|
||||
Compatibility
|
||||
-------------
|
||||
|
||||
PHP 5.2 or later
|
||||
|
||||
Requirements
|
||||
------------
|
||||
PHP 5.2 or later
|
||||
cURL extension for PHP
|
||||
JSON extension for PHP
|
||||
Multibyte String extension for PHP
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Agregar en la documentación lo siguiente:
|
||||
* composer 1 : versión php 2.1.*
|
||||
* composer 2: versión 2.2.* || version 3.0.0
|
||||
|
||||
|
||||
|
||||
|
||||
### Composer
|
||||
The preferred method is via [composer](https://getcomposer.org). Follow the
|
||||
[installation instructions](https://getcomposer.org/doc/00-intro.md) if you do not already have
|
||||
composer installed.
|
||||
|
||||
Once composer is installed, execute the following command in your project root to install this library:
|
||||
|
||||
```sh
|
||||
composer require openpay/sdk
|
||||
```
|
||||
Finally, be sure to include the autoloader:
|
||||
|
||||
```php
|
||||
require_once '/path/to/your-project/vendor/autoload.php';
|
||||
```
|
||||
|
||||
### Manual installation
|
||||
|
||||
To install, just:
|
||||
|
||||
- Clone the repository or download the library and copy/create a folder named
|
||||
**'Openpay'** inside your project folder structure. If you downloaded the
|
||||
client library as a compressed file, uncompress it and create the proper
|
||||
folder structure.
|
||||
- At the top of the PHP script in which the client library will be used (or
|
||||
in the section you include other libraries), add the client's library main
|
||||
script:
|
||||
|
||||
```php
|
||||
require(dirname(__FILE__) . '/Openpay/Openpay.php');
|
||||
```
|
||||
|
||||
> NOTE: In the example above, the library is located in the directory named
|
||||
> Openpay, located inside the same directory that the PHP file which is
|
||||
> including the cliente. Make sure to adjust the paths inside your project,
|
||||
> otherwise the library will not work.
|
||||
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
||||
#### Configuration #####
|
||||
|
||||
Before use the library will be necessary to set up your Merchant ID and
|
||||
Private key. There are three options:
|
||||
|
||||
- Use the methods **Openpay::setId()*, **Openpay::setApiKey()** and **Openpay::setCountry()** . Just
|
||||
pass the proper parameters to each function:
|
||||
|
||||
```php
|
||||
Openpay::setId('moiep6umtcnanql3jrxp');
|
||||
Openpay::setApiKey('sk_3433941e467c4875b178ce26348b0fac');
|
||||
Openpay::setCountry('MX'); // MX, CO, PE
|
||||
Openpay::setPublicIp('127.0.0.1');
|
||||
```
|
||||
- The **PublicIp** parameter refers to the IP of the customer who makes the purchase. This parameter is added for security reasons. It can be IPv4 and IPv6.
|
||||
- Pass Merchant ID, Private Key, country code and public ip as parameters to the method **Openpay::getInstance()**,
|
||||
which is the instance generator:
|
||||
|
||||
```php
|
||||
$openpay = Openpay::getInstance('MERCHANT_ID', 'PRIVATE_KEY', 'COUNTRY_CODE', 'PUBLIC_IP');
|
||||
|
||||
// MERCHANT_ID = moiep6umtcnanql3jrxp
|
||||
// PRIVATE_KEY = sk_3433941e467c1055b178ce26348b0fac
|
||||
// COUNTRY_CODE = MX (México), CO (Colombia), PE (Peru)
|
||||
//PUBLIC_IP = 127.0.0.1 (Sustituir por tu ip publica)
|
||||
```
|
||||
|
||||
- Configure the Marchant ID, the Private Key and country code as well, as environment
|
||||
variables. This method has its own advantages as this sensitive data is not
|
||||
exposed directly in any script.
|
||||
|
||||
> NOTE: please, refer to PHP documentation for further information about this method.
|
||||
|
||||
|
||||
##### Sandbox/Production Mode #####
|
||||
|
||||
By convenience and security, the sandbox mode is activated by default in the
|
||||
client library. This allows you to test your own code when implementing
|
||||
Openpay, before charging any credit card in production environment. Once you
|
||||
have finished your integration, use the method **OpenPay::setProductionMode(FLAG)** which
|
||||
will allow you to active/inactivate the sandbox mode.
|
||||
|
||||
````php
|
||||
Openpay::setProductionMode(true);
|
||||
````
|
||||
Also you can use environment variables for this purpose:
|
||||
````
|
||||
SetEnv OPENPAY_PRODUCTION_MODE true
|
||||
````
|
||||
|
||||
If its necessary, you can use the method **Openpay::getProductionMode()** to
|
||||
determine anytime, which is the sandbox mode status:
|
||||
|
||||
````php
|
||||
// will return TRUE/FALSE, depending on if sandbox mode is activated or not.
|
||||
Openpay::getProductionMode();
|
||||
````
|
||||
|
||||
#### PHP client library intro #####
|
||||
|
||||
Once configured the library, you can use it to interact with Openpay API
|
||||
services. The first step is get an instance with the generator:
|
||||
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
````
|
||||
|
||||
In this example **$openpay** will be an instance of a merchant (root), wich
|
||||
will be used to call any derived child resource. According to the current version
|
||||
of the Openpay API, these resources are:
|
||||
|
||||
- customers
|
||||
- cards
|
||||
- charges
|
||||
- payouts
|
||||
- fees
|
||||
- plans
|
||||
|
||||
You can access all of these resources as public variables of the root instance,
|
||||
so, if you want to add a new customer you will be able to do it as follows:
|
||||
|
||||
````php
|
||||
$openpay->customers->add(PARAMETERS);
|
||||
````
|
||||
|
||||
Every call to any resource will return an instance of that resource. In the
|
||||
example above, calling the method **add()** in the resource **customers** will
|
||||
return an instance of Customer, calling the method **add()** in the resource **cards**
|
||||
will return an instance of Card, and so on. The only exception occurs when you retrieve
|
||||
a list of resources using the method **getList()**, in which case an array of
|
||||
instances will be returned:
|
||||
|
||||
````
|
||||
// a SINGLE instance of Customer will be returned
|
||||
$customer = $openpay->customers->add(PARAMETERS);
|
||||
|
||||
|
||||
// an ARRAY of instances of Customers will be returned
|
||||
customerList = $openpay->customers->getList(PARAMETERS);
|
||||
````
|
||||
|
||||
On the other hand, the resources derived from Customer, according to Openpay
|
||||
API documentation, are:
|
||||
|
||||
- cards
|
||||
- bankaccounts
|
||||
- charges
|
||||
- transfers
|
||||
- payouts
|
||||
- suscriptions
|
||||
|
||||
#### Parameters ####
|
||||
|
||||
Those methods which receive more than one parameter (for example, when trying
|
||||
to add a new customer or a new customer's card), must be passed
|
||||
as associatives arrays:
|
||||
|
||||
````php
|
||||
array('PARAMETER_INTEGER' => VALUE,
|
||||
'PARAMETER_STRING' => 'VALUE');
|
||||
'PARAMETER_DERIVED' => array('PARAMETER_INTEGER' => VALUE),
|
||||
'PARAMETER_STRING' => 'VALUE'));
|
||||
````
|
||||
|
||||
> NOTE: Please refer to Openpay API docuemntation to determine wich parameters
|
||||
> are accepted, wich required and which of those are optional, in every case.
|
||||
|
||||
|
||||
#### Error handling ####
|
||||
|
||||
The Openpay API generates several types of errors depending on the situation,
|
||||
to handle this, the PHP client has implemented five type of exceptions:
|
||||
|
||||
- **OpenpayApiTransactionError**. This category includes those errors ocurred when
|
||||
the transaction does not complete successfully: declined card, insufficient
|
||||
funds, inactive destination account, etc.
|
||||
- **OpenpayApiRequestError**. It refers to errors generated when a request to the
|
||||
API fail. Examples: invalid format in data request, incorrect parameters in
|
||||
the request, Openpay internal servers errors, etc.
|
||||
- **OpenpayApiConnectionError**. These exceptions are generated when the library
|
||||
try to connect to the API but fails in the attempt. For example: timeouts,
|
||||
domain name servers, etc.
|
||||
- **OpenpayApiAuthError**. Errors which are generated when the authentication
|
||||
data are specified in an invalid format or, if are not fully validated on
|
||||
the Openpay server (Merchant ID or Private Key).
|
||||
- **OpenpayApiError**. This category includes all generic errors when processing
|
||||
with the client library.
|
||||
|
||||
All these error exceptions make available all the information returned by the
|
||||
Openpay API, with the following methods:
|
||||
|
||||
- **getDescription()**: Error description generated by Openpay server.
|
||||
- **getErrorCode()**: Error code generated by Openpay server. When the error
|
||||
is generated before the request, this value is equal to zero.
|
||||
- **getCategory()**: Error category generated and determined by Openpay server.
|
||||
When the error is generated before or during the request, this value is an
|
||||
empty string.
|
||||
- **getHttpCode()**: HTTP error code generated when request the Openpay
|
||||
server. When the error is generated before or during the request, this
|
||||
value is equal to zero.
|
||||
- **getRequestId()**: ID generated by the Openpay server when process a
|
||||
request. When the error is generated before the request, this value is
|
||||
an empty string.
|
||||
|
||||
The following is an more complete example of error catching:
|
||||
|
||||
````php
|
||||
try {
|
||||
Openpay::setProductionMode(true);
|
||||
|
||||
// the following line will generate an error because the
|
||||
// private key is empty. The exception generated will be
|
||||
// a OpenpayApiAuthError
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', '', 'MX');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$customer->name = 'Juan';
|
||||
$customer->last_name = 'Godinez';
|
||||
$customer->save();
|
||||
|
||||
} catch (OpenpayApiTransactionError $e) {
|
||||
error_log('ERROR on the transaction: ' . $e->getMessage() .
|
||||
' [error code: ' . $e->getErrorCode() .
|
||||
', error category: ' . $e->getCategory() .
|
||||
', HTTP code: '. $e->getHttpCode() .
|
||||
', request ID: ' . $e->getRequestId() . ']', 0);
|
||||
|
||||
} catch (OpenpayApiRequestError $e) {
|
||||
error_log('ERROR on the request: ' . $e->getMessage(), 0);
|
||||
|
||||
} catch (OpenpayApiConnectionError $e) {
|
||||
error_log('ERROR while connecting to the API: ' . $e->getMessage(), 0);
|
||||
|
||||
} catch (OpenpayApiAuthError $e) {
|
||||
error_log('ERROR on the authentication: ' . $e->getMessage(), 0);
|
||||
|
||||
} catch (OpenpayApiError $e) {
|
||||
error_log('ERROR on the API: ' . $e->getMessage(), 0);
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('Error on the script: ' . $e->getMessage(), 0);
|
||||
}
|
||||
````
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
#### Customers ####
|
||||
|
||||
Add a new customer to a merchant:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customerData = array(
|
||||
'name' => 'Teofilo',
|
||||
'last_name' => 'Velazco',
|
||||
'email' => 'teofilo@payments.com',
|
||||
'phone_number' => '4421112233',
|
||||
'address' => array(
|
||||
'line1' => 'Privada Rio No. 12',
|
||||
'line2' => 'Co. El Tintero',
|
||||
'line3' => '',
|
||||
'postal_code' => '76920',
|
||||
'state' => 'Querétaro',
|
||||
'city' => 'Querétaro.',
|
||||
'country_code' => 'MX'));
|
||||
|
||||
$customer = $openpay->customers->add($customerData);
|
||||
````
|
||||
|
||||
Get a customer:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
````
|
||||
|
||||
Get the list of customers:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
|
||||
$customerList = $openpay->customers->getList($findData);
|
||||
````
|
||||
|
||||
Update a customer:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$customer->name = 'Juan';
|
||||
$customer->last_name = 'Godinez';
|
||||
$customer->save();
|
||||
````
|
||||
|
||||
Delete a customer:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$customer->delete();
|
||||
````
|
||||
|
||||
|
||||
#### Cards ####
|
||||
|
||||
**On a merchant:**
|
||||
|
||||
Add a card:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$cardData = array(
|
||||
'holder_name' => 'Luis Pérez',
|
||||
'card_number' => '4111111111111111',
|
||||
'cvv2' => '123',
|
||||
'expiration_month' => '12',
|
||||
'expiration_year' => '15',
|
||||
'address' => array(
|
||||
'line1' => 'Av. 5 de Febrero No. 1',
|
||||
'line2' => 'Col. Felipe Carrillo Puerto',
|
||||
'line3' => 'Zona industrial Carrillo Puerto',
|
||||
'postal_code' => '76920',
|
||||
'state' => 'Querétaro',
|
||||
'city' => 'Querétaro',
|
||||
'country_code' => 'MX'));
|
||||
|
||||
$card = $openpay->cards->add($cardData);
|
||||
````
|
||||
|
||||
Get a card:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$card = $openpay->cards->get('k9pn8qtsvr7k7gxoq1r5');
|
||||
````
|
||||
|
||||
Get the list of cards:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
|
||||
$cardList = $openpay->cards->getList($findData);
|
||||
````
|
||||
|
||||
Delete a card:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$card = $openpay->cards->get('k9pn8qtsvr7k7gxoq1r5');
|
||||
$card->delete();
|
||||
````
|
||||
|
||||
**On a customer:**
|
||||
|
||||
Add a card:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$cardData = array(
|
||||
'holder_name' => 'Teofilo Velazco',
|
||||
'card_number' => '4916394462033681',
|
||||
'cvv2' => '123',
|
||||
'expiration_month' => '12',
|
||||
'expiration_year' => '15',
|
||||
'address' => array(
|
||||
'line1' => 'Privada Rio No. 12',
|
||||
'line2' => 'Co. El Tintero',
|
||||
'line3' => '',
|
||||
'postal_code' => '76920',
|
||||
'state' => 'Querétaro',
|
||||
'city' => 'Querétaro.',
|
||||
'country_code' => 'MX'));
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$card = $customer->cards->add($cardData);
|
||||
````
|
||||
|
||||
Get a card:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$card = $customer->cards->get('k9pn8qtsvr7k7gxoq1r5');
|
||||
````
|
||||
|
||||
Get the list of cards:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$cardList = $customer->cards->getList($findData);
|
||||
````
|
||||
|
||||
Delete a card
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$card = $customer->cards->get('k9pn8qtsvr7k7gxoq1r5');
|
||||
$card->delete();
|
||||
````
|
||||
|
||||
|
||||
#### Bank Accounts ####
|
||||
|
||||
Add a bank account to a customer:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$bankData = array(
|
||||
'clabe' => '072910007380090615',
|
||||
'alias' => 'Cuenta principal',
|
||||
'holder_name' => 'Teofilo Velazco');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$bankaccount = $customer->bankaccounts->add($bankData);
|
||||
````
|
||||
|
||||
Get a banck account
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$bankaccount = $customer->bankaccounts->get('b4vcouaavwuvkpufh0so');
|
||||
````
|
||||
|
||||
Get the list of bank accounts:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$bankaccountList = $customer->bankaccounts->getList($findData);
|
||||
````
|
||||
|
||||
Delete a bank account:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$bankaccount = $customer->bankaccounts->get('b4vcouaavwuvkpufh0so');
|
||||
$bankaccount->delete();
|
||||
````
|
||||
|
||||
|
||||
#### Charges ####
|
||||
|
||||
**On a Merchant:**
|
||||
|
||||
Make a charge on a merchant:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$chargeData = array(
|
||||
'method' => 'card',
|
||||
'source_id' => 'krfkkmbvdk3hewatruem',
|
||||
'amount' => 100,
|
||||
'description' => 'Cargo inicial a mi merchant',
|
||||
'order_id' => 'ORDEN-00071');
|
||||
|
||||
$charge = $openpay->charges->create($chargeData);
|
||||
````
|
||||
|
||||
Get a charge:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$charge = $openpay->charges->get('tvyfwyfooqsmfnaprsuk');
|
||||
````
|
||||
|
||||
Get list of charges:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
|
||||
$chargeList = $openpay->charges->getList($findData);
|
||||
````
|
||||
|
||||
Make a capture:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$captureData = array('amount' => 150.00 );
|
||||
|
||||
$charge = $openpay->charges->get('tvyfwyfooqsmfnaprsuk');
|
||||
$charge->capture($captureData);
|
||||
````
|
||||
|
||||
Make a refund:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$refundData = array('description' => 'Devolución' );
|
||||
|
||||
$charge = $openpay->charges->get('tvyfwyfooqsmfnaprsuk');
|
||||
$charge->refund($refundData);
|
||||
````
|
||||
|
||||
**On a Customer:**
|
||||
|
||||
Make a charge on a customer:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$chargeData = array(
|
||||
'source_id' => 'tvyfwyfooqsmfnaprsuk',
|
||||
'method' => 'card',
|
||||
'amount' => 100,
|
||||
'description' => 'Cargo inicial a mi cuenta',
|
||||
'order_id' => 'ORDEN-00070');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$charge = $customer->charges->create($chargeData);
|
||||
````
|
||||
|
||||
Get a charge:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$charge = $customer->charges->get('tvyfwyfooqsmfnaprsuk');
|
||||
````
|
||||
|
||||
Get list of charges:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$chargeList = $customer->charges->getList($findData);
|
||||
````
|
||||
|
||||
Make a capture:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$captureData = array('amount' => 150.00 );
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$charge = $customer->charges->get('tvyfwyfooqsmfnaprsuk');
|
||||
$charge->capture($captureData);
|
||||
````
|
||||
|
||||
Make a refund:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$refundData = array('description' => 'Reembolso' );
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$charge = $customer->charges->get('tvyfwyfooqsmfnaprsuk');
|
||||
$charge->refund($refundData);
|
||||
````
|
||||
|
||||
|
||||
#### Transfers ####
|
||||
|
||||
Make a transfer:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$transferData = array(
|
||||
'customer_id' => 'aqedin0owpu0kexr2eor',
|
||||
'amount' => 12.50,
|
||||
'description' => 'Cobro de Comisión',
|
||||
'order_id' => 'ORDEN-00061');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$transfer = $customer->transfers->create($transferData);
|
||||
````
|
||||
|
||||
Get a transfer:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$transfer = $customer->transfers->get('tyxesptjtx1bodfdjmlb');
|
||||
````
|
||||
|
||||
Get list of transfers:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$transferList = $customer->transfers->getList($findData);
|
||||
````
|
||||
|
||||
|
||||
#### Payouts ####
|
||||
|
||||
**On a Merchant:**
|
||||
|
||||
Make a payout on a merchant:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$payoutData = array(
|
||||
'method' => 'card',
|
||||
'destination_id' => 'krfkkmbvdk3hewatruem',
|
||||
'amount' => 500,
|
||||
'description' => 'Retiro de saldo semanal',
|
||||
'order_id' => 'ORDEN-00072');
|
||||
|
||||
$payout = $openpay->payouts->create($payoutData);
|
||||
````
|
||||
|
||||
Get a payout:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$payout = $openpay->payouts->get('t4tzkjspndtj9bnsop2i');
|
||||
````
|
||||
|
||||
Get list of payouts:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
|
||||
$payoutList = $openpay->payouts->getList($findData);
|
||||
````
|
||||
|
||||
**On a Customer:**
|
||||
|
||||
Make a payout on a customer:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$payoutData = array(
|
||||
'method' => 'card',
|
||||
'destination_id' => 'k9pn8qtsvr7k7gxoq1r5',
|
||||
'amount' => 1000,
|
||||
'description' => 'Retiro de saldo semanal',
|
||||
'order_id' => 'ORDEN-00062');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$payout = $customer->payouts->create($payoutData);
|
||||
````
|
||||
|
||||
Get a payout:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$payout = $customer->payouts->get('tysznlyigrkwnks6eq2c');
|
||||
````
|
||||
|
||||
Get list pf payouts:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$payoutList = $customer->payouts->getList($findData);
|
||||
````
|
||||
|
||||
|
||||
#### Fees ####
|
||||
|
||||
Make a fee charge
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$feeData = array(
|
||||
'customer_id' => 'a9ualumwnrcxkl42l6mh',
|
||||
'amount' => 12.50,
|
||||
'description' => 'Cobro de Comisión',
|
||||
'order_id' => 'ORDEN-00063');
|
||||
|
||||
$fee = $openpay->fees->create($feeData);
|
||||
````
|
||||
|
||||
Get list of fees charged:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
|
||||
$feeList = $openpay->fees->getList($findData);
|
||||
````
|
||||
|
||||
|
||||
#### Plans ####
|
||||
|
||||
Add a plan:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$planData = array(
|
||||
'amount' => 150.00,
|
||||
'status_after_retry' => 'cancelled',
|
||||
'retry_times' => 2,
|
||||
'name' => 'Plan Curso Verano',
|
||||
'repeat_unit' => 'month',
|
||||
'trial_days' => '30',
|
||||
'repeat_every' => '1',
|
||||
'currency' => 'MXN');
|
||||
|
||||
$plan = $openpay->plans->add($planData);
|
||||
````
|
||||
|
||||
Get a plan:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$plan = $openpay->plans->get('pduar9iitv4enjftuwyl');
|
||||
````
|
||||
|
||||
Get list of plans:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
|
||||
$planList = $openpay->plans->getList($findData);
|
||||
````
|
||||
|
||||
Update a plan:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$plan = $openpay->plans->get('pduar9iitv4enjftuwyl');
|
||||
$plan->name = 'Plan Curso de Verano 2014';
|
||||
$plan->save();
|
||||
````
|
||||
|
||||
Delete a plan:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$plan = $openpay->plans->get('pduar9iitv4enjftuwyl');
|
||||
$plan->delete();
|
||||
````
|
||||
|
||||
Get list of subscriptors of a plan:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
|
||||
$plan = $openpay->plans->get($planId);
|
||||
$subscriptionList = $plan->subscriptions->getList($findData);
|
||||
````
|
||||
|
||||
|
||||
#### Subscriptions ####
|
||||
|
||||
Add a subscription:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$subscriptionData = array(
|
||||
"trial_end_date":"2014-01-01",
|
||||
'plan_id' => 'pduar9iitv4enjftuwyl',
|
||||
'card_id' => 'konvkvcd5ih8ta65umie');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$subscription = $customer->subscriptions->add($subscriptionData);
|
||||
````
|
||||
See [documetation](http://docs.openpay.mx/#suscripciones$agregar-con-registrada) for more detail, creating subscriptions.
|
||||
|
||||
Get a subscription:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$subscription = $customer->subscriptions->get('s7ri24srbldoqqlfo4vp');
|
||||
````
|
||||
|
||||
Get list of subscriptions:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$findData = array(
|
||||
'creation[gte]' => '2013-01-01',
|
||||
'creation[lte]' => '2013-12-31',
|
||||
'offset' => 0,
|
||||
'limit' => 5);
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$subscriptionList = $customer->subscriptions->getList($findData);
|
||||
````
|
||||
|
||||
Update a subscription:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$subscription = $customer->subscriptions->get('s7ri24srbldoqqlfo4vp');
|
||||
$subscription->trial_end_date = '2014-12-31';
|
||||
$subscription->save();
|
||||
````
|
||||
|
||||
Delete a subscription:
|
||||
````php
|
||||
$openpay = Openpay::getInstance('moiep6umtcnanql3jrxp', 'sk_3433941e467c1055b178ce26348b0fac', 'MX', '127.0.0.1');
|
||||
|
||||
$customer = $openpay->customers->get('a9ualumwnrcxkl42l6mh');
|
||||
$subscription = $customer->subscriptions->get('s7ri24srbldoqqlfo4vp');
|
||||
$subscription->delete();
|
||||
````
|
||||
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "openpay/sdk",
|
||||
"description": "This is a client implementing the payment services for Openpay at openpay.mx",
|
||||
"type": "library",
|
||||
"minimum-stability": "dev",
|
||||
"license": "Apache-2.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Openpay",
|
||||
"homepage": "https://www.openpay.mx/",
|
||||
"email": "soporte@openpay.mx"
|
||||
},
|
||||
{
|
||||
"name": "Federico Balderas",
|
||||
"homepage": "https://openpay.mx/",
|
||||
"email": "plugins@openpay.mx"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.2.1",
|
||||
"ext-curl": "*",
|
||||
"ext-hash": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.8.*"
|
||||
},
|
||||
"support": {
|
||||
"issues": "https://github.com/open-pay/openpay-php/issues"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Openpay\\": "Openpay/"
|
||||
}
|
||||
}
|
||||
}
|
||||
+1168
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user