· 8 years ago · Dec 26, 2017, 03:18 AM
1<?php
2
3require __DIR__ . '/init.php';
4
5// Create a gateway for the Pin REST Gateway
6// (routes to GatewayFactory::create)
7$gateway = Omnipay\Omnipay::create('Pin');
8
9// Initialise the gateway
10$gateway->initialize(array(
11 'secretKey' => 'tEf4zyjfEKRzkB5FjV46kw',
12 'testMode' => true, // Or false when you are ready for live transactions
13));
14
15// Create a credit card object
16// This card can be used for testing.
17// See https://pin.net.au/docs/api/test-cards for a list of card
18// numbers that can be used for testing.
19$card = new Omnipay\Common\CreditCard(array(
20 'firstName' => 'Raveendra',
21 'lastName' => 'Naphix',
22 'number' => '4200000000000000',
23 'expiryMonth' => '01',
24 'expiryYear' => '2020',
25 'cvv' => '123',
26 'email' => 'customer@example.com',
27 'billingAddress1' => '1 Scrubby Creek Road',
28 'billingCountry' => 'AU',
29 'billingCity' => 'Scrubby Creek',
30 'billingPostcode' => '44600',
31 'billingState' => 'QLD',
32));
33
34// Do a purchase transaction on the gateway
35$transaction = $gateway->purchase(array(
36 'description' => 'My example order',
37 'amount' => '999.99',
38 'currency' => 'AUD',
39 'clientIp' => $_SERVER['REMOTE_ADDR'],
40 'card' => $card,
41));
42
43$response = $transaction->send();
44
45echo "<pre>";
46 print_r($response);
47echo "</pre>";
48
49if ($response->isSuccessful()) {
50 echo "Purchase transaction was successful!\n";
51 $sale_id = $response->getTransactionReference();
52 echo "Transaction reference = " . $sale_id . "\n";
53}