Skip to content

Instantly share code, notes, and snippets.

@jeremyjclarke
Last active November 29, 2017 18:41
Show Gist options
  • Save jeremyjclarke/85940b6530714a4f95541dd424a49d42 to your computer and use it in GitHub Desktop.
Save jeremyjclarke/85940b6530714a4f95541dd424a49d42 to your computer and use it in GitHub Desktop.
Populate PDF Receipt from PHP
<?php
//$user = User information from app
//$account = Account information from app
//$payment = Payment information from app
$customerInfo = array(
'CustomerName' => $user->first_name.' '.$user->last_name,
'Email' => $user->email,
'Company' => $account->company,
'State' => $account->state,
'Address' => $account->street_address.', '.$account->city.', '.$account->state.' '.$account->zip,
'Description' => 'Subscription Renewal',
'Amount' => $payment->amount,
'OrderNum' => $payment->id
);
$mergeUrl = 'https://www.webmerge.me/merge/12345/abcdef';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $mergeUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($customerInfo));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'
));
$res = curl_exec($ch);
$response = json_decode($res, true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($status == 201){
//success
}else{
die('Error: '.$response['error']);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment