53 - Generating a Valid Payment Token

This commit is contained in:
Adam Wathan
2016-12-29 14:56:42 -05:00
parent a2965eeb0b
commit 908fd87ca4
3 changed files with 88 additions and 3 deletions

View File

@@ -7,7 +7,8 @@
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.3.*",
"zondicons/blade-bridge": "^0.1.0"
"zondicons/blade-bridge": "^0.1.0",
"stripe/stripe-php": "^4.3"
},
"require-dev": {
"fzaninotto/faker": "~1.4",

59
composer.lock generated
View File

@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "aa61d5762f0cbc8027e79c0b940a6b7d",
"content-hash": "50e4deb4c8728b5460bf609f167ef2b2",
"hash": "8cdff7401ffaa77e712fc773720a0a25",
"content-hash": "4283a0ebb9e0602a14c02b45b50cb2d7",
"packages": [
{
"name": "classpreloader/classpreloader",
@@ -1027,6 +1027,61 @@
],
"time": "2016-10-02 15:51:17"
},
{
"name": "stripe/stripe-php",
"version": "v4.3.0",
"source": {
"type": "git",
"url": "https://github.com/stripe/stripe-php.git",
"reference": "234bcbd7483873c8762a67dfbdf2e6594b0a2ecc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stripe/stripe-php/zipball/234bcbd7483873c8762a67dfbdf2e6594b0a2ecc",
"reference": "234bcbd7483873c8762a67dfbdf2e6594b0a2ecc",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "~0.6.1",
"squizlabs/php_codesniffer": "~2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-4": {
"Stripe\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Stripe and contributors",
"homepage": "https://github.com/stripe/stripe-php/contributors"
}
],
"description": "Stripe PHP Library",
"homepage": "https://stripe.com/",
"keywords": [
"api",
"payment processing",
"stripe"
],
"time": "2016-11-30 19:16:32"
},
{
"name": "swiftmailer/swiftmailer",
"version": "v5.4.3",

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class StripePaymentGatewayTest extends TestCase
{
/** @test */
function charges_with_a_valid_payment_token_are_successful()
{
// Create a new StripePaymentGateway
$paymentGateway = new StripePaymentGateway;
$token = \Stripe\Token::create([
"card" => [
"number" => "4242424242424242",
"exp_month" => 1,
"exp_year" => date('Y') + 1,
"cvc" => "123"
]
], ['api_key' => config('services.stripe.secret')])->id;
// Create a new charge for some amount using a valid token
$paymentGateway->charge(2500, $token);
// Verify that the charge was completed successfully
}
}