<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://test-api.pin.net.au/1/charges");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_CERTINFO, true);
// downloaded from http://curl.haxx.se/docs/caextract.html
$crt = getcwd() . '/cacert.pem';
// specify CAINFO to allow HTTPS
curl_setopt($ch, CURLOPT_CAINFO, $crt);
curl_setopt($ch, CURLOPT_USERPWD, "YOUR_TEST_SECRET_API_KEY");
$fields = array(
'amount' => '400',
'description' => 'test charge',
'email' => 'roland@pin.net.au',
'ip_address' => '203.192.1.172',
'card' => array(
'number' => '5520000000000000',
'expiry_month' => '05',
'expiry_year' => '2013',
'cvc' => '123',
'name' => 'Roland Robot',
'address_line1' => '42 Sevenoaks St',
'address_city' => 'Lathlain',
'address_postcode' => '6454',
'address_state' => 'WA',
'address_country' => 'AU'
)
);
$postData = json_encode($fields);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$response = curl_exec($ch); curl_close($ch);
$jsonResponse = json_decode($response, true);
$sucess = $jsonResponse["response"]["status_message"];