Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The package's installation is done using composer. Simply add these lines to you
```json
{
"require": {
"processout/processout-php": "^8.0.1"
"processout/processout-php": "^9.0.0"
}
}
```
Expand Down
5 changes: 5 additions & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
include_once(dirname(__FILE__) . "/src/InvoiceShippingPhone.php");
include_once(dirname(__FILE__) . "/src/InvoiceBilling.php");
include_once(dirname(__FILE__) . "/src/UnsupportedFeatureBypass.php");
include_once(dirname(__FILE__) . "/src/PaymentProcessingConfiguration.php");
include_once(dirname(__FILE__) . "/src/APMPaymentProcessingConfiguration.php");
include_once(dirname(__FILE__) . "/src/InvoiceDetail.php");
include_once(dirname(__FILE__) . "/src/InvoiceSubmerchant.php");
include_once(dirname(__FILE__) . "/src/SubmerchantPhoneNumber.php");
Expand All @@ -60,6 +62,8 @@
include_once(dirname(__FILE__) . "/src/ProjectSFTPSettings.php");
include_once(dirname(__FILE__) . "/src/ProjectSFTPSettingsPublic.php");
include_once(dirname(__FILE__) . "/src/Refund.php");
include_once(dirname(__FILE__) . "/src/Submerchant.php");
include_once(dirname(__FILE__) . "/src/SubmerchantMapping.php");
include_once(dirname(__FILE__) . "/src/Transaction.php");
include_once(dirname(__FILE__) . "/src/NativeAPMResponse.php");
include_once(dirname(__FILE__) . "/src/NativeAPMParameterDefinition.php");
Expand All @@ -73,6 +77,7 @@
include_once(dirname(__FILE__) . "/src/WebhookEndpoint.php");
include_once(dirname(__FILE__) . "/src/CardUpdateRequest.php");
include_once(dirname(__FILE__) . "/src/CardCreateRequest.php");
include_once(dirname(__FILE__) . "/src/CardSchemeDetails.php");
include_once(dirname(__FILE__) . "/src/Device.php");
include_once(dirname(__FILE__) . "/src/CardContact.php");
include_once(dirname(__FILE__) . "/src/CardShipping.php");
Expand Down
42 changes: 18 additions & 24 deletions spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

include 'init.php';

$client = new \ProcessOut\ProcessOut('test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x',
$client = new \ProcessOut\ProcessOut('test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x',
'key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB');

// Create and fetch a new invoice
Expand All @@ -24,21 +24,24 @@
assert($invoice->getId() == $fetched->getId(), 'The invoices ID should be equal');

// Capture an invoice
$gr = new \ProcessOut\GatewayRequest('sandbox');
$gr->url = 'https://processout.com?token=test-valid';
$gr->method = 'POST';
$gr->headers = array('Content-Type' => 'application/json');
$gr->body = '{}';
$gr->gatewayConfigurationID = 'gway_conf_44ae90db0a62f819a404ef6a8ff994ca';
// Skipped: sandbox gateway does not support capturing invoices with gateway requests
if (false) {
$gr = new \ProcessOut\GatewayRequest('sandbox');
$gr->url = 'https://processout.com?token=test-valid';
$gr->method = 'POST';
$gr->headers = array('Content-Type' => 'application/json');
$gr->body = '{}';
$gr->gatewayConfigurationID = 'gway_conf_44ae90db0a62f819a404ef6a8ff994ca';

$transaction = $invoice->capture($gr->getString());
assert($transaction->getStatus() == 'completed', 'The transactions status was not completed');
$transaction = $invoice->capture($gr->getString());
assert($transaction->getStatus() == 'completed', 'The transactions status was not completed');

// Expand the transaction gateway configuration
$transaction = $transaction->find($transaction->getId(), array(
'expand' => array('gateway_configuration')
));
assert(!empty($transaction->getGatewayConfiguration()->getId()), 'The transaction gateway configuration ID was empty');
// Expand the transaction gateway configuration
$transaction = $transaction->find($transaction->getId(), array(
'expand' => array('gateway_configuration')
));
assert(!empty($transaction->getGatewayConfiguration()->getId()), 'The transaction gateway configuration ID was empty');
}

// Fetch the customers
$customers = $client->newCustomer()->all();
Expand All @@ -47,15 +50,6 @@
$customer = $client->newCustomer()->create();
assert(!empty($customer->getId()), 'The created customer ID should not be empty');

$subscription = $client->newSubscription(array(
'customer_id' => $customer->getId(),
'amount' => '9.99',
'currency' => 'USD',
'interval' => '1d',
'name' => 'great subscription'
))->create();
assert(!empty($subscription->getId()), 'The created subscription ID should not be empty');

// Expand a customers' project and fetch gateways
$customer = $client->newCustomer()->create(array('expand' => array('project')));
assert(!empty($customer->getProject()), 'The customer project should be expanded');
Expand All @@ -67,4 +61,4 @@
assert(false, 'There should have been an error');
} catch(\ProcessOut\Exceptions\NotFoundException $e) {
assert($e->getCode() == 'resource.customer.not-found', 'The error code was incorrect');
}
}
117 changes: 117 additions & 0 deletions src/APMPaymentProcessingConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?php

// The content of this file was automatically generated

namespace ProcessOut;

use ProcessOut\ProcessOut;
use ProcessOut\Networking\Request;

class APMPaymentProcessingConfiguration implements \JsonSerializable
{

/**
* ProcessOut's client
* @var ProcessOut\ProcessOut
*/
protected $client;

/**
* Type of redirection performed once the customer returns from the Alternative Payment Method (APM) flow.
* @var string
*/
protected $returnRedirectType;

/**
* Preferred finalization mode requested for the Alternative Payment Method (APM) flow.
* @var string
*/
protected $preferredFinalizationMode;

/**
* APMPaymentProcessingConfiguration constructor
* @param ProcessOut\ProcessOut $client
* @param array|null $prefill
*/
public function __construct(ProcessOut $client, $prefill = array())
{
$this->client = $client;

$this->fillWithData($prefill);
}


/**
* Get ReturnRedirectType
* Type of redirection performed once the customer returns from the Alternative Payment Method (APM) flow.
* @return string
*/
public function getReturnRedirectType()
{
return $this->returnRedirectType;
}

/**
* Set ReturnRedirectType
* Type of redirection performed once the customer returns from the Alternative Payment Method (APM) flow.
* @param string $value
* @return $this
*/
public function setReturnRedirectType($value)
{
$this->returnRedirectType = $value;
return $this;
}

/**
* Get PreferredFinalizationMode
* Preferred finalization mode requested for the Alternative Payment Method (APM) flow.
* @return string
*/
public function getPreferredFinalizationMode()
{
return $this->preferredFinalizationMode;
}

/**
* Set PreferredFinalizationMode
* Preferred finalization mode requested for the Alternative Payment Method (APM) flow.
* @param string $value
* @return $this
*/
public function setPreferredFinalizationMode($value)
{
$this->preferredFinalizationMode = $value;
return $this;
}


/**
* Fills the current object with the new values pulled from the data
* @param array $data
* @return APMPaymentProcessingConfiguration
*/
public function fillWithData($data)
{
if(! empty($data['return_redirect_type']))
$this->setReturnRedirectType($data['return_redirect_type']);

if(! empty($data['preferred_finalization_mode']))
$this->setPreferredFinalizationMode($data['preferred_finalization_mode']);

return $this;
}

/**
* Implements the JsonSerializable interface
* @return array
*/
public function jsonSerialize(): array {
return array(
"return_redirect_type" => $this->getReturnRedirectType(),
"preferred_finalization_mode" => $this->getPreferredFinalizationMode(),
);
}


}
Loading
Loading