Giter Club home page Giter Club logo

chip-php-sdk's Introduction

Chip PHP library

Requirements

PHP 8.0 and later.

The following PHP extensions are required:

  • curl
  • json
  • openssl

Prerequisite

Before you start, make sure you already have created Brand ID and API Key from your developer dashboard by logging-in into merchant portal.

Installation

Composer

Add the following on your composer.json

"repositories": [
  ...
  {
      "type": "vcs",
      "url": "[email protected]:CHIPAsia/chip-php-sdk.git"
  }
],
"require": {
    "chip/chip-sdk-php": "^1.0"
}

And run command

composer install
# OR
composer update

Functions

getPaymentMethods

Get list of payment methods that available for your account.

createPurchase

Create checkout & direct post URL.

getPurchase

Get purchase detail by its ID

verify

Verify callback or webhook response from our server. For webhook public key, it is generated when you register your webhook URL. Refer to our API (https://developer.chip-in.asia/api) for more information.

And more which you can refer to /lib/ChipApi.php for more information.

Getting Started

Simple usage looks like:

<?php
  require_once 'vendor/autoload.php';
  $chip = new \Chip\ChipApi($config['brand_id'], $config['api_key'], $config['endpoint']);
  $client = new \Chip\Model\ClientDetails();
  $client->email = '[email protected]';
  $purchase = new \Chip\Model\Purchase();
  $purchase->client = $client;
  $details = new \Chip\Model\PurchaseDetails();
  $product = new \Chip\Model\Product();
  $product->name = 'Test';
  $product->price = 100;
  $details->products = [$product];
  $purchase->purchase = $details;
  $purchase->brand_id = $config['brand_id'];
  $purchase->success_redirect = 'https://yourdomain.com/redirect.php?success=1';
  $purchase->success_callback = 'https://yourdomain.com/callback.php?success=0';
  $purchase->failure_redirect = 'https://yourdomain.com/redirect.php?success=0';

  $result = $chip->createPurchase($purchase);

  if ($result && $result->checkout_url) {
    // Redirect user to checkout
    header("Location: " . $result->checkout_url);
    exit;
  }

Testing

./vendor/bin/phpunit tests 

Example

Check our examples here.

chip-php-sdk's People

Contributors

wzul avatar azuddin avatar syamsoul avatar mamadcloud avatar msufians avatar aslamshoev avatar

Stargazers

Abdus Fauzi avatar

Watchers

Abdus Fauzi avatar  avatar Helmi Ruza avatar  avatar

chip-php-sdk's Issues

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.