コード例 #1
0
<?php

/**
 * This file is part of the wolopay.com (c)
 *
 * Example to create a payment without show the shop and also without article.
 * It is recommended to insert this code within iframe to make async requests
 */
require_once __DIR__ . "/../lib/WolopayApi.php";
$wolopayApi = new \Wolopay\WolopayApi($apiClientId = 'app_542221a9eda4', $apiClientSecret = 'e6c7435cb68030ee3123b3b48fb25c831b1', $sandbox = true, $debug = true);
// See the doc to view all optional parameters
$result = $wolopayApi->directPaymentWidget($gamerId = 'user13', $amount = 0.1, $currency = 'EUR', $articleTitle = 'My title', $articleDescription = 'My description', $extraOptions = array('country' => 'US'), $autoRedirect = false);
if (!$result) {
    die("Request can't be generated");
}
// the best width iframe is 280 - 410 - 540 - 670 (+130 to show more payMethods)
?>
<iframe src="<?php 
echo $result->url;
?>
" width="540" style="border: 0" height="120"></iframe>
コード例 #2
0
<?php

/**
 * This file is part of the wolopay.com (c)
 *
 * To find out how long it takes the client to perform their first purchases
 */
require_once __DIR__ . "/../lib/WolopayApi.php";
$wolopayApi = new \Wolopay\WolopayApi($apiClientId = 'app_123', $apiClientSecret = 'c12c30d195b007f5bb6e7f8097a406bd222cbf54', $sandbox = true, $debug = true);
if (!$wolopayApi->createGamer($gamerId = '3123')) {
    echo "Some crash, set debug = true to see the errors";
    throw new \Exception("Error");
}
echo "Looks good!";
コード例 #3
0
/**
 * This file is part of the wolopay.com (c)
 *
 * Example of notifications requests
 */
require_once "../lib/WolopayApi.php";
/*
 * POST PARAMETERS example
 *
 * notificationId=WONOT_54b8115f65dc8&itemId=fd1ee940-9a48-11e4-acee-00259068f82e&payCategory=Special+provider+method
 * &tab=Unique+Payment&price=2&currency=USD&payout=1.54&gamerId=user13&userId=user13&amount=7
 * &transactionId=WOT_54b8111c13781&status=success&providerId=WOP_54b8115f64b81&exchangeEUR=0.6252
 * &articleId=fd1ee940-9a48-11e4-acee-00259068f82e&country=US
 */
$wolopayApi = new \Wolopay\WolopayApi($apiClientId = '123123', $apiClientSecret = '33123123', $sandbox = true, $debug = true);
// Verify this request is from wolopay
if (!$wolopayApi->isAValidRequest()) {
    // Be careful, If you are using php v <= 5.3 and you write some text (like errors, print_r, echo ...)
    // PHP httpCode Header doesn't work
    $wolopayApi->setHttpCode(400, 'Bad Request');
    echo "This payment is invalid";
    throw new \Exception("invalid request");
}
// IMPORTANT: Last verifications is with your system. you will need to ensure that the $_POST['notificationId']
// wasn't used and success
if ($_POST['event'] === 'payment.completed') {
    if ($_POST['test']) {
        echo "Your logic when it was a test";
    }
} elseif ($_POST['event'] === 'payment.cancelled') {
コード例 #4
0
<?php

/**
 * This file is part of the wolopay.com (c)
 *
 * Update a promotional code, previously created ofc
 */
require_once __DIR__ . "/../lib/WolopayApi.php";
$wolopayApi = new \Wolopay\WolopayApi($apiClientId = 'app_123', $apiClientSecret = '123', $sandbox = true, $debug = true);
// See the doc to view all extra parameters
$optionalParameters = array('n_total_uses' => 3);
if (!$wolopayApi->updatePromotionalCode($promoCode = '547dec25cd700', $articleId = 'a55459ca-6bdb-11e4-acee-00259068f82e', $optionalParameters)) {
    echo "Some crash, set debug = true to see the errors";
    throw new \Exception("Error");
}
echo "Looks good!";
コード例 #5
0
<?php

/**
 * This file is part of the wolopay.com (c)
 *
 * Create a promotional code
 */
require_once __DIR__ . "/../lib/WolopayApi.php";
$wolopayApi = new \Wolopay\WolopayApi($apiClientId = 'app_123213123', $apiClientSecret = '4b574b6fc22acf4747a30f07cb27a1212147cefe', $sandbox = true, $debug = true);
$result = $wolopayApi->getArticlesByCountry('ES');
if ($result === false) {
    echo "Some crash, set debug = true to see the errors";
    throw new \Exception("Error");
}
echo "Looks good!";
var_dump($result);
コード例 #6
0
<?php

/**
 * This file is part of the wolopay.com (c)
 *
 * Create a promotional code
 */
require_once __DIR__ . "/../lib/WolopayApi.php";
$wolopayApi = new \Wolopay\WolopayApi($apiClientId = 'app_123', $apiClientSecret = 'c12c30d195b007f5bb6e7f8097a406bd222cbf54', $sandbox = true, $debug = true);
if (!$wolopayApi->createPromotionalCode($promoCode = 'MY_CODE', $articleId = '1378a7c4-aae0-11e4-acee-00259068f82e')) {
    echo "Some crash, set debug = true to see the errors";
    throw new \Exception("Error");
}
echo "Looks good!";
コード例 #7
0
<?php

require '../src/WolopayApi.php';
$wo = new \Wolopay\WolopayApi('<your_api_client_id>', '<your_api_secret>', true, true);
$data = $wo->createTransaction($gamerId = 'user13', $level = 3, $extraOptions = array('external_store' => 'facebook', 'test' => 1), $autoRedirect = false);
?>
<!DOCTYPE html>
<html>
<head>
    <title>Wolopay shop :P</title>
    <style>
        html, body, .wolo-shop{
            height: 100%;
        }
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

</head>

<body>
<div id="fb-root"></div>

<div class="wolo-shop"></div>
<script src="<?php 
echo $data->url_js;
?>
"></script>

</body>
</html>
コード例 #8
0
<?php

/**
 * This file is part of the wolopay.com (c)
 *
 * Example to create a transaction
 */
$wolopayApi = new \Wolopay\WolopayApi($apiClientId = 'app_54818a4d61253', $apiClientSecret = 'c38a908de00ffb3ef77f1ac52ea3d3a39ae4d1e0', $sandbox = true, $debug = true);
// See the doc to view all optional parameters
$trans = $wolopayApi->createTransaction($gamerId = 'user13', $level = 3, $extraOptions = array('fixed_country' => '1'), $autoRedirect = true);
if (!$trans) {
    die("Request can't be generated");
}
/*
 * If you want to save the new transaction Id, before to redirect.
 *
 * $result = $wolopayApi->createTransaction($gamerId='user13', $level=3)
 * $result->id  have a transactionId
 * header("Location: ".$result->url);
 */
コード例 #9
0
ファイル: promo_use.php プロジェクト: wolopay/wolopay-api-php
<?php

/**
 * This file is part of the wolopay.com (c)
 *
 * Create a promotional code
 */
require_once __DIR__ . "/../lib/WolopayApi.php";
$wolopayApi = new \Wolopay\WolopayApi($apiClientId = 'app_123', $apiClientSecret = 'c12c30d195b007f5bb6e7f8097a406bd222cbf54', $sandbox = true, $debug = true);
if (!$wolopayApi->usePromotionalCodeByGamerId($promoCode = 'MY_CODE', $gamerId = '3123')) {
    echo "Some crash, set debug = true to see the errors";
    throw new \Exception("Error");
}
echo "Looks good!";
コード例 #10
0
<?php

/**
 * This file is part of the wolopay.com (c)
 *
 * Example to create a payment without show the shop and also without article.
 */
require_once __DIR__ . "/../lib/WolopayApi.php";
$wolopayApi = new \Wolopay\WolopayApi($apiClientId = 'app_54edbb04d96d7', $apiClientSecret = 'dc1bf90ff630a84b379a4c9ef3d7ad14ee437f8c', $sandbox = true, $debug = true);
// See the doc to view all optional parameters
$result = $wolopayApi->directPayment($gamerId = 'user13', $amount = 0.1, $currency = 'EUR', $country = 'ES', $payMethodId = 210, $articleTitle = 'My title', $articleDescription = 'My description', $extraOptions = array(), $autoRedirect = true);
if (!$result) {
    die("Request can't be generated");
}
/*<iframe src="<?= $result->url ?>" width="100%" height="100%"></iframe>*/