Casos de Usos


Introducción

En esta sección se une todo lo anterior para exponer ejemplos más concretos de los casos más comunes que se podrían tener como un comercio utilizando el SDK.

Realizar cobros / Venta directa

Los cobros son una forma segura de pagar usando PixelPay sin ser redirigidos a otro sitio web o ver el modal de pago.

Existen dos maneras de realizar un pago:

  • Agregar al objeto de transacción Sale, una compra (Order), tarjeta (Card) y un billing (Billing).
  • Agregar al objeto de transacción Sale, una compra (Order) y una tarjeta tokenizada.

Transacción con Tarjeta sin Tokenización (Dispositivos Móviles)

import PixelPaySDK // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado let settings = Settings() settings.setupEndpoint(endpoint: "https://{endpoint}") settings.setupCredentials(key: "2222222222", hash: "elhashmd5delsecretkeydelcomercio") let card = Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" let billing = Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" let item = Item() item.code = "00001" item.title = "Videojuego" item.price = 800 item.qty = 1 let order = Order() order.id = "ORDER-12948" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item: item) let sale = SaleTransaction() // sale.withAuthenticationRequest() en caso de solicitar transacciones con protección 3DSecure. sale.setOrder(order: order) sale.setCard(card: card) sale.setBilling(billing: billing) let service = Transaction(settings: settings) do { try service.doSale(transaction: sale) { response in if TransactionResult.validateResponse(response: response) { let result = TransactionResult.fromResponse(response: response) let valid_payment = service.verifyPaymentHash( hash: result.payment_hash, order_id: sale.order_id, secret: "abc..." ) if valid_payment { // SUCCESS Valid Payment } } } } catch { // ERROR } import com.pixel.sdk.models.Item import com.pixel.sdk.models.Order import com.pixel.sdk.models.Settings import com.pixel.sdk.models.Card import com.pixel.sdk.models.Billing import com.pixel.sdk.entities.TransactionResult import com.pixel.sdk.requests.SaleTransaction import com.pixel.sdk.mobile.services.Transaction // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado val settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") val card = Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" val billing = Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" val item = Item() item.code = "00001" item.title = "Videojuego" item.price = 800.0 item.qty = 1 val order = Order() order.id = "ORDER-12948" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) val sale = SaleTransaction() // sale.withAuthenticationRequest() en caso de solicitar transacciones con protección 3DSecure. sale.setOrder(order) sale.setCard(card) sale.setBilling(billing) // enviamos el current activity como segundo parametro val service = Transaction(settings, this) try { service.doSale(sale).then { if (TransactionResult.validateResponse(it)) { val result = TransactionResult.fromResponse(it) if (service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")) { // SUCCESS Payment } } else { System.out.println(it.message); } }.thenCatch { it.printStackTrace() } } catch (e: Exception) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Item; import com.pixel.sdk.models.Order; import com.pixel.sdk.models.Settings; import com.pixel.sdk.models.Card; import com.pixel.sdk.models.Billing; import com.pixel.sdk.entities.TransactionResult; import com.pixel.sdk.requests.SaleTransaction; import com.pixel.sdk.mobile.services.Transaction; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); Card card = new Card(); card.number = "4111111111111111"; card.cvv2 = "999"; card.expire_month = 7; card.expire_year = 2023; card.cardholder = "SERGIO PEREZ"; Billing billing = new Billing(); billing.address = "Ave Circunvalacion"; billing.country = "HN"; billing.state = "HN-CR"; billing.city = "San Pedro Sula"; billing.phone = "99999999"; Item item = new Item(); item.code = "00001"; item.title = "Videojuego"; item.price = 800; item.qty = 1; Order order = new Order(); order.id = "ORDER-12948"; order.currency = "HNL"; order.customer_name = "SERGIO PEREZ"; order.customer_email = "sergio.perez@gmail.com"; order.addItem(item); SaleTransaction sale = new SaleTransaction(); sale.setOrder(order); sale.setCard(card); sale.setBilling(billing); // enviamos el current activity como segundo parametro Transaction service = new Transaction(settings, this); service.doSale(sale).then(response -> { if (TransactionResult.validateResponse(response)) { TransactionResult result = TransactionResult.fromResponse(response); if (service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")) { // SUCCESS Payment } } }).thenCatch(err -> { // ERROR }).start(); import 'package:pixelpay_sdk/models/item.dart' as pixelpay; import 'package:pixelpay_sdk/models/order.dart' as pixelpay; import 'package:pixelpay_sdk/models/settings.dart' as pixelpay; import 'package:pixelpay_sdk/models/card.dart' as pixelpay; import 'package:pixelpay_sdk/models/billing.dart' as pixelpay; import 'package:pixelpay_sdk/entities/transaction_result.dart' as pixelpay; import 'package:pixelpay_sdk/requests/sale_transaction.dart' as pixelpay; import 'package:pixelpay_sdk/services/transaction.dart' as pixelpay; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado final settings = pixelpay.Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); final card = pixelpay.Card(); card.number = "4111111111111111"; card.cvv2 = "999"; card.expire_month = 7; card.expire_year = 2023; card.cardholder = "SERGIO PEREZ"; final billing = pixelpay.Billing(); billing.address = "Ave Circunvalacion"; billing.city = "San Pedro Sula"; billing.country = "HN"; billing.state = "HN-CR"; billing.phone = "99999999"; final item = pixelpay.Item(); item.code = "00001"; item.title = "Videojuego"; item.price = 800; item.qty = 1; final order = pixelpay.Order(); order.id = "ORDER-12948"; order.customer_name = "SERGIO PEREZ"; order.currency = "HNL"; order.customer_email = "sergio.perez@gmail.com"; order.addItem(item); final sale = pixelpay.SaleTransaction(); sale.setCard(card); sale.setBilling(billing); sale.setOrder(order); final service = pixelpay.Transaction(settings); final response = await service.doSale(sale); if (pixelpay.TransactionResult.validateResponse(response!)) { // SUCCESS } else { // ERROR } import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import Card from "@pixelpay/sdk-core/lib/models/Card"; import Billing from "@pixelpay/sdk-core/lib/models/Billing"; import Item from "@pixelpay/sdk-core/lib/models/Item"; import Order from "@pixelpay/sdk-core/lib/models/Order"; import SaleTransaction from "@pixelpay/sdk-core/lib/requests/SaleTransaction"; import TransactionResult from "@pixelpay/sdk-core/lib/entities/TransactionResult"; import { Transaction } from '@pixelpay/capacitor-plugin'; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const item = new Item() item.code = "00001" item.title = "Videojuego" item.price = 800 item.qty = 1 const order = new Order() order.id = "ORDER-88888" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) const sale = new SaleTransaction() sale.setOrder(order) sale.setCard(card) sale.setBilling(billing) const service = new Transaction(settings) // with async / await try { const response = await service.doSale(sale) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const validPayment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (validPayment) { // SUCCESS Valid Payment } } } catch (error) { // ERROR } // with callback service.doSale(sale).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const validPayment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (validPayment) { // SUCCESS Valid Payment } } }).catch((error) => { // ERROR })

Transacción con Tarjeta sin Tokenización (Legacy)

import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import Card from "@pixelpay/sdk-core/lib/models/Card"; import Billing from "@pixelpay/sdk-core/lib/models/Billing"; import Item from "@pixelpay/sdk-core/lib/models/Item"; import Order from "@pixelpay/sdk-core/lib/models/Order"; import SaleTransaction from "@pixelpay/sdk-core/lib/requests/SaleTransaction"; import Transaction from "@pixelpay/sdk-core/lib/services/Transaction"; import TransactionResult from "@pixelpay/sdk-core/lib/entities/TransactionResult"; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const item = new Item() item.code = "00001" item.title = "Videojuego" item.price = 800 item.qty = 1 const order = new Order() order.id = "ORDER-88888" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) const sale = new SaleTransaction() sale.setOrder(order) sale.setCard(card) sale.setBilling(billing) const service = new Transaction(settings) // with async / await try { const response = await service.doSale(sale) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const validPayment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (validPayment) { // SUCCESS Valid Payment } } } catch (error) { // ERROR } // with callback service.doSale(sale).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const validPayment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (validPayment) { // SUCCESS Valid Payment } } }).catch((error) => { // ERROR }) <?php use PixelPay\Sdk\Base\Response; use PixelPay\sdk\Models\Settings; use PixelPay\sdk\Models\Card; use PixelPay\sdk\Models\Billing; use PixelPay\sdk\Models\Item; use PixelPay\sdk\Models\Order; use PixelPay\sdk\Requests\SaleTransaction; use PixelPay\sdk\Services\Transaction; use PixelPay\sdk\Entities\TransactionResult; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado $settings = new Settings(); $settings->setupEndpoint("https://{endpoint}"); $settings->setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); $card = new Card(); $card->number = "4111111111111111"; $card->cvv2 = "999"; $card->expire_month = 7; $card->expire_year = 2023; $card->cardholder = "SERGIO PEREZ"; $billing = new Billing(); $billing->address = "Ave Circunvalacion"; $billing->country = "HN"; $billing->state = "HN-CR"; $billing->city = "San Pedro Sula"; $billing->phone = "99999999"; $item = new Item(); $item->code = "00001"; $item->title = "Videojue;go"; $item->price = 800; $item->qty = 1; $order = new Order(); $order->id = "ORDER-88888"; $order->currency = "HNL"; $order->customer_name = "SERGIO PEREZ"; $order->customer_email = "sergio.perez@gmail.com"; $order->addItem($item); $sale = new SaleTransaction(); $sale->setOrder($order); $sale->setCard($card); $sale->setBilling($billing); $service = new Transaction($settings); try { $response = $service->doSale($sale); if (TransactionResult::validateResponse($response)) { $result = TransactionResult::fromResponse($response); $is_valid = $service->verifyPaymentHash( $result->payment_hash, $order->id, "abc...", // secret ); if ($valid_payment) { // SUCCESS Valid Payment } } else { // CHECK Failed Response echo $response->message; } } catch ( Exception $e) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Item; import com.pixel.sdk.models.Order; import com.pixel.sdk.models.Settings; import com.pixel.sdk.models.Card; import com.pixel.sdk.models.Billing; import com.pixel.sdk.entities.TransactionResult; import com.pixel.sdk.requests.SaleTransaction; import com.pixel.sdk.services.Transaction; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); Card card = new Card(); card.number = "4111111111111111"; card.cvv2 = "999"; card.expire_month = 7; card.expire_year = 2023; card.cardholder = "SERGIO PEREZ"; Billing billing = new Billing(); billing.address = "Ave Circunvalacion"; billing.country = "HN"; billing.state = "HN-CR"; billing.city = "San Pedro Sula"; billing.phone = "99999999"; Item item = new Item(); item.code = "00001"; item.title = "Videojuego"; item.price = 800; item.qty = 1; Order order = new Order(); order.id = "ORDER-12948"; order.currency = "HNL"; order.customer_name = "SERGIO PEREZ"; order.customer_email = "sergio.perez@gmail.com"; order.addItem(item); SaleTransaction sale = new SaleTransaction(); sale.setOrder(order); sale.setCard(card); sale.setBilling(billing); // enviamos el current activity como segundo parametro Transaction service = new Transaction(settings, this); try { service.doSale(sale); if (TransactionResult.validateResponse(response)) { TransactionResult result = TransactionResult.fromResponse(response); if (service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")) { // SUCCESS Payment } } } catch(Exception e) { // ERROR } from pixelpay.services import Transaction from pixelpay.models import Item, Order, Settings, Card, Billing from pixelpay.requests import SaleTransaction from pixelpay.entities import TransactionResult try: settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") card = Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" billing = Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" item = Item() item.code = "00001" item.title = "Videojuego" item.price = 800 item.qty = 1 order = Order() order.id = "ORDER-12948" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) sale = SaleTransaction() sale.setOrder(order) sale.setCard(card) sale.setBilling(billing) service = Transaction(settings) response = service.doSale(sale) if TransactionResult.validateResponse(response): # SUCCESS entity = TransactionResult.fromResponse(response) print(f"ENTITY JSON: {entity}") except Exception as e: # ERROR print(f"ERR: {str(e)}") e.with_traceback() # En desarrollo. // En desarrollo. // En desarrollo.

Transacción con Tarjeta Tokenizada (Dispositivos Móviles)

import PixelPaySDK // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado let settings = Settings() settings.setupEndpoint(endpoint: "https://{endpoint}") settings.setupCredentials(key: "2222222222", hash: "elhashmd5delsecretkeydelcomercio") let item = Item() item.code = "00001" item.title = "Videojuego" item.price = 1000 item.qty = 1 let order = Order() order.id = "ORDER-12948" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item: item) let token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" let sale = SaleTransaction() // sale.withAuthenticationRequest() en caso de solicitar transacciones con protección 3DSecure. sale.setOrder(order: order) sale.setCardToken(token: token) let service = Transaction(settings: settings) do { try service.doSale(transaction: sale) { response in if TransactionResult.validateResponse(response: response) { let result = TransactionResult.fromResponse(response: response) let valid_payment = service.verifyPaymentHash( hash: result.payment_hash, order_id: sale.order_id, secret: "abc..." ) if valid_payment { // SUCCESS Valid Payment } } } } catch { // ERROR } import com.pixel.sdk.models.Item import com.pixel.sdk.models.Order import com.pixel.sdk.models.Settings import com.pixel.sdk.entities.TransactionResult import com.pixel.sdk.requests.SaleTransaction import com.pixel.sdk.mobile.services.Transaction // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado val settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") val item = Item() item.code = "00001" item.title = "Videojuego" item.price = 1000.0 item.qty = 1 val order = Order() order.id = "ORDER-12948" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) val token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" val sale = SaleTransaction() // sale.withAuthenticationRequest() en caso de solicitar transacciones con protección 3DSecure. sale.setOrder(order) sale.setCardToken(token) // enviamos el current activity como segundo parametro val service = Transaction(settings, this) try { service.doSale(sale).then { if (TransactionResult.validateResponse(it)) { val result = TransactionResult.fromResponse(it) if (service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")) { // SUCCESS Payment } } else { System.out.println(it.message); } }.thenCatch { it.printStackTrace() } } catch (e: Exception) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Item; import com.pixel.sdk.models.Order; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.TransactionResult; import com.pixel.sdk.requests.SaleTransaction; import com.pixel.sdk.mobile.services.Transaction; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); Item item = new Item(); item.code = "00001"; item.title = "Videojuego"; item.price = 1000; item.qty = 1; Order order = new Order(); order.id = "ORDER-12948"; order.currency = "HNL"; order.customer_name = "SERGIO PEREZ"; order.customer_email = "sergio.perez@gmail.com"; order.addItem(item); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; SaleTransaction sale = new SaleTransaction(); sale.setOrder(order); sale.setCardToken(token); // enviamos el current activity como segundo parametro Transaction service = new Transaction(settings, this); service.doSale(sale).then(response -> { if (TransactionResult.validateResponse(response)) { TransactionResult result = TransactionResult.fromResponse(response); if (service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")) { // SUCCESS Payment } } }).thenCatch(err -> { // ERROR }).start(); import 'package:pixelpay_sdk/models/settings.dart' as pixelpay; import 'package:pixelpay_sdk/models/item.dart' as pixelpay; import 'package:pixelpay_sdk/models/order.dart' as pixelpay; import 'package:pixelpay_sdk/requests/sale_transaction.dart' as pixelpay; import 'package:pixelpay_sdk/services/transaction.dart' as pixelpay; import 'package:pixelpay_sdk/entities/transaction_result.dart' as pixelpay; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") final item = pixelpay.Item(); item.code = "00001"; item.title = "Videojuego"; item.price = 1000.0; item.qty = 1; final order = pixelpay.Order(); order.id = "ORDER-12948"; order.customer_name = "SERGIO PEREZ"; order.currency = "HNL"; order.customer_email = "sergio.perez@gmail.com"; order.addItem(item); String token = "T-1cb07ea3-d45c-4a64-a081-68078b8fc796"; final sale = pixelpay.SaleTransaction(); sale.setOrder(order); sale.setCardToken(token); final service = pixelpay.Transaction(settings); final response = await service.doSale(sale); if (pixelpay.TransactionResult.validateResponse(response!)) { // SUCCESS } else { // ERROR } import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import Item from "@pixelpay/sdk-core/lib/models/Item"; import Order from "@pixelpay/sdk-core/lib/models/Order"; import SaleTransaction from "@pixelpay/sdk-core/lib/requests/SaleTransaction"; import TransactionResult from "@pixelpay/sdk-core/lib/entities/TransactionResult"; import { Transaction } from '@pixelpay/capacitor-plugin'; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const item = new Item() item.code = "00001" item.title = "Videojuego" item.price = 800 item.qty = 1 const order = new Order() order.id = "ORDER-12949" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) const token = "T-1cb07ea3-d45c-4a64-a081-68078b8fc796" const sale = new SaleTransaction() sale.setOrder(order) sale.setCardToken(token) const service = new Transaction(settings) // with async / await try { const response = await service.doSale(sale) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const validPayment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (validPayment) { // SUCCESS Valid Payment } } } catch (error) { // ERROR } // with callback service.doSale(sale).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const validPayment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (validPayment) { // SUCCESS Valid Payment } } }).catch((error) => { // ERROR })

Transacción con Tarjeta Tokenizada (Legacy)

import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import Item from "@pixelpay/sdk-core/lib/models/Item"; import Order from "@pixelpay/sdk-core/lib/models/Order"; import SaleTransaction from "@pixelpay/sdk-core/lib/requests/SaleTransaction"; import Transaction from "@pixelpay/sdk-core/lib/services/Transaction"; import TransactionResult from "@pixelpay/sdk-core/lib/entities/TransactionResult"; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const item = new Item() item.code = "00001" item.title = "Videojuego" item.price = 800 item.qty = 1 const order = new Order() order.id = "ORDER-12949" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) const token = "T-1cb07ea3-d45c-4a64-a081-68078b8fc796" const sale = new SaleTransaction() sale.setOrder(order) sale.setCardToken(token) const service = new Transaction(settings) // with async / await try { const response = await service.doSale(sale) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const validPayment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (validPayment) { // SUCCESS Valid Payment } } } catch (error) { // ERROR } // with callback service.doSale(sale).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const validPayment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (validPayment) { // SUCCESS Valid Payment } } }).catch((error) => { // ERROR }) <?php use PixelPay\sdk\Models\Settings; use PixelPay\sdk\Models\Item; use PixelPay\sdk\Models\Order; use PixelPay\sdk\Requests\SaleTransaction; use PixelPay\sdk\Services\Transaction; use PixelPay\sdk\Entities\TransactionResult; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado $settings = new Settings(); $settings->setupEndpoint("https://{endpoint}"); $settings->setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); $item = new Item(); $item->code = "00001"; $item->title = "Videojuego"; $item->price = 800; $item->qty = 1; $order = new $order(); $order->id = "$order-12949"; $order->currency = "HNL"; $order->customer_name = "SERGIO PEREZ"; $order->customer_email = "sergio->perez@gmail->com"; $order->addItem($item); $token = "T-1cb07ea3-d45c-4a64-a081-68078b8fc796"; $sale = new SaleTransaction(); $sale->setOrder($order); $sale->setCardToken($token); $service = new Transaction($settings); try { $response = $service->doSale($sale); if (TransactionResult::validateResponse($response)) { $result = TransactionResult::fromResponse($response); $is_valid = $service->verifyPaymentHash( $result->payment_hash, $order->id, "abc...", // secret ); if ($valid_payment) { // SUCCESS Valid Payment } } else { // CHECK Failed Response echo $response->message; } } catch (Exception $e) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Item; import com.pixel.sdk.models.Order; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.TransactionResult; import com.pixel.sdk.requests.SaleTransaction; import com.pixel.sdk.services.Transaction; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); Item item = new Item(); item.code = "00001"; item.title = "Videojuego"; item.price = 1000; item.qty = 1; Order order = new Order(); order.id = "ORDER-12948"; order.currency = "HNL"; order.customer_name = "SERGIO PEREZ"; order.customer_email = "sergio.perez@gmail.com"; order.addItem(item); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; SaleTransaction sale = new SaleTransaction(); sale.setOrder(order); sale.setCardToken(token); // enviamos el current activity como segundo parametro Transaction service = new Transaction(settings, this); try { service.doSale(sale); if (TransactionResult.validateResponse(response)) { TransactionResult result = TransactionResult.fromResponse(response); if (service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")) { // SUCCESS Payment } } } catch (Exception e) { // ERROR } from pixelpay.services import Transaction from pixelpay.models import Item, Order, Settings from pixelpay.requests import SaleTransaction from pixelpay.entities import TransactionResult try: settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") item = Item() item.code = "00001" item.title = "Videojuego" item.price = 1000 item.qty = 1 order = Order() order.id = "ORDER-12948" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" sale = SaleTransaction() sale.setOrder(order) sale.setCardToken(token) service = Transaction(settings) response = service.doSale(sale) if TransactionResult.validateResponse(response): # SUCCESS entity = TransactionResult.fromResponse(response) print(f"ENTITY JSON: {entity}") except Exception as e: # ERROR print(f"ERR: {str(e)}") e.with_traceback() # En desarrollo. // En desarrollo. // En desarrollo.

Puede ser que la solicitud falle al intentar comunicarse con los servicios de PixelPay, por eso importante siempre cubrir el bloque de código en un try/catch.


Autorización y Captura de Pagos

Para enviar una transacción de tipo autorización, se siguen los mismos pasos con el ejemplo anterior, con la excepción de que se necesita hacer una transacción de captura en el futuro para completar la transacción.

De igual manera que en el ejemplo anterior, se puede realizar una transacción de autorización con una tarjeta de crédito / débito o con una tarjeta tokenizada. Para este ejemplo se utilizará una tarjeta que ya ha sido tokenizada:

Autorización de Pago (Dispositivos Móviles)

import PixelPaySDK // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado let settings = Settings() settings.setupEndpoint(endpoint: "https://{endpoint}") settings.setupCredentials(key: "2222222222", hash: "elhashmd5delsecretkeydelcomercio") let item = Item() item.code = "00001" item.title = "Videojuego" item.price = 1000 item.qty = 1 let order = Order() order.id = "ORDER-12948" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item: item) let token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" let auth = AuthTransaction() // auth.withAuthenticationRequest() en caso de solicitar transacciones con protección 3DSecure. auth.setOrder(order: order) auth.setCardToken(token: token) let service = Transaction(settings: settings) do { try service.doAuth(transaction: auth) { response in if TransactionResult.validateResponse(response: response) { let result = TransactionResult.fromResponse(response: response) // SUCCESS } } } catch { // ERROR } import com.pixel.sdk.models.Item import com.pixel.sdk.models.Order import com.pixel.sdk.models.Settings import com.pixel.sdk.entities.TransactionResult import com.pixel.sdk.requests.AuthTransaction import com.pixel.sdk.mobile.services.Transaction // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado val settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") val item = Item() item.code = "00001" item.title = "Videojuego" item.price = 1000 item.qty = 1 val order = Order() order.id = "ORDER-12948" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" val auth = AuthTransaction() // auth.withAuthenticationRequest() en caso de solicitar transacciones con protección 3DSecure. auth.setOrder(order) auth.setCardToken(token) // enviamos el current activity como segundo parametro val service = Transaction(settings, this) try { service.doAuth(auth).then { if (TransactionResult.validateResponse(it)) { val result = TransactionResult.fromResponse(it) // SUCCESS } else { System.out.println(it.message); } }.thenCatch { it.printStackTrace() } } catch (e: Exception) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Item; import com.pixel.sdk.models.Order; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.TransactionResult; import com.pixel.sdk.requests.AuthTransaction; import com.pixel.sdk.mobile.services.Transaction; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); Item item = new Item(); item.code = "00001"; item.title = "Videojuego"; item.price = 1000; item.qty = 1; Order order = new Order(); order.id = "ORDER-12948"; order.currency = "HNL"; order.customer_name = "SERGIO PEREZ"; order.customer_email = "sergio.perez@gmail.com"; order.addItem(item); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; AuthTransaction auth = new AuthTransaction(); auth.setOrder(order); auth.setCardToken(token); // enviamos el current activity como segundo parametro Transaction service = new Transaction(settings, this); service.doAuth(auth).then(response -> { if (TransactionResult.validateResponse(response)) { TransactionResult result = TransactionResult.fromResponse(response); // SUCCESS } }).thenCatch(err -> { // ERROR }).start(); import 'package:pixelpay_sdk/models/item.dart' as pixelpay; import 'package:pixelpay_sdk/models/order.dart' as pixelpay; import 'package:pixelpay_sdk/models/settings.dart' as pixelpay; import 'package:pixelpay_sdk/entities/transaction_result.dart' as pixelpay; import 'package:pixelpay_sdk/requests/auth_transaction.dart' as pixelpay; import 'package:pixelpay_sdk/services/transaction.dart' as pixelpay; final settings = pixelpay.Settings(); settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") final item = pixelpay.Item(); item.code = "00001"; item.title = "Videojuego"; item.price = 1000; item.qty = 1; final order = pixelpay.Order(); order.id = "ORDER-12948"; order.customer_name = "SERGIO PEREZ"; order.currency = "HNL"; order.customer_email = "sergio.perez@gmail.com"; order.addItem(item); String token = "T-1cb07ea3-d45c-4a64-a081-68078b8fc796"; final auth = pixelpay.AuthTransaction(); auth.setOrder(order); auth.setCardToken(token); final service = pixelpay.Transaction(settings); final response = await service.doAuth(auth); if (pixelpay.TransactionResult.validateResponse(response!)) { // SUCCESS } else { // ERROR } import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import Item from "@pixelpay/sdk-core/lib/models/Item"; import AuthTransaction from "@pixelpay/sdk-core/lib/requests/AuthTransaction"; import Order from "@pixelpay/sdk-core/lib/models/Order"; import Card from "@pixelpay/sdk-core/lib/models/Card"; import TransactionResult from "@pixelpay/sdk-core/lib/entities/TransactionResult"; import { Transaction } from '@pixelpay/capacitor-plugin'; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const item = new Item() item.code = "00001" item.title = "Videojuego" item.price = 800 item.qty = 1 const order = new Order() order.id = "ORDER-12949" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const auth = new AuthTransaction() auth.setOrder(order) auth.setCardToken(card) const service = new Transaction(settings) // with async / await try { const response = await service.doAuth(auth) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // with callback service.doAuth(auth).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR })

Autorización de Pago (Legacy)

import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import Item from "@pixelpay/sdk-core/lib/models/Item"; import AuthTransaction from "@pixelpay/sdk-core/lib/requests/AuthTransaction"; import Order from "@pixelpay/sdk-core/lib/models/Order"; import Card from "@pixelpay/sdk-core/lib/models/Card"; import Transaction from "@pixelpay/sdk-core/lib/services/Transaction"; import TransactionResult from "@pixelpay/sdk-core/lib/entities/TransactionResult"; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const item = new Item() item.code = "00001" item.title = "Videojuego" item.price = 800 item.qty = 1 const order = new Order() order.id = "ORDER-12949" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const auth = new AuthTransaction() auth.setOrder(order) auth.setCardToken(card) const service = new Transaction(settings) // with async / await try { const response = await service.doAuth(auth) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // with callback service.doAuth(auth).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR }) <?php use PixelPay\sdk\Models\Settings; use PixelPay\sdk\Models\Item; use PixelPay\sdk\Models\Order; use PixelPay\sdk\Models\Card; use PixelPay\sdk\Requests\AuthTransaction; use PixelPay\sdk\Services\Transaction; use PixelPay\sdk\Entities\TransactionResult; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado $settings = new Settings(); $settings->setupEndpoint("https://{endpoint}"); $settings->setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); $item = new Item(); $item->code = "00001"; $item->title = "Videojuego"; $item->price = 800; $item->qty = 1; $order = new Order(); $order->id = "$order-12949"; $order->currency = "HNL"; $order->customer_name = "SERGIO PEREZ"; $order->customer_email = "sergio->perez@gmail->com"; $order->addItem($item); $card = new Card(); $card->number = "4111111111111111"; $card->cvv2 = "999"; $card->expire_month = 7; $card->expire_year = 2023; $card->cardholder = "SERGIO PEREZ"; $token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; $auth = new AuthTransaction(); $auth->setOrder($order); $auth->setCardToken($token); $service = new Transaction($settings); try { $response = $service->doAuth($auth); if (TransactionResult::validateResponse($response)) { $result = TransactionResult::fromResponse($response); // SUCCESS } } catch (Exception $e) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Item; import com.pixel.sdk.models.Order; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.TransactionResult; import com.pixel.sdk.requests.AuthTransaction; import com.pixel.sdk.services.Transaction; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); Item item = new Item(); item.code = "00001"; item.title = "Videojuego"; item.price = 1000; item.qty = 1; Order order = new Order(); order.id = "ORDER-12948"; order.currency = "HNL"; order.customer_name = "SERGIO PEREZ"; order.customer_email = "sergio.perez@gmail.com"; order.addItem(item); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; AuthTransaction auth = new AuthTransaction(); auth.setOrder(order); auth.setCardToken(token); // enviamos el current activity como segundo parametro Transaction service = new Transaction(settings, this); try { service.doAuth(auth); if (TransactionResult.validateResponse(response)) { TransactionResult result = TransactionResult.fromResponse(response); // SUCCESS } } catch (Exception e) { // ERROR } from pixelpay.services import Transaction from pixelpay.models import Item, Order, Settings from pixelpay.requests import AuthTransaction from pixelpay.entities import TransactionResult try: settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") item = Item() item.code = "00001" item.title = "Videojuego" item.price = 1000 item.qty = 1 order = Order() order.id = "ORDER-12948" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" auth = AuthTransaction() auth.setOrder(order) auth.setCardToken(token) service = Transaction(settings) response = service.doAuth(auth) if TransactionResult.validateResponse(response): # SUCCESS entity = TransactionResult.fromResponse(response) print(f"ENTITY JSON: {entity}") except Exception as e: # ERROR print(f"ERR: {str(e)}") e.with_traceback() # En desarrollo. // En desarrollo. // En desarrollo.

Captura de Pago (Dispositivos Móviles)

import PixelPaySDK // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado let settings = Settings() settings.setupEndpoint(endpoint: "https://{endpoint}") settings.setupCredentials(key: "2222222222", hash: "elhashmd5delsecretkeydelcomercio") let capture = CaptureTransaction() capture.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" capture.transaction_approved_amount = "1000" let service = Transaction(settings: settings) do { try service.doCapture(transaction: capture) { response in if TransactionResult.validateResponse(response: response) { let result = TransactionResult.fromResponse(response: response) // SUCCESS } } } catch { // ERROR } import com.pixel.sdk.models.Settings import com.pixel.sdk.entities.TransactionResult import com.pixel.sdk.requests.CaptureTransaction import com.pixel.sdk.mobile.services.Transaction // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado val settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") val capture = CaptureTransaction() capture.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" capture.transaction_approved_amount = "1000" // enviamos el current activity como segundo parametro val service = Transaction(settings, this) try { service.doCapture(capture).then { if (TransactionResult.validateResponse(it)) { val result = TransactionResult.fromResponse(it) // SUCCESS } else { System.out.println(it.message); } }.thenCatch { it.printStackTrace() } } catch (e: Exception) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.TransactionResult; import com.pixel.sdk.requests.CaptureTransaction; import com.pixel.sdk.mobile.services.Transaction; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); CaptureTransaction capture = new CaptureTransaction(); capture.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"; capture.transaction_approved_amount = "1000"; // enviamos el current activity como segundo parametro Transaction service = new Transaction(settings, this); service.doCapture(capture).then(response -> { if (TransactionResult.validateResponse(response)) { TransactionResult result = TransactionResult.fromResponse(response); // SUCCESS } }).thenCatch(err -> { // ERROR }).start(); import 'package:pixelpay_sdk/models/settings.dart' as pixelpay; import 'package:pixelpay_sdk/entities/transaction_result.dart' as pixelpay; import 'package:pixelpay_sdk/requests/capture_transaction.dart' as pixelpay; import 'package:pixelpay_sdk/services/transaction.dart' as pixelpay; final settings = pixelpay.Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); final capture = pixelpay.CaptureTransaction(); capture.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"; capture.transaction_approved_amount = "1000"; final service = pixelpay.Transaction(settings); final response = await service.doCapture(capture); if (pixelpay.TransactionResult.validateResponse(response!)) { // SUCCESS } else { // ERROR } import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import CaptureTransaction from "@pixelpay/sdk-core/lib/requests/CaptureTransaction"; import TransactionResult from "@pixelpay/sdk-core/lib/entities/TransactionResult"; import { Transaction } from '@pixelpay/capacitor-plugin'; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const capture = new CaptureTransaction() capture.payment_uuid = "P-4eb5d39b-482d-49f5-a198-d14eedc4f47d" capture.transaction_approved_amount = "1000" const service = new Transaction(settings) // with async / await try { const response = await service.doCapture(capture) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // with callback service.doCapture(capture).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR })

Captura de Pago (Legacy)

import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import CaptureTransaction from "@pixelpay/sdk-core/lib/requests/CaptureTransaction"; import Transaction from "@pixelpay/sdk-core/lib/services/Transaction"; import TransactionResult from "@pixelpay/sdk-core/lib/entities/TransactionResult"; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const capture = new CaptureTransaction() capture.payment_uuid = "P-4eb5d39b-482d-49f5-a198-d14eedc4f47d" capture.transaction_approved_amount = "1000" const service = new Transaction(settings) // with async / await try { const response = await service.doCapture(capture) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // with callback service.doCapture(capture).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR }) <?php use PixelPay\sdk\Models\Settings; use PixelPay\sdk\Requests\CaptureTransaction; use PixelPay\sdk\Services\Transaction; use PixelPay\sdk\Entities\TransactionResult; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado $settings = new Settings(); $settings->setupEndpoint("https://{endpoint}"); $settings->setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); $capture = new CaptureTransaction(); $capture->payment_uuid = "P-4eb5d39b-482d-49f5-a198-d14eedc4f47d"; $capture->transaction_approved_amount = "1000"; $service = new Transaction($settings); try { $response = $service->doCapture($capture); if (TransactionResult::validateResponse($response)) { $result = TransactionResult::fromResponse($response); // SUCCESS } } catch (Exception $e) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.TransactionResult; import com.pixel.sdk.requests.CaptureTransaction; import com.pixel.sdk.services.Transaction; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); CaptureTransaction capture = new CaptureTransaction(); capture.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"; capture.transaction_approved_amount = "1000"; // enviamos el current activity como segundo parametro Transaction service = new Transaction(settings, this); try { service.doCapture(capture); if (TransactionResult.validateResponse(response)) { TransactionResult result = TransactionResult.fromResponse(response); // SUCCESS } } catch (Exception e) { // ERROR } from pixelpay.services import Transaction from pixelpay.models import Settings from pixelpay.requests import CaptureTransaction from pixelpay.entities import TransactionResult try: settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") service = Transaction(settings) capture = CaptureTransaction() capture.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" capture.transaction_approved_amount = "1000" response = service.doCapture(capture) if TransactionResult.validateResponse(response): # SUCCESS entity = TransactionResult.fromResponse(response) print(f"ENTITY JSON: {entity}") except Exception as e: # ERROR print(f"ERR: {str(e)}") e.with_traceback() # En desarrollo. // En desarrollo. // En desarrollo.

Puede ser que la solicitud falle al intentar comunicarse con los servicios de PixelPay, por eso importante siempre cubrir el bloque de código en un try/catch.


Anular cobros

Para anular un cobro es necesario configurar el usuario que del comercio que quiere anular el cobro con el método setupPlatformUser en el modelo de configuración del SDK.

Ejemplo (Dispositivos Móviles)

import PixelPaySDK // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado let settings = Settings() settings.setupEndpoint(endpoint: "https://{endpoint}") settings.setupCredentials(key: "2222222222", hash: "elhashmd5delsecretkeydelcomercio") settings.setupPlatformUser(hash: "elhashsha512delcorreodelusuariodelcomercio") let void = VoidTransaction() void.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" void.void_reason = "El cliente quiso cancelar" let service = Transaction(settings: settings) do { try service.doVoid(transaction: void) { response in if TransactionResult.validateResponse(response: response) { let result = TransactionResult.fromResponse(response: response) // SUCCESS } } } catch { // ERROR } import com.pixel.sdk.models.Settings import com.pixel.sdk.entities.TransactionResult import com.pixel.sdk.requests.VoidTransaction import com.pixel.sdk.mobile.services.Transaction // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado val settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") settings.setupPlatformUser("elhashsha512delcorreodelusuariodelcomercio") val void_tx = VoidTransaction() void_tx.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" void_tx.void_reason = "El cliente quiso cancelar" // enviamos el current activity como segundo parametro val service = Transaction(settings, this) try { service.doVoid(void_tx).then { if (TransactionResult.validateResponse(it)) { val result = TransactionResult.fromResponse(it) // SUCCESS } else { System.out.println(it.message); } }.thenCatch { it.printStackTrace() } } catch (e: Exception) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.TransactionResult; import com.pixel.sdk.requests.VoidTransaction; import com.pixel.sdk.mobile.services.Transaction; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); settings.setupPlatformUser("elhashsha512delcorreodelusuariodelcomercio"); VoidTransaction void_tx = new VoidTransaction(); void_tx.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"; void_tx.void_reason = "El cliente quiso cancelar"; // enviamos el current activity como segundo parametro Transaction service = new Transaction(settings, this); service.doVoid(void_tx).then(response -> { if (TransactionResult.validateResponse(response)) { TransactionResult result = TransactionResult.fromResponse(response); // SUCCESS } }).thenCatch(err -> { // ERROR }).start(); import 'package:pixelpay_sdk/models/settings.dart' as pixelpay; import 'package:pixelpay_sdk/entities/transaction_result.dart' as pixelpay; import 'package:pixelpay_sdk/requests/void_transaction.dart' as pixelpay; import 'package:pixelpay_sdk/services/transaction.dart' as pixelpay; final settings = pixelpay.Settings(); settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") settings.setupPlatformUser("elhashsha512delcorreodelusuariodelcomercio") final void_tx = pixelpay.VoidTransaction(); void_tx.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"; void_tx.void_reason = "El cliente quiso cancelar"; final service = pixelpay.Transaction(settings); final response = await service.doVoid(void_tx); if (pixelpay.TransactionResult.validateResponse(response!)) { // SUCCESS } else { // ERROR } import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import VoidTransaction from "@pixelpay/sdk-core/lib/requests/VoidTransaction"; import TransactionResult from "@pixelpay/sdk-core/lib/entities/TransactionResult"; import { Transaction } from '@pixelpay/capacitor-plugin'; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") settings.setupPlatformUser("elhashsha512delcorreodelusuariodelcomercio") const void_tx = new VoidTransaction() void_tx.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" void_tx.void_reason = "El cliente quiso cancelar" const service = new Transaction(settings) // with async / await try { const response = await service.doVoid(void_tx) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // with callback service.doVoid(void_tx).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR })

Ejemplo (Legacy)

import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import VoidTransaction from "@pixelpay/sdk-core/lib/requests/VoidTransaction"; import Transaction from "@pixelpay/sdk-core/lib/services/Transaction"; import TransactionResult from "@pixelpay/sdk-core/lib/entities/TransactionResult"; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") settings.setupPlatformUser("elhashsha512delcorreodelusuariodelcomercio") const void_tx = new VoidTransaction() void_tx.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" void_tx.void_reason = "El cliente quiso cancelar" const service = new Transaction(settings) // with async / await try { const response = await service.doVoid(void_tx) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // with callback service.doVoid(void_tx).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR }) <?php use PixelPay\sdk\Models\Settings; use PixelPay\sdk\Requests\VoidTransaction; use PixelPay\sdk\Services\Transaction; use PixelPay\sdk\Entities\TransactionResult; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado $settings = new Settings(); $settings->setupEndpoint("https://{endpoint}"); $settings->setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); $settings->setupPlatformUser("elhashsha512delcorreodelusuariodelcomercio"); $void_tx = new VoidTransaction(); $void_tx->payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"; $void_tx->void_reason = "El cliente quiso cancelar"; $service = new Transaction($settings); try { $response = $service->doVoid($void_tx); if (TransactionResult::validateResponse($response)) { $result = TransactionResult::fromResponse($response); // SUCCESS } } catch (Exception $e) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.TransactionResult; import com.pixel.sdk.requests.VoidTransaction; import com.pixel.sdk.services.Transaction; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); settings.setupPlatformUser("elhashsha512delcorreodelusuariodelcomercio"); VoidTransaction void_tx = new VoidTransaction(); void_tx.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"; void_tx.void_reason = "El cliente quiso cancelar"; // enviamos el current activity como segundo parametro Transaction service = new Transaction(settings, this); try { service.doVoid(void_tx); if (TransactionResult.validateResponse(response)) { TransactionResult result = TransactionResult.fromResponse(response); // SUCCESS } } catch (Exception e) { // ERROR } from pixelpay.services import Transaction from pixelpay.models import Settings from pixelpay.requests import VoidTransaction from pixelpay.entities import TransactionResult try: settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") settings.setupPlatformUser("elhashsha512delcorreodelusuariodelcomercio") service = Transaction(settings) void_tx = VoidTransaction() void_tx.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" void_tx.void_reason = "El cliente quiso cancelar" response = service.doVoid(void_tx) if TransactionResult.validateResponse(response): # SUCCESS entity = TransactionResult.fromResponse(response) print(f"ENTITY JSON: {entity}") except Exception as e: # ERROR print(f"ERR: {str(e)}") e.with_traceback() # En desarrollo. // En desarrollo. // En desarrollo.

Consultar estado de un cobro

Ejemplo (Dispositivos Móviles)

import PixelPaySDK // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado let settings = Settings() settings.setupEndpoint(endpoint: "https://{endpoint}") settings.setupCredentials(key: "2222222222", hash: "elhashmd5delsecretkeydelcomercio") let status = StatusTransaction() status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" let service = Transaction(settings: settings) do { try service.getStatus(transaction: status) { response in if TransactionResult.validateResponse(response: response) { let result = TransactionResult.fromResponse(response: response) // SUCCESS } } } catch { // ERROR } import com.pixel.sdk.models.Settings import com.pixel.sdk.entities.TransactionResult import com.pixel.sdk.requests.StatusTransaction import com.pixel.sdk.mobile.services.Transaction // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado val settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") val status = StatusTransaction() status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" // enviamos el current activity como segundo parametro val service = Transaction(settings, this) try { service.getStatus(status).then { if (TransactionResult.validateResponse(it)) { val result = TransactionResult.fromResponse(it) // SUCCESS } else { System.out.println(it.message); } }.thenCatch { it.printStackTrace() } } catch (e: Exception) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.TransactionResult; import com.pixel.sdk.requests.StatusTransaction; import com.pixel.sdk.mobile.services.Transaction; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); StatusTransaction status = new StatusTransaction(); status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"; // enviamos el current activity como segundo parametro Transaction service = new Transaction(settings, this); service.getStatus(status).then(response -> { if (TransactionResult.validateResponse(response)) { TransactionResult result = TransactionResult.fromResponse(response); // SUCCESS } }).thenCatch(err -> { // ERROR }).start(); import 'package:pixelpay_sdk/models/settings.dart' as pixelpay; import 'package:pixelpay_sdk/entities/transaction_result.dart' as pixelpay; import 'package:pixelpay_sdk/requests/status_transaction.dart' as pixelpay; import 'package:pixelpay_sdk/services/transaction.dart' as pixelpay; final settings = pixelpay.Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); final status = pixelpay.StatusTransaction(); status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"; final service = pixelpay.Transaction(settings); final response = await service.getStatus(status); if (pixelpay.TransactionResult.validateResponse(response!)) { // SUCCESS } else { // ERROR } import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import StatusTransaction from "@pixelpay/sdk-core/lib/requests/StatusTransaction"; import TransactionResult from "@pixelpay/sdk-core/lib/entities/TransactionResult"; import { Transaction } from '@pixelpay/capacitor-plugin'; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const status = new StatusTransaction() status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" const service = new Transaction(settings) // with async / await try { const response = await service.getStatus(status) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // with callback service.getStatus(status).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR })

Ejemplo (Legacy)

import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import StatusTransaction from "@pixelpay/sdk-core/lib/requests/StatusTransaction"; import Transaction from "@pixelpay/sdk-core/lib/services/Transaction"; import TransactionResult from "@pixelpay/sdk-core/lib/entities/TransactionResult"; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const status = new StatusTransaction() status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" const service = new Transaction(settings) // with async / await try { const response = await service.getStatus(status) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // with callback service.getStatus(status).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR }) <?php use PixelPay\Sdk\Entities\TransactionResult; use PixelPay\Sdk\Models\Settings; use PixelPay\Sdk\Requests\StatusTransaction; use PixelPay\Sdk\Services\Transaction; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado $settings = new Settings(); $settings->setupEndpoint("https://{endppoint}"); $settings->setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); $status = new StatusTransaction(); $status->payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"; $service = new Transaction($settings); try { $response = $service->getStatus($status); if(TransactionResult::validateResponse($response)) { $result = TransactionResult::fromResponse($response); // SUCCESS } else { // ERROR } } catch (Exception $e) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.TransactionResult; import com.pixel.sdk.requests.StatusTransaction; import com.pixel.sdk.services.Transaction; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); StatusTransaction status = new StatusTransaction(); status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"; // enviamos el current activity como segundo parametro Transaction service = new Transaction(settings, this); try { service.getStatus(status); if (TransactionResult.validateResponse(response)) { TransactionResult result = TransactionResult.fromResponse(response); // SUCCESS } } catch (Exception e) { // ERROR } from pixelpay.services import Transaction from pixelpay.models import Settings from pixelpay.requests import StatusTransaction from pixelpay.entities import TransactionResult try: settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") service = Transaction(settings) status = StatusTransaction() status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" response = service.getStatus(status) if TransactionResult.validateResponse(response): # SUCCESS entity = TransactionResult.fromResponse(response) print(f"ENTITY JSON: {entity}") except Exception as e: # ERROR print(f"ERR: {str(e)}") e.with_traceback() # En desarrollo. // En desarrollo. // En desarrollo.

Verificar Cobro

Siempre que se realiza una transacción de venta exitosa, se envía el campo payment_hash dentro de la data de respuesta que contiene una cadena para verificar la autenticidad del cobro. Para comparar el valor payment_hash y verificar que la transacción sea real, se necesitan 3 elementos:

  • el order_id: el identificador de la orden
  • el key ID: la llave del comercio
  • el secret key: el secreto del comercio.

Esta verificación solo se puede hacer del lado del servidor y no del lado del cliente, ya que hacerlo del lado del cliente expondría tu llave secreta al público.

La documentación aquí explica como extraer las llaves del comercio.

Luego que se tengan todos los datos mencionados anteriormente, se concatenan los tres elementos con el símbolo | entre cada uno en el siguiente orden: order_id|key_id|secret_key.

A continuación veremos un ejemplo:

Nombre Valor
order_id 00000123
key ID 7812290000
secret key abc...

Y el resultado de este ejemplo: 00000123|7812290000|abc....

Para finalizar la validación, se convierte el valor concatenado en un hash md5 y se procede a compararlo con el parámetro payment_hash. Si ambos hash son iguales (hash remoto == hash local) entonces el pago es válido.

El servicio de Transaction tiene la función de utilidad verifyPaymentHash que verifica si el payment_hash es válido o no.

Ejemplo (Dispositivos Móviles)

// Luego de realizar una transacción do { try service.doSale(transaction: sale) { response in if TransactionResult.validateResponse(response: response) { let result = TransactionResult.fromResponse(response: response) let valid_payment = service.verifyPaymentHash( hash: result.payment_hash, order_id: sale.order_id, secret: "abc..." ) if valid_payment { // SUCCESS Valid Payment } } } } catch { // ERROR } // Luego de realizar una transacción try { service.doSale(sale).then { if (TransactionResult.validateResponse(it)) { val result = TransactionResult.fromResponse(it) if (service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")) { // SUCCESS Valid Payment } } else { System.out.println(it.message); } }.thenCatch { it.printStackTrace() } } catch (e: Exception) { // ERROR } // Luego de realizar una transacción service.doSale(sale).then(response -> { if (TransactionResult.validateResponse(response)) { TransactionResult result = TransactionResult.fromResponse(response); if (service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")) { // SUCCESS Valid Payment } } }).thenCatch(err -> { // ERROR }).start(); final service = pixelpay.Transaction(settings); final response = await service.doSale(sale); if (pixelpay.TransactionResult.validateResponse(response!)){ final result = pixelpay.TransactionResult.fromResponse(response); if (service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")){ // SUCCESS Valid Payment }else{ // ERROR } } // Luego de realizar una transacción con async / await try { const response = await service.doSale(sale) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const validPayment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (validPayment) { // SUCCESS Valid Payment } } } catch (error) { // ERROR } // Luego de realizar una transacción con callback service.doSale(sale).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const validPayment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (validPayment) { // SUCCESS Valid Payment } } }).catch((error) => { // ERROR })

Ejemplo (Legacy)

// Luego de realizar una transacción con async / await try { const response = await service.doSale(sale) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const validPayment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (validPayment) { // SUCCESS Valid Payment } } } catch (error) { // ERROR } // Luego de realizar una transacción con callback service.doSale(sale).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const validPayment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (validPayment) { // SUCCESS Valid Payment } } }).catch((error) => { // ERROR }) <?php use PixelPay\Sdk\Entities\TransactionResult; try { $response = $service->doSale($sale); if (TransactionResult::validateResponse($response)) { $result = TransactionResult::fromResponse($response); $validPayment = $service->verifyPaymentHash( $result->payment_hash, $order->id, "abc..." // secret ); if ($validPayment) { // SUCCESS Valid Payment } } } catch (Exception $e) { // ERROR } from pixelpay.entities import TransactionResult try: response = service.doSale(sale) if TransactionResult.validateResponse(response): entity = TransactionResult.fromResponse(response) print(f"ENTITY JSON: {entity}") valid_payment = service.verifyPaymentHash( result.payment_hash, order.id "abc...", # secret ) if valid_payment: # SUCCESS pass except Exception as e: # ERROR print(f"ERR: {str(e)}") e.with_traceback() # En desarrollo. // En desarrollo. // En desarrollo.

Tokenización

El servicio de tokenización de PixelPay permite almacenar información de tarjetas de forma segura utilizando un servicio de tokens que simplifica el proceso de pago y le permite al comercio acceder a una variedad de beneficios adicionales que incluyen: experiencias omnicanal, información sobre los clientes y más.

El SDK simplifica la integración con el servicio de tokenización ofreciendo ya los métodos para tokenizar una tarjeta, actualizar, asociar tarjetas a comercio, obtener la información de las tarjetas y eliminar las tarjetas.

Para más información sobre el Tokenización puedes revisar aquí.

Tokenizar una Tarjeta (Dispositivos Móviles)

import PixelPaySDK // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado let settings = Settings() settings.setupEndpoint(endpoint: "https://{endpoint}") settings.setupCredentials(key: "2222222222", hash: "elhashmd5delsecretkeydelcomercio") let card = Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" let billing = Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" let card_token = CardTokenization() card_token.setCard(card: card) card_token.setBilling(billing: billing) let tokenization = Tokenization(settings: settings) do { try tokenization.vaultCard(card: card_token) { response in if CardResult.validateResponse(response: response) { let result = CardResult.fromResponse(response: response) // SUCCESS } } } catch { // ERROR } import com.pixel.sdk.models.Settings import com.pixel.sdk.models.Card import com.pixel.sdk.models.Billing import com.pixel.sdk.entities.CardResult import com.pixel.sdk.requests.CardTokenization import com.pixel.sdk.mobile.services.Tokenization // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado val settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") val card = Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" val billing = Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" val card_token = CardTokenization() card_token.setCard(card) card_token.setBilling(billing) // enviamos el current activity como segundo parametro val tokenization = Tokenization(settings, this) try { tokenization.vaultCard(card_token).then { if (CardResult.validateResponse(it)) { val result = CardResult.fromResponse(it) // SUCCESS } else { System.out.println(it.message); } }.thenCatch { it.printStackTrace() } } catch (e: Exception) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Settings; import com.pixel.sdk.models.Card; import com.pixel.sdk.models.Billing; import com.pixel.sdk.entities.CardResult; import com.pixel.sdk.requests.CardTokenization; import com.pixel.sdk.mobile.services.Tokenization; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); Card card = new Card(); card.number = "4111111111111111"; card.cvv2 = "999"; card.expire_month = 7; card.expire_year = 2023; card.cardholder = "SERGIO PEREZ"; Billing billing = new Billing(); billing.address = "Ave Circunvalacion"; billing.country = "HN"; billing.state = "HN-CR"; billing.city = "San Pedro Sula"; billing.phone = "99999999"; CardTokenization card_token = new CardTokenization(); card_token.setCard(card); card_token.setBilling(billing); // enviamos el current activity como segundo parametro Tokenization tokenization = new Tokenization(settings, this); tokenization.vaultCard(card_token).then(response -> { if (CardResult.validateResponse(response)) { CardResult result = CardResult.fromResponse(response); // SUCCESS } }).thenCatch(err -> { // ERROR }).start(); import 'package:pixelpay_sdk/models/settings.dart' as pixelpay; import 'package:pixelpay_sdk/models/card.dart' as pixelpay; import 'package:pixelpay_sdk/models/billing.dart' as pixelpay; import 'package:pixelpay_sdk/entities/card_result.dart' as pixelpay; import 'package:pixelpay_sdk/requests/card_tokenization.dart' as pixelpay; import 'package:pixelpay_sdk/services/tokenization.dart' as pixelpay; final settings = pixelpay.Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); final card = pixelpay.Card(); card.number = "4111111111111111"; card.cvv2 = "999"; card.expire_month = 7; card.expire_year = 2023; card.cardholder = "SERGIO PEREZ"; final billing = pixelpay.Billing(); billing.address = "Ave Circunvalacion"; billing.city = "San Pedro Sula"; billing.country = "HN"; billing.state = "HN-CR"; billing.phone = "99999999"; final card_token = pixelpay.CardTokenization(); card_token.setCard(card); card_token.setBilling(billing); final tokenization = pixelpay.Tokenization(settings); final response = await tokenization.vaultCard(card_token); if (pixelpay.CardResult.validateResponse(response!)) { // SUCCESS } else { // ERROR } import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import Card from "@pixelpay/sdk-core/lib/models/Card"; import Billing from "@pixelpay/sdk-core/lib/models/Billing"; import CardTokenization from "@pixelpay/sdk-core/lib/requests/CardTokenization"; import CardResult from "@pixelpay/sdk-core/lib/entities/CardResult"; import { Tokenization } from '@pixelpay/capacitor-plugin'; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const card_token = new CardTokenization() card_token.setCard(card) card_token.setBilling(billing) const tokenization = new Tokenization(settings) // with async / await try { const response = await tokenization.vaultCard(card_token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // with callback tokenization.vaultCard(card_token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR })

Tokenizar una Tarjeta (Legacy)

import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import Card from "@pixelpay/sdk-core/lib/models/Card"; import Billing from "@pixelpay/sdk-core/lib/models/Billing"; import Tokenization from "@pixelpay/sdk-core/lib/services/Tokenization"; import CardTokenization from "@pixelpay/sdk-core/lib/requests/CardTokenization"; import CardResult from "@pixelpay/sdk-core/lib/entities/CardResult"; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const card_token = new CardTokenization() card_token.setCard(card) card_token.setBilling(billing) const tokenization = new Tokenization(settings) // with async / await try { const response = await tokenization.vaultCard(card_token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // with callback tokenization.vaultCard(card_token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR }) <?php use PixelPay\Sdk\Entities\CardResult; use PixelPay\Sdk\Models\Billing; use PixelPay\Sdk\Models\Card; use PixelPay\Sdk\Models\Settings; use PixelPay\Sdk\Requests\CardTokenization; use PixelPay\Sdk\Services\Tokenization; $settings = new Settings(); $settings->setupEndpoint("https://{endppoint}"); $settings->setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); $card = new Card(); $card->number = "4111 1111 1111 1111"; $card->cvv2 = "999"; $card->expire_month = 7; $card->expire_year = 2023; $card->cardholder = "SERGIO PEREZ"; $billing = new Billing(); $billing->address = "Ave Circunvalacion"; $billing->country = "HN"; $billing->state = "HN-CR"; $billing->city = "San Pedro Sula"; $billing->phone = "998877766"; $card_token = new CardTokenization(); $card_token->setCard($card); $card_token->setBilling($billing); $tokenization = new Tokenization($settings); try { $response = $tokenization->vaultCard($card_token); if (CardResult::validateResponse($response)) { $result = CardResult::fromResponse($response); // SUCCESS } else { // ERROR } } catch (Exception $e) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Settings; import com.pixel.sdk.models.Card; import com.pixel.sdk.models.Billing; import com.pixel.sdk.entities.CardResult; import com.pixel.sdk.requests.CardTokenization; import com.pixel.sdk.services.Tokenization; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); Card card = new Card(); card.number = "4111111111111111"; card.cvv2 = "999"; card.expire_month = 7; card.expire_year = 2023; card.cardholder = "SERGIO PEREZ"; Billing billing = new Billing(); billing.address = "Ave Circunvalacion"; billing.country = "HN"; billing.state = "HN-CR"; billing.city = "San Pedro Sula"; billing.phone = "99999999"; CardTokenization card_token = new CardTokenization(); card_token.setCard(card); card_token.setBilling(billing); // enviamos el current activity como segundo parametro Tokenization tokenization = new Tokenization(settings, this); try { tokenization.vaultCard(card_token); if (CardResult.validateResponse(response)) { CardResult result = CardResult.fromResponse(response); // SUCCESS } } catch (Exception e) { // ERROR } from pixelpay.services import Tokenization from pixelpay.models import Card, Billing, Settings from pixelpay.requests import CardTokenization from pixelpay.entities import CardResult try: settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") card = Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" billing = Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" card_token = CardTokenization() card_token.setCard(card) card_token.setBilling(billing) tokenization = Tokenization(settings) response = tokenization.vaultCard(card_token) if CardResult.validateResponse(response): # SUCCESS entity = CardResult.fromResponse(response) print(f"ENTITY JSON: {entity}") except Exception as e: # ERROR print(f"ERR: {str(e)}") e.with_traceback() # En desarrollo. // En desarrollo. // En desarrollo.

Actualizar una Tarjeta Tokenizada (Dispositivos Móviles)

import PixelPaySDK // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado let settings = Settings() settings.setupEndpoint(endpoint: "https://{endpoint}") settings.setupCredentials(key: "2222222222", hash: "elhashmd5delsecretkeydelcomercio") let card = Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "LUIS MILTON" let billing = Billing() billing.address = "Colonia San Jorge" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" let card_token = CardTokenization() card_token.setCard(card: card) card_token.setBilling(billing: billing) let token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" let tokenization = Tokenization(settings: settings) do { try tokenization.updateCard(token: token, card: card_token) { response in if CardResult.validateResponse(response: response) { let result = CardResult.fromResponse(response: response) // SUCCESS } } } catch { // ERROR } import com.pixel.sdk.models.Settings import com.pixel.sdk.models.Card import com.pixel.sdk.models.Billing import com.pixel.sdk.entities.CardResult import com.pixel.sdk.requests.CardTokenization import com.pixel.sdk.mobile.services.Tokenization // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado val settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") val card = Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "LUIS MILTON" val billing = Billing() billing.address = "Colonia San Jorge" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" val card_token = CardTokenization() card_token.setCard(card) card_token.setBilling(billing) String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" // enviamos el current activity como segundo parametro val tokenization = Tokenization(settings, this) try { tokenization.updateCard(token, card_token).then { if (CardResult.validateResponse(it)) { val result = CardResult.fromResponse(it) // SUCCESS } else { System.out.println(it.message); } }.thenCatch { it.printStackTrace() } } catch (e: Exception) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Settings; import com.pixel.sdk.models.Card; import com.pixel.sdk.models.Billing; import com.pixel.sdk.entities.CardResult; import com.pixel.sdk.requests.CardTokenization; import com.pixel.sdk.mobile.services.Tokenization; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); Card card = new Card(); card.number = "4111111111111111"; card.cvv2 = "999"; card.expire_month = 7; card.expire_year = 2023; card.cardholder = "LUIS MILTON"; Billing billing = new Billing(); billing.address = "Colonia San Jorge"; billing.country = "HN"; billing.state = "HN-CR"; billing.city = "San Pedro Sula"; billing.phone = "99999999"; CardTokenization card_token = new CardTokenization(); card_token.setCard(card); card_token.setBilling(billing); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; // enviamos el current activity como segundo parametro Tokenization tokenization = new Tokenization(settings, this); tokenization.updateCard(token, card_token).then(response -> { if (CardResult.validateResponse(response)) { CardResult result = CardResult.fromResponse(response); // SUCCESS } }).thenCatch(err -> { // ERROR }).start(); import 'package:pixelpay_sdk/models/settings.dart' as pixelpay; import 'package:pixelpay_sdk/models/card.dart' as pixelpay; import 'package:pixelpay_sdk/models/billing.dart' as pixelpay; import 'package:pixelpay_sdk/entities/card_result.dart' as pixelpay; import 'package:pixelpay_sdk/requests/card_tokenization.dart' as pixelpay; import 'package:pixelpay_sdk/services/tokenization.dart' as pixelpay; final settings = pixelpay.Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); final card = pixelpay.Card(); card.number = "4111111111111111"; card.cvv2 = "999"; card.expire_month = 7; card.expire_year = 2023; card.cardholder = "LUIS MILTON"; final billing = pixelpay.Billing(); billing.address = "Colonia San Jorge"; billing.city = "San Pedro Sula"; billing.country = "HN"; billing.state = "HN-CR"; billing.phone = "99999999"; final card_token = pixelpay.CardTokenization(); card_token.setCard(card); card_token.setBilling(billing); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; final tokenization = pixelpay.Tokenization(settings); final response = await tokenization.updateCard(token, card_token); if (pixelpay.CardResult.validateResponse(response!)) { // SUCCESS } else { // ERROR } import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import Card from "@pixelpay/sdk-core/lib/models/Card"; import Billing from "@pixelpay/sdk-core/lib/models/Billing"; import CardTokenization from "@pixelpay/sdk-core/lib/requests/CardTokenization"; import CardResult from "@pixelpay/sdk-core/lib/entities/CardResult"; import { Tokenization } from '@pixelpay/capacitor-plugin'; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const card_token = new CardTokenization() card_token.setCard(card) card_token.setBilling(billing) const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // with async / await try { const response = await tokenization.updateCard(token, card_token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // with callback tokenization.updateCard(token, card_token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR })

Actualizar una Tarjeta Tokenizada (Legacy)

import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import Card from "@pixelpay/sdk-core/lib/models/Card"; import Billing from "@pixelpay/sdk-core/lib/models/Billing"; import CardTokenization from "@pixelpay/sdk-core/lib/requests/CardTokenization"; import Tokenization from "@pixelpay/sdk-core/lib/services/Tokenization"; import CardResult from "@pixelpay/sdk-core/lib/entities/CardResult"; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const card_token = new CardTokenization() card_token.setCard(card) card_token.setBilling(billing) const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // with async / await try { const response = await tokenization.updateCard(token, card_token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // with callback tokenization.updateCard(token, card_token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR }) <?php use PixelPay\Sdk\Entities\CardResult; use PixelPay\Sdk\Models\Billing; use PixelPay\Sdk\Models\Card; use PixelPay\Sdk\Models\Settings; use PixelPay\Sdk\Requests\CardTokenization; use PixelPay\Sdk\Services\Tokenization; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado $settings = new Settings(); $settings->setupEndpoint("https://{endppoint}"); $settings->setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); $card = new Card(); $card->number = "4111 1111 1111 1111"; $card->cvv2 = "999"; $card->expire_month = 7; $card->expire_year = 2023; $card->cardholder = "SERGIO PEREZ"; $billing = new Billing(); $billing->address = "Ave Circunvalacion"; $billing->country = "HN"; $billing->state = "HN-CR"; $billing->city = "San Pedro Sula"; $billing->phone = "998877766"; $card_token = new CardTokenization(); $card_token->setCard($card); $card_token->setBilling($billing); $token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; $tokenization = new Tokenization($settings); try { $response = $tokenization->updateCard($token, $card_token); if (CardResult::validateResponse($response)) { $result = CardResult::fromResponse($response); // SUCCESS } else { // ERROR } } catch (Exception $e) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Settings; import com.pixel.sdk.models.Card; import com.pixel.sdk.models.Billing; import com.pixel.sdk.entities.CardResult; import com.pixel.sdk.requests.CardTokenization; import com.pixel.sdk.services.Tokenization; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); Card card = new Card(); card.number = "4111111111111111"; card.cvv2 = "999"; card.expire_month = 7; card.expire_year = 2023; card.cardholder = "LUIS MILTON"; Billing billing = new Billing(); billing.address = "Colonia San Jorge"; billing.country = "HN"; billing.state = "HN-CR"; billing.city = "San Pedro Sula"; billing.phone = "99999999"; CardTokenization card_token = new CardTokenization(); card_token.setCard(card); card_token.setBilling(billing); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; // enviamos el current activity como segundo parametro Tokenization tokenization = new Tokenization(settings, this); try { tokenization.updateCard(token, card_token); if (CardResult.validateResponse(response)) { CardResult result = CardResult.fromResponse(response); // SUCCESS } } catch (Exception e) { // ERROR } from pixelpay.services import Tokenization from pixelpay.models import Card, Billing, Settings from pixelpay.requests import CardTokenization from pixelpay.entities import CardResult try: settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") card = Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "LUIS MILTON" billing = Billing() billing.address = "Colonia San Jorge" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" card_token = CardTokenization() card_token.setCard(card) card_token.setBilling(billing) token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" tokenization = Tokenization(settings) response = tokenization.updateCard(token, card_token) if CardResult.validateResponse(response): # SUCCESS entity = CardResult.fromResponse(response) print(f"ENTITY JSON: {entity}") except Exception as e: # ERROR print(f"ERR: {str(e)}") e.with_traceback() # En desarrollo. // En desarrollo. // En desarrollo.

Obtener Metadata de una Tarjeta Tokenizada (Dispositivos Móviles)

import PixelPaySDK // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado let settings = Settings() settings.setupEndpoint(endpoint: "https://{endpoint}") settings.setupCredentials(key: "2222222222", hash: "elhashmd5delsecretkeydelcomercio") let token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" let tokenization = Tokenization(settings: settings) do { try tokenization.showCard(token: token) { response in if CardResult.validateResponse(response: response) { let result = CardResult.fromResponse(response: response) // SUCCESS } } } catch { // ERROR } import com.pixel.sdk.models.Settings import com.pixel.sdk.entities.CardResult import com.pixel.sdk.mobile.services.Tokenization // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado val settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" // enviamos el current activity como segundo parametro val tokenization = Tokenization(settings, this) try { tokenization.showCard(token).then { if (CardResult.validateResponse(it)) { val result = CardResult.fromResponse(it) // SUCCESS } else { System.out.println(it.message); } }.thenCatch { it.printStackTrace() } } catch (e: Exception) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.CardResult; import com.pixel.sdk.mobile.services.Tokenization; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; // enviamos el current activity como segundo parametro Tokenization tokenization = new Tokenization(settings, this); tokenization.showCard(token).then(response -> { if (CardResult.validateResponse(response)) { CardResult result = CardResult.fromResponse(response); // SUCCESS } }).thenCatch(err -> { // ERROR }).start(); import 'package:pixelpay_sdk/models/settings.dart' as pixelpay; import 'package:pixelpay_sdk/entities/card_result.dart' as pixelpay; import 'package:pixelpay_sdk/services/tokenization.dart' as pixelpay; final settings = pixelpay.Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; final tokenization = pixelpay.Tokenization(settings); final response = await tokenization.showCard(token); if (pixelpay.CardResult.validateResponse(response!)){ // SUCCESS } else { // ERROR } import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import CardTokenization from "@pixelpay/sdk-core/lib/requests/CardTokenization"; import CardResult from "@pixelpay/sdk-core/lib/entities/CardResult"; import { Transaction } from '@pixelpay/capacitor-plugin'; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // with async / await try { const response = await tokenization.showCard(token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // with callback tokenization.showCard(token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR })

Obtener Metadata de una Tarjeta Tokenizada (Legacy)

import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import Tokenization from "@pixelpay/sdk-core/lib/services/Tokenization"; import CardTokenization from "@pixelpay/sdk-core/lib/requests/CardTokenization"; import CardResult from "@pixelpay/sdk-core/lib/entities/CardResult"; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // with async / await try { const response = await tokenization.showCard(token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // with callback tokenization.showCard(token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR }) <?php use PixelPay\Sdk\Entities\CardResult; use PixelPay\Sdk\Models\Settings; use PixelPay\Sdk\Services\Tokenization; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado $settings = new Settings(); $settings->setupEndpoint("https://{endppoint}"); $settings->setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); $token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; $tokenization = new Tokenization($settings); try { $response = $tokenization->showCard($token); if (CardResult::validateResponse($response)) { $result = CardResult::fromResponse($response); // SUCCESS } else { // ERROR } } catch (Exception $e) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.CardResult; import com.pixel.sdk.services.Tokenization; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; // enviamos el current activity como segundo parametro Tokenization tokenization = new Tokenization(settings, this); try { tokenization.showCard(token); if (CardResult.validateResponse(response)) { CardResult result = CardResult.fromResponse(response); // SUCCESS } } catch (Exception e) { // ERROR } from pixelpay.services import Tokenization from pixelpay.models import Settings from pixelpay.entities import CardResult try: settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" tokenization = Tokenization(settings) response = tokenization.showCard(token) if CardResult.validateResponse(response): # SUCCESS entity = CardResult.fromResponse(response) print(f"ENTITY JSON: {entity}") except Exception as e: # ERROR print(f"ERR: {str(e)}") e.with_traceback() # En desarrollo. // En desarrollo. // En desarrollo.

Eliminar una Tarjeta Tokenizada (Dispositivos Móviles)

import PixelPaySDK // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado let settings = Settings() settings.setupEndpoint(endpoint: "https://{endpoint}") settings.setupCredentials(key: "2222222222", hash: "elhashmd5delsecretkeydelcomercio") let token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" let tokenization = Tokenization(settings: settings) do { try tokenization.deleteCard(token: token) { response in if response is SuccessResponse { // SUCCESS } } } catch { // ERROR } import com.pixel.sdk.responses.SuccessResponse import com.pixel.sdk.models.Settings import com.pixel.sdk.entities.CardResult import com.pixel.sdk.mobile.services.Tokenization // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado val settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" // enviamos el current activity como segundo parametro val tokenization = Tokenization(settings, this) try { tokenization.deleteCard(token).then { if (it is SuccessResponse) { // SUCCESS } else { System.out.println(it.message); } }.thenCatch { it.printStackTrace() } } catch (e: Exception) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.responses.SuccessResponse; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.CardResult; import com.pixel.sdk.mobile.services.Tokenization; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; // enviamos el current activity como segundo parametro Tokenization tokenization = new Tokenization(settings, this); tokenization.deleteCard(token).then(response -> { if (response instanceof SuccessResponse) { // SUCCESS } }).thenCatch(err -> { // ERROR }).start(); import 'package:pixelpay_sdk/models/settings.dart' as pixelpay; import 'package:pixelpay_sdk/entities/card_result.dart' as pixelpay; import 'package:pixelpay_sdk/services/tokenization.dart' as pixelpay; import 'package:pixelpay_sdk/responses/success_response.dart' as pixelpay; final settings = pixelpay.Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; final tokenization = pixelpay.Tokenization(settings); final response = await tokenization.deleteCard(token); if (response instanceof SuccessResponse) { // SUCCESS } else { // ERROR } import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import CardTokenization from "@pixelpay/sdk-core/lib/requests/CardTokenization"; import CardResult from "@pixelpay/sdk-core/lib/entities/CardResult"; import { Transaction } from '@pixelpay/capacitor-plugin'; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // with async / await try { const response = await tokenization.deleteCard(token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // with callback tokenization.deleteCard(token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR })

Eliminar una Tarjeta Tokenizada (Legacy)

import Settings from "@pixelpay/sdk-core/lib/models/Settings"; import Tokenization from "@pixelpay/sdk-core/lib/services/Tokenization"; import CardTokenization from "@pixelpay/sdk-core/lib/requests/CardTokenization"; import CardResult from "@pixelpay/sdk-core/lib/entities/CardResult"; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // with async / await try { const response = await tokenization.deleteCard(token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // with callback tokenization.deleteCard(token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR }) <?php use PixelPay\Sdk\Entities\CardResult; use PixelPay\Sdk\Models\Settings; use PixelPay\Sdk\Services\Tokenization; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado $settings = new Settings(); $settings->setupEndpoint("https://{endppoint}"); $settings->setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); $token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; $tokenization = new Tokenization($settings); try { $response = $tokenization->deleteCard($token); if (CardResult::validateResponse($response)) { $result = CardResult::fromResponse($response); // SUCCESS } else { // ERROR } } catch (Exception $e) { // ERROR } import com.pixel.sdk.base.Response; import com.pixel.sdk.responses.SuccessResponse; import com.pixel.sdk.models.Settings; import com.pixel.sdk.entities.CardResult; import com.pixel.sdk.services.Tokenization; // Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; // enviamos el current activity como segundo parametro Tokenization tokenization = new Tokenization(settings, this); try { tokenization.deleteCard(token); if (response instanceof SuccessResponse) { // SUCCESS } } catch (Exception e) { // ERROR } from pixelpay.services import Tokenization from pixelpay.models import Settings from pixelpay.entities import CardResult from pixelpay.responses import SuccessResponse try: settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" tokenization = Tokenization(settings) response = tokenization.deleteCard(token) if isinstance(response, SuccessResponse): # SUCCESS entity = CardResult.fromResponse(response) print(f"ENTITY JSON: {entity}") except Exception as e: # ERROR print(f"ERR: {str(e)}") e.with_traceback() # En desarrollo. // En desarrollo. // En desarrollo.

Puede ser que la solicitud falle al intentar comunicarse con los servicios de PixelPay, por eso importante siempre cubrir el bloque de código en un try/catch.