- json_decode: documentation ( source)
- http_build_query: documentation ( source)
<?php
$data['vendor_id'] = 415;
$data['vendor_auth_code'] = '4205:42e7aaa88b48137a16a1acd04ed9112520dd4dd5865055a091a6e8548220aca3';
$data['product_id'] = '493518';
$data['webhook_url'] = 'http://mysite.com/callback'; // URL to call when product is purchased
// You must provide at least one price for the checkout, here we are setting multiple for different currencies.
$data['prices'] = ['USD:4.99'];
$data['expires'] = '2015-09-20'; // YYYY-MM-DD
// This is where we specify the other participants that we wish to split earnings with
$data['affiliates'] = [
'11740:0.30', // Vendor 11740 gets 30%
]; // You (requester) gets 70%
// Here we make the request to the Paddle API
$url = 'https://vendors.paddle.com/api/2.0/product/generate_pay_link';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$response = curl_exec($ch);
// And handle the response...
$data = json_decode($response);
if($data->success) {
echo "Success! Checkout URL:".$data->response->url;
} else {
echo "Your request failed with error: ".$data->error->message;
}
?>