sarkhanrasimoghlu/laravel-golden-pay-payment

Laravel package for Golden Pay payment gateway integration

Maintainers

Package info

github.com/Rasimoghlu/laravel-golden-pay-payment

pkg:composer/sarkhanrasimoghlu/laravel-golden-pay-payment

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-04-10 19:21 UTC

This package is auto-updated.

Last update: 2026-04-10 19:24:23 UTC


README

Laravel package for Golden Pay payment gateway integration. Supports regular payments, Apple Pay, Google Pay, card save & tokenized payments, and subscription/recurring payments.

Requirements

  • PHP 8.3+
  • Laravel 12.x
  • Guzzle 7.8+

Installation

composer require sarkhanrasimoghlu/laravel-golden-pay-payment

The package uses Laravel's auto-discovery, so the service provider will be registered automatically.

Publish Configuration

php artisan vendor:publish --tag=golden-pay-config

Run Migrations

php artisan migrate

Or publish migrations for customization:

php artisan vendor:publish --tag=golden-pay-migrations

Configuration

Add the following to your .env file:

GOLDEN_PAY_BASE_URL=https://rest-newpgtest.goldenpay.az
GOLDEN_PAY_AUTH_KEY=your-auth-key
GOLDEN_PAY_MERCHANT_NAME=your-merchant-name
GOLDEN_PAY_REDIRECT_URL=https://yourapp.com/golden-pay/return
GOLDEN_PAY_SUCCESS_URL=https://yourapp.com/payment/success
GOLDEN_PAY_ERROR_URL=https://yourapp.com/payment/error

# Card Save & Subscription API (Basic Auth)
GOLDEN_PAY_BASIC_USERNAME=your-username
GOLDEN_PAY_BASIC_PASSWORD=your-password

# Optional
GOLDEN_PAY_LANGUAGE=az
GOLDEN_PAY_TIMEOUT=30
GOLDEN_PAY_LOG_CHANNEL=stack
GOLDEN_PAY_LOG_LEVEL=info

Environments

Environment Base URL
Test https://rest-newpgtest.goldenpay.az
Production https://rest-pg.goldenpay.az

Usage

Regular Payment

use Sarkhanrasimoghlu\GoldenPay\Contracts\GoldenPayServiceInterface;
use Sarkhanrasimoghlu\GoldenPay\DataTransferObjects\PaymentRequest;
use Sarkhanrasimoghlu\GoldenPay\Enums\Language;

$service = app(GoldenPayServiceInterface::class);

$response = $service->createPayment(new PaymentRequest(
    amount: 10.50,
    description: 'Order #1234',
    language: Language::AZ,
    orderId: '1234',
));

if ($response->isSuccessful()) {
    return redirect($response->payPageUrl);
}

Apple Pay / Google Pay

use Sarkhanrasimoghlu\GoldenPay\Enums\CardType;

$response = $service->createPayment(new PaymentRequest(
    amount: 10.50,
    description: 'Order #1234',
    cardType: CardType::ApplePay, // or CardType::GooglePay
    orderId: '1234',
));

Get Payment Result

$result = $service->getPaymentResult($paymentKey);

if ($result->isSuccessful()) {
    // Payment succeeded
    $cardNumber = $result->cardNumber;
    $rrn = $result->rrn;
}

Reverse / Refund

use Sarkhanrasimoghlu\GoldenPay\DataTransferObjects\ReverseRequest;

$result = $service->reversePayment(new ReverseRequest(
    paymentKey: 'e93585e2-426d-440a-ae54-67bd20d362be',
    amount: 10.50,
));

if ($result->isSuccessful()) {
    // Payment reversed
}

Card Save

use Sarkhanrasimoghlu\GoldenPay\DataTransferObjects\CardSaveRequest;

$response = $service->saveCard(new CardSaveRequest(
    pin: 'customer-unique-id',
    phone: '+994501234567',
    fullName: 'John Doe',
    description: 'Save card for future payments',
));

// Redirect user to card entry page
return redirect($response->payPage);

Pay with Saved Card

use Sarkhanrasimoghlu\GoldenPay\DataTransferObjects\CardPayRequest;

// 1. Create payment key
$payment = $service->createCardPayment(new CardPayRequest(
    amount: 20.00,
    description: 'Recurring charge',
));

// 2. Execute payment with card token
$result = $service->cardPay($payment->key, $cardToken);

if ($result->isSuccessful()) {
    // Payment completed
}

Get User's Saved Cards

$cards = $service->getUserCards('customer-pin');

Delete Saved Card

$service->deleteCard($paymentKey);

Subscription

use Sarkhanrasimoghlu\GoldenPay\DataTransferObjects\SubscriptionRequest;

// Create subscriber
$subscriber = $service->createSubscriber(new SubscriptionRequest(
    amount: 29.99,
    identifierKey: 'customer-fin-code',
    callbackUrl: 'https://yourapp.com/subscription/callback',
    phone: '+994501234567',
    fullName: 'John Doe',
    description: 'Monthly subscription',
    cardToken: $existingCardToken, // null if card needs to be saved first
));

// Get subscriber details
$details = $service->getSubscriber($subscriberId);

// Cancel subscriber
$service->cancelSubscriber($subscriberId);

Return URL

The package registers two routes to handle the return from Golden Pay:

  • GET /golden-pay/return?payment_key={key} (named golden-pay.return)
  • GET /golden-pay/return/{paymentKey} (named golden-pay.return.key)

Set your GOLDEN_PAY_REDIRECT_URL to point to one of these routes. The controller will verify the payment result and redirect the user to your success_url or error_url.

Events

The package dispatches events you can listen to:

Event When
PaymentCreated Payment key obtained, user redirected to pay page
PaymentCompleted Payment result verified as successful
PaymentFailed Payment result verified as failed
// In your EventServiceProvider
use Sarkhanrasimoghlu\GoldenPay\Events\PaymentCompleted;

protected $listen = [
    PaymentCompleted::class => [
        YourPaymentCompletedListener::class,
    ],
];

API Reference

Payment Gateway

Method Endpoint Description
createPayment() POST /getPaymentKey Initialize a payment
getPaymentResult() GET /getPaymentResult Check payment outcome
reversePayment() POST /reversePaymentKey Reverse/refund a payment

Card Save

Method Endpoint Description
saveCard() POST /api/1.0/card-save/cards Save card, get token
createCardPayment() POST /api/1.0/card-save/payments Create payment key
cardPay() POST /api/1.0/card-save/payments/{id}/pay Pay with saved card
getUserCards() GET /api/1.0/card-save/cards/user-cards List user's cards
getMerchantCards() GET /api/1.0/card-save/cards/merchant-cards List merchant's cards
getCardPaymentStatus() GET /api/1.0/card-save/payments/{key} Check card payment status
deleteCard() DELETE /api/1.0/card-save/cards/{key} Delete saved card

Subscription

Method Endpoint Description
createSubscriber() POST /api/1.0/subscribers/create Create subscriber
getSubscriber() GET /api/1.0/subscribers/{id} Get subscriber details
cancelSubscriber() PATCH /api/v1/subscribers/{id}/cancel Cancel subscriber

Status Codes

Code Description
1 Success
803 Hashcode empty or mismatch
811 Payment key empty
812 Invalid payment key
813 Payment not finished
814 Payment canceled
815 Payment error
816 Payment failed
817 Payment reversed
818 Payment in progress
819 Payment timeout
900 Internal exception
901 Invalid request data

Database

The package creates a golden_pay_transactions table with the following columns:

Column Type Description
payment_key string(36) Unique payment identifier
order_id string Your application's order ID
amount decimal(10,2) Payment amount
status string pending, succeeded, failed, reversed
merchant_name string Merchant name
card_number string Masked card number
rrn string Reference number
payment_date string Payment date from Golden Pay
description string Payment description
paid_at timestamp When payment succeeded

Error Handling

use Sarkhanrasimoghlu\GoldenPay\Exceptions\GoldenPayException;
use Sarkhanrasimoghlu\GoldenPay\Exceptions\HttpException;
use Sarkhanrasimoghlu\GoldenPay\Exceptions\InvalidPaymentException;

try {
    $response = $service->createPayment($request);
} catch (InvalidPaymentException $e) {
    // Invalid payment parameters
} catch (HttpException $e) {
    // API connection or response error
} catch (GoldenPayException $e) {
    // General Golden Pay error
}

License

MIT