I'm currently working on a project with the MangoPay api (with PHP SDK) and I have some trouble with the PaymentDetails. The function below generate this key (when I call the MangoPay Create method on my PayIn object) :
payins_stdclass-direct_create
instead of :
payins_preauthorized-direct_create
The function I'm using :
<?php
private function createAuthorizationPayIn($authorization, $fees)
{
$payIn = new MangoPay\PayIn();
$payIn->CreditedWalletId = $this->adminWalletId;
$payIn->AuthorId = $this->adminUserId;
$payIn->PaymentType = "PREAUTHORIZED";
$PayIn->PaymentDetails = new MangoPay\PayInPaymentDetailsPreAuthorized();
$payIn->PaymentDetails->PreauthorizationId = $authorization->Id;
$payIn->DebitedFunds = new MangoPay\Money();
$payIn->DebitedFunds->Currency = $authorization->DebitedFunds->Currency;
$payIn->DebitedFunds->Amount = $authorization->DebitedFunds->Amount;
$payIn->CreditedFunds = new MangoPay\Money();
$payIn->CreditedFunds->Currency = $authorization->DebitedFunds->Currency;
$payIn->CreditedFunds->Amount = $authorization->DebitedFunds->Amount;
$payIn->Fees = $fees;
$payIn->ExecutionType = "DIRECT";
$payIn->ExecutionDetails = new MangoPay\PayInExecutionDetailsDirect();
$payIn->ExecutionDetails->SecureMode = "DEFAULT";
$payIn->ExecutionDetails->SecureModeReturnURL = "https://website.com";
$payIn = $this->mangoPayApi->PayIns->Create($payIn);
$authorization->payinId = $payIn->Id;
$authorization = $this->mangoPayApi->CardPreAuthorizations->Update($authorization);
return $payIn;
}
How can I create the right PaymentDetails object to create a preAuthorized PayIn ?
Related
I am using nopcommerce 3.5. I have added plugin of UPS of TransitInTime and Rate API. I want to get rates by calling UPS Rate API. I want all Rates in dropdown on page load.
So for the first I am using test application using webservices of RateWebReference and in which I get only one Rate but I want Rates for all shipping option.
Here is my code of RateWSClient.cs
RateService rate = new RateService();
RateRequest rateRequest = new RateRequest();
UPSSecurity upss = new UPSSecurity();
UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken();
upssSvcAccessToken.AccessLicenseNumber = "CC....";
upss.ServiceAccessToken = upssSvcAccessToken;
UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken();
upssUsrNameToken.Username = "gi..";
upssUsrNameToken.Password = "Ch..";
upss.UsernameToken = upssUsrNameToken;
rate.UPSSecurityValue = upss;
RequestType request = new RequestType();
String[] requestOption = { "Rate" };
request.RequestOption = requestOption;
rateRequest.Request = request;
ShipmentType shipment = new ShipmentType();
ShipperType shipper = new ShipperType();
shipper.ShipperNumber = "A65V88";
RateWSSample.RateWebReference1.AddressType shipperAddress = new RateWSSample.RateWebReference1.AddressType();
String[] addressLine = { "", "", "" };
shipperAddress.AddressLine = addressLine;
shipperAddress.City = "";
shipperAddress.PostalCode = "30076";
shipperAddress.StateProvinceCode = "GA";
shipperAddress.CountryCode = "US";
shipperAddress.AddressLine = addressLine;
shipper.Address = shipperAddress;
shipment.Shipper = shipper;
ShipFromType shipFrom = new ShipFromType();
RateWSSample.RateWebReference1.AddressType shipFromAddress = new RateWSSample.RateWebReference1.AddressType();
shipFromAddress.AddressLine = addressLine;
shipFromAddress.City = "";
shipFromAddress.PostalCode = "30076";
shipFromAddress.StateProvinceCode = "GA";
shipFromAddress.CountryCode = "US";
shipFrom.Address = shipFromAddress;
shipment.ShipFrom = shipFrom;
ShipToType shipTo = new ShipToType();
ShipToAddressType shipToAddress = new ShipToAddressType();
String[] addressLine1 = { "", "", "" };
shipToAddress.AddressLine = addressLine1;
shipToAddress.City = "";
shipToAddress.PostalCode = "92262";
shipToAddress.StateProvinceCode = "";
shipToAddress.CountryCode = "US";
shipTo.Address = shipToAddress;
shipment.ShipTo = shipTo;
CodeDescriptionType service = new CodeDescriptionType();
//Below code uses dummy date for reference. Please udpate as required.
service.Code = "02";
shipment.Service = service;
PackageType package = new PackageType();
PackageWeightType packageWeight = new PackageWeightType();
packageWeight.Weight = "125";
CodeDescriptionType uom = new CodeDescriptionType();
uom.Code = "LBS";
uom.Description = "pounds";
packageWeight.UnitOfMeasurement = uom;
package.PackageWeight = packageWeight;
CodeDescriptionType packType = new CodeDescriptionType();
packType.Code = "02";
package.PackagingType = packType;
PackageType[] pkgArray = { package };
shipment.Package = pkgArray;
//Shipping Rate Chart
// ShipmentRatingOptionsType SRO = new ShipmentRatingOptionsType();
//SRO.RateChartIndicator = "";
//shipment.ShipmentRatingOptions= SRO;
//rateRequest.Shipment = shipment;
ShipmentRatingOptionsType SRO = new ShipmentRatingOptionsType();
SRO.NegotiatedRatesIndicator = "";
shipment.ShipmentRatingOptions = SRO;
rateRequest.Shipment = shipment;
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
Console.WriteLine(rateRequest);
RateResponse rateResponse = rate.ProcessRate(rateRequest);
Console.WriteLine("The transaction was a " + rateResponse.Response.ResponseStatus.Description);
Console.WriteLine("Total Shipment Charges " + rateResponse.RatedShipment[0].TotalCharges.MonetaryValue + rateResponse.RatedShipment[0].TotalCharges.CurrencyCode);
Console.ReadKey();
I have resolved this questions. So If you face this kind of problem don't forget to use
String[] requestOption = { "Shop" };
in place of
String[] requestOption = { "Rate" };
Then you will get rates for all shipping options.
I can't seem to include PaymayaSDK into my Laravel app I already run the command composer require "paymaya/paymaya-sdk:*" and it's already in the vendor folder. But when I try to use it in the controller it says Class 'PayMayaSDK' not found. I already try composer dump-autoload too.
This is my code
What am I missing?
I also tried integrating PaymayaSDK to Laravel via composer, it also didn't work for me.
What I did was I downloaded the PayMaya SDK from the github, then I put it in app\Libraries\PayMaya, but you have to change the namespace of the files of the sdk accordingly.
Also I think you have to edit the sample/Checkout/User.php also based on your requirements.
Here's my sample code:
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Libraries\PayMaya\lib\PayMayaSDK;
use App\Libraries\PayMaya\lib\API\Webhook;
use App\Libraries\PayMaya\lib\API\Checkout;
use App\Libraries\PayMaya\lib\API\Customization;
use App\Libraries\PayMaya\lib\Model\Checkout\Item;
use App\Libraries\PayMaya\lib\Model\Checkout\ItemAmount;
use App\Libraries\PayMaya\sample\Checkout\User as PayMayaUser;
use App\Libraries\PayMaya\lib\Model\Checkout\ItemAmountDetails;
class PayMayaTestController extends Controller
{
public function setupPayMaya()
{
PayMayaSDK::getInstance()->initCheckout(
env('PAYMAYA_PUBLIC_KEY'),
env('PAYMAYA_SECRET_KEY'),
(\App::environment('production') ? 'PRODUCTION' : 'SANDBOX')
);
$this->setShopCustomization();
$this->setWebhooks();
return redirect('/');
}
public function redirectToPayMaya()
{
$sample_item_name = 'Product 1';
$sample_total_price = 1000.00;
$sample_user_phone = '1234567';
$sample_user_email = 'test#gmail.com';
$sample_reference_number = '1234567890';
PayMayaSDK::getInstance()->initCheckout(
env('PAYMAYA_PUBLIC_KEY'),
env('PAYMAYA_SECRET_KEY'),
(\App::environment('production') ? 'PRODUCTION' : 'SANDBOX')
);
// Item
$itemAmountDetails = new ItemAmountDetails();
$itemAmountDetails->tax = "0.00";
$itemAmountDetails->subtotal = number_format($sample_total_price, 2, '.', '');
$itemAmount = new ItemAmount();
$itemAmount->currency = "PHP";
$itemAmount->value = $itemAmountDetails->subtotal;
$itemAmount->details = $itemAmountDetails;
$item = new Item();
$item->name = $sample_item_name;
$item->amount = $itemAmount;
$item->totalAmount = $itemAmount;
// Checkout
$itemCheckout = new Checkout();
$user = new PayMayaUser();
$user->contact->phone = $sample_user_phone;
$user->contact->email = $sample_user_email;
$itemCheckout->buyer = $user->buyerInfo();
$itemCheckout->items = array($item);
$itemCheckout->totalAmount = $itemAmount;
$itemCheckout->requestReferenceNumber = $sample_reference_number;
$itemCheckout->redirectUrl = array(
"success" => url('returl-url/success'),
"failure" => url('returl-url/failure'),
"cancel" => url('returl-url/cancel'),
);
$itemCheckout->execute();
$itemCheckout->retrieve();
return redirect()->to($itemCheckout->url);
}
private function setShopCustomization()
{
$shopCustomization = new Customization();
$shopCustomization->get();
$shopCustomization->logoUrl = asset('logo.jpg');
$shopCustomization->iconUrl = asset('favicon.ico');
$shopCustomization->appleTouchIconUrl = asset('favicon.ico');
$shopCustomization->customTitle = 'PayMaya Payment Gateway';
$shopCustomization->colorScheme = '#f3dc2a';
$shopCustomization->set();
}
private function setWebhooks()
{
$webhooks = Webhook::retrieve();
foreach ($webhooks as $webhook) {
$webhook->delete();
}
$successWebhook = new Webhook();
$successWebhook->name = Webhook::CHECKOUT_SUCCESS;
$successWebhook->callbackUrl = url('callback/success');
$successWebhook->register();
$failureWebhook = new Webhook();
$failureWebhook->name = Webhook::CHECKOUT_FAILURE;
$failureWebhook->callbackUrl = url('callback/error');
$failureWebhook->register();
}
}
Seems you haven't configured properly.
Please read the usage section.
After installing you need to replace PayMaya-PHP-SDK with the vendor.
Previously in PHP 5.4 I have create a payment redirection module. The bank ask me for security reasons to calculate the value $digest. Here is the code:
$form_data = "";
$form_data_array = array();
$form_data_array[1] = $merchantID;
$form_data_array[2] = $lang_fixed;
$form_data_array[3] = $orderId;
$form_data_array[4] = $order_descr_fixed;
$form_data_array[5] = $price_fixed;
$form_data_array[6] = $crncy;
$form_data_array[7] = $customerEmail;
$form_data_array[8] = $trans_type;
$form_data_array[9] = $form_confirmUrl;
$form_data_array[10] = $form_cancelUrl;
$form_data_array[11] = $sharedSecretKey;
$form_data = implode("", $form_data_array);
$digest = base64_encode(sha1($form_data,true));
This working fine with PHP 5.4. But when I choose PHP 5.6 the $digest is not calculated.
I'm using php toolkit for netsuite 2013.1. Here my code:
require_once("2013_1/NetSuiteService.php");
$service = new NetSuiteService();
$getCustomizationType = "itemCustomField";
$getCustomizationIdRq = new GetCustomizationIdRequest();
$getCustomizationIdRq->customizationType = new CustomizationType();
$getCustomizationIdRq->customizationType->getCustomizationTypeSpecified=true;
$getCustomizationIdRq->customizationType->getCustomizationType = GetCustomizationType::itemCustomField;
$getCustomizationIdResult = $service->getCustomizationId($getCustomizationIdRq, false);
And the result:
No such operation 'getCustomizationId'
So I think this function is missing? Function link
Here ya go...
$NSservice = new NetSuiteService();
$cT = new CustomizationType();
$cT->getCustomizationType = "customRecordType"; // or itemCustomField or whatever
$gcIdR = new GetCustomizationIdRequest();
$gcIdR->customizationType = $cT;
$gcIdR->includeInactives = false;
$readResp = $NSservice->getCustomizationId($gcIdR);
print_r($readResp);
ok so i have a php file that includes code for do a sql insert
myfile.php
include($somewhere.'/addleads.php');
addleads.php
require_once(MAIN_CLASS_PATH."common/class.Common.php");
require_once(MAIN_CLASS_PATH."modules/Leads/class.Leads.php");
$objcommon = new common();
$objLeads = new Leads();
$Errormsg = $objLeads->AddLBCleads($_REQUEST);
class.Leads.php
class Leads extends Common{
function Leads(){
$this->Common();
$this->Leadstype = "Leadstype";
$this->Leads = "Leads";
}
function AddLBCleads($objArray){
global $_REQUEST,$objSmarty,$global_config;
$objLeads = new Leads();
$objInsertArray['txtP_Ident'] = $objArray['selProperty'];
$objInsertArray['txtFirstName'] = $objArray['txtfirstname'];
$objInsertArray['txtLastName'] = $objArray['txtlastname'];
$objInsertArray['txtEmail'] = $objArray['txtEmail'];
$objInsertArray['txtPhone'] = $objArray['txtPhone'];
$objInsertArray['txtTypeId'] = $objArray['selleadtype'];
$objInsertArray['txtComments'] = $objArray['txtcomments'];
$StrEnterdate = date('Y-m-d H:i:s');
$objInsertArray['txtMoveDate'] = $StrMoveDate;
$objInsertArray['txtEntereddate'] = $StrEnterdate;
$current_id = $this->AddInfoToDB($objInsertArray,"txt",$this->LBCPrimary_leads);
How do i get $current_id from myfile.php, when i try to access it is unavailable
Just below this line:
class Leads extends Common{
Add:
public $current_id = null; // create a public accessible variable
And instead of:
$current_id = $this->AddInfoToDB($objInsertArray,"txt",$this->LBCPrimary_leads);
Use:
$this->current_id = $this->AddInfoToDB($objInsertArray,"txt",$this->LBCPrimary_leads);
Now you can get it like:
$objLeads = new Leads();
echo $objLeads->current_id;