Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require("pagarme-php/Pagarme.php");
- $api_key = "SUA_CHAVE_DE_API";
- Pagarme::setApiKey($api_key);
- $plan_id = "246102";
- $plan = PagarMe_Plan::findById($plan_id); //encontra um plano
- $subscriptionData = array(
- 'plan' => $plan,
- 'customer' => $_POST['customer']
- );
- if(isset($_POST['card_hash'])) {
- $card = new PagarMe_Card(array(
- 'card_hash' => $_POST['card_hash']
- ));
- $card->create();
- $subscriptionData['payment_method'] = 'credit_card';
- $subscriptionData['card_id'] = $card->id;
- } else {
- $subscriptionData['payment_method'] = 'boleto';
- }
- $subscription = new PagarMe_Subscription($subscriptionData);
- $subscription->create();
- echo "Subscription ID: " . $subscription->id;
- ?>
Add Comment
Please, Sign In to add comment