Code Monkey home page Code Monkey logo

stone-ecommerce-php's Introduction

Stone PHP Library

Latest Stable Version License Build Status

Getting Started

Simple PHP SDK to ease the integration with Stone payment solutions

Installing

There are two ways to install this SDK, the next sections will guide you through manual installation and using composer.

Manual installation

require __DIR__ . '/stone-ecommerce-php/init.php';

Composer

$ composer require stone-pagamentos/stone-ecommerce-php

Running tests

To run tests you have to clone this repository

$ git clone [email protected]:stone-payments/stone-ecommerce-php.git
$ cd stone-ecommerce-php
$ composer install
$ vendor/bin/phpunit

Usage example

try
{
    // Carrega dependências
    require_once(dirname(__FILE__) . '/vendor/autoload.php');

    // Define a url utilizada
    \Gateway\ApiClient::setBaseUrl("https://transaction.stone.com.br");

    // Define a chave da loja
    \Gateway\ApiClient::setMerchantKey("merchant key");

    // Cria objeto requisição
    $createSaleRequest = new \Gateway\One\DataContract\Request\CreateSaleRequest();

    // Cria objeto do cartão de crédito
    $creditCard = \Gateway\One\Helper\CreditCardHelper::createCreditCard("5555 4444 3333 2222", "gateway", "12/2030", "999");

    // Define dados do pedido
    $createSaleRequest->addCreditCardTransaction()
        ->setPaymentMethodCode(\Gateway\One\DataContract\Enum\PaymentMethodEnum::SIMULATOR)
        ->setCreditCardOperation(\Gateway\One\DataContract\Enum\CreditCardOperationEnum::AUTH_AND_CAPTURE)
        ->setAmountInCents(150000)
        ->setCreditCard($creditCard);
        ;

    // Cria um objeto ApiClient
    $apiClient = new \Gateway\ApiClient();

    // Faz a chamada para criação
    $response = $apiClient->createSale($createSaleRequest);

    // Mapeia resposta
    $httpStatusCode = $response->isSuccess() ? 201 : 401;
    $response = array("message" => $response->getData()->CreditCardTransactionResultCollection[0]->AcquirerMessage);
}
catch (\Gateway\One\DataContract\Report\CreditCardError $error)
{
    $httpStatusCode = 400;
    $response = array("message" => $error->getMessage());
}
catch (\Gateway\One\DataContract\Report\ApiError $error)
{
    $httpStatusCode = $error->errorCollection->ErrorItemCollection[0]->ErrorCode;
    $response = array("message" => $error->errorCollection->ErrorItemCollection[0]->Description);
}
catch (\Exception $ex)
{
    $httpStatusCode = 500;
    $response = array("message" => "Ocorreu um erro inesperado.");
}
finally
{
    // Devolve resposta
    http_response_code($httpStatusCode);
    header('Content-Type: application/json');
    print json_encode($response);
}

Simulation values

You can use these values to get specific responses from API

Authorization

  • <= $ 1.050,00 -> Authorized
  • >= $ 1.050,01 && < $ 1.051,71 -> Timeout
  • >= $ 1.500,00 -> Not Authorized

Capture

  • <= $ 1.050,00 -> Captured
  • >= $ 1.050,01 -> Not Captured

Cancellation

  • <= $ 1.050,00 -> Cancelled
  • >= $ 1.050,01 -> Not Cancelled

Refund

  • <= $ 1.050,00 -> Refunded
  • >= $ 1.050,01 -> Not Refunded

Releases

For a list with all releases, please refer to releases page

More Information

For more information, please refer to our wiki.

stone-ecommerce-php's People

Contributors

felipebool avatar munirwanis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stone-ecommerce-php's Issues

Geração de instantBuyKey

Olá,

Verifiquei que a geração de token de cartão de crédito através do método CreateInstantBuyDataRequest, com oneDollarAuthEnabled(false). Está resultando em tokens diferentes para o mesmo cartão.

Códigos BIN desatualizados

Pessoal, percebi que o Master está desatualizado. Atualmente o range é de 51 até 55 ou 2221 até 2720.

Fiz uma regex pra isso. Ela leva em conta quantos dígitos faltam para completar os 6 primeiros. Se isso não for necessário, basta retirar os '\d' da regex. Segue:

(5[1-5]\d{4}|2(2(2[1-9]\d{2}|[3-9]\d{3})|[3-6]\d{4}|7([01]\d{3}|20\d{2})))

Me pergunto se os outros números estão desatualizados também. Se alguém tiver uma informação, seria legal atualizar.

setNotificationUrl

Olá, verifiquei que a inclusão da notificação de URL não esta descrita na classe, embora eu tenha criado-a manualmente gostaria de reportar :) ...

Os arquivos estão em /lib/One/DataContract/Request/CreateSaleRequestData

Arquivo Comprimido.zip

Abs!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.