PHP code example of ediasoft / gomypay-api-php

1. Go to this page and download the library: Download ediasoft/gomypay-api-php 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/ */

    

ediasoft / gomypay-api-php example snippets


use eDiasoft\Gomypay\GomypayApiClient;

$gomypay = new GomypayApiClient('CUSTOMER_ID', 'SECRET_KEY_THIS_IS_OPTIONAL', array(
    'test'              => true, //This will change the transaction to test.
    'store_id'          => 'GOMYPAY_STORE_ID',  //Set the store id.
    'returnUrl'         => 'https://example.com/gomypay/return',
    'callbackUrl'       => 'https://example.com/gomypay/callback'
));

use eDiasoft\Gomypay\Types\PaymentMethods;

$creditcard = $gomypay->payWith(PaymentMethods::CREDITCARD)->create([
    'Order_No'      => uniqid(), //Must be unique everytime
    'Amount'        => 1000, //Amount in TWD, must be more than 35 yuan
    'Buyer_Name'    => 'John Doe',
    'Buyer_Telm'    => '0912345678',
    'Buyer_Mail'    => '[email protected]',
    'Buyer_Memo'    => 'Noodles',
    'CardNo'        => '4907060600015101', //Example creditcard number that results in success
    'ExpireDate'    => '2412', //YYMM
    'CVV'           => '615'
]);

use eDiasoft\Gomypay\Types\Response;

$creditcard->execute(); //Normal execute with redirect to Gomypay page

$creditcard->execute(Response::json); //Request json response