I just want to add a redirect to a certain url after purchase by using the Stripe API for PHP. My approach so far is:
$link = $stripe->paymentLinks->create([
'line_items' => [
[
'price' => $product['default_price'],
'quantity' => 1,
],
],
'after_completion' => [
[
'redirect' => [
'url' => 'https://www.trainer-va.de/Trainer-Cloud/123.php?product=' . $product['default_price'] . '',
],
'type' => 'redirect'
],
]);
but it's not working. Any hints what's going wrong here?
Thanks in advance!
Your request body is malformatted at the after_completion attribute level[1].
You should do like this instead:
$link = $stripe->paymentLinks->create([
'line_items' => [
[
'price' => $product['default_price'],
'quantity' => 1,
],
],
'after_completion' => [
'redirect' => [
'url' => 'https://www.trainer-va.de/Trainer-Cloud/123.php?product=' . $product['default_price'] . '',
],
'type' => 'redirect'
],
]);
[1] https://stripe.com/docs/api/payment_links/payment_links/create#create_payment_link-after_completion
I've been trying to create a checkout session for a payment which should be directed in connected account.
whenever I'm trying to create a session using the code below I get InvalidRequestException saying Invalid array
Here's my code below,
\Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
$stripe = new \Stripe\StripeClient(env('STRIPE_SECRET'));
$session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [
'price_data' => [
'unit_amount' => 25000,
'currency' => 'usd',
'product_data' => ['name' => 'Product8', 'active' => true],
],
'quantity' => 2,
],
'mode' => 'payment',
'success_url' => 'http://devweb.drivinggradebook.com/',
'cancel_url' => 'https://www.drivinggradebook.com/',
'payment_intent_data' => [
'application_fee_amount' => 10,
],
], ['stripe_account' => 'acct_1L7ugjSJzLhcy6eF']);
Please help me out with it,
Thanks
In my case I have it running as follows with laravel 8.75 and stripe/stripe-php 10.1
public function checkout(Request $request)
{
\Stripe\Stripe::setApiKey(STRIPE_SECRET);
header('Content-Type: application/json');
$checkout_session = \Stripe\Checkout\Session::create([
'line_items' => [
[
'price_data' => [
'currency' => 'eur',
'product_data' => [
'name' => 'Home'
],
'unit_amount' => 500
],
'quantity' => 1
],
],
'mode' => 'payment',
'success_url' => url("/stripe_success?session_id={CHECKOUT_SESSION_ID}&tenant_id=$request->id"),
'cancel_url' => route('payments.index'),
]);
return redirect()->away($checkout_session->url);
}
The request is successfully sent, but when I check the content of the request, the indempotency value is not in the array, Do I have a syntax error or am I doing something wrong?
$idempotency_key = bin2hex(random_bytes(16));
$intent = \Stripe\PaymentIntent::create([
'amount' => $price,
'currency' => 'usd',
'customer' => ''.$_SESSION['uid'].'',
'payment_method' => ''.$payid.'',
'description' => ''.$title.'',
"metadata" => [
'task' => ''.$_POST['pid'].'',
'offer' => ''.$_POST['accept'].'',
'category' => ''.$category.'',
'location' => ''.$location.''
],
'off_session' => false,
'confirm' => true,
'confirmation_method' => 'automatic',
'use_stripe_sdk' => true,
], [
"idempotency_key" => ''.$idempotency_key.'',
]);
I want to update the status of an Amazon CloudFront distribution using the updatedistribution method provided by AWS.
I don't know default value of all the required parameters.
My code is:
list($before, $after) = explode('.', $domain, 2);
$domain_Items = "*." . $after;
$result = $client->updateDistribution([
'DistributionConfig' =>
[
'Aliases' =>
[
'Items' => [$domain_Items, $after],
'Quantity' => 2
],
'CallerReference' => $domain,
'Comment' => 'custom domain for ' . $domain,
'Enabled' => false,
'PriceClass' => 'PriceClass_All',
'CacheBehaviors' => [
'Items' => [
[
'AllowedMethods' =>
[
'CachedMethods' =>
[
'Items' => ['HEAD', 'GET'],
'Quantity' => 2,
],
'Items' => ['HEAD', 'GET', 'OPTIONS', 'PUT', 'POST', 'PATCH', 'DELETE'],
'Quantity' => 7,
],
'Compress' => true,
'DefaultTTL' => 0,
//'FieldLevelEncryptionId' => '<string>',
'ForwardedValues' => [
'Cookies' => [
'Forward' => 'all',
'WhitelistedNames' => [
'Quantity' => 5,
'Items' => ['Host', 'Referer', 'Orign', 'User-Agent', 'HTTP_REFERER'],
],
],
'Headers' =>
[
'Items' => ['Host', 'Referer', 'Orign', 'User-Agent', 'HTTP_REFERER'],
'Quantity' => 5
],
'QueryString' => true,
'QueryStringCacheKeys' => [
'Items' => ['Host', 'Referer', 'Orign', 'User-Agent', 'HTTP_REFERER'],
'Quantity' => 5
],
],
'LambdaFunctionAssociations' => [
'Items' => [
[
'EventType' => 'viewer-request',
'IncludeBody' => true,
'LambdaFunctionARN' => '', //<string>
]
],
'Quantity' => 1,
],
'MaxTTL' => 0,
'MinTTL' => 0,
'PathPattern' => '', //<string>
'SmoothStreaming' => true,
'TargetOriginId' => 'ELB-saglus-test-uat-web-783948842',
'TrustedSigners' => [
'Enabled' => false,
//'Items' => ['<string>'],
'Quantity' => 0,
],
'ViewerProtocolPolicy' => 'redirect-to-https',
],
],
'Quantity' => 1,
],
'DefaultCacheBehavior' =>
[
'AllowedMethods' =>
[
'CachedMethods' =>
[
'Items' => ['HEAD', 'GET'],
'Quantity' => 2,
],
'Items' => ['HEAD', 'GET', 'OPTIONS', 'PUT', 'POST', 'PATCH', 'DELETE'],
'Quantity' => 7,
],
'Compress' => true,
'DefaultTTL' => 0,
'FieldLevelEncryptionId' => '',
'ForwardedValues' =>
[
'Cookies' =>
[
'Forward' => 'all'
],
'WhitelistedNames' => [
'Quantity' => 5,
'Items' => ['Host', 'Referer', 'Orign', 'User-Agent', 'HTTP_REFERER'],
],
'Headers' =>
[
'Items' => ['Host', 'Referer', 'Orign', 'User-Agent', 'HTTP_REFERER'],
'Quantity' => 5,
],
'QueryString' => true,
'QueryStringCacheKeys' => [
'Items' => ['Host', 'Referer', 'Orign', 'User-Agent', 'HTTP_REFERER'],
'Quantity' => 5, // REQUIRED
],
],
'LambdaFunctionAssociations' => [
'Items' => [
[
'EventType' => 'viewer-request',
'IncludeBody' => false,
'LambdaFunctionARN' => '', // REQUIRED <string>
]
],
'Quantity' => 1, // REQUIRED
],
'MaxTTL' => 600,
'MinTTL' => 0,
'SmoothStreaming' => false,
'TargetOriginId' => 'ELB-saglus-test-uat-web-783948842',
'TrustedSigners' =>
[
'Enabled' => false,
'Quantity' => 0
],
'ViewerProtocolPolicy' => 'redirect-to-https'
],
'DefaultRootObject' => '',
'HttpVersion' => 'http2',
'IsIPV6Enabled' => false,
'Logging' => [
'Bucket' => 'saglus-aws-logs.s3.amazonaws.com', // REQUIRED
'Enabled' => true, // REQUIRED
'IncludeCookies' => true, // REQUIRED
'Prefix' => 'logs-for-' . $domain, // REQUIRED
],
'Origins' =>
[
'Items' =>
[
[
'CustomHeaders' =>
[
'Items' =>
[
[
'HeaderName' => 'X-Origin-Verify',
'HeaderValue' => 'cnxpwcausbtobmebhebadbergdifn'
],
],
'Quantity' => 1
],
'CustomOriginConfig' =>
[
'HTTPPort' => 80,
'HTTPSPort' => 443,
'OriginKeepaliveTimeout' => 5,
'OriginProtocolPolicy' => 'http-only',
'OriginReadTimeout' => 120,
'OriginSslProtocols' =>
[
'Items' => ['TLSv1'],
'Quantity' => 1
],
],
'DomainName' => 'saglus-test-uat-web-783948842.us-east-1.elb.amazonaws.com',
'Id' => 'ELB-saglus-test-uat-web-783948842',
'OriginPath' => ''
],
],
'Quantity' => 1,
],
'WebACLId' => '108e7697-00db-4330-8d55-bbe57ca94e44'
],
'Id' => $distribution_id,
'IfMatch' => $ETag,
]);
However, I get the error:
Reference link: updatedistribution in AWS SDK for PHP 3.x
$client = new Aws\CloudFront\CloudFrontClient([
'region' => 'us-east-1',
'version' => 'latest',
'credentials' => [
'key' => $this->AcmKey,
'secret' => $this->AcmSecret
]
]);
// $id = 'E2SYUN95DWJFXC';
$id = $business_custom_data->distribution_id;
try {
$result = $client->getDistribution([
'Id' => $id,
]);
} catch (AwsException $e) {
// output error message if fails
echo $e->getMessage();
echo "\n";
}
$currentConfig = $result["Distribution"]["DistributionConfig"];
$ETag = $result["ETag"];
$distribution = [
'CallerReference' => $currentConfig["CallerReference"], // REQUIRED
'Comment' => $currentConfig["Comment"], // REQUIRED
'DefaultCacheBehavior' => $currentConfig["DefaultCacheBehavior"], // REQUIRED
'DefaultRootObject' => $currentConfig["DefaultRootObject"],
//'Enabled' => $currentConfig["Enabled"], // REQUIRED
'Enabled' => False, // REQUIRED
'Origins' => $currentConfig["Origins"], // REQUIRED
'Aliases' => $currentConfig["Aliases"],
'CustomErrorResponses' => $currentConfig["CustomErrorResponses"],
'HttpVersion' => $currentConfig["HttpVersion"],
'CacheBehaviors' => $currentConfig["CacheBehaviors"],
'Logging' => $currentConfig["Logging"],
'PriceClass' => $currentConfig["PriceClass"],
'Restrictions' => $currentConfig["Restrictions"],
'ViewerCertificate' => $currentConfig["ViewerCertificate"],
'WebACLId' => $currentConfig["WebACLId"],
];
try {
$result = $client->updateDistribution([
'DistributionConfig' => $distribution,
'Id' => $id,
'IfMatch' => $ETag
]);
$status = true;
//var_dump($result);
//die;
} catch (AwsException $e) {
// output error message if fails
echo $e->getMessage();
echo "\n";
}
I am having issues when sending documents for a recipient to sign it. The documents should be prefilled using the data from my database which works fine. I know this because when I var_dump $this->textTabs I can see the data. $global is false.
The issue I am having is that when the recipient receives an email to sign the document, the fields which should be prefilled are blank. The Data Label matches the tabLabel in the code below and image
$this->textTabs = [
[
'tabLabel' => 'RegisteredName',
'value' => $contactData->company->name,
'global' => $global,
],
[
'tabLabel' => 'NumberOfEmployees',
'value' => $contactData->company->employee_size,
'global' => $global,
],
[
'tabLabel' => 'RegisteredNumber',
'value' => $contactData->company->reg_no,
'global' => $global,
],
[
'tabLabel' => 'SupplyAddress',
'value' => $supplyAddress_1 . $supplyAddress_2 . $supplyCity . $supplyTown . $supplyCounty . $supplyPostcode,
'global' => $global,
],
[
'tabLabel' => 'SicCode',
'value' => $contactData->company->gapSite->scat_code,
'global' => $global,
],
[
'tabLabel' => 'Recipient_UserTitle',
'value' => $title,
'global' => $global,
],
[
'tabLabel' => 'Recipient_UserName',
'value' => $title . $firstName . $lastName,
'global' => $global,
],
[
'tabLabel' => 'Recipient_Email',
'value' => $contactData->email,
'global' => $global,
],
[
'tabLabel' => 'ContactTelephone',
'value' => $contactData->telephone,
'global' => $global,
],
];
private function send(string $status): ?array
{
try {
return Docusign::createEnvelope([
'templateId' => $this->templateId,
'emailSubject' => $this->emailSubject,
'status' => $status,
'templateRoles' => [
[
'name' => $this->recipient['name'],
'email' => $this->recipient['email'],
'roleName' => 'Client',
'tabs' => [
'textTabs' => $this->textTabs,
/* 'signHereTabs' => [
[
"xPosition" => 400,
"yPosition" => 263,
"documentId" => 1,
"pageNumber" => 6
]
],
*/
]
]
],
'eventNotification' => [
'url' => 'https://webhook.site/697fabec-145a-491f-87ce-1d62be82b298',
'LoggingEnabled' => true,
'RequireAcknowledgment' => true,
'UseSoapInterface' => false,
'IncludeCertificateWithSoap' => false,
'SignMessageWithX509Cert' => false,
'includeDocuments' => true,
'includeEnvelopeVoidReason' => true,
'includeTimeZone' => true,
'includeSenderAccountAsCustomField' => true,
'includeDocumentFields' => true,
'includeCertificateOfCompletion' => true,
'envelopeEventStatusCode' => $this->getRecipientEvents(),
'recipientEvents' => $this->getEventNotification(),
]
]);
} catch (\Exception $e) {
}
}
The fact That recipient receives the email to sign the document, already eliminate any issue to do with my code but why is it not prefilling with the data?
After a while, I decided to create a new docusign account and this seems to have solved the issue. I believe my account was bugger or maybe some technical issue on docusign,