Skip to content

Instantly share code, notes, and snippets.

@spencerhunter
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spencerhunter/e4c178b1a77fa47b0aa4 to your computer and use it in GitHub Desktop.
Save spencerhunter/e4c178b1a77fa47b0aa4 to your computer and use it in GitHub Desktop.
Dwolla Off-Site Gateway - Generate checkoutID
<?php
$url = 'https://uat.dwolla.com/oauth/rest/offsitegateway/checkouts';
$dwollaJson = array(
'client_id' => '*******',
'client_secret' => '*******',
'callback' => 'http://requestb.in/164go6s1',
'redirect' => 'https://purple.com',
'orderId' => 'test123',
'test' => 'false',
'allowFundingSources' => true,
'allowGuestCheckout' => true,
'purchaseOrder' => array(
'orderItems' => array(
'name' => 'Prime Rib Sandwich',
'description' => 'A somewhat tasty non-vegetarian sandwich',
'quantity'=> '1',
'price'=> '15.00'
),
'destinationId' => '812-741-5935',
'total' => 15.00,
'notes' => 'notes test'
)
);
$dwollaJson = json_encode($dwollaJson);
// create a new cURL resource
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// tell curl to use HTTP POST
curl_setopt($ch, CURLOPT_POST, 1);
// tell curl that this is the body of the POST
curl_setopt($ch, CURLOPT_POSTFIELDS, $dwollaJson);
// set HTTP HEADER fields
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
// obtain response
$response = curl_exec($ch);
curl_close($ch);
// print everything out
print_r($response);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment