ApiOperations
1 year ago
Apps
1 year ago
Billing
1 year ago
BillingPortal
1 year ago
Checkout
1 year ago
Climate
1 year ago
Entitlements
1 year ago
EventData
1 year ago
Events
1 year ago
Exception
1 year ago
FinancialConnections
1 year ago
Forwarding
1 year ago
HttpClient
1 year ago
Identity
1 year ago
Issuing
1 year ago
Radar
1 year ago
Reporting
1 year ago
Service
1 year ago
Sigma
1 year ago
Tax
1 year ago
Terminal
1 year ago
TestHelpers
1 year ago
Treasury
1 year ago
Util
1 year ago
V2
1 year ago
Account.php
1 year ago
AccountLink.php
1 year ago
AccountSession.php
1 year ago
ApiRequestor.php
1 year ago
ApiResource.php
2 years ago
ApiResponse.php
2 years ago
ApplePayDomain.php
1 year ago
Application.php
2 years ago
ApplicationFee.php
1 year ago
ApplicationFeeRefund.php
2 years ago
Balance.php
1 year ago
BalanceTransaction.php
1 year ago
BankAccount.php
1 year ago
BaseStripeClient.php
1 year ago
BaseStripeClientInterface.php
1 year ago
Capability.php
1 year ago
Card.php
1 year ago
CashBalance.php
2 years ago
Charge.php
1 year ago
Collection.php
1 year ago
ConfirmationToken.php
1 year ago
ConnectCollectionTransfer.php
2 years ago
CountrySpec.php
1 year ago
Coupon.php
1 year ago
CreditNote.php
1 year ago
CreditNoteLineItem.php
1 year ago
Customer.php
1 year ago
CustomerBalanceTransaction.php
2 years ago
CustomerCashBalanceTransaction.php
2 years ago
CustomerSession.php
1 year ago
Discount.php
1 year ago
Dispute.php
1 year ago
EphemeralKey.php
1 year ago
ErrorObject.php
1 year ago
Event.php
1 year ago
ExchangeRate.php
1 year ago
File.php
1 year ago
FileLink.php
1 year ago
FundingInstructions.php
2 years ago
Invoice.php
1 year ago
InvoiceItem.php
1 year ago
InvoiceLineItem.php
1 year ago
InvoiceRenderingTemplate.php
1 year ago
LineItem.php
1 year ago
LoginLink.php
1 year ago
Mandate.php
1 year ago
OAuth.php
2 years ago
OAuthErrorObject.php
1 year ago
PaymentIntent.php
1 year ago
PaymentLink.php
1 year ago
PaymentMethod.php
1 year ago
PaymentMethodConfiguration.php
1 year ago
PaymentMethodDomain.php
1 year ago
Payout.php
1 year ago
Person.php
1 year ago
Plan.php
1 year ago
Price.php
1 year ago
Product.php
1 year ago
ProductFeature.php
1 year ago
PromotionCode.php
1 year ago
Quote.php
1 year ago
Reason.php
1 year ago
RecipientTransfer.php
2 years ago
Refund.php
1 year ago
RelatedObject.php
1 year ago
RequestTelemetry.php
2 years ago
ReserveTransaction.php
2 years ago
Review.php
1 year ago
SearchResult.php
1 year ago
SetupAttempt.php
1 year ago
SetupIntent.php
1 year ago
ShippingRate.php
1 year ago
SingletonApiResource.php
2 years ago
Source.php
1 year ago
SourceMandateNotification.php
2 years ago
SourceTransaction.php
2 years ago
Stripe.php
1 year ago
StripeClient.php
1 year ago
StripeClientInterface.php
2 years ago
StripeObject.php
1 year ago
StripeStreamingClientInterface.php
2 years ago
Subscription.php
1 year ago
SubscriptionItem.php
1 year ago
SubscriptionSchedule.php
1 year ago
TaxCode.php
1 year ago
TaxDeductedAtSource.php
2 years ago
TaxId.php
1 year ago
TaxRate.php
1 year ago
ThinEvent.php
1 year ago
Token.php
1 year ago
Topup.php
1 year ago
Transfer.php
1 year ago
TransferReversal.php
1 year ago
UsageRecord.php
1 year ago
UsageRecordSummary.php
1 year ago
Webhook.php
1 year ago
WebhookEndpoint.php
1 year ago
WebhookSignature.php
2 years ago
OAuth.php
76 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPForms\Vendor\Stripe; |
| 4 | |
| 5 | abstract class OAuth |
| 6 | { |
| 7 | /** |
| 8 | * Generates a URL to Stripe's OAuth form. |
| 9 | * |
| 10 | * @param null|array $params |
| 11 | * @param null|array $opts |
| 12 | * |
| 13 | * @return string the URL to Stripe's OAuth form |
| 14 | */ |
| 15 | public static function authorizeUrl($params = null, $opts = null) |
| 16 | { |
| 17 | $params = $params ?: []; |
| 18 | $base = $opts && \array_key_exists('connect_base', $opts) ? $opts['connect_base'] : Stripe::$connectBase; |
| 19 | $params['client_id'] = self::_getClientId($params); |
| 20 | if (!\array_key_exists('response_type', $params)) { |
| 21 | $params['response_type'] = 'code'; |
| 22 | } |
| 23 | $query = Util\Util::encodeParameters($params); |
| 24 | return $base . '/oauth/authorize?' . $query; |
| 25 | } |
| 26 | /** |
| 27 | * Use an authoriztion code to connect an account to your platform and |
| 28 | * fetch the user's credentials. |
| 29 | * |
| 30 | * @param null|array $params |
| 31 | * @param null|array $opts |
| 32 | * |
| 33 | * @throws \Stripe\Exception\OAuth\OAuthErrorException if the request fails |
| 34 | * |
| 35 | * @return StripeObject object containing the response from the API |
| 36 | */ |
| 37 | public static function token($params = null, $opts = null) |
| 38 | { |
| 39 | $base = $opts && \array_key_exists('connect_base', $opts) ? $opts['connect_base'] : Stripe::$connectBase; |
| 40 | $requestor = new ApiRequestor(null, $base); |
| 41 | list($response, $apiKey) = $requestor->request('post', '/oauth/token', $params, null); |
| 42 | return Util\Util::convertToStripeObject($response->json, $opts); |
| 43 | } |
| 44 | /** |
| 45 | * Disconnects an account from your platform. |
| 46 | * |
| 47 | * @param null|array $params |
| 48 | * @param null|array $opts |
| 49 | * |
| 50 | * @throws \Stripe\Exception\OAuth\OAuthErrorException if the request fails |
| 51 | * |
| 52 | * @return StripeObject object containing the response from the API |
| 53 | */ |
| 54 | public static function deauthorize($params = null, $opts = null) |
| 55 | { |
| 56 | $params = $params ?: []; |
| 57 | $base = $opts && \array_key_exists('connect_base', $opts) ? $opts['connect_base'] : Stripe::$connectBase; |
| 58 | $requestor = new ApiRequestor(null, $base); |
| 59 | $params['client_id'] = self::_getClientId($params); |
| 60 | list($response, $apiKey) = $requestor->request('post', '/oauth/deauthorize', $params, null); |
| 61 | return Util\Util::convertToStripeObject($response->json, $opts); |
| 62 | } |
| 63 | private static function _getClientId($params = null) |
| 64 | { |
| 65 | $clientId = $params && \array_key_exists('client_id', $params) ? $params['client_id'] : null; |
| 66 | if (null === $clientId) { |
| 67 | $clientId = Stripe::getClientId(); |
| 68 | } |
| 69 | if (null === $clientId) { |
| 70 | $msg = 'No client_id provided. (HINT: set your client_id using ' . '"Stripe::setClientId(<CLIENT-ID>)". You can find your client_ids ' . 'in your Stripe dashboard at ' . 'https://dashboard.stripe.com/account/applications/settings, ' . 'after registering your account as a platform. See ' . 'https://stripe.com/docs/connect/standard-accounts for details, ' . 'or email support@stripe.com if you have any questions.'; |
| 71 | throw new Exception\AuthenticationException($msg); |
| 72 | } |
| 73 | return $clientId; |
| 74 | } |
| 75 | } |
| 76 |