我正在Paymill中创建客户端和优惠,但我不知道如何向客户添加付款详细信息,然后将优惠分配给客户。有谁知道我怎么能这样做?
以下是我创建客户端和优惠的代码:
$params = array(
'amount' => '3000', // E.g. "4200" for 42.00 EUR
'currency' => 'GBP', // ISO 4217
'interval' => '1 MONTH', // Options: "# DAY", "# WEEK", "# MONTH" and "# YEAR"
'name' => 'Tier 1'
);
$apiKey = '111111111111111111111';
$apiEndpoint = 'https://api.paymill.com/v2/';
$offersObject = new Services_Paymill_Offers($apiKey, $apiEndpoint);
$offer = $offersObject->create($params);
$email = $_POST['email'];
$description = "Tier 1";
$clientsObject = new Services_Paymill_Clients($apiKey, $apiEndpoint);
$client = $clientsObject->create(array(
'email' => $email,
'description' => $description
));
print_r($clientsObject);
echo "tier 1 success<br/><br/>";
print_r($offersObject);
我发现很难从文档中掌握并且还没有设法找到教程 - 任何帮助都会很棒!谢谢,乔
答案 0 :(得分:2)
您必须创建客户,付款和优惠。之后,使用创建的客户端,付款和要约创建订阅。
以下代码将解决此问题:
$apiKey = '111111111111111111111';
$apiEndpoint = 'https://api.paymill.de/v2/';
$clientsObject = new Services_Paymill_Clients($apiKey, $apiEndpoint);
$clientData = array(
'email' => $_POST['email'],
'description' => 'Tier 1'
);
$client = $clientsObject->create($clientData);
$paymentObject = new Services_Paymill_Payments($apiKey, $apiEndpoint);
$paymentData = array(
'token' => '098f6bcd4621d373cade4e832627b4f6', //general test-token
'client' => $client['id']
);
$payment = $paymentObject->create($paymentData);
$offersObject = new Services_Paymill_Offers($apiKey, $apiEndpoint);
$offersData = array(
'amount' => '3000', // E.g. "4200" for 42.00 EUR
'currency' => 'GBP', // ISO 4217
'interval' => '1 MONTH', // Options: "# DAY", "# WEEK", "# MONTH" and "# YEAR"
'name' => 'Tier 1'
);
$offer = $offersObject->create($offersData);
$subscriptionObject = new Services_Paymill_Subscriptions($apiKey, $apiEndpoint);
$subscriptionData = array(
'client' => $client['id'],
'offer' => $offer['id'],
'payment' => $payment['id']
);
$subscription = $subscriptionObject->create($subscriptionData);
祝你好运
林檎
Paymill Developer
答案 1 :(得分:1)
关于Ringo回答的问题。
不需要为现有客户创建每次使用此特定信用卡的第一笔交易的令牌。令牌仅在第一个事务中使用。在第一笔交易的响应中收到paymentobject_id后,您可以使用此方法进行重复/重复交易,而无需为此客户的此付款对象创建另一个令牌。但是,如果客户想要用另一个例如第二个信用卡,你现在没有付款对象。你需要像以前一样为第一个交易创建一个令牌,这个支付对象比第一个交易之后得到另一个paymentobject_id
最佳, 基督教