0

I'm creating a client and an offer in Paymill but I don't know how to add payment details to the client, and then assign the offer to the client. Does anyone know how I can do this?

Here is my code that creates both the client and the offer:

$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);

I'm finding it difficult to grasp from the documentation and haven't managed to find a tutorial yet- Any help would be amazing! Thanks, Joe

4

2 回答 2

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 开发人员

于 2013-09-05T10:57:54.563 回答
1

关于林戈回答的问题。

不,您不需要每次都为使用此特定信用卡进行的第一笔交易的现有客户创建另一个令牌。该令牌仅在第一次交易中使用。在第一笔交易的响应中收到 paymentobject_id 后,您可以使用它来进行重复/重复交易,而无需为此客户端的此支付对象创建另一个令牌。但是,如果客户想用另一张信用卡付款,例如您现在没有付款对象的第二张信用卡。您需要像之前一样为第一笔交易创建一个令牌,然后在第一笔交易之后获得另一个 paymentobject_id

最好的,克里斯蒂安

于 2013-09-06T07:35:29.427 回答