How to assign payment details and an offer to a client in Paymill with PHP? -
i'm creating client , offer in paymill don't know how add payment details client, , assign offer client. know how can this?
here code creates both client , offer:
$params = array( 'amount' => '3000', // e.g. "4200" 42.00 eur 'currency' => 'gbp', // iso 4217 'interval' => '1 month', // options: "# day", "# week", "# month" , "# 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 difficult grasp documentation , haven't managed find tutorial yet- amazing! thanks, joe
you have create client, payment , offer. after that, create subscription created client, payment , offer.
the following code solve issue:
$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" 42.00 eur 'currency' => 'gbp', // iso 4217 'interval' => '1 month', // options: "# day", "# week", "# month" , "# 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); best regards
ringo
paymill developer
Comments
Post a Comment