PHPackages                             degaray/openpay-magento2-module - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. degaray/openpay-magento2-module

ActiveMagento2-module[Payment Processing](/categories/payments)

degaray/openpay-magento2-module
===============================

OpenPay module for Magento2, a payment gateway in Mexico

3591[1 issues](https://github.com/degaray/openpay-magento2-module/issues)PHP

Since Jun 22Pushed 9y agoCompare

[ Source](https://github.com/degaray/openpay-magento2-module)[ Packagist](https://packagist.org/packages/degaray/openpay-magento2-module)[ RSS](/packages/degaray-openpay-magento2-module/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (2)Used By (0)

At the moment this module is only thought to be used as one for Magento2 and using its rest API. However you are always welcome to develop a controller or additional functionality to it.

How to use this module:

Configure OpenPay Payment keys.
-------------------------------

[](#configure-openpay-payment-keys)

Enter into Magento2 admin panel and go to `Stores > Configuration > Sales > Payment Methods > OpenPay` and **enable** the payment method, then enter all the information provided by OpenPay in the correct fields. Also select **yes** from `Modo pruebas (Sandbox)` if you want to use sandbox credentials or **no** if you want to use production credentials.

Create a card
-------------

[](#create-a-card)

In order to create a card, first you will need to create a card token [see how](http://www.openpay.mx/docs/openpayjs.html) as well as a device session id [see how](http://www.openpay.mx/en/docs/fraud-tool.html) in the frontend.

Then you can either create the card at the time of creating a new customer \[POST\] or by updating the customer \[PUT\]. In any case all you will need to do is send an additional `Card` object as an `extension_attribute`. The only way to create a card using this module is by token. So you need to send a blank `Card` object filling only the `token` and the `device_session_id`.

> **Note:** This module looks for all the new tokens sent as part of the `extension_attributes` and it creates the cards according those tokens.

Here are two examples of how to create a card, one using the POST call and another using a PUT call:

### `[POST] /rest/v1/customers`

[](#post-restv1customers)

### Request

[](#request)

**Body:**

```
{
    "customer": {
        "email": "example@domain.com",
        "firstname": "Pedro",
        "lastname": "Juárez",
        "storeId": 1,
        "websiteId": 1,
        "addresses": [
            {
                "country_id": "MX",
                "street": [
                  "Some address 23"
                ],
                "telephone": "5555555558",
                "postcode": "09823",
                "city": "México",
                "firstname": "Pedro",
                "lastname": "Juárez",
                "default_shipping": true,
                "default_billing": true
            }
        ],
        "extension_attributes": {
          "openpay_card": [
            {
              "token": null,
              "device_session_id": null
          ]
        }
    },
    "password": "a_Wi3rd_P4zzw0rt"
}

```

### Response

[](#response)

```
{
  "id": 1,
  "group_id": 1,
  "default_billing": "1",
  "default_shipping": "1",
  "created_at": "2015-12-15 00:44:20",
  "updated_at": "2016-01-04 22:19:24",
  "created_in": "Default Store View",
  "email": "example@domain.com",
  "firstname": "Pedro",
  "lastname": "Juárez",
  "store_id": 1,
  "website_id": 1,
  "addresses": [
    {
      "id": 1,
      "customer_id": 1,
      "region": {
        "region_code": null,
        "region": null,
        "region_id": 0
      },
      "region_id": 0,
      "country_id": "MX",
      "street": [
        "Some address 23"
      ],
      "telephone": "5555555558",
      "postcode": "09823",
      "city": "México",
      "firstname": "Pedro",
      "lastname": "Juárez",
      "default_shipping": true,
      "default_billing": true
    }
  ],
  "disable_auto_group_change": 0,
  "extension_attributes": {
    "openpay_card": [
      {
        "customer_id": "atxdxf8dtsfiqj6jlykp",
        "card_id": "krotlgka8xqeebtxpjf9",
        "created_at": "2016-01-04T16:18:32-06:00",
        "updated_at": null,
        "token": null,
        "device_session_id": null,
        "type": "debit",
        "brand": "visa",
        "card_number": "411111XXXXXX1111",
        "holder_name": "Pedro Juarez Ramirez",
        "expiration_year": "20",
        "expiration_month": "12",
        "allows_charges": false,
        "allows_payouts": true,
        "bank_name": "Banamex",
        "bank_code": "002",
        "address": {
          "city": "Querétaro",
          "country_code": "MX",
          "line1": "Av 5 de Febrero",
          "line2": "Roble 207",
          "line3": "col carrillo",
          "postal_code": "76900",
          "state": "Queretaro"
        }
      }
    ]
  },
  "custom_attributes": [
    {
      "attribute_code": "openpay_customer_id",
      "value": "atxdxfodtsfiqj4jlykp"
    }
  ]
}

```

### `[PUT] /rest/v1/customers/me`

[](#put-restv1customersme)

### Request

[](#request-1)

**Body:**

```
{
    "customer": {
        "id": 1,
        "email": "example@domain.com",
        "firstname": "Pedro",
        "lastname": "Juárez",
        "storeId": 1,
        "websiteId": 1,
        "addresses": [
            {
                "country_id": "MX",
                "street": [
                  "Some address 23"
                ],
                "telephone": "5555555558",
                "postcode": "09823",
                "city": "México",
                "firstname": "Pedro",
                "lastname": "Juárez",
                "default_shipping": true,
                "default_billing": true
            }
        ],
        "extension_attributes": {
          "openpay_card": [
            {
              "token": null,
              "device_session_id": null
            }
          ]
        }
    }
}

```

### Response

[](#response-1)

```
{
  "id": 1,
  "group_id": 1,
  "default_billing": "1",
  "default_shipping": "1",
  "created_at": "2015-12-15 00:44:20",
  "updated_at": "2016-01-04 22:19:24",
  "created_in": "Default Store View",
  "email": "example@domain.com",
  "firstname": "Pedro",
  "lastname": "Juárez",
  "store_id": 1,
  "website_id": 1,
  "addresses": [
    {
      "id": 1,
      "customer_id": 1,
      "region": {
        "region_code": null,
        "region": null,
        "region_id": 0
      },
      "region_id": 0,
      "country_id": "MX",
      "street": [
        "Some address 23"
      ],
      "telephone": "5555555558",
      "postcode": "09823",
      "city": "México",
      "firstname": "Pedro",
      "lastname": "Juárez",
      "default_shipping": true,
      "default_billing": true
    }
  ],
  "disable_auto_group_change": 0,
  "extension_attributes": {
    "openpay_card": [
      {
        "customer_id": "atxdxf8dtsfiqj6jlykp",
        "card_id": "krotlgka8xqeebtxpjf9",
        "created_at": "2016-01-04T16:18:32-06:00",
        "updated_at": null,
        "token": null,
        "device_session_id": null,
        "type": "debit",
        "brand": "visa",
        "card_number": "411111XXXXXX1111",
        "holder_name": "Pedro Juarez Ramirez",
        "expiration_year": "20",
        "expiration_month": "12",
        "allows_charges": false,
        "allows_payouts": true,
        "bank_name": "Banamex",
        "bank_code": "002",
        "address": {
          "city": "Querétaro",
          "country_code": "MX",
          "line1": "Av 5 de Febrero",
          "line2": "Roble 207",
          "line3": "col carrillo",
          "postal_code": "76900",
          "state": "Queretaro"
        }
      }
    ]
  },
  "custom_attributes": [
    {
      "attribute_code": "openpay_customer_id",
      "value": "atxdxfodtsfiqj4jlykp"
    }
  ]
}

```

Delete a card
-------------

[](#delete-a-card)

In order to delete a card, you will need to suppress the card from your PUT call and the module will infere you are trying to delete that card.

> **Note:** This module looks for all the cards sent as part of the `customers` `extension_attributes` and it compares them with the previous cards that were saved. If an existing card is not present in your request, the module will delete such a card.

Here you can find an example for deleting a card:

### `[PUT] /rest/v1/customers/me`

[](#put-restv1customersme-1)

### Request

[](#request-2)

**Body:**

```
{
  "customer": {
    "id": 1,
    "email": "example@domain.com",
    "firstname": "Pedro",
    "lastname": "Juárez",
    "storeId": 1,
    "websiteId": 1,
    "addresses": [
      {
        "country_id": "MX",
        "street": [
          "Some address 23"
        ],
        "telephone": "5555555558",
        "postcode": "09823",
        "city": "México",
        "firstname": "Pedro",
        "lastname": "Juárez",
        "default_shipping": true,
        "default_billing": true
      }
    ],
    "extension_attributes": {
      "openpay_card": []
    },
    "custom_attributes": [
      {
        "attribute_code": "openpay_customer_id",
        "value": "atxdxfodtsfiqj4jlykp"
      }
    ]
  }
}

```

### Response

[](#response-2)

```
{
  "id": 1,
  "group_id": 1,
  "default_billing": "1",
  "default_shipping": "1",
  "created_at": "2015-12-15 00:44:20",
  "updated_at": "2016-01-04 22:19:24",
  "created_in": "Default Store View",
  "email": "example@domain.com",
  "firstname": "Pedro",
  "lastname": "Juárez",
  "store_id": 1,
  "website_id": 1,
  "addresses": [
    {
      "id": 1,
      "customer_id": 1,
      "region": {
        "region_code": null,
        "region": null,
        "region_id": 0
      },
      "region_id": 0,
      "country_id": "MX",
      "street": [
        "Some address 23"
      ],
      "telephone": "5555555558",
      "postcode": "09823",
      "city": "México",
      "firstname": "Pedro",
      "lastname": "Juárez",
      "default_shipping": true,
      "default_billing": true
    }
  ],
  "disable_auto_group_change": 0,
  "extension_attributes": {
    "openpay_card": []
  },
  "custom_attributes": [
    {
      "attribute_code": "openpay_customer_id",
      "value": "atxdxfodtsfiqj4jlykp"
    }
  ]
}

```

Obtain a customer cards
-----------------------

[](#obtain-a-customer-cards)

In order to get all the cards of a given customer, you will need to make a \[GET\] request to bring the customer and the response will include all of the customer's cards inside the `extension_attributes`.

### `[GET] /rest/v1/customers/me`

[](#get-restv1customersme)

### Response

[](#response-3)

```
{
  "id": 1,
  "group_id": 1,
  "default_billing": "1",
  "default_shipping": "1",
  "created_at": "2015-12-15 00:44:20",
  "updated_at": "2016-01-04 22:19:24",
  "created_in": "Default Store View",
  "email": "example@domain.com",
  "firstname": "Pedro",
  "lastname": "Juárez",
  "store_id": 1,
  "website_id": 1,
  "addresses": [
    {
      "id": 1,
      "customer_id": 1,
      "region": {
        "region_code": null,
        "region": null,
        "region_id": 0
      },
      "region_id": 0,
      "country_id": "MX",
      "street": [
        "Some address 23"
      ],
      "telephone": "5555555558",
      "postcode": "09823",
      "city": "México",
      "firstname": "Pedro",
      "lastname": "Juárez",
      "default_shipping": true,
      "default_billing": true
    }
  ],
  "disable_auto_group_change": 0,
  "extension_attributes": {
    "openpay_card": [
      {
        "customer_id": "atxdxf8dtsfiqj6jlykp",
        "card_id": "krotlgka8xqeebtxpjf9",
        "created_at": "2016-01-04T16:18:32-06:00",
        "updated_at": null,
        "token": null,
        "device_session_id": null,
        "type": "debit",
        "brand": "visa",
        "card_number": "411111XXXXXX1111",
        "holder_name": "Pedro Juarez Ramirez",
        "expiration_year": "20",
        "expiration_month": "12",
        "allows_charges": false,
        "allows_payouts": true,
        "bank_name": "Banamex",
        "bank_code": "002",
        "address": {
          "city": "Querétaro",
          "country_code": "MX",
          "line1": "Av 5 de Febrero",
          "line2": "Roble 207",
          "line3": "col carrillo",
          "postal_code": "76900",
          "state": "Queretaro"
        }
      }
    ]
  },
  "custom_attributes": [
    {
      "attribute_code": "openpay_customer_id",
      "value": "atxdxfodtsfiqj4jlykp"
    }
  ]
}

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f7b2f03640075b247cb33b68041e6666dbbba4dddc617f7d91ac2cdb30ff740?d=identicon)[degaray](/maintainers/degaray)

---

Top Contributors

[![degaray](https://avatars.githubusercontent.com/u/3189403?v=4)](https://github.com/degaray "degaray (126 commits)")

### Embed Badge

![Health badge](/badges/degaray-openpay-magento2-module/health.svg)

```
[![Health](https://phpackages.com/badges/degaray-openpay-magento2-module/health.svg)](https://phpackages.com/packages/degaray-openpay-magento2-module)
```

###  Alternatives

[omnipay/coinbase

Coinbase driver for the Omnipay payment processing library

18570.2k1](/packages/omnipay-coinbase)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
