PHP code example of markronquillo / magpie-php-sdk

1. Go to this page and download the library: Download markronquillo/magpie-php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

markronquillo / magpie-php-sdk example snippets


$pk = 'pk_test_';
$sk = 'sk_test_';
$magpie = new Magpie\Magpie($pk, $sk);

$pk = 'pk_test_';
$sk = 'sk_test_';
$magpie = new Magpie\Magpie($pk, $sk);
$params = [
    'email' => '[email protected]',
    'description' => 'Person Name'
];
$customer = $magpie->customer->create($params);

$pk = 'pk_test_';
$sk = 'sk_test_';
$magpie = new Magpie\Magpie($pk, $sk);
$customerId = 'cus_';
$customer = $magpie->customer->get($customerId);

$pk = 'pk_test_';
$sk = 'sk_test_';
$magpie = new Magpie\Magpie($pk, $sk);
$customerId = 'cus_';
$customer = $magpie->customer->delete($customerId);

$token = $magpie->token->create([
    'card' => [
        'number' => '4242424242424242',
        'name' => 'Mark',
        'exp_month' => '02',
        'exp_year' => '2023',
        'cvc' => '2023',
    ]
]);

$id = 'tok_';
$cardToken = $magpie->token->get($id);

$params = [
    "amount" => 50000,
    "currency" => "php",
    "source" => $token,
    "description" => "Pet food and other supplies",
    "statement_descriptor" => "Pet Shop Inc",
    "capture" => true
];
$charge = $magpie->charge->create($params);

$chargeId = 'ch_'
$charge = $magpie->charge->get($chargeId);

$captureCharge = $magpie->charge->capture($chargeId, [
    'amount' => 50000
]);

$magpie->charge->void($chargeId);

$magpie->charge->refund($chargeId, ['amount' => 50000]);