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.
Para configurar el SDK, se necesita extraer el Endpoint, Key ID y Secret Key desde la plataforma.
Es muy importante que el valor del Secret Key se convierta a un MD5 hash.
Para más información Ver extracción de endpoint y llaves
Como buena práctica, todas las funciones del SDK de PixelPay excepto el método withAuthenticationRequest
deben de ser llamadas desde el backend de la integración, enviando los datos requeridos desde el frontend de ser necesario.
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 y Navegadores)
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)
// Con async / await
try {
const response = await service.doSale(sale)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
} catch (error) {
// ERROR
}
// Con callback
service.doSale(sale).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// ERROR
})
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 is_valid_payment = service.verifyPaymentHash(
hash: result.payment_hash,
order_id: sale.order_id,
secret: "abc..."
)
if is_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
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 parámetro
Transaction service = new Transaction(settings, activity);
service.doSale(sale).then(response -> {
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
boolean is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).thenCatch(err -> {
// ERROR
}).start();
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 parámetro
val service = Transaction(settings, activity)
try {
service.doSale(sale).then {
if (TransactionResult.validateResponse(it)) {
val result = TransactionResult.fromResponse(it)
val is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")
if (is_valid_payment) {
// SUCCESS Valid Payment
}
} else {
System.out.println(it.message);
}
}.thenCatch {
it.printStackTrace()
}
} catch (e: Exception) {
// ERROR
}
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.country = "HN";
billing.state = "HN-CR";
billing.city = "San Pedro Sula";
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.currency = "HNL";
order.customer_name = "SERGIO PEREZ";
order.customer_email = "sergio.perez@gmail.com";
order.addItem(item);
final sale = pixelpay.SaleTransaction();
sale.setOrder(order);
sale.setCard(card);
sale.setBilling(billing);
final service = pixelpay.Transaction(settings);
final response = await service.doSale(sale);
if (pixelpay.TransactionResult.validateResponse(response!)) {
final result = pixelpay.TransactionResult.fromResponse(response);
final is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Valid Payment
} else {
// ERROR
}
} 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)
// Con async / await
try {
const response = await service.doSale(sale)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
} catch (error) {
// ERROR
}
// Con callback
service.doSale(sale).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// 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/react-native-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)
// Con async / await
try {
const response = await service.doSale(sale)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
} catch (error) {
// ERROR
}
// Con callback
service.doSale(sale).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// ERROR
})
Transacción con Tarjeta sin Tokenización (Legacy)
Para realizar pagos autenticados con 3D Secure debes utilizar un SDK de Dispositivo Móvil y no Legacy.
<?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_payment = $service->verifyPaymentHash(
$result->payment_hash,
$order->id,
"abc...", // secret
);
if ($is_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);
Transaction service = new Transaction(settings);
try {
Response response = service.doSale(sale);
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
boolean is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Valid 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):
response_result = TransactionResult.fromResponse(response)
print(f"RESULT JSON: {response_result}")
is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", # secret
)
if is_valid_payment:
# SUCCESS
pass
except Exception as e:
# ERROR
print(f"ERR: {str(e)}")
e.with_traceback()
using PixelPaySDK.Base;
using PixelPaySDK.Entities;
using PixelPaySDK.Models;
using PixelPaySDK.Requests;
using PixelPaySDK.Services;
// 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-99999";
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);
Transaction service = new Transaction(settings);
try {
Response response = service.doSale(sale);
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
bool is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Payment
}
}
} catch (Exception e) {
// ERROR
}
import (
"bitbucket.org/pixelpay/sdk-go/pkg/entities"
"bitbucket.org/pixelpay/sdk-go/pkg/models"
"bitbucket.org/pixelpay/sdk-go/pkg/requests"
"bitbucket.org/pixelpay/sdk-go/pkg/services"
)
// Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings := models.NewSettings()
settings.SetupEndpoint("https://{endpoint}")
settings.SetupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio")
card := models.NewCard()
card.Number = "4111111111111111"
card.Cvv2 = "999"
card.ExpireMonth = 7
card.ExpireYear = 2023
card.Cardholder = "SERGIO PEREZ"
billing := models.NewBilling()
billing.Address = "Ave Circunvalacion"
billing.Country = "HN"
billing.State = "HN-CR"
billing.City = "San Pedro Sula"
billing.Phone = "99999999"
item := models.NewItem()
item.Code = "00001"
item.Title = "Videojuego"
item.Price = 800
item.Qty = 1
order := models.NewOrder()
order.Id = "ORDER-99999"
order.Currency = "HNL"
order.CustomerName = "SERGIO PEREZ"
order.CustomerEmail = "sergio.perez@gmail.com"
order.AddItem(*item)
sale := requests.NewSaleTransaction()
sale.SetCard(*card)
sale.SetBilling(*billing)
sale.SetOrder(*order)
service := services.NewTransaction(*settings)
response, err := service.DoSale(sale)
if err != nil {
// ERROR
}
if entities.ValidateResponseTransactionResult(response) {
result, err := entities.FromResponseTransactionResult(response)
if err != nil {
// ERROR
}
isValidPayment := service.VerifyPaymentHash(result.PaymentHash, sale.OrderId, "abc...")
if isValidPayment {
// SUCCESS
}
}
require "pixelpay_sdk"
# Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings = Settings.new()
settings.setup_endpoint("https://{endpoint}")
settings.setup_credentials("2222222222", "elhashmd5delsecretkeydelcomercio")
card = Card.new()
card.number = "4111111111111111"
card.cvv2 = "999"
card.expire_month = 7
card.expire_year = 2023
card.cardholder = "SERGIO PEREZ"
billing = Billing.new()
billing.address = "Ave Circunvalacion"
billing.country = "HN"
billing.state = "HN-CR"
billing.city = "San Pedro Sula"
billing.phone = "99999999"
item = Item.new()
item.code = "00001"
item.title = "Videojuego"
item.price = 800
item.qty = 1
order = Order.new()
order.id = "ORDER-88888"
order.currency = "HNL"
order.customer_name = "SERGIO PEREZ"
order.customer_email = "sergio.perez@gmail.com"
order.add_item(item)
sale = SaleTransaction.new()
sale.set_order(order)
sale.set_card(card)
sale.set_billing(billing)
service = Transaction.new(settings)
begin
response = service.do_sale(sale)
if TransactionResult.validate_response(response)
result = TransactionResult.from_response(response)
is_valid_payment = service.verify_payment_hash(
result.payment_hash,
order.id,
"abc..." # secret
)
if is_valid_payment
# SUCCESS Valid Payment
end
end
rescue StandardError => e
# ERROR
end
Transacción con Tarjeta Tokenizada (Dispositivos Móviles y Navegadores)
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)
// Con async / await
try {
const response = await service.doSale(sale)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
} catch (error) {
// ERROR
}
// Con callback
service.doSale(sale).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// ERROR
})
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 is_valid_payment = service.verifyPaymentHash(
hash: result.payment_hash,
order_id: sale.order_id,
secret: "abc..."
)
if is_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
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 parámetro
Transaction service = new Transaction(settings, activity);
service.doSale(sale).then(response -> {
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
boolean is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).thenCatch(err -> {
// ERROR
}).start();
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 parámetro
val service = Transaction(settings, activity)
try {
service.doSale(sale).then {
if (TransactionResult.validateResponse(it)) {
val result = TransactionResult.fromResponse(it)
val is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")
if (is_valid_payment) {
// SUCCESS Valid Payment
}
} else {
System.out.println(it.message);
}
}.thenCatch {
it.printStackTrace()
}
} catch (e: Exception) {
// ERROR
}
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!)) {
final result = pixelpay.TransactionResult.fromResponse(response);
final is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Valid Payment
} else {
// ERROR
}
} 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)
// Con async / await
try {
const response = await service.doSale(sale)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
} catch (error) {
// ERROR
}
// Con callback
service.doSale(sale).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// 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/react-native-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-88888"
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)
// Con async / await
try {
const response = await service.doSale(sale)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
} catch (error) {
// ERROR
}
// Con callback
service.doSale(sale).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// ERROR
})
Transacción con Tarjeta Tokenizada (Legacy)
Para realizar pagos autenticados con 3D Secure debes utilizar un SDK de Dispositivo Móvil y no Legacy.
<?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_payment = $service->verifyPaymentHash(
$result->payment_hash,
$order->id,
"abc...", // secret
);
if ($is_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);
Transaction service = new Transaction(settings);
try {
Response response = service.doSale(sale);
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
boolean is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Valid 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
response_result = TransactionResult.fromResponse(response)
print(f"RESULT JSON: {response_result}")
is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", # secret
)
if is_valid_payment:
# SUCCESS
pass
except Exception as e:
# ERROR
print(f"ERR: {str(e)}")
e.with_traceback()
using PixelPaySDK.Base;
using PixelPaySDK.Entities;
using PixelPaySDK.Models;
using PixelPaySDK.Requests;
using PixelPaySDK.Services;
// 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 = 800;
item.qty = 1;
Order order = new Order();
order.id = "ORDER-99999";
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);
Transaction service = new Transaction(settings);
try {
Response response = service.doSale(sale);
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
bool is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Payment
}
}
} catch (Exception e) {
// ERROR
}
import (
"bitbucket.org/pixelpay/sdk-go/pkg/entities"
"bitbucket.org/pixelpay/sdk-go/pkg/models"
"bitbucket.org/pixelpay/sdk-go/pkg/requests"
"bitbucket.org/pixelpay/sdk-go/pkg/services"
)
// Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings := models.NewSettings()
settings.SetupEndpoint("https://{endpoint}")
settings.SetupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio")
item := models.NewItem()
item.Code = "00001"
item.Title = "Videojuego"
item.Price = 800
item.Qty = 1
order := models.NewOrder()
order.Id = "ORDER-99999"
order.Currency = "HNL"
order.CustomerName = "SERGIO PEREZ"
order.CustomerEmail = "sergio.perez@gmail.com"
order.AddItem(*item)
token := "T-6611b606-8ca6-4097-8584-4bc816b8612b"
sale := requests.NewSaleTransaction()
sale.SetCardToken(token)
sale.SetOrder(*order)
service := services.NewTransaction(*settings)
response, err := service.DoSale(sale)
if err != nil {
// ERROR
}
if entities.ValidateResponseTransactionResult(response) {
result, err := entities.FromResponseTransactionResult(response)
if err != nil {
// ERROR
}
isValidPayment := service.VerifyPaymentHash(result.PaymentHash, sale.OrderId, "abc...")
if isValidPayment {
// SUCCESS
}
}
require "pixelpay_sdk"
# Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings = Settings.new()
settings.setup_endpoint("https://{endpoint}")
settings.setup_credentials("2222222222", "elhashmd5delsecretkeydelcomercio")
item = Item.new()
item.code = "00001"
item.title = "Videojuego"
item.price = 800
item.qty = 1
order = Order.new()
order.id = "ORDER-12949"
order.currency = "HNL"
order.customer_name = "SERGIO PEREZ"
order.customer_email = "sergio.perez@gmail.com"
order.add_item(item)
token = "T-1cb07ea3-d45c-4a64-a081-68078b8fc796"
sale = SaleTransaction.new()
sale.set_order(order)
sale.set_card_token(token)
service = Transaction.new(settings)
begin
response = service.do_sale(sale)
if TransactionResult.validate_response(response)
result = TransactionResult.from_response(response)
is_valid_payment = service.verify_payment_hash(
result.payment_hash,
order.id,
"abc..." # secret
)
if is_valid_payment
# SUCCESS Valid Payment
end
end
rescue StandardError => e
# ERROR
end
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.
Utiliza método de anulación para liberar fondos que han sido autorizados o capturados.
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 y Navegadores)
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 AuthTransaction from "@pixelpay/sdk-core/lib/requests/AuthTransaction";
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-6611b606-8ca6-4097-8584-4bc816b8612b"
const auth = new AuthTransaction()
auth.setOrder(order)
auth.setCardToken(token)
const service = new Transaction(settings)
// Con async / await
try {
const response = await service.doAuth(auth)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
} catch (error) {
// ERROR
}
// Con callback
service.doAuth(auth).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
}).catch((error) => {
// ERROR
})
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
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 parámetro
Transaction service = new Transaction(settings, activity);
service.doAuth(auth).then(response -> {
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
// SUCCESS
}
}).thenCatch(err -> {
// ERROR
}).start();
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 parámetro
val service = Transaction(settings, activity)
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 '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!)) {
final result = pixelpay.TransactionResult.fromResponse(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 AuthTransaction from "@pixelpay/sdk-core/lib/requests/AuthTransaction";
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-6611b606-8ca6-4097-8584-4bc816b8612b"
const auth = new AuthTransaction()
auth.setOrder(order)
auth.setCardToken(token)
const service = new Transaction(settings)
// Con async / await
try {
const response = await service.doAuth(auth)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
} catch (error) {
// ERROR
}
// Con callback
service.doAuth(auth).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
}).catch((error) => {
// 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 TransactionResult from '@pixelpay/sdk-core/lib/entities/TransactionResult';
import AuthTransaction from '@pixelpay/sdk-core/lib/requests/AuthTransaction';
import { Transaction } from '@pixelpay/react-native-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-6611b606-8ca6-4097-8584-4bc816b8612b"
const auth = new AuthTransaction()
auth.setOrder(order)
auth.setCardToken(token)
const service = new Transaction(settings)
// Con async / await
try {
const response = await service.doAuth(auth)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
} catch (error) {
// ERROR
}
// Con callback
service.doAuth(auth).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
}).catch((error) => {
// ERROR
})
Autorización de Pago (Legacy)
Para realizar pagos autenticados con 3D Secure debes utilizar un SDK de Dispositivo Móvil y no Legacy.
<?php
use PixelPay\sdk\Models\Settings;
use PixelPay\sdk\Models\Item;
use PixelPay\sdk\Models\Order;
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);
$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);
Transaction service = new Transaction(settings);
try {
Response response = 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
response_result = TransactionResult.fromResponse(response)
print(f"RESULT JSON: {response_result}")
except Exception as e:
# ERROR
print(f"ERR: {str(e)}")
e.with_traceback()
using PixelPaySDK.Base;
using PixelPaySDK.Entities;
using PixelPaySDK.Models;
using PixelPaySDK.Requests;
using PixelPaySDK.Services;
// 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 = 800;
item.qty = 1;
Order order = new Order();
order.id = "ORDER-99999";
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);
Transaction service = new Transaction(settings);
try {
Response response = service.doAuth(auth);
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
// SUCCESS
}
} catch (Exception e) {
// Error
}
import (
"bitbucket.org/pixelpay/sdk-go/pkg/entities"
"bitbucket.org/pixelpay/sdk-go/pkg/models"
"bitbucket.org/pixelpay/sdk-go/pkg/requests"
"bitbucket.org/pixelpay/sdk-go/pkg/services"
)
// Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings := models.NewSettings()
settings.SetupEndpoint("https://{endpoint}")
settings.SetupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio")
item := models.NewItem()
item.Code = "00001"
item.Title = "Videojuego"
item.Price = 800
item.Qty = 1
order := models.NewOrder()
order.Id = "ORDER-99999"
order.Currency = "HNL"
order.CustomerName = "SERGIO PEREZ"
order.CustomerEmail = "sergio.perez@gmail.com"
order.AddItem(*item)
token := "T-6611b606-8ca6-4097-8584-4bc816b8612b"
auth := requests.NewAuthTransaction()
auth.SetCardToken(token)
auth.SetOrder(*order)
service := services.NewTransaction(*settings)
response, err := service.DoAuth(auth)
if err != nil {
// ERROR
}
if entities.ValidateResponseTransactionResult(response) {
result, err := entities.FromResponseTransactionResult(response)
if err != nil {
// ERROR
}
// SUCCESS
}
require "pixelpay_sdk"
# Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings = Settings.new()
settings.setup_endpoint("https://{endpoint}")
settings.setup_credentials("2222222222", "elhashmd5delsecretkeydelcomercio")
item = Item.new()
item.code = "00001"
item.title = "Videojuego"
item.price = 800
item.qty = 1
order = Order.new()
order.id = "ORDER-12949"
order.currency = "HNL"
order.customer_name = "SERGIO PEREZ"
order.customer_email = "sergio.perez@gmail.com"
order.add_item(item)
token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"
auth = AuthTransaction.new()
auth.set_order(order)
auth.set_card_token(token)
service = Transaction.new(settings)
begin
response = service.do_auth(auth)
if TransactionResult.validate_response(response)
result = TransactionResult.from_response(response)
# SUCCESS
end
rescue StandardError => e
# ERROR
end
Captura de Pago (Dispositivos Móviles y Navegadores)
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)
// Con async / await
try {
const response = await service.doCapture(capture)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
} catch (error) {
// ERROR
}
// Con callback
service.doCapture(capture).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
}).catch((error) => {
// ERROR
})
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
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 parámetro
Transaction service = new Transaction(settings, activity);
service.doCapture(capture).then(response -> {
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
// SUCCESS
}
}).thenCatch(err -> {
// ERROR
}).start();
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 parámetro
val service = Transaction(settings, activity)
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 '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!)) {
final result = pixelpay.TransactionResult.fromResponse(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)
// Con async / await
try {
const response = await service.doCapture(capture)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
} catch (error) {
// ERROR
}
// Con callback
service.doCapture(capture).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
}).catch((error) => {
// 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/react-native-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)
// Con async / await
try {
const response = await service.doCapture(capture)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
} catch (error) {
// ERROR
}
// Con callback
service.doCapture(capture).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
}).catch((error) => {
// ERROR
})
Captura de Pago (Legacy)
<?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";
Transaction service = new Transaction(settings);
try {
Response response = 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
response_result = TransactionResult.fromResponse(response)
print(f"RESULT JSON: {response_result}")
except Exception as e:
# ERROR
print(f"ERR: {str(e)}")
e.with_traceback()
using PixelPaySDK.Base;
using PixelPaySDK.Entities;
using PixelPaySDK.Models;
using PixelPaySDK.Requests;
using PixelPaySDK.Services;
// 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";
Transaction service = new Transaction(settings);
try {
Response response = service.doCapture(capture);
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
// SUCCESS
}
} catch (Exception e) {
// ERROR
}
import (
"bitbucket.org/pixelpay/sdk-go/pkg/entities"
"bitbucket.org/pixelpay/sdk-go/pkg/models"
"bitbucket.org/pixelpay/sdk-go/pkg/requests"
"bitbucket.org/pixelpay/sdk-go/pkg/services"
)
// Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings := models.NewSettings()
settings.SetupEndpoint("https://{endpoint}")
settings.SetupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio")
capture := requests.NewCaptureTransaction()
capture.PaymentUuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"
capture.TransactionApprovedAmount = "1000"
service := services.NewTransaction(*settings)
response, err := service.DoCapture(capture)
if err != nil {
// ERROR
}
if entities.ValidateResponseTransactionResult(response) {
result, err := entities.FromResponseTransactionResult(response)
if err != nil {
// ERROR
}
// SUCCESS
}
require "pixelpay_sdk"
# Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings = Settings.new()
settings.setup_endpoint("https://{endpoint}")
settings.setup_credentials("2222222222", "elhashmd5delsecretkeydelcomercio")
capture = CaptureTransaction.new()
capture.payment_uuid = "P-4eb5d39b-482d-49f5-a198-d14eedc4f47d"
capture.transaction_approved_amount = "1000"
service = Transaction.new(settings)
begin
response = service.do_capture(capture)
if TransactionResult.validate_response(response)
result = TransactionResult.from_response(response)
# SUCCESS
end
rescue StandardError => e
# ERROR
end
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
La anulación te permite liberar fondos de pagos que fueron realizados en el mismo día.
Es necesario establecer el parámetro auth_user
utilizando el método setupPlatformUser
del modelo Settings
con el valor SHA-512 del correo electrónico del usuario del comercio autorizado para poder anular cobros. A continuación un ejemplo:
Correo electrónico |
auth_user |
prueba@comercio.com |
ef2b760f...038506b7 |
sergio.perez@gmail.com |
a369a152...f2c138c5 |
También es necesario enviar una firma de anulación para autenticar que es el comercio el que ejecuta la petición. La firma esta compuesta por 3 elementos:
- el
auth_user
: el correo electrónico, mismo del punto anterior
- el
order_id
: el identificador de la orden
- el
secret key
: el secreto del comercio
Es importante ejecutar peticiones de anulación exclusivamente en tus servidores (backend), ya que hacerlo del lado del cliente expondría la firma de anulación del pago al público.
La documentación aquí explica como extraer el secreto del comercio.
Una vez obtenidos los tres elementos mencionados anteriormente, es necesario concatenarlos en una sola cadena, utilizando el carácter |
como delimitador. La cadena concatenada debe seguir este patrón: auth_user|order_id|secret_key
. Por ejemplo:
Nombre |
Valor |
auth_user |
prueba@comercio.com |
order_id |
PAGO-2023-0000726 |
secret key |
3422da00-4dc2-4602-d366-56ac7 |
El valor concatenado resulta siendo: prueba@comercio.com|PAGO-2023-0000726|3422da00-4dc2-4602-d366-56ac7
.
Para generar la firma se procesa el valor anterior con una función de hash SHA-512
. Para nuestro ejemplo, la firma de anulación resultante es 8a944906...777ffae7
.
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"
void_tx.void_signature = "8a944906...777ffae7"
const service = new Transaction(settings)
// Con async / await
try {
const response = await service.doVoid(void_tx)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response);
// SUCCESS
}
} catch (error) {
// ERROR
}
// Con 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";
$void_tx->void_signature = "8a944906...777ffae7";
$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";
void_tx.void_signature = "8a944906...777ffae7";
Transaction service = new Transaction(settings);
try {
Response response = 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"
void_tx.void_signature = "8a944906...777ffae7"
response = service.doVoid(void_tx)
if TransactionResult.validateResponse(response):
# SUCCESS
response_result = TransactionResult.fromResponse(response)
print(f"RESULT JSON: {response_result}")
except Exception as e:
# ERROR
print(f"ERR: {str(e)}")
e.with_traceback()
using PixelPaySDK.Base;
using PixelPaySDK.Entities;
using PixelPaySDK.Models;
using PixelPaySDK.Requests;
using PixelPaySDK.Services;
// 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";
void_tx.void_signature = "8a944906...777ffae7";
Transaction service = new Transaction(settings);
try {
Response response = service.doVoid(void_tx);
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
// SUCCESS
}
} catch (Exception e) {
// ERROR
}
import (
"bitbucket.org/pixelpay/sdk-go/pkg/entities"
"bitbucket.org/pixelpay/sdk-go/pkg/models"
"bitbucket.org/pixelpay/sdk-go/pkg/requests"
"bitbucket.org/pixelpay/sdk-go/pkg/services"
)
// Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings := models.NewSettings()
settings.SetupEndpoint("https://{endpoint}")
settings.SetupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio")
settings.SetupPlatformUser("elhashsha512delcorreodelusuariodelcomercio")
void_tx := requests.NewVoidTransaction()
void_tx.PaymentUuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"
void_tx.VoidReason = "El cliente quiso cancelar"
void_tx.VoidSignature = "8a944906...777ffae7"
service := services.NewTransaction(*settings)
response, err := service.DoVoid(void_tx)
if err != nil {
// ERROR
}
if entities.ValidateResponseTransactionResult(response) {
result, err := entities.FromResponseTransactionResult(response)
if err != nil {
// ERROR
}
// SUCCESS
}
require "pixelpay_sdk"
# Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings = Settings.new()
settings.setup_endpoint("https://{endpoint}")
settings.setup_credentials("2222222222", "elhashmd5delsecretkeydelcomercio")
settings.setup_platform_user("elhashsha512delcorreodelusuariodelcomercio")
void_tx = VoidTransaction.new()
void_tx.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"
void_tx.void_reason = "El cliente quiso cancelar"
void_tx.void_signature = "8a944906...777ffae7"
service = Transaction.new(settings)
begin
response = service.do_void(void_tx)
if TransactionResult.validate_response(response)
result = TransactionResult.from_response(response)
# SUCCESS
end
rescue StandardError => e
# ERROR
end
Consultar estado de un cobro
Ejemplo (Dispositivos Móviles y Navegadores)
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)
// Con async / await
try {
const response = await service.getStatus(status)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
} catch (error) {
// ERROR
}
// Con callback
service.getStatus(status).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
}).catch((error) => {
// ERROR
})
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
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 parámetro
Transaction service = new Transaction(settings, activity);
service.getStatus(status).then(response -> {
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
// SUCCESS
}
}).thenCatch(err -> {
// ERROR
}).start();
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 parámetro
val service = Transaction(settings, activity)
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 '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!)) {
final result = pixelpay.TransactionResult.fromResponse(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)
// Con async / await
try {
const response = await service.getStatus(status)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
} catch (error) {
// ERROR
}
// Con callback
service.getStatus(status).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
}).catch((error) => {
// 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/react-native-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)
// Con async / await
try {
const response = await service.getStatus(status)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
} catch (error) {
// ERROR
}
// Con callback
service.getStatus(status).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
// SUCCESS
}
}).catch((error) => {
// ERROR
})
Ejemplo (Legacy)
<?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";
Transaction service = new Transaction(settings);
try {
Response response = 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")
status = StatusTransaction()
status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"
service = Transaction(settings)
response = service.getStatus(status)
if TransactionResult.validateResponse(response):
# SUCCESS
response_result = TransactionResult.fromResponse(response)
print(f"RESULT JSON: {response_result}")
except Exception as e:
# ERROR
print(f"ERR: {str(e)}")
e.with_traceback()
using PixelPaySDK.Base;
using PixelPaySDK.Entities;
using PixelPaySDK.Models;
using PixelPaySDK.Requests;
using PixelPaySDK.Services;
// 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";
Transaction service = new Transaction(settings);
try {
Response response = service.getStatus(status);
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
// SUCCESS
}
} catch (Exception e) {
// ERROR
}
import (
"bitbucket.org/pixelpay/sdk-go/pkg/entities"
"bitbucket.org/pixelpay/sdk-go/pkg/models"
"bitbucket.org/pixelpay/sdk-go/pkg/requests"
"bitbucket.org/pixelpay/sdk-go/pkg/services"
)
// Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings := models.NewSettings()
settings.SetupEndpoint("https://{endpoint}")
settings.SetupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio")
status := requests.NewStatusTransaction()
status.PaymentUuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"
service := services.NewTransaction(*settings)
response, err := service.GetStatus(status)
if err != nil {
// ERROR
}
if entities.ValidateResponseTransactionResult(response) {
result, err := entities.FromResponseTransactionResult(response)
if err != nil {
// ERROR
}
// SUCCESS
}
require "pixelpay_sdk"
# Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings = Settings.new()
settings.setup_endpoint("https://{endpoint}")
settings.setup_credentials("2222222222", "elhashmd5delsecretkeydelcomercio")
status = StatusTransaction.new()
status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d"
service = Transaction.new(settings)
begin
response = service.get_status(status)
if TransactionResult.validate_response(response)
result = TransactionResult.from_response(response)
# SUCCESS
end
rescue StandardError => e
# ERROR
end
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.
Una vez obtenidos los tres elementos mencionados anteriormente, es necesario concatenarlos en una sola cadena, utilizando el carácter |
como delimitador. La cadena concatenada debe seguir este patrón: order_id|key_id|secret_key
.
A continuación veremos un ejemplo:
Nombre |
Valor |
order_id |
00000123 |
key ID |
7812290000 |
secret key |
3422da00-4dc2-4602-d366-56ac7 |
Y el resultado de este ejemplo: 00000123|7812290000|3422da00-4dc2-4602-d366-56ac7
.
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 y Navegadores)
// 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 is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// 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 is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// ERROR
})
// 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 is_valid_payment = service.verifyPaymentHash(
hash: result.payment_hash,
order_id: sale.order_id,
secret: "abc..."
)
if is_valid_payment {
// SUCCESS Valid Payment
}
}
}
} catch {
// ERROR
}
// Luego de realizar una transacción
service.doSale(sale).then(response -> {
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
boolean is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).thenCatch(err -> {
// ERROR
}).start();
// Luego de realizar una transacción
try {
service.doSale(sale).then {
if (TransactionResult.validateResponse(it)) {
val result = TransactionResult.fromResponse(it)
val is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")
if (is_valid_payment) {
// SUCCESS Valid Payment
}
} else {
System.out.println(it.message);
}
}.thenCatch {
it.printStackTrace()
}
} catch (e: Exception) {
// ERROR
}
final service = pixelpay.Transaction(settings);
final response = await service.doSale(sale);
if (pixelpay.TransactionResult.validateResponse(response!)) {
final result = pixelpay.TransactionResult.fromResponse(response);
final is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// 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 is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// 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 is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// 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 is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// 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 is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// ERROR
})
Ejemplo (Legacy)
<?php
use PixelPay\Sdk\Entities\TransactionResult;
try {
$response = $service->doSale($sale);
if (TransactionResult::validateResponse($response)) {
$result = TransactionResult::fromResponse($response);
$is_valid_payment = $service->verifyPaymentHash(
$result->payment_hash,
$order->id,
"abc..." // secret
);
if ($is_valid_payment) {
// SUCCESS Valid Payment
}
}
} catch (Exception $e) {
// ERROR
}
// Luego de realizar una transacción
try {
Response response = service.doSale(sale);
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
boolean is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Payment
}
}
} catch(Exception e) {
// ERROR
}
from pixelpay.entities import TransactionResult
try:
response = service.doSale(sale)
if TransactionResult.validateResponse(response):
response_result = TransactionResult.fromResponse(response)
print(f"RESULT JSON: {response_result}")
is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", # secret
)
if is_valid_payment:
# SUCCESS
pass
except Exception as e:
# ERROR
print(f"ERR: {str(e)}")
e.with_traceback()
// Luego de realizar una transacción
try {
Response response = service.doSale(sale);
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
bool is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Payment
}
}
} catch (Exception e) {
// ERROR
}
// Luego de realizar una transacción
response, err := service.DoSale(sale)
if err != nil {
// ERROR
}
if entities.ValidateResponseTransactionResult(response) {
result, err := entities.FromResponseTransactionResult(response)
if err != nil {
// ERROR
}
isValidPayment := service.VerifyPaymentHash(result.PaymentHash, sale.OrderId, "abc...")
if isValidPayment {
// SUCCESS
}
}
# Luego de realizar una transacción
begin
response = service.do_sale(sale)
if TransactionResult.validate_response(response)
result = TransactionResult.from_response(response)
is_valid_payment = service.verify_payment_hash(
result.payment_hash,
order.id,
"abc..." # secret
)
if is_valid_payment
# SUCCESS Valid Payment
end
end
rescue StandardError => e
# ERROR
end
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 y Navegadores)
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)
// Con 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
}
// Con callback
tokenization.vaultCard(card_token).then((response) => {
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
}).catch((error) => {
// ERROR
})
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
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 parámetro
Tokenization tokenization = new Tokenization(settings, activity);
tokenization.vaultCard(card_token).then(response -> {
if (CardResult.validateResponse(response)) {
CardResult result = CardResult.fromResponse(response);
// SUCCESS
}
}).thenCatch(err -> {
// ERROR
}).start();
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 parámetro
val tokenization = Tokenization(settings, activity)
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 '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.country = "HN";
billing.state = "HN-CR";
billing.city = "San Pedro Sula";
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!)) {
final result = pixelpay.CardResult.fromResponse(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)
// Con 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
}
// Con callback
tokenization.vaultCard(card_token).then((response) => {
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
}).catch((error) => {
// 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/react-native-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)
// Con 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
}
// Con 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)
<?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);
Tokenization tokenization = new Tokenization(settings);
try {
Response response = 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
response_result = CardResult.fromResponse(response)
print(f"RESULT JSON: {response_result}")
except Exception as e:
# ERROR
print(f"ERR: {str(e)}")
e.with_traceback()
using PixelPaySDK.Base;
using PixelPaySDK.Entities;
using PixelPaySDK.Models;
using PixelPaySDK.Requests;
using PixelPaySDK.Responses;
using PixelPaySDK.Services;
// 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 = "22900000";
CardTokenization card_token = new CardTokenization();
card_token.setCard(card);
card_token.setBilling(billing);
Tokenization tokenization = new Tokenization(settings);
try {
Response response = tokenization.vaultCard(card_token);
if (CardResult.validateResponse(response)) {
CardResult result = CardResult.fromResponse((SuccessResponse)response);
// SUCCESS
}
} catch (Exception e) {
// ERROR
}
import (
"bitbucket.org/pixelpay/sdk-go/pkg/entities"
"bitbucket.org/pixelpay/sdk-go/pkg/models"
"bitbucket.org/pixelpay/sdk-go/pkg/requests"
"bitbucket.org/pixelpay/sdk-go/pkg/services"
)
// Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings := models.NewSettings()
settings.SetupEndpoint("https://{endpoint}")
settings.SetupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio")
card := models.NewCard()
card.Number = "4111111111111111"
card.Cvv2 = "999"
card.ExpireMonth = 7
card.ExpireYear = 2023
card.Cardholder = "SERGIO PEREZ"
billing := models.NewBilling()
billing.Address = "Ave Circunvalacion"
billing.Country = "HN"
billing.State = "HN-CR"
billing.City = "San Pedro Sula"
billing.Phone = "99999999"
cardToken := requests.NewCardTokenization()
cardToken.SetCard(*card)
cardToken.SetBilling(*billing)
tokenization := services.NewTokenization(*settings)
response, err := tokenization.VaultCard(cardToken)
if err != nil {
// ERROR
}
if entities.ValidateResponseCardResult(response) {
result, err := entities.FromResponseCardResult(response)
if err != nil {
// ERROR
}
// SUCCESS
}
require "pixelpay_sdk"
# Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings = Settings.new()
settings.setup_endpoint("https://{endpoint}")
settings.setup_credentials("2222222222", "elhashmd5delsecretkeydelcomercio")
card = Card.new()
card.number = "4111111111111111"
card.cvv2 = "999"
card.expire_month = 7
card.expire_year = 2023
card.cardholder = "SERGIO PEREZ"
billing = Billing.new()
billing.address = "Ave Circunvalacion"
billing.country = "HN"
billing.state = "HN-CR"
billing.city = "San Pedro Sula"
billing.phone = "99999999"
card_token = CardTokenization.new()
card_token.set_card(card)
card_token.set_billing(billing)
tokenization = Tokenization.new(settings)
begin
response = tokenization.vault_card(card_token)
if CardResult.validate_response(response)
result = CardResult.from_response(response)
# SUCCESS
end
rescue StandardError => e
# ERROR
end
Actualizar una Tarjeta Tokenizada (Dispositivos Móviles y Navegadores)
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)
// Con 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
}
// Con callback
tokenization.updateCard(token, card_token).then((response) => {
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
}).catch((error) => {
// ERROR
})
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
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 parámetro
Tokenization tokenization = new Tokenization(settings, activity);
tokenization.updateCard(token, card_token).then(response -> {
if (CardResult.validateResponse(response)) {
CardResult result = CardResult.fromResponse(response);
// SUCCESS
}
}).thenCatch(err -> {
// ERROR
}).start();
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 parámetro
val tokenization = Tokenization(settings, activity)
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 '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.country = "HN";
billing.state = "HN-CR";
billing.city = "San Pedro Sula";
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!)) {
final result = pixelpay.CardResult.fromResponse(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)
// Con 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
}
// Con callback
tokenization.updateCard(token, card_token).then((response) => {
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
}).catch((error) => {
// 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/react-native-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)
// Con 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
}
// Con 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)
<?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";
Tokenization tokenization = new Tokenization(settings);
try {
Response response = 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
response_result = CardResult.fromResponse(response)
print(f"RESULT JSON: {response_result}")
except Exception as e:
# ERROR
print(f"ERR: {str(e)}")
e.with_traceback()
using PixelPaySDK.Base;
using PixelPaySDK.Entities;
using PixelPaySDK.Models;
using PixelPaySDK.Requests;
using PixelPaySDK.Responses;
using PixelPaySDK.Services;
// 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";
Tokenization tokenization = new Tokenization(settings);
try {
Response response = tokenization.updateCard(token, card_token);
if (CardResult.validateResponse(response)) {
CardResult result = CardResult.fromResponse((SuccessResponse)response);
// SUCCESS
}
} catch (Exception e) {
// ERROR
}
import (
"bitbucket.org/pixelpay/sdk-go/pkg/entities"
"bitbucket.org/pixelpay/sdk-go/pkg/models"
"bitbucket.org/pixelpay/sdk-go/pkg/requests"
"bitbucket.org/pixelpay/sdk-go/pkg/services"
)
// Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings := models.NewSettings()
settings.SetupEndpoint("https://{endpoint}")
settings.SetupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio")
card := models.NewCard()
card.Number = "4111111111111111"
card.Cvv2 = "999"
card.ExpireMonth = 7
card.ExpireYear = 2023
card.Cardholder = "LUIS MILTON"
billing := models.NewBilling()
billing.Address = "Colonia San Jorge"
billing.Country = "HN"
billing.State = "HN-CR"
billing.City = "San Pedro Sula"
billing.Phone = "99999999"
cardToken := requests.NewCardTokenization()
cardToken.SetCard(*card)
cardToken.SetBilling(*billing)
token := "T-6611b606-8ca6-4097-8584-4bc816b8612b"
tokenization := services.NewTokenization(*settings)
response, err := tokenization.UpdateCard(token, cardToken)
if err != nil {
// ERROR
}
if entities.ValidateResponseCardResult(response) {
result, err := entities.FromResponseCardResult(response)
if err != nil {
// ERROR
}
// SUCCESS
}
require "pixelpay_sdk"
# Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings = Settings.new()
settings.setup_endpoint("https://{endpoint}")
settings.setup_credentials("2222222222", "elhashmd5delsecretkeydelcomercio")
card = Card.new()
card.number = "4111111111111111"
card.cvv2 = "999"
card.expire_month = 7
card.expire_year = 2023
card.cardholder = "SERGIO PEREZ"
billing = Billing.new()
billing.address = "Ave Circunvalacion"
billing.country = "HN"
billing.state = "HN-CR"
billing.city = "San Pedro Sula"
billing.phone = "99999999"
card_token = CardTokenization.new()
card_token.set_card(card)
card_token.set_billing(billing)
token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"
tokenization = Tokenization.new(settings)
begin
response = tokenization.update_card(token, card_token)
if CardResult.validate_response(response)
result = CardResult.from_response(response)
# SUCCESS
end
rescue StandardError => e
# ERROR
end
Obtener Metadata de una Tarjeta Tokenizada (Dispositivos Móviles y Navegadores)
import Settings from "@pixelpay/sdk-core/lib/models/Settings";
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 token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"
const tokenization = new Tokenization(settings)
// Con async / await
try {
const response = await tokenization.showCard(token)
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
} catch (error) {
// ERROR
}
// Con callback
tokenization.showCard(token).then((response) => {
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
}).catch((error) => {
// ERROR
})
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
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 parámetro
Tokenization tokenization = new Tokenization(settings, activity);
tokenization.showCard(token).then(response -> {
if (CardResult.validateResponse(response)) {
CardResult result = CardResult.fromResponse(response);
// SUCCESS
}
}).thenCatch(err -> {
// ERROR
}).start();
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 parámetro
val tokenization = Tokenization(settings, activity)
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 '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!)){
final result = pixelpay.CardResult.fromResponse(response);
// SUCCESS
} else {
// ERROR
}
import Settings from "@pixelpay/sdk-core/lib/models/Settings";
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 token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"
const tokenization = new Tokenization(settings)
// Con async / await
try {
const response = await tokenization.showCard(token)
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
} catch (error) {
// ERROR
}
// Con callback
tokenization.showCard(token).then((response) => {
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
}).catch((error) => {
// ERROR
})
import Settings from '@pixelpay/sdk-core/lib/models/Settings';
import CardResult from '@pixelpay/sdk-core/lib/entities/CardResult';
import { Tokenization } from '@pixelpay/react-native-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)
// Con async / await
try {
const response = await tokenization.showCard(token)
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
} catch (error) {
// ERROR
}
// Con 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)
<?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";
Tokenization tokenization = new Tokenization(settings);
try {
Response response = 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
response_result = CardResult.fromResponse(response)
print(f"RESULT JSON: {response_result}")
except Exception as e:
# ERROR
print(f"ERR: {str(e)}")
e.with_traceback()
using PixelPaySDK.Base;
using PixelPaySDK.Entities;
using PixelPaySDK.Models;
using PixelPaySDK.Responses;
using PixelPaySDK.Services;
// 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";
Tokenization tokenization = new Tokenization(settings);
try {
Response response = tokenization.showCard(token);
if (CardResult.validateResponse(response)) {
CardResult result = CardResult.fromResponse((SuccessResponse)response);
// SUCCESS
}
} catch (Exception e) {
// ERROR
}
import (
"bitbucket.org/pixelpay/sdk-go/pkg/entities"
"bitbucket.org/pixelpay/sdk-go/pkg/models"
"bitbucket.org/pixelpay/sdk-go/pkg/services"
)
// Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings := models.NewSettings()
settings.SetupEndpoint("https://{endpoint}")
settings.SetupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio")
token := "T-6611b606-8ca6-4097-8584-4bc816b8612b"
tokenization := services.NewTokenization(*settings)
response, err := tokenization.ShowCard(token)
if err != nil {
// ERROR
}
if entities.ValidateResponseCardResult(response) {
result, err := entities.FromResponseCardResult(response)
if err != nil {
// ERROR
}
// SUCCESS
}
require "pixelpay_sdk"
# Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings = Settings.new()
settings.setup_endpoint("https://{endpoint}")
settings.setup_credentials("2222222222", "elhashmd5delsecretkeydelcomercio")
token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"
tokenization = Tokenization.new(settings)
begin
response = tokenization.show_card(token)
if CardResult.validate_response(response)
result = CardResult.from_response(response)
# SUCCESS
end
rescue StandardError => e
# ERROR
end
Eliminar una Tarjeta Tokenizada (Dispositivos Móviles y Navegadores)
import Settings from "@pixelpay/sdk-core/lib/models/Settings";
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 token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"
const tokenization = new Tokenization(settings)
// Con async / await
try {
const response = await tokenization.deleteCard(token)
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
} catch (error) {
// ERROR
}
// Con callback
tokenization.deleteCard(token).then((response) => {
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
}).catch((error) => {
// ERROR
})
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 {
let result = CardResult.fromResponse(response: response)
// 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
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 parámetro
Tokenization tokenization = new Tokenization(settings, activity);
tokenization.deleteCard(token).then(response -> {
if (response instanceof SuccessResponse) {
CardResult result = CardResult.fromResponse(response);
// SUCCESS
}
}).thenCatch(err -> {
// ERROR
}).start();
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 parámetro
val tokenization = Tokenization(settings, activity)
try {
tokenization.deleteCard(token).then {
if (it is SuccessResponse) {
val result = CardResult.fromResponse(it)
// SUCCESS
} else {
System.out.println(it.message);
}
}.thenCatch {
it.printStackTrace()
}
} catch (e: Exception) {
// ERROR
}
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) {
final result = pixelpay.CardResult.fromResponse(response);
// SUCCESS
} else {
// ERROR
}
import Settings from "@pixelpay/sdk-core/lib/models/Settings";
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 token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"
const tokenization = new Tokenization(settings)
// Con async / await
try {
const response = await tokenization.deleteCard(token)
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
} catch (error) {
// ERROR
}
// Con callback
tokenization.deleteCard(token).then((response) => {
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
}).catch((error) => {
// ERROR
})
import Settings from '@pixelpay/sdk-core/lib/models/Settings';
import CardResult from '@pixelpay/sdk-core/lib/entities/CardResult';
import { Tokenization } from '@pixelpay/react-native-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)
// Con async / await
try {
const response = await tokenization.deleteCard(token)
if (CardResult.validateResponse(response)) {
const result = CardResult.fromResponse(response)
// SUCCESS
} else {
// ERROR
}
} catch (error) {
// ERROR
}
// Con 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)
<?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";
Tokenization tokenization = new Tokenization(settings);
try {
Response response = tokenization.deleteCard(token);
if (response instanceof SuccessResponse) {
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
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
response_result = CardResult.fromResponse(response)
print(f"RESULT JSON: {response_result}")
except Exception as e:
# ERROR
print(f"ERR: {str(e)}")
e.with_traceback()
using PixelPaySDK.Base;
using PixelPaySDK.Models;
using PixelPaySDK.Responses;
using PixelPaySDK.Services;
// 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";
Tokenization tokenization = new Tokenization(settings);
try {
Response response = tokenization.deleteCard(token);
if (response is SuccessResponse) {
// SUCCESS
}
} catch (Exception e) {
// ERROR
}
import (
"bitbucket.org/pixelpay/sdk-go/pkg/entities"
"bitbucket.org/pixelpay/sdk-go/pkg/models"
"bitbucket.org/pixelpay/sdk-go/pkg/services"
)
// Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings := models.NewSettings()
settings.SetupEndpoint("https://{endpoint}")
settings.SetupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio")
token := "T-6611b606-8ca6-4097-8584-4bc816b8612b"
tokenization := services.NewTokenization(*settings)
response, err := tokenization.DeleteCard(token)
if err != nil {
// ERROR
}
if entities.ValidateResponseCardResult(response) {
result, err := entities.FromResponseCardResult(response)
if err != nil {
// ERROR
}
// SUCCESS
}
require "pixelpay_sdk"
# Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings = Settings.new()
settings.setup_endpoint("https://{endpoint}")
settings.setup_credentials("2222222222", "elhashmd5delsecretkeydelcomercio")
token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"
tokenization = Tokenization.new(settings)
begin
response = tokenization.delete_card(token)
if CardResult.validate_response(response)
result = CardResult.from_response(response)
# SUCCESS
end
rescue StandardError => e
# ERROR
end
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
.
Programas de lealtad
La integración de programas a través del SDK de PixelPay abre un mundo de posibilidades técnicas para los comercios al gestionar sus transacciones.
Los comercios pueden no solo realizar cobros de manera eficiente, sino también proporcionar a sus clientes la capacidad de realizar pagos utilizando planes de financiamiento precisos, como el intra-financiamiento y el extra-financiamiento.
El número de cuotas permitidas para estos planes de pagos son 3, 6, 9, 12, 18, 24 y 36 meses.
De igual manera que en Realizar cobros / Venta directa, Autorización y Captura de Pagos, se puede realizar una transacción de programas 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:
Intra-financiamiento
Para realizar este tipo de cobro debes agregar al objeto de transacción (Sale
) el método setInstallment
indicando el número de meses e intra
como tipo de financiamiento.
Transacción con Tarjeta Tokenizada (Dispositivos Móviles y Navegadores)
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)
sale.setInstallment(9, "intra");
const service = new Transaction(settings)
// Con async / await
try {
const response = await service.doSale(sale)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
} catch (error) {
// ERROR
}
// Con callback
service.doSale(sale).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// ERROR
})
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)
sale.setInstallment(months: 9, type: "intra")
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 is_valid_payment = service.verifyPaymentHash(
hash: result.payment_hash,
order_id: sale.order_id,
secret: "abc..."
)
if is_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
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);
sale.setInstallment(9, "intra");
// Enviamos el current activity como segundo parámetro
Transaction service = new Transaction(settings, activity);
service.doSale(sale).then(response -> {
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
boolean is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).thenCatch(err -> {
// ERROR
}).start();
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)
sale.setInstallment(9, "intra");
// Enviamos el current activity como segundo parámetro
val service = Transaction(settings, activity)
try {
service.doSale(sale).then {
if (TransactionResult.validateResponse(it)) {
val result = TransactionResult.fromResponse(it)
val is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")
if (is_valid_payment) {
// SUCCESS Valid Payment
}
} else {
System.out.println(it.message);
}
}.thenCatch {
it.printStackTrace()
}
} catch (e: Exception) {
// 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)
sale.setInstallment(9, "intra")
const service = new Transaction(settings)
// Con async / await
try {
const response = await service.doSale(sale)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
} catch (error) {
// ERROR
}
// Con callback
service.doSale(sale).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// 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/react-native-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-88888"
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)
sale.setInstallment(9, "intra")
const service = new Transaction(settings)
// Con async / await
try {
const response = await service.doSale(sale)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
} catch (error) {
// ERROR
}
// Con callback
service.doSale(sale).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// ERROR
})
Transacción con Tarjeta Tokenizada (Legacy)
<?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);
$sale->setInstallment(9, "intra");
$service = new Transaction($settings);
try {
$response = $service->doSale($sale);
if (TransactionResult::validateResponse($response)) {
$result = TransactionResult::fromResponse($response);
$is_valid_payment = $service->verifyPaymentHash(
$result->payment_hash,
$order->id,
"abc...", // secret
);
if ($is_valid_payment) {
// SUCCESS Valid Payment
}
} else {
// CHECK Failed Response
echo $response->message;
}
} catch (Exception $e) {
// 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
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);
sale.setInstallment(9, "intra");
// Enviamos el current activity como segundo parámetro
Transaction service = new Transaction(settings, activity);
service.doSale(sale).then(response -> {
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
boolean is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).thenCatch(err -> {
// ERROR
}).start();
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)
sale.setInstallment(9, "intra")
service = Transaction(settings)
response = service.doSale(sale)
if TransactionResult.validateResponse(response):
# SUCCESS
response_result = TransactionResult.fromResponse(response)
print(f"RESULT JSON: {response_result}")
is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", # secret
)
if is_valid_payment:
# SUCCESS
pass
except Exception as e:
# ERROR
print(f"ERR: {str(e)}")
e.with_traceback()
using PixelPaySDK.Base;
using PixelPaySDK.Entities;
using PixelPaySDK.Models;
using PixelPaySDK.Requests;
using PixelPaySDK.Services;
// 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 = 800;
item.qty = 1;
Order order = new Order();
order.id = "ORDER-99999";
order.currency = "HNL";
order.customer_name = "SERGIO PEREZ";
order.customer_email = "sergio.perez@gmail.com";
order.addItem(item);
String token = "T-ec0aeda8-fca2-4aca-9230-b8d7a2bda20a";
SaleTransaction sale = new SaleTransaction();
sale.setOrder(order);
sale.setCardToken(token);
sale.setInstallment(9, "intra");
Transaction service = new Transaction(settings);
try
{
Response response = service.doSale(sale);
if (TransactionResult.validateResponse(response))
{
TransactionResult result = TransactionResult.fromResponse(response);
bool is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment)
{
// SUCCESS Payment
}
}
}
catch (Exception e)
{
// ERROR
}
import (
"bitbucket.org/pixelpay/sdk-go/pkg/entities"
"bitbucket.org/pixelpay/sdk-go/pkg/models"
"bitbucket.org/pixelpay/sdk-go/pkg/requests"
"bitbucket.org/pixelpay/sdk-go/pkg/services"
)
// Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings := models.NewSettings()
settings.SetupEndpoint("https://{endpoint}")
settings.SetupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio")
item := models.NewItem()
item.Code = "00001"
item.Title = "Videojuego"
item.Price = 800
item.Qty = 1
order := models.NewOrder()
order.Id = "ORDER-99999"
order.Currency = "HNL"
order.CustomerName = "SERGIO PEREZ"
order.CustomerEmail = "sergio.perez@gmail.com"
order.AddItem(*item)
token := "T-ec0aeda8-fca2-4aca-9230-b8d7a2bda20a"
sale := requests.NewSaleTransaction()
sale.SetCardToken(token)
sale.SetOrder(*order)
sale.SetInstallment(9, "intra")
service := services.NewTransaction(*settings)
response, err := service.DoSale(sale)
if err != nil {
// ERROR
}
if entities.ValidateResponseTransactionResult(response) {
result, err := entities.FromResponseTransactionResult(response)
if err != nil {
// ERROR
}
isValidPayment := service.VerifyPaymentHash(result.PaymentHash, sale.OrderId, "abc...")
if isValidPayment {
// SUCCESS
}
}
require "pixelpay_sdk"
# Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings = Settings.new()
settings.setup_endpoint("https://{endpoint}")
settings.setup_credentials("2222222222", "elhashmd5delsecretkeydelcomercio")
item = Item.new()
item.code = "00001"
item.title = "Videojuego"
item.price = 800
item.qty = 1
order = Order.new()
order.id = "ORDER-12949"
order.currency = "HNL"
order.customer_name = "SERGIO PEREZ"
order.customer_email = "sergio.perez@gmail.com"
order.add_item(item)
token = "T-1cb07ea3-d45c-4a64-a081-68078b8fc796"
sale = SaleTransaction.new()
sale.set_order(order)
sale.set_card_token(token)
sale.set_installment(9, "intra")
service = Transaction.new(settings)
begin
response = service.do_sale(sale)
if TransactionResult.validate_response(response)
result = TransactionResult.from_response(response)
is_valid_payment = service.verify_payment_hash(
result.payment_hash,
order.id,
"abc..." # secret
)
if is_valid_payment
# SUCCESS Valid Payment
end
end
rescue StandardError => e
# ERROR
end
Extra-financiamiento
Para realizar este tipo de cobro se debe agregar al objeto de transacción (Sale
) el método setInstallment
indicando el número de meses y extra
como tipo de financiamiento.
Transacción con Tarjeta Tokenizada (Dispositivos Móviles y Navegadores)
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)
sale.setInstallment(12, "extra");
const service = new Transaction(settings)
// Con async / await
try {
const response = await service.doSale(sale)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
} catch (error) {
// ERROR
}
// Con callback
service.doSale(sale).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// ERROR
})
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)
sale.setInstallment(months: 12, type: "extra")
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 is_valid_payment = service.verifyPaymentHash(
hash: result.payment_hash,
order_id: sale.order_id,
secret: "abc..."
)
if is_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
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);
sale.setInstallment(12, "extra");
// Enviamos el current activity como segundo parámetro
Transaction service = new Transaction(settings, activity);
service.doSale(sale).then(response -> {
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
boolean is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).thenCatch(err -> {
// ERROR
}).start();
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)
sale.setInstallment(12, "extra");
// Enviamos el current activity como segundo parámetro
val service = Transaction(settings, activity)
try {
service.doSale(sale).then {
if (TransactionResult.validateResponse(it)) {
val result = TransactionResult.fromResponse(it)
val is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...")
if (is_valid_payment) {
// SUCCESS Valid Payment
}
} else {
System.out.println(it.message);
}
}.thenCatch {
it.printStackTrace()
}
} catch (e: Exception) {
// 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)
sale.setInstallment(12, "extra")
const service = new Transaction(settings)
// Con async / await
try {
const response = await service.doSale(sale)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
} catch (error) {
// ERROR
}
// Con callback
service.doSale(sale).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// 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/react-native-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-88888"
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)
sale.setInstallment(12, "extra")
const service = new Transaction(settings)
// Con async / await
try {
const response = await service.doSale(sale)
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
} catch (error) {
// ERROR
}
// Con callback
service.doSale(sale).then((response) => {
if (TransactionResult.validateResponse(response)) {
const result = TransactionResult.fromResponse(response)
const is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", // secret
)
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).catch((error) => {
// ERROR
})
Transacción con Tarjeta Tokenizada (Legacy)
<?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);
$sale->setInstallment(12, "extra");
$service = new Transaction($settings);
try {
$response = $service->doSale($sale);
if (TransactionResult::validateResponse($response)) {
$result = TransactionResult::fromResponse($response);
$is_valid_payment = $service->verifyPaymentHash(
$result->payment_hash,
$order->id,
"abc...", // secret
);
if ($is_valid_payment) {
// SUCCESS Valid Payment
}
} else {
// CHECK Failed Response
echo $response->message;
}
} catch (Exception $e) {
// 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
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);
sale.setInstallment(12, "extra");
// Enviamos el current activity como segundo parámetro
Transaction service = new Transaction(settings, activity);
service.doSale(sale).then(response -> {
if (TransactionResult.validateResponse(response)) {
TransactionResult result = TransactionResult.fromResponse(response);
boolean is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment) {
// SUCCESS Valid Payment
}
}
}).thenCatch(err -> {
// ERROR
}).start();
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)
sale.setInstallment(12, "extra")
service = Transaction(settings)
response = service.doSale(sale)
if TransactionResult.validateResponse(response):
# SUCCESS
response_result = TransactionResult.fromResponse(response)
print(f"RESULT JSON: {response_result}")
is_valid_payment = service.verifyPaymentHash(
result.payment_hash,
order.id,
"abc...", # secret
)
if is_valid_payment:
# SUCCESS
pass
except Exception as e:
# ERROR
print(f"ERR: {str(e)}")
e.with_traceback()
using PixelPaySDK.Base;
using PixelPaySDK.Entities;
using PixelPaySDK.Models;
using PixelPaySDK.Requests;
using PixelPaySDK.Services;
// 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 = 800;
item.qty = 1;
Order order = new Order();
order.id = "ORDER-99999";
order.currency = "HNL";
order.customer_name = "SERGIO PEREZ";
order.customer_email = "sergio.perez@gmail.com";
order.addItem(item);
String token = "T-ec0aeda8-fca2-4aca-9230-b8d7a2bda20a";
SaleTransaction sale = new SaleTransaction();
sale.setOrder(order);
sale.setCardToken(token);
sale.setInstallment(12, "extra");
Transaction service = new Transaction(settings);
try
{
Response response = service.doSale(sale);
if (TransactionResult.validateResponse(response))
{
TransactionResult result = TransactionResult.fromResponse(response);
bool is_valid_payment = service.verifyPaymentHash(result.payment_hash, sale.order_id, "abc...");
if (is_valid_payment)
{
// SUCCESS Payment
}
}
}
catch (Exception e)
{
// ERROR
}
import (
"bitbucket.org/pixelpay/sdk-go/pkg/entities"
"bitbucket.org/pixelpay/sdk-go/pkg/models"
"bitbucket.org/pixelpay/sdk-go/pkg/requests"
"bitbucket.org/pixelpay/sdk-go/pkg/services"
)
// Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings := models.NewSettings()
settings.SetupEndpoint("https://{endpoint}")
settings.SetupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio")
item := models.NewItem()
item.Code = "00001"
item.Title = "Videojuego"
item.Price = 800
item.Qty = 1
order := models.NewOrder()
order.Id = "ORDER-99999"
order.Currency = "HNL"
order.CustomerName = "SERGIO PEREZ"
order.CustomerEmail = "sergio.perez@gmail.com"
order.AddItem(*item)
token := "T-ec0aeda8-fca2-4aca-9230-b8d7a2bda20a"
sale := requests.NewSaleTransaction()
sale.SetCardToken(token)
sale.SetOrder(*order)
sale.SetInstallment(12, "extra")
service := services.NewTransaction(*settings)
response, err := service.DoSale(sale)
if err != nil {
// ERROR
}
if entities.ValidateResponseTransactionResult(response) {
result, err := entities.FromResponseTransactionResult(response)
if err != nil {
// ERROR
}
isValidPayment := service.VerifyPaymentHash(result.PaymentHash, sale.OrderId, "abc...")
if isValidPayment {
// SUCCESS
}
}
require "pixelpay_sdk"
# Agregar llaves del comercio y endpoint brindado por el banco una vez afiliado
settings = Settings.new()
settings.setup_endpoint("https://{endpoint}")
settings.setup_credentials("2222222222", "elhashmd5delsecretkeydelcomercio")
item = Item.new()
item.code = "00001"
item.title = "Videojuego"
item.price = 800
item.qty = 1
order = Order.new()
order.id = "ORDER-12949"
order.currency = "HNL"
order.customer_name = "SERGIO PEREZ"
order.customer_email = "sergio.perez@gmail.com"
order.add_item(item)
token = "T-1cb07ea3-d45c-4a64-a081-68078b8fc796"
sale = SaleTransaction.new()
sale.set_order(order)
sale.set_card_token(token)
sale.set_installment(12, "extra")
service = Transaction.new(settings)
begin
response = service.do_sale(sale)
if TransactionResult.validate_response(response)
result = TransactionResult.from_response(response)
is_valid_payment = service.verify_payment_hash(
result.payment_hash,
order.id,
"abc..." # secret
)
if is_valid_payment
# SUCCESS Valid Payment
end
end
rescue StandardError => e
# ERROR
end
El número de cuotas permitidas para estos planes de pagos son 3, 6, 9, 12, 18, 24 y 36 meses.
Recursos
El recurso Locations
alberga un inventario de ubicaciones, todas ellas en conformidad con las directrices establecidas por las normas ISO-3166-1 e ISO-3166-2. Es fundamental mantener coherencia con dichos estándares, dado que son las que se manejan dentro del ecosistema de PixelPay.
Ejemplo (Dispositivos Móviles y Navegadores)
import Locations from '@pixelpay/sdk-core/lib/resources/Locations';
// Obtener listado de países
const countries = Locations.countriesList()
// ej. {HN: "Honduras", NI: "Nicaragua", US: "Estados Unidos", ...}
// Obtener listado de subdivisiones del país
const states = Locations.statesList('HN')
// ej. {HN-AT: "Atlantida", HN-CH: "Choluteca", HN-CL: "Colon", ...}
// Obtener formatos de código postal y teléfono del país
const formats = Locations.formatsList('HN')
// ej. {phone_code: 504, zip_format: ""}
import PixelPaySDK
// Obtener listado de países
let countries = Locations.countriesList()
// ej. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...}
// Obtener listado de subdivisiones del país
let states = Locations.statesList(country_code: "HN")
// ej. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...}
// Obtener formatos de código postal y teléfono del país
let formats = Locations.formatsList(country_code: "HN")
// ej. {"phone_code": "504", "zip_format": ""}
import com.pixel.sdk.resources.Locations;
// Obtener listado de países
Map<String, String> countries = Locations.countriesList();
// ej. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...}
// Obtener listado de subdivisiones del país
Map<String, String> states = Locations.statesList("HN");
// ej. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...}
// Obtener formatos de código postal y teléfono del país
Map<String, String> formats = Locations.formatsList("HN");
// ej. {"phone_code": 504, "zip_format": ""}
import com.pixel.sdk.resources.Locations;
// Obtener listado de países
val countries = Locations.countriesList()
// ej. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...}
// Obtener listado de subdivisiones del país
val states = Locations.statesList("HN")
// ej. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...}
// Obtener formatos de código postal y teléfono del país
val formats = Locations.formatsList("HN")
// ej. {"phone_code": 504, "zip_format": ""}
import 'package:pixelpay_sdk/resources/locations.dart' as pixelpay;
// Obtener listado de países
final countries = await pixelpay.Locations.countriesList();
// ej. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...}
// Obtener listado de subdivisiones del país
final states = await pixelpay.Locations.statesList("HN");
// ej. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...}
// Obtener formatos de código postal y teléfono del país
final formats = await pixelpay.Locations.formatsList("HN");
// ej. {"phone_code": 504, "zip_format": ""}
import Locations from '@pixelpay/sdk-core/lib/resources/Locations';
// Obtener listado de países
const countries = Locations.countriesList()
// ej. {HN: "Honduras", NI: "Nicaragua", US: "Estados Unidos", ...}
// Obtener listado de subdivisiones del país
const states = Locations.statesList('HN')
// ej. {HN-AT: "Atlantida", HN-CH: "Choluteca", HN-CL: "Colon", ...}
// Obtener formatos de código postal y teléfono del país
const formats = Locations.formatsList('HN')
// ej. {phone_code: 504, zip_format: ""}
import Locations from '@pixelpay/sdk-core/lib/resources/Locations';
// Obtener listado de países
const countries = Locations.countriesList()
// ej. {HN: "Honduras", NI: "Nicaragua", US: "Estados Unidos", ...}
// Obtener listado de subdivisiones del país
const states = Locations.statesList('HN')
// ej. {HN-AT: "Atlantida", HN-CH: "Choluteca", HN-CL: "Colon", ...}
// Obtener formatos de código postal y teléfono del país
const formats = Locations.formatsList('HN')
// ej. {phone_code: 504, zip_format: ""}
Ejemplo (Legacy)
<?php
use PixelPay\Sdk\Resources\Locations;
// Obtener listado de países
$countries = Locations::countriesList();
/* ej.
{
["HN"]=> "Honduras"
["NI"]=> "Nicaragua"
["US"]=> "Estados Unidos"
...
}
*/
// Obtener listado de subdivisiones del país
$states = Locations::statesList('HN');
/* ej.
{
["HN-AT"]=> "Atlantida"
["HN-CH"]=> "Choluteca"
["HN-CL"]=> "Colon"
...
}
*/
// Obtener formatos de código postal y teléfono del país
$formats = Locations::formatsList('HN');
/* ej.
{
["phone_code"]=> 504
["zip_format"]=> ""
}
*/
import com.pixel.sdk.resources.Locations;
// Obtener listado de países
Map<String, String> countries = Locations.countriesList();
// ej. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...}
// Obtener listado de subdivisiones del país
Map<String, String> states = Locations.statesList("HN");
// ej. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...}
// Obtener formatos de código postal y teléfono del país
Map<String, String> formats = Locations.formatsList("HN");
// ej. {"phone_code": 504, "zip_format": ""}
from pixelpay.resources import Locations
# Obtener listado de países
countries = Locations.countriesList()
# ej. {'HN': 'Honduras', 'NI': 'Nicaragua', 'US': 'Estados Unidos', ...}
# Obtener listado de subdivisiones del país
states = Locations.statesList("HN")
# ej. {'HN-AT': 'Atlantida', 'HN-CH': 'Choluteca', 'HN-CL': 'Colon', ...}
# Obtener formatos de código postal y teléfono del país
formats = Locations.formatsList("HN")
# ej. {'phone_code': 504, 'zip_format': ''}
using PixelPaySDK.Resources;
// Obtener listado de países
var countries = Locations.CountriesList();
// ej. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...}
// Obtener listado de subdivisiones del país
var states = Locations.StatesList("HN");
// ej. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...}
// Obtener formatos de código postal y teléfono del país
var formats = Locations.FormatsList("HN");
// ej. {"phone_code": 504, "zip_format": ""}
import (
"bitbucket.org/pixelpay/sdk-go/pkg/resources"
)
// Obtener listado de países
countries := resources.CountriesList()
// ej. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...}
// Obtener listado de subdivisiones del país
states := resources.StatesList("HN")
// ej. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...}
// Obtener formatos de código postal y teléfono del país
formats := resources.FormatsList("HN")
// ej. {"phone_code": 504, "zip_format": ""}
require "pixelpay_sdk"
# Obtener listado de países
countries = Locations.countries_list
# ej. {"HN"=>"Honduras", "NI"=>"Nicaragua", "US"=>"Estados Unidos", ...}
# Obtener listado de subdivisiones del país
states = Locations.states_list("HN")
# ej. {"HN-AT"=>"Atlantida", "HN-CH"=>"Choluteca", "HN-CL"=>"Colon", ...}
# Obtener formatos de código postal y teléfono del país
formats = Locations.formats_list("HN")
# ej. {"phone_code"=>504, "zip_format"=>""}