Use Cases


Intro

This section brings together all the previously mentioned scenarios showcasing the most common cases that a merchant could face using the PixelPay Sandbox.

To configure the SDK, you need to extract the Endpoint, Key ID and Secret Key from the platform.

It is very important that the Secret Key value is converted to an MD5 hash. For more information See endpoint and key extraction


As a good practice, all PixelPay SDK (except withAuthenticationRequest) functions should be called from the backend of the integration, sending the required data from the frontend if necessary.

Create Payment / Direct Sale

Payments are a safe way to pay for goods or services using PixelPay, without being redirected to another website or having to see the payment modal.

There are two ways to make a payment:

  • By sending the transaction (Sale), order (Order), card object (Card), and billing address (Billing).
  • By sending the transaction (Sale), the transaction order (Order), and a tokenized card.

Transaction without using a tokenized Card (Mobile Devices and Browsers)

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"; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const item = new Item() item.code = "00001" item.title = "Videojuego" item.price = 800 item.qty = 1 const order = new Order() order.id = "ORDER-88888" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) const sale = new SaleTransaction() sale.setOrder(order) sale.setCard(card) sale.setBilling(billing) const service = new Transaction(settings) // With async / await try { const response = await service.doSale(sale) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const is_valid_payment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (is_valid_payment) { // SUCCESS Valid Payment } } } catch (error) { // ERROR } // With 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 // Add the merchant keys and endpoint provided by the bank once affiliated 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() in case 3DS protection is enabled 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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); // Send current activity as a second parameter 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 // Add the merchant keys and endpoint provided by the bank once affiliated 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() in case 3DS protection is enabled sale.setOrder(order) sale.setCard(card) sale.setBilling(billing) // Send current activity as a second parameter 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const item = new Item() item.code = "00001" item.title = "Videojuego" item.price = 800 item.qty = 1 const order = new Order() order.id = "ORDER-88888" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) const sale = new SaleTransaction() sale.setOrder(order) sale.setCard(card) sale.setBilling(billing) const service = new Transaction(settings) // With async / await try { const response = await service.doSale(sale) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const is_valid_payment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (is_valid_payment) { // SUCCESS Valid Payment } } } catch (error) { // ERROR } // With 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings : Settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const item = new Item() item.code = "00001" item.title = "Videojuego" item.price = 800 item.qty = 1 const order = new Order() order.id = "ORDER-88888" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) const sale = new SaleTransaction() sale.setOrder(order) sale.setCard(card) sale.setBilling(billing) const service = new Transaction(settings) // With async / await try { const response = await service.doSale(sale) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const is_valid_payment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (is_valid_payment) { // SUCCESS Valid Payment } } } catch (error) { // ERROR } // With 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 })

Transaction without using a tokenized Card (Legacy)

To make authenticated payments with 3D Secure you must use a Mobile SDK and not 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; // Add the merchant keys and endpoint provided by the bank once affiliated $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; // Add the merchant keys and endpoint provided by the bank once affiliated 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_paymentx) { // 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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" ) // Add the merchant keys and endpoint provided by the bank once affiliated 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" # Add the merchant keys and endpoint provided by the bank once affiliated 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

Transaction with tokenized Card (Mobile Devices and Browsers)

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"; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const item = new Item() item.code = "00001" item.title = "Videojuego" item.price = 800 item.qty = 1 const order = new Order() order.id = "ORDER-12949" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) const token = "T-1cb07ea3-d45c-4a64-a081-68078b8fc796" const sale = new SaleTransaction() sale.setOrder(order) sale.setCardToken(token) const service = new Transaction(settings) // With async / await try { const response = await service.doSale(sale) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const is_valid_payment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (is_valid_payment) { // SUCCESS Valid Payment } } } catch (error) { // ERROR } // With 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 // Add the merchant keys and endpoint provided by the bank once affiliated 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() in case 3DS protection is enabled 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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); // Send current activity as a second parameter 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 // Add the merchant keys and endpoint provided by the bank once affiliated 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() in case 3DS protection is enabled sale.setOrder(order) sale.setCardToken(token) // Send current activity as a second parameter 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 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const item = new Item() item.code = "00001" item.title = "Videojuego" item.price = 800 item.qty = 1 const order = new Order() order.id = "ORDER-12949" order.currency = "HNL" order.customer_name = "SERGIO PEREZ" order.customer_email = "sergio.perez@gmail.com" order.addItem(item) const token = "T-1cb07ea3-d45c-4a64-a081-68078b8fc796" const sale = new SaleTransaction() sale.setOrder(order) sale.setCardToken(token) const service = new Transaction(settings) // With async / await try { const response = await service.doSale(sale) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) const is_valid_payment = service.verifyPaymentHash( result.payment_hash, order.id, "abc...", // secret ) if (is_valid_payment) { // SUCCESS Valid Payment } } } catch (error) { // ERROR } // With 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'; // Add the merchant keys and endpoint provided by the bank once affiliated 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) // With 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 } // With 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 })

Transaction with a tokenized Card (Legacy)

To make authenticated payments with 3D Secure you must use a Mobile SDK and not 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; // Add the merchant keys and endpoint provided by the bank once affiliated $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; // Add the merchant keys and endpoint provided by the bank once affiliated 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); // Send current activity as a second parameter 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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" ) // Add the merchant keys and endpoint provided by the bank once affiliated 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" # Add the merchant keys and endpoint provided by the bank once affiliated 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

It is important to use try/catch blocks to handle any exceptions that may arise from a miscommunication with the PixelPay servers.


Payment Authorization and Capture

To send a Payment Authorization, the same steps for creating a Direct Sale must be followed, as shown in the previous example. However, a Capture transaction must also be executed to complete the payment.

Use the void method to release funds that have been authorized or captured.

Just like in the previous example, a Payment Authorization can be done using a credit or debit card, tokenized or not. For this example, a tokenized card will be used.

Payment Authorization (Mobile Devices and Browsers)

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"; // Add the merchant keys and endpoint provided by the bank once affiliated 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) // With async / await try { const response = await service.doAuth(auth) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // With callback service.doAuth(auth).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR }) import PixelPaySDK // Add the merchant keys and endpoint provided by the bank once affiliated 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() in case 3DS protection is enabled 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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); // Send current activity as a second parameter 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 // Add the merchant keys and endpoint provided by the bank once affiliated 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() in case 3DS protection is enabled auth.setOrder(order) auth.setCardToken(token) // Send current activity as a second parameter 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'; // Add the merchant keys and endpoint provided by the bank once affiliated 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) // With async / await try { const response = await service.doAuth(auth) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // With callback service.doAuth(auth).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR }) 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'; // Add the merchant keys and endpoint provided by the bank once affiliated 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) // With async / await try { const response = await service.doAuth(auth) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // With callback service.doAuth(auth).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR })

Payment Authorization (Legacy)

To make authenticated payments with 3D Secure you must use a Mobile SDK and not 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; // Add the merchant keys and endpoint provided by the bank once affiliated $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; // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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" ) // Add the merchant keys and endpoint provided by the bank once affiliated 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" # Add the merchant keys and endpoint provided by the bank once affiliated 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

Payment Capture (Mobile Devices and Browsers)

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"; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const capture = new CaptureTransaction() capture.payment_uuid = "P-4eb5d39b-482d-49f5-a198-d14eedc4f47d" capture.transaction_approved_amount = "1000" const service = new Transaction(settings) // With async / await try { const response = await service.doCapture(capture) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // With callback service.doCapture(capture).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR }) import PixelPaySDK // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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"; // Send current activity as a second parameter 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 // Add the merchant keys and endpoint provided by the bank once affiliated 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" // Send current activity as a second parameter 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const capture = new CaptureTransaction() capture.payment_uuid = "P-4eb5d39b-482d-49f5-a198-d14eedc4f47d" capture.transaction_approved_amount = "1000" const service = new Transaction(settings) // With async / await try { const response = await service.doCapture(capture) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // With callback service.doCapture(capture).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR }) 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const capture = new CaptureTransaction() capture.payment_uuid = "P-4eb5d39b-482d-49f5-a198-d14eedc4f47d" capture.transaction_approved_amount = "1000" const service = new Transaction(settings) // With async / await try { const response = await service.doCapture(capture) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // With callback service.doCapture(capture).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR })

Payment Capture (Legacy)

<?php use PixelPay\sdk\Models\Settings; use PixelPay\sdk\Requests\CaptureTransaction; use PixelPay\sdk\Services\Transaction; use PixelPay\sdk\Entities\TransactionResult; // Add the merchant keys and endpoint provided by the bank once affiliated $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; // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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" ) // Add the merchant keys and endpoint provided by the bank once affiliated 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" # Add the merchant keys and endpoint provided by the bank once affiliated 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

It is important to use try/catch blocks to handle any exceptions that may arise from a miscommunication with the PixelPay servers.


Cancelling Payments

Cancel transactions allows you to release funds from payments that were made on the same day.

It is necessary to set the auth_user parameter using the setupPlatformUser method of the Settings model with the SHA-512 value of the email of the authorized merchant user in order to cancel charges. Below is an example:

E-mail auth_user
prueba@comercio.com ef2b760f...038506b7
sergio.perez@gmail.com a369a152...f2c138c5

It is also necessary to send a cancellation signature to authenticate that it is the merchant that executes the request. The signature is made up of 3 elements:

  • auth_user: the email, same as the previous point
  • order_id: the order identifier
  • secret key: the merchant's secret key

It is important to run cancellation requests exclusively on your servers/backend, as doing so on the client side would expose the payment cancellation signature to the public.

Merchant's secret key extraction is further explained here.

Once the three elements mentioned above have been obtained, it is necessary to concatenate them into a single string, using the | character as a delimiter. The concatenated string must follow this pattern: auth_user|order_id|secret_key. For example:

Name Value
auth_user prueba@comercio.com
order_id PAGO-2023-0000726
secret key 3422da00-4dc2-4602-d366-56ac7

The concatenated value results in: prueba@comercio.com|PAGO-2023-0000726|3422da00-4dc2-4602-d366-56ac7.

To generate the signature, the previous value is hashed with the SHA-512 function. For our example, the resulting cancellation signature is 8a944906...777ffae7.

Example (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"; // Add the merchant keys and endpoint provided by the bank once affiliated 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) // With async / await try { const response = await service.doVoid(void_tx) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response); // SUCCESS } } catch (error) { // ERROR } // With callback service.doVoid(void_tx).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response); // SUCCESS } }).catch((error) => { // ERROR }) <?php use PixelPay\sdk\Models\Settings; use PixelPay\sdk\Requests\VoidTransaction; use PixelPay\sdk\Services\Transaction; use PixelPay\sdk\Entities\TransactionResult; // Add the merchant keys and endpoint provided by the bank once affiliated $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; // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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" ) // Add the merchant keys and endpoint provided by the bank once affiliated 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" # Add the merchant keys and endpoint provided by the bank once affiliated 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

Checking a Payment's Status

Example (Mobile Devices and Browsers)

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"; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const status = new StatusTransaction() status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" const service = new Transaction(settings) // With async / await try { const response = await service.getStatus(status) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // With callback service.getStatus(status).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR }) import PixelPaySDK // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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"; // Send current activity as a second parameter 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 // Add the merchant keys and endpoint provided by the bank once affiliated val settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") val status = StatusTransaction() status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" // Send current activity as a second parameter 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const status = new StatusTransaction() status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" const service = new Transaction(settings) // With async / await try { const response = await service.getStatus(status) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // With callback service.getStatus(status).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR }) 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const status = new StatusTransaction() status.payment_uuid = "P-8d938206-59bf-4298-aa61-a44a3a61674d" const service = new Transaction(settings) // With async / await try { const response = await service.getStatus(status) if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } } catch (error) { // ERROR } // With callback service.getStatus(status).then((response) => { if (TransactionResult.validateResponse(response)) { const result = TransactionResult.fromResponse(response) // SUCCESS } }).catch((error) => { // ERROR })

Example (Legacy)

<?php use PixelPay\Sdk\Entities\TransactionResult; use PixelPay\Sdk\Models\Settings; use PixelPay\Sdk\Requests\StatusTransaction; use PixelPay\Sdk\Services\Transaction; // Add the merchant keys and endpoint provided by the bank once affiliated $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; // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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" ) // Add the merchant keys and endpoint provided by the bank once affiliated 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" # Add the merchant keys and endpoint provided by the bank once affiliated 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

Verifying a Payment

Whenever a transaction is succesfully executed, the field payment_hash is included within the response. This field contains a string value that verifies the authenticity of a payment. To compare the received payment_hash value and verify that the transaction is genuine, three elements are needed:

  • order_id: Order identifier
  • key ID: Merchant's key
  • secret key: Merchant's secret key.

Payment verification can only be done on the server side, and not on the cliente side. If the client had access to this information, the payment hash would be available to the general public.

Merchant's key extraction is further explained here.

Once the three elements previously mentioned are obtained, it is necessary to concatenate them in a single string, using the character | as a delimiter. The concatenated string must follow this pattern: order_id|key_id|secret_key.

For example,

Name Value
order_id 00000123
key ID 7812290000
secret key abc...

Concatenated string: 00000123|7812290000|abc....

To finish the validation process, it is necessary to apply an MD5 hash to the concatenated string, and it can then be compared to the value returned in the payment_hash field. If both values are the same, the payment can be verified as genuine.

The Transaction services contains the verifyPaymentHash method which verifies whether the payment_hash is valid or not.

Example (Mobile Devices and Browsers)

// After executing a transaction with 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 } // After executing a transaction with 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 }) // After executing a transaction 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 } // After executing a transaction 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(); // After executing a transaction 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 } } // After executing a transaction with 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 } // After executing a transaction with 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 }) // After executing a transaction with 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 } // After executing a transaction with 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 })

Example (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 } // After executing a transaction 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() // After executing a transaction 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 } // After executing a transaction 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 } } # After executing a transaction 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

Tokenization

PixelPay's tokenization service allows card information to be stored securely using a token that simplifies the payment process and allows the merchant to access a variety of additional benefits including: omnichannel experiences, customer insights, and more.

The SDK simplifies integration with the tokenization service by offering the methods to tokenize a card, update card information, associate cards with merchants, obtain card information and deleting cards.

For more information about Tokenization, click here.

Tokenizing a Card (Mobile Devices and Browsers)

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"; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const card_token = new CardTokenization() card_token.setCard(card) card_token.setBilling(billing) const tokenization = new Tokenization(settings) // With async / await try { const response = await tokenization.vaultCard(card_token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // With callback tokenization.vaultCard(card_token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR }) import PixelPaySDK // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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); // Send current activity as a second parameter 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 // Add the merchant keys and endpoint provided by the bank once affiliated 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) // Send current activity as a second parameter 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const card_token = new CardTokenization() card_token.setCard(card) card_token.setBilling(billing) const tokenization = new Tokenization(settings) // With async / await try { const response = await tokenization.vaultCard(card_token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // With callback tokenization.vaultCard(card_token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR }) 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const card_token = new CardTokenization() card_token.setCard(card) card_token.setBilling(billing) const tokenization = new Tokenization(settings) // With async / await try { const response = await tokenization.vaultCard(card_token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // With callback tokenization.vaultCard(card_token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR })

Tokenizing a Card (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; // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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" ) // Add the merchant keys and endpoint provided by the bank once affiliated 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" # Add the merchant keys and endpoint provided by the bank once affiliated 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

Updating a tokenized Card's information (Mobile Devices and Browsers)

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"; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const card_token = new CardTokenization() card_token.setCard(card) card_token.setBilling(billing) const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // With async / await try { const response = await tokenization.updateCard(token, card_token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // With callback tokenization.updateCard(token, card_token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR }) import PixelPaySDK // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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"; // Send current activity as a second parameter 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 // Add the merchant keys and endpoint provided by the bank once affiliated 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" // Send current activity as a second parameter 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const card_token = new CardTokenization() card_token.setCard(card) card_token.setBilling(billing) const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // With async / await try { const response = await tokenization.updateCard(token, card_token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // With callback tokenization.updateCard(token, card_token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR }) 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const card = new Card() card.number = "4111111111111111" card.cvv2 = "999" card.expire_month = 7 card.expire_year = 2023 card.cardholder = "SERGIO PEREZ" const billing = new Billing() billing.address = "Ave Circunvalacion" billing.country = "HN" billing.state = "HN-CR" billing.city = "San Pedro Sula" billing.phone = "99999999" const card_token = new CardTokenization() card_token.setCard(card) card_token.setBilling(billing) const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // With async / await try { const response = await tokenization.updateCard(token, card_token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // With callback tokenization.updateCard(token, card_token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR })

Update a tokenized Card's information (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; // Add the merchant keys and endpoint provided by the bank once affiliated $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; // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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" ) // Add the merchant keys and endpoint provided by the bank once affiliated 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" # Add the merchant keys and endpoint provided by the bank once affiliated 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

Retrieve a Card's information (Mobile Devices and Browsers)

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"; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // With async / await try { const response = await tokenization.showCard(token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // With callback tokenization.showCard(token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR }) import PixelPaySDK // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; // Send current activity as a second parameter 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 // Add the merchant keys and endpoint provided by the bank once affiliated val settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" // Send current activity as a second parameter 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // With async / await try { const response = await tokenization.showCard(token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // With callback tokenization.showCard(token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR }) 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // With async / await try { const response = await tokenization.showCard(token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // With callback tokenization.showCard(token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR })

Retrieve a Card's information (Legacy)**

<?php use PixelPay\Sdk\Entities\CardResult; use PixelPay\Sdk\Models\Settings; use PixelPay\Sdk\Services\Tokenization; // Add the merchant keys and endpoint provided by the bank once affiliated $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; // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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" ) // Add the merchant keys and endpoint provided by the bank once affiliated 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" # Add the merchant keys and endpoint provided by the bank once affiliated 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

Deleting a tokenized Card (Mobile Devices and Browsers)

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"; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // With async / await try { const response = await tokenization.deleteCard(token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // With callback tokenization.deleteCard(token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR }) import PixelPaySDK // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated Settings settings = new Settings(); settings.setupEndpoint("https://{endpoint}"); settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio"); String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b"; // Send current activity as a second parameter 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 // Add the merchant keys and endpoint provided by the bank once affiliated val settings = Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") String token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" // Send current activity as a second parameter 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // With async / await try { const response = await tokenization.deleteCard(token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // With callback tokenization.deleteCard(token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR }) 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'; // Add the merchant keys and endpoint provided by the bank once affiliated const settings = new Settings() settings.setupEndpoint("https://{endpoint}") settings.setupCredentials("2222222222", "elhashmd5delsecretkeydelcomercio") const token = "T-6611b606-8ca6-4097-8584-4bc816b8612b" const tokenization = new Tokenization(settings) // With async / await try { const response = await tokenization.deleteCard(token) if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } } catch (error) { // ERROR } // With callback tokenization.deleteCard(token).then((response) => { if (CardResult.validateResponse(response)) { const result = CardResult.fromResponse(response) // SUCCESS } else { // ERROR } }).catch((error) => { // ERROR })

Deleting a tokenized Card (Legacy)

<?php use PixelPay\Sdk\Entities\CardResult; use PixelPay\Sdk\Models\Settings; use PixelPay\Sdk\Services\Tokenization; // Add the merchant keys and endpoint provided by the bank once affiliated $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; // Add the merchant keys and endpoint provided by the bank once affiliated 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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" ) // Add the merchant keys and endpoint provided by the bank once affiliated 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" # Add the merchant keys and endpoint provided by the bank once affiliated 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

It is important to use try/catch blocks to handle any exceptions that may arise from a miscommunication with the PixelPay servers.


Financing installments

Financing installments integration through the PixelPay SDK opens up a world of technical possibilities for merchants when managing their transactions. Merchants can not only collect payments efficiently, but also provide their customers with the ability to make payments using precise financing plans, such as intra-financing and extra-financing.

The number of installments allowed for these payment plans are 3, 6, 9, 12, 18, 24 and 36 months.

Just like in Create Payment / Direct Sale and Payment Authorization and Capture, a installment transaction can be done using a credit or debit card, tokenized or not. For this example, a tokenized card will be used.

Intrafinancing

To make this type of payment, you must add the setInstallment method to the transaction object (Sale), indicating the number of months and intra as the type of installment.

Transaction without using a tokenized Card (Mobile Devices and Browsers)

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"; // Add the merchant keys and endpoint provided by the bank once affiliated 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) // With 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 } // With 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 // Add the merchant keys and endpoint provided by the bank once affiliated 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() in case 3DS protection is enabled 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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"); // Send current activity as a second parameter 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 // Add the merchant keys and endpoint provided by the bank once affiliated 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() in case 3DS protection is enabled 3DSecure. sale.setOrder(order) sale.setCardToken(token) sale.setInstallment(9, "intra"); // Send current activity as a second parameter 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'; // Add the merchant keys and endpoint provided by the bank once affiliated 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) // With 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 } // With 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'; // Add the merchant keys and endpoint provided by the bank once affiliated 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) // With 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 } // With 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 })

Transaction with a tokenized Card (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; // Add the merchant keys and endpoint provided by the bank once affiliated $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; // Add the merchant keys and endpoint provided by the bank once affiliated 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"); // Send current activity as a second parameter 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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" ) // Add the merchant keys and endpoint provided by the bank once affiliated 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" # Add the merchant keys and endpoint provided by the bank once affiliated 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

To make this type of payment, you must add the setInstallment method to the transaction object (Sale), indicating the number of months and extra as the type of installment.

Transaction without using a tokenized Card (Mobile Devices and Browsers)

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"; // Add the merchant keys and endpoint provided by the bank once affiliated 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) // With 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 } // With 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 // Add the merchant keys and endpoint provided by the bank once affiliated 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() in case 3DS protection is enabled 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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"); // Send current activity as a second parameter 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 // Add the merchant keys and endpoint provided by the bank once affiliated 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() in case 3DS protection is enabled 3DSecure. sale.setOrder(order) sale.setCardToken(token) sale.setInstallment(12, "extra"); // Send current activity as a second parameter 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'; // Add the merchant keys and endpoint provided by the bank once affiliated 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) // With 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 } // With 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'; // Add the merchant keys and endpoint provided by the bank once affiliated 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) // With 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 } // With 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 })

Transaction with a tokenized Card (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; // Add the merchant keys and endpoint provided by the bank once affiliated $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; // Add the merchant keys and endpoint provided by the bank once affiliated 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"); // Send current activity as a second parameter 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; // Add the merchant keys and endpoint provided by the bank once affiliated 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" ) // Add the merchant keys and endpoint provided by the bank once affiliated 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" # Add the merchant keys and endpoint provided by the bank once affiliated 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

The number of installments allowed for these payment plans are 3, 6, 9, 12, 18, 24 and 36 months.


Resources

The Locations resource hosts an inventory of locations, all of which conform to the guidelines established by ISO-3166-1 and ISO-3166-2. It is essential to maintain consistency with these standards, given that they are the ones managed within the PixelPay ecosystem.

Example (Mobile Devices and Browsers)

import Locations from '@pixelpay/sdk-core/lib/resources/Locations'; // Get list of countries const countries = Locations.countriesList() // e.g. {HN: "Honduras", NI: "Nicaragua", US: "Estados Unidos", ...} // Get a list of country subdivisions const states = Locations.statesList('HN') // e.g. {HN-AT: "Atlantida", HN-CH: "Choluteca", HN-CL: "Colon", ...} // Get country postal code and phone formats const formats = Locations.formatsList('HN') // e.g. {phone_code: 504, zip_format: ""} import PixelPaySDK // Get list of countries let countries = Locations.countriesList() // e.g. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...} // Get a list of country subdivisions let states = Locations.statesList(country_code: "HN") // e.g. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...} // Get country postal code and phone formats let formats = Locations.formatsList(country_code: "HN") // e.g. {"phone_code": "504", "zip_format": ""} import com.pixel.sdk.resources.Locations; // Get list of countries Map<String, String> countries = Locations.countriesList(); // e.g. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...} // Get a list of country subdivisions Map<String, String> states = Locations.statesList("HN"); // e.g. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...} // Get country postal code and phone formats Map<String, String> formats = Locations.formatsList("HN"); // e.g. {"phone_code": 504, "zip_format": ""} import com.pixel.sdk.resources.Locations; // Get list of countries val countries = Locations.countriesList() // e.g. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...} // Get a list of country subdivisions val states = Locations.statesList("HN") // e.g. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...} // Get country postal code and phone formats val formats = Locations.formatsList("HN") // e.g. {"phone_code": 504, "zip_format": ""} import 'package:pixelpay_sdk/resources/locations.dart' as pixelpay; // Get list of countries final countries = await pixelpay.Locations.countriesList(); // e.g. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...} // Get a list of country subdivisions final states = await pixelpay.Locations.statesList("HN"); // e.g. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...} // Get country postal code and phone formats final formats = await pixelpay.Locations.formatsList("HN"); // e.g. {"phone_code": 504, "zip_format": ""} import Locations from '@pixelpay/sdk-core/lib/resources/Locations'; // Get list of countries const countries = Locations.countriesList() // e.g. {HN: "Honduras", NI: "Nicaragua", US: "Estados Unidos", ...} // Get a list of country subdivisions const states = Locations.statesList('HN') // e.g. {HN-AT: "Atlantida", HN-CH: "Choluteca", HN-CL: "Colon", ...} // Get country postal code and phone formats const formats = Locations.formatsList('HN') // e.g. {phone_code: 504, zip_format: ""} import Locations from '@pixelpay/sdk-core/lib/resources/Locations'; // Get list of countries const countries = Locations.countriesList() // e.g. {HN: "Honduras", NI: "Nicaragua", US: "Estados Unidos", ...} // Get a list of country subdivisions const states = Locations.statesList('HN') // e.g. {HN-AT: "Atlantida", HN-CH: "Choluteca", HN-CL: "Colon", ...} // Get country postal code and phone formats const formats = Locations.formatsList('HN') // e.g. {phone_code: 504, zip_format: ""}

Example (Legacy)

<?php use PixelPay\Sdk\Resources\Locations; // Get list of countries $countries = Locations::countriesList(); /* e.g. { ["HN"]=> "Honduras" ["NI"]=> "Nicaragua" ["US"]=> "Estados Unidos" ... } */ // Get a list of country subdivisions $states = Locations::statesList('HN'); /* e.g. { ["HN-AT"]=> "Atlantida" ["HN-CH"]=> "Choluteca" ["HN-CL"]=> "Colon" ... } */ // Get country postal code and phone formats $formats = Locations::formatsList('HN'); /* e.g. { ["phone_code"]=> 504 ["zip_format"]=> "" } */ import com.pixel.sdk.resources.Locations; // Get list of countries Map<String, String> countries = Locations.countriesList(); // e.g. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...} // Get a list of country subdivisions Map<String, String> states = Locations.statesList("HN"); // e.g. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...} // Get country postal code and phone formats Map<String, String> formats = Locations.formatsList("HN"); // e.g. {"phone_code": 504, "zip_format": ""} from pixelpay.resources import Locations # Get list of countries countries = Locations.countriesList() # e.g. {'HN': 'Honduras', 'NI': 'Nicaragua', 'US': 'Estados Unidos', ...} # Get a list of country subdivisions states = Locations.statesList("HN") # e.g. {'HN-AT': 'Atlantida', 'HN-CH': 'Choluteca', 'HN-CL': 'Colon', ...} # Get country postal code and phone formats formats = Locations.formatsList("HN") # e.g. {'phone_code': 504, 'zip_format': ''} using PixelPaySDK.Resources; // Get list of countries var countries = Locations.CountriesList(); // e.g. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...} // Get a list of country subdivisions var states = Locations.StatesList("HN"); // e.g. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...} // Get country postal code and phone formats var formats = Locations.FormatsList("HN"); // e.g. {"phone_code": 504, "zip_format": ""} import ( "bitbucket.org/pixelpay/sdk-go/pkg/resources" ) // Get list of countries countries := resources.CountriesList() // e.g. {"HN": "Honduras", "NI": "Nicaragua", "US": "Estados Unidos", ...} // Get a list of country subdivisions states := resources.StatesList("HN") // e.g. {"HN-AT": "Atlantida", "HN-CH": "Choluteca", "HN-CL": "Colon", ...} // Get country postal code and phone formats formats := resources.FormatsList("HN") // e.g. {"phone_code": 504, "zip_format": ""} require "pixelpay_sdk" # Get list of countries countries = Locations.countries_list # e.g. {"HN"=>"Honduras", "NI"=>"Nicaragua", "US"=>"Estados Unidos", ...} # Get a list of country subdivisions states = Locations.states_list("HN") # e.g. {"HN-AT"=>"Atlantida", "HN-CH"=>"Choluteca", "HN-CL"=>"Colon", ...} # Get country postal code and phone formats formats = Locations.formats_list("HN") # e.g. {"phone_code"=>504, "zip_format"=>""}