Файловый менеджер - Редактировать - /var/www/html/gocardless.zip
Ðазад
PK ! `�c c ( src/Message/CompletePurchaseResponse.phpnu �[��� <?php namespace Omnipay\GoCardless\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RequestInterface; /** * GoCardless Complete Purchase Response */ class CompletePurchaseResponse extends AbstractResponse { protected $transactionReference; public function __construct(RequestInterface $request, $data, $transactionReference) { parent::__construct($request, $data); $this->transactionReference = $transactionReference; } public function isSuccessful() { return !isset($this->data['error']); } public function getTransactionReference() { return $this->transactionReference; } public function getMessage() { if (!$this->isSuccessful()) { return reset($this->data['error']); } } } PK ! ��?� src/Message/CaptureRequest.phpnu �[��� <?php /** * GoCardless Capture Request */ namespace Omnipay\GoCardless\Message; use Omnipay\GoCardless\Gateway; /** * GoCardless Capture Request - this captures an existing pre-authorization. * * All you need for this method is the pre_authorization_id that we expect to be the transactionReference. * This is a very similar call to just creating a standard bill - but doesnt require a hand off to the * payment provider. * * @see AuthorizeRequest * @link https://developer.gocardless.com/#create-a-bill-under-a-pre-auth */ class CaptureRequest extends AbstractRequest { public function getData() { $this->validate('amount', 'transactionReference'); $data = array(); $bill = array(); $bill['amount'] = $this->getAmount(); $bill['pre_authorization_id'] = $this->getTransactionReference(); $bill['name'] = $this->getDescription(); $bill['charge_customer_at'] = $this->getChargeCustomerAt(); $data['bill'] = $bill; return $data; } public function sendData($data) { $httpResponse = $this->httpClient->request( 'POST', $this->getEndpoint() . '/api/v1/bills', array('Accept' => 'application/json', 'Authorization' => 'Bearer ' . $this->getAccessToken()), Gateway::generateQueryString($data) ); return $this->response = new CaptureResponse($this, json_decode($httpResponse->getBody()->getContents())); } } PK ! #�du src/Message/PurchaseResponse.phpnu �[��� <?php namespace Omnipay\GoCardless\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RedirectResponseInterface; use Omnipay\GoCardless\Gateway; /** * GoCardless Purchase Response */ class PurchaseResponse extends AbstractResponse implements RedirectResponseInterface { public function isSuccessful() { return false; } public function isRedirect() { return true; } public function getRedirectUrl() { return $this->getRequest()->getEndpoint().'/connect/bills/new?'.Gateway::generateQueryString($this->data); } public function getRedirectMethod() { return 'GET'; } public function getRedirectData() { return null; } } PK ! X'�A� � src/Message/AbstractRequest.phpnu �[��� <?php namespace Omnipay\GoCardless\Message; use Omnipay\GoCardless\Gateway; /** * GoCardless Abstract Request */ abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest { protected $liveEndpoint = 'https://gocardless.com'; protected $testEndpoint = 'https://sandbox.gocardless.com'; public function getAppId() { return $this->getParameter('appId'); } public function setAppId($value) { return $this->setParameter('appId', $value); } public function getAppSecret() { return $this->getParameter('appSecret'); } public function setAppSecret($value) { return $this->setParameter('appSecret', $value); } public function getMerchantId() { return $this->getParameter('merchantId'); } public function setMerchantId($value) { return $this->setParameter('merchantId', $value); } public function getAccessToken() { return $this->getParameter('accessToken'); } public function setAccessToken($value) { return $this->setParameter('accessToken', $value); } public function getChargeCustomerAt() { return $this->getParameter('chargeCustomerAt'); } public function setChargeCustomerAt($value) { return $this->setParameter('chargeCustomerAt', $value); } public function getState() { return $this->getParameter('state'); } public function setState($value) { return $this->setParameter('state', $value); } public function getIntervalLength() { return $this->getParameter('intervalLength'); } public function setIntervalLength($value) { return $this->setParameter('intervalLength', $value); } public function getIntervalUnit() { return $this->getParameter('intervalUnit'); } public function setIntervalUnit($value) { return $this->setParameter('intervalUnit', $value); } public function getCalendarInterval() { return $this->getParameter('calendarInterval'); } public function setCalendarInterval($value) { return $this->setParameter('calendarInterval', $value); } public function getSetupFee() { return $this->getParameter('setupFee'); } public function setSetupFee($value) { return $this->setParameter('setupFee', $value); } public function getPreAuthExpire() { return $this->getParameter('preAuthExpire'); } public function setPreAuthExpire($value) { return $this->setParameter('preAuthExpire', $value); } public function getIntervalCount() { return $this->getParameter('intervalCount'); } public function setIntervalCount($value) { return $this->setParameter('intervalCount', $value); } /** * Generate a signature for the data array */ public function generateSignature($data) { return hash_hmac('sha256', Gateway::generateQueryString($data), $this->getAppSecret()); } public function getEndpoint() { return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint; } /** * Generate a nonce for each request */ protected function generateNonce() { $nonce = ''; for ($i = 0; $i < 64; $i++) { // append random ASCII character $nonce .= chr(mt_rand(33, 126)); } return base64_encode($nonce); } } PK ! �]�� � src/Message/PurchaseRequest.phpnu �[��� <?php namespace Omnipay\GoCardless\Message; /** * GoCardless Purchase Request */ class PurchaseRequest extends AbstractRequest { public function getData() { $this->validate('amount'); $data = array(); $data['client_id'] = $this->getAppId(); $data['nonce'] = $this->generateNonce(); $data['timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); $data['redirect_uri'] = $this->getReturnUrl(); $data['cancel_uri'] = $this->getCancelUrl(); $data['state'] = $this->getState(); $data['bill'] = array(); $data['bill']['merchant_id'] = $this->getMerchantId(); $data['bill']['amount'] = $this->getAmount(); $data['bill']['name'] = $this->getDescription(); if ($this->getCard()) { $data['bill']['user'] = array(); $data['bill']['user']['first_name'] = $this->getCard()->getFirstName(); $data['bill']['user']['last_name'] = $this->getCard()->getLastName(); $data['bill']['user']['email'] = $this->getCard()->getEmail(); $data['bill']['user']['billing_address1'] = $this->getCard()->getAddress1(); $data['bill']['user']['billing_address2'] = $this->getCard()->getAddress2(); $data['bill']['user']['billing_town'] = $this->getCard()->getCity(); $data['bill']['user']['billing_county'] = $this->getCard()->getCountry(); $data['bill']['user']['billing_postcode'] = $this->getCard()->getPostcode(); } $data['signature'] = $this->generateSignature($data); return $data; } public function sendData($data) { return $this->response = new PurchaseResponse($this, $data); } } PK ! ���� ! src/Message/AuthorizeResponse.phpnu �[��� <?php namespace Omnipay\GoCardless\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RedirectResponseInterface; use Omnipay\GoCardless\Gateway; class AuthorizeResponse extends AbstractResponse implements RedirectResponseInterface { public function isSuccessful() { return false; } public function isRedirect() { return true; } public function getRedirectUrl() { return $this->getRequest()->getEndpoint(). '/connect/pre_authorizations/new?'. Gateway::generateQueryString($this->data); } public function getRedirectMethod() { return 'GET'; } public function getRedirectData() { return null; } } PK ! ��F F ) src/Message/CompleteAuthorizeResponse.phpnu �[��� <?php namespace Omnipay\GoCardless\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RequestInterface; class CompleteAuthorizeResponse extends AbstractResponse { protected $transactionReference; public function __construct(RequestInterface $request, $data, $transactionReference) { parent::__construct($request, $data); $this->transactionReference = $transactionReference; } public function isSuccessful() { return !isset($this->data['error']); } public function getTransactionReference() { return $this->transactionReference; } public function getMessage() { if (!$this->isSuccessful()) { return reset($this->data['error']); } return null; } } PK ! �@#� � src/Message/AuthorizeRequest.phpnu �[��� <?php /** * GoCardless Authorize Request */ namespace Omnipay\GoCardless\Message; /** * GoCardless Authorize Request * * Use this method to create a pre- authorization for a charge. Because we are dealing with direct debits we can do * a few things that other providers don't or can't do. It also means we some extra parameters. * * Required parameters: * - amount - we're using this as the max_amount for the authorization, * you have the ability to capture less then this later * - intervalLength - the number of intervalUnits that make up an interval (1 month) would be monthly charge * - intervalUnit - string of `day` `week` or `month` * * Optional Parameters: * see documentation. * * * @see \Omnipay\GoCardless\Gateway * @link https://developer.gocardless.com/#create-a-pre-auth */ class AuthorizeRequest extends AbstractRequest { public function getData() { $this->validate('amount', 'intervalLength', 'intervalUnit'); $data = array(); //Required Items from the API $data['client_id'] = $this->getAppId(); $data['nonce'] = $this->generateNonce(); $data['timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); $data['pre_authorization']['max_amount'] = $this->getAmount(); $data['pre_authorization']['interval_length'] = $this->getIntervalLength(); $data['pre_authorization']['interval_unit'] = $this->getIntervalUnit(); $data['pre_authorization']['merchant_id'] = $this->getMerchantId(); $data['redirect_uri'] = $this->getReturnUrl(); //Nice to haves. if ($this->getCancelUrl()) { $data['cancel_uri'] = $this->getCancelUrl(); } if ($this->getState()) { $data['state'] = $this->getState(); } if ($this->getDescription()) { $data['name'] = $this->getDescription(); } if ($this->getCalendarInterval()) { $data['pre_authorization']['calendar_intervals'] = $this->getCalendarInterval(); } if ($this->getSetupFee()) { $data['pre_authorization']['setup_fee'] = $this->getSetupFee(); } if ($this->getIntervalCount()) { $data['pre_authorization']['interval_count'] = $this->getIntervalCount(); } if ($this->getPreAuthExpire()) { $data['pre_authorization']['expires_at'] = $this->getPreAuthExpire(); } if ($this->getCard()) { $data['bill']['user'] = array(); $data['bill']['user']['first_name'] = $this->getCard()->getFirstName(); $data['bill']['user']['last_name'] = $this->getCard()->getLastName(); $data['bill']['user']['email'] = $this->getCard()->getEmail(); $data['bill']['user']['billing_address1'] = $this->getCard()->getAddress1(); $data['bill']['user']['billing_address2'] = $this->getCard()->getAddress2(); $data['bill']['user']['billing_town'] = $this->getCard()->getCity(); $data['bill']['user']['billing_county'] = $this->getCard()->getCountry(); $data['bill']['user']['billing_postcode'] = $this->getCard()->getPostcode(); } $data['signature'] = $this->generateSignature($data); return $data; } public function sendData($data) { return $this->response = new AuthorizeResponse($this, $data); } } PK ! ��_ ( src/Message/CompleteAuthorizeRequest.phpnu �[��� <?php /** * GoCardless Complete Authorize Request */ namespace Omnipay\GoCardless\Message; use Omnipay\Common\Exception\InvalidResponseException; use Omnipay\GoCardless\Gateway; /** * This completes and confirms that the auth is going to be used. It has a 3 hour * life from the moment we create the pre-auth request. * * * @package Omnipay\GoCardless\Message * @link https://developer.gocardless.com/#confirm-a-new-pre-auth */ class CompleteAuthorizeRequest extends AbstractRequest { public function getData() { $data = array(); $data['resource_uri'] = $this->httpRequest->get('resource_uri'); $data['resource_id'] = $this->httpRequest->get('resource_id'); $data['resource_type'] = $this->httpRequest->get('resource_type'); if ($this->httpRequest->get('state')) { $data['state'] = $this->httpRequest->get('state'); } if ($this->generateSignature($data) !== $this->httpRequest->get('signature')) { throw new InvalidResponseException; } unset($data['resource_uri']); return $data; } public function sendData($data) { $credentials = base64_encode($this->getAppId() . ':' . $this->getAppSecret()); $httpResponse = $this->httpClient->request( 'POST', $this->getEndpoint() . '/api/v1/confirm', array('Accept' => 'application/json', 'Authorization' => 'Basic ' . $credentials), Gateway::generateQueryString($data) ); return $this->response = new CompleteAuthorizeResponse( $this, json_decode($httpResponse->getBody()->getContents()), $this->httpRequest->get('resource_id') ); } } PK ! �� � � src/Message/CaptureResponse.phpnu �[��� <?php namespace Omnipay\GoCardless\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RequestInterface; class CaptureResponse extends AbstractResponse { public function isSuccessful() { return !isset($this->data['error']); } public function getMessage() { if (!$this->isSuccessful()) { return reset($this->data['error']); } return null; } } PK ! +�� '