Overview
  • Namespace
  • Class

Namespaces

  • Omnipay
    • Pagarme
      • Message

Classes

  • AbstractRequest
  • AuthorizeRequest
  • CaptureRequest
  • CreateCardRequest
  • CreateCustomerRequest
  • InstallmentsRequest
  • PurchaseRequest
  • RefundRequest
  • Response
  • VoidRequest

Class PurchaseRequest

Pagarme Authorize Request

An Authorize request is similar to a purchase request but the charge issues an authorization (or pre-authorization), and no money is transferred. The transaction will need to be captured later in order to effect payment. Uncaptured transactions expire in 5 days.

Either a card object or card_id is required by default. Otherwise, you must provide a card_hash, like the ones returned by Pagarme.js or use the boleto's payment method.

Pagarme gateway supports only two types of "payment_method":

  • credit_card
  • boleto

Optionally, you can provide the customer details to use the antifraude feature. These details is passed using the following attributes available on credit card object:

  • firstName
  • lastName
  • name
  • birthday
  • gender
  • address1 (must be in the format "street, street_number and neighborhood")
  • address2 (used to specify the optional parameter "street_complementary")
  • postcode
  • phone (must be in the format "DDD PhoneNumber" e.g. "19 98888 5555")
  • holder_document_number (CPF or CNPJ)

Example:

// Create a gateway for the Pagarme Gateway
  // (routes to GatewayFactory::create)
  $gateway = Omnipay::create('Pagarme');

  // Initialise the gateway
  $gateway->initialize(array(
      'apiKey' => 'MyApiKey',
  ));

  // Create a credit card object
  // This card can be used for testing.
  $card = new CreditCard(array(
              'firstName'    => 'Example',
              'lastName'     => 'Customer',
              'number'       => '4242424242424242',
              'expiryMonth'  => '01',
              'expiryYear'   => '2020',
              'cvv'          => '123',
              'email'        => 'customer@example.com',
              'address1'     => 'Street name, Street number, Complementary',
              'address2'     => 'Neighborhood',
              'postcode'     => '05443100',
              'phone'        => '19 3242 8855',
              'holder_document_number' => '214.278.589-40',
  ));

  // Do an authorize transaction on the gateway
  $transaction = $gateway->authorize(array(
      'amount'           => '10.00',
      'soft_descriptor'  => 'test',
      'payment_method'   => 'credit_card',
      'card'             => $card,
      'metadata'         => array(
                                'product_id' => 'ID1111',
                                'invoice_id' => 'IV2222',
                            ),
  ));
  $response = $transaction->send();
  if ($response->isSuccessful()) {
      echo "Authorize transaction was successful!\n";
      $sale_id = $response->getTransactionReference();
      $customer_id = $response->getCustomerReference();
      $card_id = $response->getCardReference();
      echo "Transaction reference = " . $sale_id . "\n";
  }
Omnipay\Common\Message\AbstractRequest
Extended by Omnipay\Pagarme\Message\AbstractRequest
Extended by Omnipay\Pagarme\Message\AuthorizeRequest
Extended by Omnipay\Pagarme\Message\PurchaseRequest
Namespace: Omnipay\Pagarme\Message
See: https://docs.pagar.me/capturing-card-data/
See: Omnipay\Pagarme\Gateway
See: Omnipay\Pagarme\Message\CaptureRequest
Link: https://docs.pagar.me/api/?shell#objeto-transaction
Located at Message/PurchaseRequest.php

Methods summary

public
# getData( )

Pagarme Purchase Request

Pagarme Purchase Request

To charge a credit card or generate a boleto you create a new transaction object. If your API key is in test mode, the supplied card won't actually be charged, though everything else will occur as if in live mode.

Either a card object or card_id is required by default. Otherwise, you must provide a card_hash, like the ones returned by Pagarme.js or use the boleto's payment method.

Pagarme gateway supports only two types of "payment_method":

  • credit_card
  • boleto

See

https://docs.pagar.me/capturing-card-data/

Optionally

,

you can provide the customer details to use the antifraude feature. These details is passed using the following attributes available on credit card object:

  • firstName
  • lastName
  • address1 (must be in the format "street
,

street_number and neighborhood") * address2 (used to specify the optional parameter "street_complementary") * postcode * phone (must be in the format "DDD PhoneNumber" e.g. "19 98888 5555")

Example:

// Create a gateway for the Pagarme Gateway // (routes to GatewayFactory::create) $gateway = Omnipay::create('Pagarme');

// Initialise the gateway $gateway->initialize(array( 'apiKey' => 'MyApiKey'

,

));

// Create a credit card object // This card can be used for testing. $card = new CreditCard(array( 'firstName' => 'Example'

, 'lastName' => 'Customer', 'number' => '4242424242424242', 'expiryMonth' => '01', 'expiryYear' => '2020', 'cvv' => '123', 'email' => 'customer@example.com', 'address1' => 'Street name, Street number, Neighborhood', 'address2' => 'address complementary', 'postcode' => '05443100', 'phone' => '19 3242 8855',

));

// Do a purchase transaction on the gateway $transaction = $gateway->purchase(array( 'amount' => '10.00'

, 'soft_descriptor' => 'test', 'payment_method' => 'credit_card', 'card' => $card,

'metadata' => array( 'product_id' => 'ID1111'

, 'invoice_id' => 'IV2222', ),

)); $response = $transaction->send(); if ($response->isSuccessful()) { echo "Purchase transaction was successful!\n"; $sale_id = $response->getTransactionReference(); $customer_id = $response->getCustomerReference(); $card_id = $response->getCardReference(); echo "Transaction reference = " . $sale_id . "\n"; }

Because a purchase request in Pagarme looks similar to an Authorize request

,

this class simply extends the AuthorizeRequest class and over-rides the getData method setting capture = true.


Omnipay\Pagarme\Gateway

Link

https://docs.pagar.me/api/?shell#criando-uma-transao

Overrides

Omnipay\Pagarme\Message\AuthorizeRequest::getData

Methods inherited from Omnipay\Pagarme\Message\AuthorizeRequest

getBoletoExpirationDate(), getEndpoint(), getInstallments(), getPostbackUrl(), getSoftDescriptor(), setBoletoExpirationDate(), setInstallments(), setPostbackUrl(), setSoftDescriptor()

Methods inherited from Omnipay\Pagarme\Message\AbstractRequest

createResponse(), extractAddress(), extractDddPhone(), getApiKey(), getCard(), getCardData(), getCardHash(), getCustomer(), getCustomerData(), getCustomerReference(), getHttpMethod(), getMetadata(), insertApiKeyToData(), sendData(), setApiKey(), setCard(), setCardHash(), setCustomer(), setCustomerReference(), setMetadata()

Properties summary

Properties inherited from Omnipay\Pagarme\Message\AbstractRequest

$endpoint

API documentation generated by ApiGen