Overview
  • Namespace
  • Class

Namespaces

  • Omnipay
    • Pagarme
      • Message

Classes

  • Omnipay\Pagarme\CreditCard
  • Omnipay\Pagarme\Gateway
  • Omnipay\Pagarme\Message\AbstractRequest
  • Omnipay\Pagarme\Message\AuthorizeRequest
  • Omnipay\Pagarme\Message\CaptureRequest
  • Omnipay\Pagarme\Message\CreateCardRequest
  • Omnipay\Pagarme\Message\CreateCustomerRequest
  • Omnipay\Pagarme\Message\InstallmentsRequest
  • Omnipay\Pagarme\Message\PurchaseRequest
  • Omnipay\Pagarme\Message\RefundRequest
  • Omnipay\Pagarme\Message\Response
  • Omnipay\Pagarme\Message\VoidRequest
 1 <?php
 2 
 3 namespace Omnipay\Pagarme\Message;
 4 
 5 class PurchaseRequest extends AuthorizeRequest
 6 {
 7     /**
 8      * Pagarme Purchase Request
 9      *
10      * To charge a credit card or generate a boleto you create a new transaction 
11      * object. If your API key is in test mode, the supplied card won't actually 
12      * be charged, though everything else will occur as if in live mode.
13      *
14      * Either a card object or card_id is required by default. Otherwise,
15      * you must provide a card_hash, like the ones returned by Pagarme.js
16      * or use the boleto's payment method.
17      * 
18      * Pagarme gateway supports only two types of "payment_method":
19      * 
20      * * credit_card
21      * * boleto
22      * 
23      * @see https://docs.pagar.me/capturing-card-data/
24      * 
25      * Optionally, you can provide the customer details to use the antifraude
26      * feature. These details is passed using the following attributes available
27      * on credit card object:
28      * 
29      * * firstName
30      * * lastName
31      * * address1 (must be in the format "street, street_number and neighborhood")
32      * * address2 (used to specify the optional parameter "street_complementary")
33      * * postcode
34      * * phone (must be in the format "DDD PhoneNumber" e.g. "19 98888 5555")
35      * 
36      * Example:
37      *
38      * <code>
39      *   // Create a gateway for the Pagarme Gateway
40      *   // (routes to GatewayFactory::create)
41      *   $gateway = Omnipay::create('Pagarme');
42      *
43      *   // Initialise the gateway
44      *   $gateway->initialize(array(
45      *       'apiKey' => 'MyApiKey',
46      *   ));
47      *
48      *   // Create a credit card object
49      *   // This card can be used for testing.
50      *   $card = new CreditCard(array(
51      *               'firstName'    => 'Example',
52      *               'lastName'     => 'Customer',
53      *               'number'       => '4242424242424242',
54      *               'expiryMonth'  => '01',
55      *               'expiryYear'   => '2020',
56      *               'cvv'          => '123',
57      *               'email'        => 'customer@example.com',
58      *               'address1'     => 'Street name, Street number, Neighborhood',
59      *               'address2'     => 'address complementary',
60      *               'postcode'     => '05443100',
61      *               'phone'        => '19 3242 8855',
62      *   ));
63      *
64      *   // Do a purchase transaction on the gateway
65      *   $transaction = $gateway->purchase(array(
66      *       'amount'           => '10.00',
67      *       'soft_descriptor'  => 'test',
68      *       'payment_method'   => 'credit_card',
69      *       'card'             => $card,
70      *       'metadata'         => array(
71      *                                 'product_id' => 'ID1111',
72      *                                 'invoice_id' => 'IV2222',
73      *                             ),
74      *   ));
75      *   $response = $transaction->send();
76      *   if ($response->isSuccessful()) {
77      *       echo "Purchase transaction was successful!\n";
78      *       $sale_id = $response->getTransactionReference();
79      *       $customer_id = $response->getCustomerReference();
80      *       $card_id = $response->getCardReference();
81      *       echo "Transaction reference = " . $sale_id . "\n";
82      *   }
83      * </code>
84      *
85      * Because a purchase request in Pagarme looks similar to an
86      * Authorize request, this class simply extends the AuthorizeRequest
87      * class and over-rides the getData method setting capture = true.
88      *
89      * @see \Omnipay\Pagarme\Gateway
90      * @link https://docs.pagar.me/api/?shell#criando-uma-transao
91      */
92     public function getData()
93     {
94         $data = parent::getData();
95         $data['capture'] = 'true';
96         return $data;
97     }
98 }
API documentation generated by ApiGen