定制 paymongo/paymongo-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

paymongo/paymongo-php

最新稳定版本:v0.0.0

Composer 安装命令:

composer require paymongo/paymongo-php

包简介

PayMongo PHP Library

README 文档

README

PayMongo PHP library provides PHP applications an easy access to the PayMongo API. Explore various classes that can represent API resources on object instantiation. The goal of this library is simplify PayMongo integration with any PHP applications.

Check example.php see usage examples.

Pending Todos

  • Unit Tests
  • Code Cleanup and Improvements

Requirements

PHP 5.6.0 and later.

Composer

You can install the library via Composer. Run the following command:

composer require paymongo/paymongo-php

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Manual Installation

If you prefer to manually install the library instead of using composer, you can download the latest release. Then, to use the bindings, include the initialize.php file.

require_once('/path/to/paymongo-php/initialize.php');

Dependencies

The bindings require the following extensions in order to work properly:

If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that the required extensions are available.

Getting Started

Simple usage looks like:

$client = new \Paymongo\PaymongoClient('sk_test_BQokikJOvBiI2HlWgH4b2fQ2'); $paymentIntent = $client->paymentIntents->create([ 'amount' => 10000, 'currency' => 'PHP', 'payment_method_allowed' => ['card'] ]); echo $paymentIntent->id;

Handle errors

try { $client = new \Paymongo\PaymongoClient('sk_test_BQokikJOvBiI2HlWgH4b2fQ2'); $paymentIntent = $client->paymentIntents->create([ 'amount' => 10000, 'currency' => 'PHP', 'payment_method_allowed' => ['card'] ]); } catch(\Paymongo\Exceptions\InvalidRequestException $e) { print "<pre>"; print_r($e->getError()); print "</pre>"; }

Verifying webhook signature

try { $payload = @file_get_contents('php://input'); $signatureHeader = $_SERVER['HTTP_PAYMONGO_SIGNATURE']; $webhookSecretKey = 'your webhook secret key here'; $event = $client->webhooks->constructEvent([ 'payload' => $payload, 'signature_header' => $signatureHeader, 'webhook_secret_key' => $webhookSecretKey ]); echo $event->id; echo $event->type; print "<pre>"; print_r($event->resource); print "</pre>"; die(); } catch (\Paymongo\Exceptions\SignatureVerificationException $e) { echo 'invalid signature'; }

To learn more about PayMongo's API, please check our developer documentation.

统计信息

  • 总下载量: 6.86k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 7
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04