我正在尝试创建订阅 i Paymill。我已经阅读了他们的例子,但我似乎不明白。
我真正想做的就是设置订阅,这是我当前的代码:
$token = $_POST['paymillToken'];
if ($token) {
require "Services/Paymill/Payments.php";
require "Services/Paymill/Transactions.php";
require "Services/Paymill/Subscriptions.php";
require "Services/Paymill/Offers.php";
$params = array(
'amount' => '49900', // Cent!
'currency' => 'SEK', // ISO 4217
'token' => $token,
'description' => 'User ID# ' . $userIdMain . ' Email: ' . $userEmail
);
$transactionsObject = new Services_Paymill_Transactions(
PAYMILL_API_KEY, PAYMILL_API_HOST
);
$transaction = $transactionsObject->create($params);
echo "<br /><br />";
print_r($transaction);
echo $transaction['client']['id'];
echo $transaction['payment']['id'];
$params = array(
'client' => $transaction['client']['id'],
'offer' => 'offer_9cdffb501f565bf827a8',
'payment' => $transaction['payment']['id']
);
$subscriptionsObject = new Services_Paymill_Subscriptions(PAYMILL_API_KEY, PAYMILL_API_HOST);
$subscription = $subscriptionsObject->create($params);
echo "<br /><br />";
print_r($subscription);
}
问题是上面一次创建了两个付款。但似乎订阅对象要求我首先有一个 payment_id (参见上面的 $transaction['payment']['id'] )。
我在这里做错了什么?