首页 > PHP资讯 > PHP培训技术 > PHP支付处理库 Omnipay

PHP支付处理库 Omnipay

PHP培训技术

Omnipay 是一个PHP支付处理库。统一的API支持数十个网关。

示例代码:

use OmnipayOmnipay;$gateway = Omnipay::create('Stripe');$gateway->setApiKey('abc123');$formData = ['number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2016', 'cvv' => '123'];$response = $gateway->purchase(['amount' => '10.00', 'currency' => 'USD', 'card' => $formData])->send();if ($response->isSuccessful()) {    // payment was successful: update database    print_r($response);} elseif ($response->isRedirect()) {    // redirect to offsite payment gateway    $response->redirect();} else {    // payment failed: display message to customer    echo $response->getMessage();}
本文由欣才IT学院整理发布,未经许可,禁止转载。