Pay an Invoice

$req = curl_init(‘https://www.beanstream.com/api/v1/payments’);

$merchantId = YOUR_MERCHANT_ID;
$passcode = “YOUR_API_PASSCODE”;
$auth = base64_encode( $merchantId.”:”.$passcode );

$headers = array(
‘Content-Type: application/json’,
‘Authorization: Passcode ‘.$auth
);

curl_setopt($req,CURLOPT_POST, true);
curl_setopt($req,CURLOPT_HTTPHEADER, $headers);
curl_setopt($req,CURLOPT_RETURNTRANSFER, true);
curl_setopt($req,CURLOPT_FAILONERROR, true);
curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);

$post = array(
‘merchant_id’ => $merchantId,
‘order_number’ => ‘100001234’,
‘amount’ => 100.00,
‘payment_method’ => ‘card’,
‘card’ => array(
‘name’ => ‘John Doe’,
‘number’ => ‘5100000010001004’,
‘expiry_month’ => ’02’,
‘expiry_year’ => ’17’,
‘cvd’ => ‘123’
)
);

curl_setopt($req,CURLOPT_POSTFIELDS, json_encode($post));
$result = curl_exec($req);
if (strpos($result,”approved”))
print(“Payment Successful!”);
else
print_r($result);
curl_close($req);