lucasamauri/moip-subscriptions-php

There is no license information available for the latest version (2.2) of this package.

Client PHP Moip for subscriptions

2.2 2020-07-17 17:13 UTC

This package is auto-updated.

Last update: 2024-09-18 02:18:52 UTC


README

Instalação

Execute em seu shell:

composer require lucasamauri/moip-subscriptions-php

Authentication

require 'vendor/autoload.php';

use Moip\Moip;

$token = '01010101010101010101010101010101';
$key = 'ABABABABABABABABABABABABABABABABABABABAB';

$moip = new Moip($token, $key, Moip::ENDPOINT_SANDBOX);

Planos

// Create a plan
$plan = $moip->plan()
    ->setCode("P99")
    ->setName("R$99")
    ->setDescription("Plano R$99")
    ->setAmount(99.00)
    ->create();

// List Plans
$moip->plan()->getList();

Assinatura

// Create a subscription
$customer = $moip->customer()
        ->setCode("01")
        ->setFullname("Your Awesome Name")
        ->setTaxDocument("999.999.999-99")
        ->setEmail("mail@example.com")
        ->setPhone(31, 99999999)
        ->setBirthDate("1980-06-02")
        ->addAddress("AV", "Larga", null, "Vila Cristina", "Belo Horizonte", "MG", "33333-333")
        ->setBillingInfo("Your Awesome Name", "5209 9026 0329 5762", 12, 21, 522)
        ;
try {
    $subscription = $moip->subscription()
        ->setCode("01")
        ->setCustomer($customer)
        ->setPlan("P99")
        ->setPaymentMethod("CREDIT_CARD")
        ->create();
}
catch (Exception $e) {
    var_dump($e->getMessage());
}